UNPKG

@umbraco/playwright-testhelpers

Version:

Test helpers for making playwright tests for Umbraco solutions

146 lines 6.74 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"); 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; packageItem; 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' }); this.packageItem = page.locator('umb-installed-packages-section-view-item'); } async isUmbracoBackofficePackageVisible(isVisible = true) { return await this.isVisible(this.umbracoBackofficePackage, isVisible); } async clickCreatedTab() { await this.page.waitForTimeout(500); await this.click(this.createdTabBtn); await this.page.waitForTimeout(500); } async clickInstalledTab() { await this.click(this.installedTabBtn); } async clickPackagesTab() { await this.click(this.packagesTabBtn); } async clickChooseBtn() { await this.chooseModalBtn.click(); } async isMarketPlaceIFrameVisible(isVisible = true) { return await this.isVisible(this.marketPlaceIFrame, isVisible); } async clickCreatePackageButton() { await this.createPackageBtn.click(); } async enterPackageName(packageName) { await this.enterText(this.packageNameTxt, packageName); await this.page.waitForTimeout(500); } async isPackageNameVisible(packageName, isVisible = true) { return await this.isVisible(this.page.getByRole('button', { name: packageName }), isVisible); } async clickExistingPackageName(packageName) { await this.page.getByRole('button', { name: packageName }).click(); await this.page.waitForTimeout(500); } async clickDeleteButtonForPackageName(packageName) { const deletePackageWithNameLocator = this.page.locator('uui-ref-node-package', { hasText: packageName }).getByLabel('Delete'); await this.click(deletePackageWithNameLocator); } async clickSaveChangesToPackageButton() { await this.saveChangesToPackageBtn.click(); } async clickAddContentToPackageButton() { await this.addContentToPackageBtn.click(); } async clickAddMediaToPackageButton() { await this.click(this.addMediaToPackageBtn); } async clickAddDocumentTypeToPackageButton() { await this.addDocumentTypeToPackageBtn.click(); } async clickAddMediaTypeToPackageButton() { await this.addMediaTypeToPackageBtn.click(); } async clickAddLanguageToPackageButton() { await this.addLanguageToPackageBtn.click(); } async clickAddDictionaryToPackageButton() { await this.addDictionaryToPackageBtn.click(); } async clickAddDataTypesToPackageButton() { await this.addDataTypesToPackageBtn.click(); } async clickAddTemplatesToPackageButton() { await this.addTemplatesToPackagesBtn.click(); } async clickAddPartialViewToPackageButton() { await this.addPartialViewToPackageBtn.click(); } async clickAddScriptToPackageButton() { await this.addScriptToPackageBtn.click(); } async clickAddStylesheetToPackageButton() { await this.addStylesheetToPackageBtn.click(); } async doesPackageWithNameContainVersion(packageName, packageVersion) { await this.containsText(this.packageItem.filter({ hasText: packageName }), packageVersion); } // 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.downloadPackageBtn.click(); const response = await responsePromise; const body = await response.body(); return body.toString().trim(); } } exports.PackageUiHelper = PackageUiHelper; //# sourceMappingURL=PackageUiHelper.js.map