UNPKG

@umbraco/playwright-testhelpers

Version:

Test helpers for making playwright tests for Umbraco solutions

142 lines 6.71 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.PackageUiHelper = void 0; const UiBaseLocators_1 = require("./UiBaseLocators"); const umbraco_config_1 = require("../../umbraco.config"); const ConstantHelper_1 = require("./ConstantHelper"); class PackageUiHelper extends UiBaseLocators_1.UiBaseLocators { createdTabBtn; marketPlaceIFrame; installedTabBtn; packagesTabBtn; createPackageBtn; packageNameTxt; saveChangesToPackageBtn; addContentToPackageBtn; addMediaToPackageBtn; addDocumentTypeToPackageBtn; addMediaTypeToPackageBtn; addLanguageToPackageBtn; addDictionaryToPackageBtn; addDataTypesToPackageBtn; addTemplatesToPackagesBtn; addPartialViewToPackageBtn; addScriptToPackageBtn; addStylesheetToPackageBtn; downloadPackageBtn; propertyLayout; umbracoBackofficePackage; viewsId; constructor(page) { super(page); this.viewsId = page.locator('#views'); // Packages this.packagesTabBtn = this.viewsId.getByRole('tab', { name: 'Packages' }); this.marketPlaceIFrame = page.frameLocator('iframe[title="Umbraco Marketplace"]').locator('umb-market-app'); // Installed this.installedTabBtn = this.viewsId.getByRole('tab', { name: 'Installed' }); // Created this.propertyLayout = page.locator('umb-property-layout'); this.createdTabBtn = this.viewsId.getByRole('tab', { name: 'Created' }); this.createPackageBtn = page.getByLabel("Create package"); this.packageNameTxt = page.getByLabel('Name of the package'); this.saveChangesToPackageBtn = page.getByLabel('Save changes to package'); this.addContentToPackageBtn = page.locator('umb-input-document').getByLabel('Choose'); this.addMediaToPackageBtn = page.locator('umb-input-media').getByLabel('Choose'); this.addDocumentTypeToPackageBtn = this.propertyLayout.filter({ hasText: 'Document Types' }).getByLabel('Choose'); this.addMediaTypeToPackageBtn = this.propertyLayout.filter({ hasText: 'Media Types' }).getByLabel('Choose'); this.addLanguageToPackageBtn = this.propertyLayout.filter({ hasText: 'Languages' }).getByLabel('Choose'); this.addDictionaryToPackageBtn = this.propertyLayout.filter({ hasText: 'Dictionary' }).getByLabel('Choose'); this.addDataTypesToPackageBtn = this.propertyLayout.filter({ hasText: 'Data Types' }).getByLabel('Choose'); this.addTemplatesToPackagesBtn = this.propertyLayout.filter({ hasText: 'Templates' }).getByLabel('Choose'); this.addPartialViewToPackageBtn = this.propertyLayout.filter({ hasText: 'Partial Views' }).getByLabel('Choose'); this.addScriptToPackageBtn = this.propertyLayout.filter({ hasText: 'Scripts' }).getByLabel('Choose'); this.addStylesheetToPackageBtn = this.propertyLayout.filter({ hasText: 'Stylesheets' }).getByLabel('Choose'); this.downloadPackageBtn = page.getByLabel('Download'); this.umbracoBackofficePackage = page.locator('uui-ref-node-package', { hasText: '@umbraco-cms/backoffice' }); } async isUmbracoBackofficePackageVisible(isVisible = true) { await this.isVisible(this.umbracoBackofficePackage, isVisible); } async clickCreatedTab() { await this.page.waitForTimeout(ConstantHelper_1.ConstantHelper.wait.short); await this.click(this.createdTabBtn); await this.page.waitForTimeout(ConstantHelper_1.ConstantHelper.wait.short); } async clickInstalledTab() { await this.click(this.installedTabBtn); } async clickPackagesTab() { await this.click(this.packagesTabBtn); } async clickChooseBtn() { await this.click(this.chooseModalBtn); } async isMarketPlaceIFrameVisible(isVisible = true) { await this.isVisible(this.marketPlaceIFrame, isVisible); } async clickCreatePackageButton() { await this.click(this.createPackageBtn); } async enterPackageName(packageName) { await this.enterText(this.packageNameTxt, packageName); await this.page.waitForTimeout(ConstantHelper_1.ConstantHelper.wait.short); } async isPackageNameVisible(packageName, isVisible = true) { return await this.isVisible(this.page.getByRole('button', { name: packageName }), isVisible); } async clickExistingPackageName(packageName) { await this.click(this.page.getByRole('button', { name: packageName })); await this.page.waitForTimeout(ConstantHelper_1.ConstantHelper.wait.short); } async clickDeleteButtonForPackageName(packageName) { const deletePackageWithNameLocator = this.page.locator('uui-ref-node-package', { hasText: packageName }).getByLabel('Delete'); await this.click(deletePackageWithNameLocator); } async clickSaveChangesToPackageButton() { await this.click(this.saveChangesToPackageBtn); } async clickAddContentToPackageButton() { await this.click(this.addContentToPackageBtn); } async clickAddMediaToPackageButton() { await this.click(this.addMediaToPackageBtn); } async clickAddDocumentTypeToPackageButton() { await this.click(this.addDocumentTypeToPackageBtn); } async clickAddMediaTypeToPackageButton() { await this.click(this.addMediaTypeToPackageBtn); } async clickAddLanguageToPackageButton() { await this.click(this.addLanguageToPackageBtn); } async clickAddDictionaryToPackageButton() { await this.click(this.addDictionaryToPackageBtn); } async clickAddDataTypesToPackageButton() { await this.click(this.addDataTypesToPackageBtn); } async clickAddTemplatesToPackageButton() { await this.click(this.addTemplatesToPackagesBtn); } async clickAddPartialViewToPackageButton() { await this.click(this.addPartialViewToPackageBtn); } async clickAddScriptToPackageButton() { await this.click(this.addScriptToPackageBtn); } async clickAddStylesheetToPackageButton() { await this.click(this.addStylesheetToPackageBtn); } // Downloads the package and converts it to a string async downloadPackage(packageId) { const responsePromise = this.page.waitForResponse(`${umbraco_config_1.umbracoConfig.environment.baseUrl}/umbraco/management/api/v1/package/created/${packageId}/download`); await this.click(this.downloadPackageBtn); const response = await responsePromise; const body = await response.body(); return body.toString().trim(); } } exports.PackageUiHelper = PackageUiHelper; //# sourceMappingURL=PackageUiHelper.js.map