UNPKG

@umbraco/playwright-testhelpers

Version:

Test helpers for making playwright tests for Umbraco solutions

148 lines 6.96 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.PackageUiHelper = void 0; const test_1 = require("@playwright/test"); 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; 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) { return await (0, test_1.expect)(this.umbracoBackofficePackage).toBeVisible({ visible: isVisible }); } async clickCreatedTab() { await this.page.waitForTimeout(500); await (0, test_1.expect)(this.createdTabBtn).toBeVisible(); await this.createdTabBtn.click(); await this.page.waitForTimeout(500); } async clickInstalledTab() { await (0, test_1.expect)(this.installedTabBtn).toBeVisible(); await this.installedTabBtn.click(); } async clickPackagesTab() { await (0, test_1.expect)(this.packagesTabBtn).toBeVisible(); await this.packagesTabBtn.click(); } async clickChooseBtn() { await this.chooseModalBtn.click(); } async isMarketPlaceIFrameVisible(isVisible = true) { return await (0, test_1.expect)(this.marketPlaceIFrame).toBeVisible({ visible: isVisible }); } async clickCreatePackageButton() { await this.createPackageBtn.click(); } async enterPackageName(packageName) { await this.packageNameTxt.clear(); await this.packageNameTxt.fill(packageName); await this.page.waitForTimeout(500); } async isPackageNameVisible(packageName, isVisible = true) { return await (0, test_1.expect)(this.page.getByRole('button', { name: packageName })).toBeVisible({ visible: 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 (0, test_1.expect)(deletePackageWithNameLocator).toBeVisible(); await deletePackageWithNameLocator.click(); } async clickSaveChangesToPackageButton() { await this.saveChangesToPackageBtn.click(); } async clickAddContentToPackageButton() { await this.addContentToPackageBtn.click(); } async clickAddMediaToPackageButton() { await (0, test_1.expect)(this.addMediaToPackageBtn).toBeVisible(); await this.addMediaToPackageBtn.click(); } 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(); } // 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