From d43a3c93c8d2870ff453a1bd5b096a0274d80ef4 Mon Sep 17 00:00:00 2001 From: wojteknowacki <124166231+wojteknowacki@users.noreply.github.com> Date: Wed, 10 Jan 2024 08:28:56 +0100 Subject: [PATCH] Maintenance e2e tests (#4606) * Migrated warehouses tests: Edit warehouse; Delete warehouse * Migrated categories tests: Create basic category; Edit category;Bulk delete categories * Migrated warehouses tests: Edit warehouse; Delete warehouse (#4593) * Migrated warehouses tests: Edit warehouse; Delete warehouse * Update nervous-flowers-hear.md * Update nervous-flowers-hear.md * Use composites in pr automation workflow (#4597) * Use composites * Use composites * Use composites * Use composites * Use composites * changed shipping metod id in shippings tests * maintenance * add console log to goto details page actions * Trigger Build * Create ten-feet-roll.md --------- Co-authored-by: Patryk Andrzejewski --- .changeset/ten-feet-roll.md | 8 ++ playwright/pages/accountSettingsPage.ts | 18 ++--- playwright/pages/appsPage.ts | 14 ++-- playwright/pages/attributesPage.ts | 45 +++++------ playwright/pages/categoriesPage.ts | 6 +- playwright/pages/channelsPage.ts | 10 ++- playwright/pages/collectionsPage.ts | 9 ++- playwright/pages/configurationPage.ts | 57 +++++++------- playwright/pages/contentPage.ts | 9 ++- playwright/pages/customersPage.ts | 9 ++- .../pages/dialogs/addPostalCodeDialog.ts | 25 +++--- playwright/pages/dialogs/addProductsDialog.ts | 24 +++--- playwright/pages/dialogs/addValueDialog.ts | 12 +-- .../pages/dialogs/assignCountriesDialog.ts | 24 +++--- .../pages/dialogs/changePasswordDialog.ts | 21 +++-- .../pages/dialogs/channelSelectDialog.ts | 18 ++--- .../pages/dialogs/deleteChannelDialog.ts | 18 ----- ...leteWarehouseDialog.ts => deleteDialog.ts} | 4 +- .../pages/dialogs/deleteDraftOrdersDialog.ts | 17 ---- .../pages/dialogs/deleteProductDialog.ts | 17 ---- .../pages/dialogs/deleteVoucherDialog.ts | 13 ---- .../pages/dialogs/deleteVouchersDialog.ts | 13 ---- .../pages/dialogs/draftOrderCreateDialog.ts | 17 ++-- .../pages/dialogs/inviteStaffMemberDialog.ts | 22 +++--- .../manageProductsChannelAvailability.ts | 0 playwright/pages/dialogs/orderCreateDialog.ts | 17 ++-- .../pages/dialogs/productCreateDialog.ts | 22 +++--- .../pages/dialogs/shippingMethodDialog.ts | 26 +++---- playwright/pages/discountsPage.ts | 9 ++- playwright/pages/draftOrdersPage.ts | 6 +- playwright/pages/homePage.ts | 38 ++++----- playwright/pages/loginPage.ts | 27 +++---- playwright/pages/mainMenuPage.ts | 67 ++++++---------- .../pages/pageElements/metadataSeoPage.ts | 78 ++++++++----------- playwright/pages/pageTypesPage.ts | 9 ++- playwright/pages/permissionGroupsPage.ts | 13 ++-- playwright/pages/pluginsPage.ts | 6 +- playwright/pages/productPage.ts | 24 +++--- playwright/pages/productTypePage.ts | 52 ++++++------- playwright/pages/setUpNewPasswordPage.ts | 17 ++-- playwright/pages/shippingMethodsPage.ts | 42 +++++----- playwright/pages/shippingRatesPage.ts | 77 ++++++++---------- playwright/pages/siteSettingsPage.ts | 9 ++- playwright/pages/staffMembersPage.ts | 42 +++++----- playwright/pages/variantsPage.ts | 14 ++-- playwright/pages/vouchersPage.ts | 15 ++-- playwright/pages/warehousePage.ts | 6 +- playwright/pages/webhooksEventsPage.ts | 9 ++- playwright/tests/discountAndVouchers.spec.ts | 2 +- playwright/tests/shippingMethods.spec.ts | 4 +- 50 files changed, 458 insertions(+), 603 deletions(-) create mode 100644 .changeset/ten-feet-roll.md delete mode 100644 playwright/pages/dialogs/deleteChannelDialog.ts rename playwright/pages/dialogs/{deleteWarehouseDialog.ts => deleteDialog.ts} (78%) delete mode 100644 playwright/pages/dialogs/deleteDraftOrdersDialog.ts delete mode 100644 playwright/pages/dialogs/deleteProductDialog.ts delete mode 100644 playwright/pages/dialogs/deleteVoucherDialog.ts delete mode 100644 playwright/pages/dialogs/deleteVouchersDialog.ts delete mode 100644 playwright/pages/dialogs/manageProductsChannelAvailability.ts diff --git a/.changeset/ten-feet-roll.md b/.changeset/ten-feet-roll.md new file mode 100644 index 00000000000..0e7cbd02137 --- /dev/null +++ b/.changeset/ten-feet-roll.md @@ -0,0 +1,8 @@ +--- +"saleor-dashboard": minor +--- + +Maintenance e2e tests: +- Class unification - selector initiation moved to constructors +- Adding navigation logs to specific products, channels, etc +- Improved imports: using aliases in all files diff --git a/playwright/pages/accountSettingsPage.ts b/playwright/pages/accountSettingsPage.ts index b7311445733..23150064f29 100644 --- a/playwright/pages/accountSettingsPage.ts +++ b/playwright/pages/accountSettingsPage.ts @@ -1,21 +1,21 @@ -import type { Locator, Page } from "@playwright/test"; - -import { BasePage } from "./basePage"; -import { ChangePasswordDialog } from "./dialogs/changePasswordDialog"; +import { ChangePasswordDialog } from "@dialogs/changePasswordDialog"; +import { BasePage } from "@pages/basePage"; +import type { Page } from "@playwright/test"; export class AccountSettingsPage { readonly page: Page; readonly basePage: BasePage; - readonly changePasswordButton: Locator; - readonly saveButton: Locator; + readonly changePasswordDialog: ChangePasswordDialog; - constructor(page: Page) { + constructor( + page: Page, + readonly changePasswordButton = page.getByTestId("changePasswordBtn"), + readonly saveButton = page.getByTestId("button-bar-confirm"), + ) { this.page = page; this.basePage = new BasePage(page); this.changePasswordDialog = new ChangePasswordDialog(page); - this.changePasswordButton = page.getByTestId("changePasswordBtn"); - this.saveButton = page.getByTestId("button-bar-confirm"); } async clickChangePasswordButton() { diff --git a/playwright/pages/appsPage.ts b/playwright/pages/appsPage.ts index 502819ecd75..7da1bb3c223 100644 --- a/playwright/pages/appsPage.ts +++ b/playwright/pages/appsPage.ts @@ -1,13 +1,15 @@ -import type { Locator, Page } from "@playwright/test"; +import type { Page } from "@playwright/test"; export class AppsPage { readonly page: Page; - readonly installExternalAppButton: Locator; - readonly appsLogosList: Locator; - constructor(page: Page) { + constructor( + page: Page, + readonly installExternalAppButton = page.getByTestId( + "add-app-from-manifest", + ), + readonly appsLogosList = page.getByTestId("app-logo"), + ) { this.page = page; - this.installExternalAppButton = page.getByTestId("add-app-from-manifest"); - this.appsLogosList = page.getByTestId("app-logo"); } } diff --git a/playwright/pages/attributesPage.ts b/playwright/pages/attributesPage.ts index 29828b57dd3..ab235ff8274 100644 --- a/playwright/pages/attributesPage.ts +++ b/playwright/pages/attributesPage.ts @@ -1,37 +1,34 @@ +import { BasePage } from "@pages/basePage"; import { AddValueDialog } from "@pages/dialogs/addValueDialog"; -import type { Locator, Page } from "@playwright/test"; - -import { BasePage } from "./basePage"; +import type { Page } from "@playwright/test"; export class AttributesPage { readonly page: Page; readonly addValueDialog: AddValueDialog; readonly basePage: BasePage; - readonly createAttributeButton: Locator; - readonly attributeSelect: Locator; - readonly attributesRows: Locator; - readonly attributeDefaultLabelInput: Locator; - readonly attributeCodeInput: Locator; - readonly assignAttributeValueButton: Locator; - readonly saveButton: Locator; - readonly valueRequiredCheckbox: Locator; - constructor(page: Page) { + constructor( + page: Page, + readonly createAttributeButton = page.getByTestId( + "create-attribute-button", + ), + readonly valueRequiredCheckbox = page.getByLabel("Value Required"), + readonly saveButton = page.getByTestId("button-bar-confirm"), + readonly attributesRows = page.getByTestId("attributes-rows"), + readonly assignAttributeValueButton = page.getByTestId( + "assign-value-button", + ), + readonly attributeSelect = page.getByTestId("attribute-type-select"), + readonly attributeDefaultLabelInput = page + .getByTestId("attribute-default-label-input") + .locator("input"), + readonly attributeCodeInput = page + .getByTestId("attribute-code-input") + .locator("input"), + ) { this.page = page; this.addValueDialog = new AddValueDialog(page); this.basePage = new BasePage(page); - this.createAttributeButton = page.getByTestId("create-attribute-button"); - this.valueRequiredCheckbox = page.getByLabel("Value Required"); - this.saveButton = page.getByTestId("button-bar-confirm"); - this.attributesRows = page.getByTestId("attributes-rows"); - this.assignAttributeValueButton = page.getByTestId("assign-value-button"); - this.attributeSelect = page.getByTestId("attribute-type-select"); - this.attributeDefaultLabelInput = page - .getByTestId("attribute-default-label-input") - .locator("input"); - this.attributeCodeInput = page - .getByTestId("attribute-code-input") - .locator("input"); } async clickCreateAttributeButton() { diff --git a/playwright/pages/categoriesPage.ts b/playwright/pages/categoriesPage.ts index 8e1a483f6e6..113e67e5d72 100644 --- a/playwright/pages/categoriesPage.ts +++ b/playwright/pages/categoriesPage.ts @@ -1,5 +1,5 @@ import { URL_LIST } from "@data/url"; -import { DeleteCategoriesDialog } from "@dialogs/deleteCategoriesDialog"; +import { DeleteDialog } from "@dialogs/deleteDialog"; import { MetadataSeoPage } from "@pageElements/metadataSeoPage"; import { BasePage } from "@pages/basePage"; import type { Page } from "@playwright/test"; @@ -7,7 +7,7 @@ import type { Page } from "@playwright/test"; export class CategoriesPage extends BasePage { readonly page: Page; readonly metadataSeoPage: MetadataSeoPage; - readonly deleteCategoriesDialog: DeleteCategoriesDialog; + readonly deleteCategoriesDialog: DeleteDialog; constructor( page: Page, @@ -28,7 +28,7 @@ export class CategoriesPage extends BasePage { super(page); this.page = page; this.metadataSeoPage = new MetadataSeoPage(page); - this.deleteCategoriesDialog = new DeleteCategoriesDialog(page); + this.deleteCategoriesDialog = new DeleteDialog(page); } async gotoCategoryListView() { diff --git a/playwright/pages/channelsPage.ts b/playwright/pages/channelsPage.ts index 9c537fb90ae..778a95ff3a8 100644 --- a/playwright/pages/channelsPage.ts +++ b/playwright/pages/channelsPage.ts @@ -1,13 +1,13 @@ import { URL_LIST } from "@data/url"; -import { DeleteChannelDialog } from "@dialogs/deleteChannelDialog"; import { RightSideDetailsPage } from "@pageElements/rightSideDetailsSection"; import { BasePage } from "@pages/basePage"; +import { DeleteDialog } from "@pages/dialogs/deleteDialog"; import { Page } from "@playwright/test"; export class ChannelPage extends BasePage { readonly page: Page; readonly rightSideDetailsPage: RightSideDetailsPage; - readonly deleteChannelDialog: DeleteChannelDialog; + readonly deleteChannelDialog: DeleteDialog; constructor( page: Page, @@ -43,7 +43,7 @@ export class ChannelPage extends BasePage { super(page); this.page = page; this.rightSideDetailsPage = new RightSideDetailsPage(page); - this.deleteChannelDialog = new DeleteChannelDialog(page); + this.deleteChannelDialog = new DeleteDialog(page); } async clickAuthorizeInsteadOfChargingCheckbox() { @@ -86,7 +86,9 @@ export class ChannelPage extends BasePage { } async gotoChannelDetails(channelId: string) { - await this.page.goto(URL_LIST.channels + channelId); + const channelDetailsUrl = URL_LIST.channels + channelId; + await console.log("Navigating to channel details: " + channelDetailsUrl); + await this.page.goto(channelDetailsUrl); } async gotoChannelList() { await this.page.goto(URL_LIST.channels); diff --git a/playwright/pages/collectionsPage.ts b/playwright/pages/collectionsPage.ts index d920a91a8a0..ad6785ac056 100644 --- a/playwright/pages/collectionsPage.ts +++ b/playwright/pages/collectionsPage.ts @@ -1,11 +1,12 @@ -import type { Locator, Page } from "@playwright/test"; +import type { Page } from "@playwright/test"; export class CollectionsPage { readonly page: Page; - readonly createCollectionButton: Locator; - constructor(page: Page) { + constructor( + page: Page, + readonly createCollectionButton = page.getByTestId("create-collection"), + ) { this.page = page; - this.createCollectionButton = page.getByTestId("create-collection"); } } diff --git a/playwright/pages/configurationPage.ts b/playwright/pages/configurationPage.ts index 2d5d38375ec..cb8db846453 100644 --- a/playwright/pages/configurationPage.ts +++ b/playwright/pages/configurationPage.ts @@ -1,41 +1,40 @@ import { URL_LIST } from "@data/url"; -import type { Locator, Page } from "@playwright/test"; +import type { Page } from "@playwright/test"; export class ConfigurationPage { readonly page: Page; - readonly channelsButton: Locator; - readonly productTypesButton: Locator; - readonly webhooksAndEventsButton: Locator; - readonly taxesButton: Locator; - readonly permissionGroupsButton: Locator; - readonly pluginsButton: Locator; - readonly pageTypesButton: Locator; - readonly siteSettingsButton: Locator; - readonly staffMembersButton: Locator; - readonly shippingMethodsButton: Locator; - readonly attributesButton: Locator; - constructor(page: Page) { - this.page = page; - this.pluginsButton = page.locator("[data-test-id*='plugins']"); - this.permissionGroupsButton = page.locator( + constructor( + page: Page, + readonly pluginsButton = page.locator("[data-test-id*='plugins']"), + readonly permissionGroupsButton = page.locator( "[data-test-id*='permission-groups']", - ); - this.staffMembersButton = page.locator("[data-test-id*='staff members']"); - this.siteSettingsButton = page.locator("[data-test-id*='site-settings']"); - this.channelsButton = page.locator("[data-test-id*='channels']"); - this.shippingMethodsButton = page.locator( + ), + readonly staffMembersButton = page.locator( + "[data-test-id*='staff members']", + ), + readonly siteSettingsButton = page.locator( + "[data-test-id*='site-settings']", + ), + readonly channelsButton = page.locator("[data-test-id*='channels']"), + readonly shippingMethodsButton = page.locator( "[data-test-id*='shipping methods']", - ); - this.productTypesButton = page.locator("[data-test-id*='product-types']"); - this.webhooksAndEventsButton = page.locator("[data-test-id*='webhooks']"); - this.attributesButton = page.locator("[data-test-id*='attributes']"); - this.pageTypesButton = page.locator( + ), + readonly productTypesButton = page.locator( + "[data-test-id*='product-types']", + ), + readonly webhooksAndEventsButton = page.locator( + "[data-test-id*='webhooks']", + ), + readonly attributesButton = page.locator("[data-test-id*='attributes']"), + readonly pageTypesButton = page.locator( "[data-test-id*='configuration-menu-page-type']", - ); - this.taxesButton = page.locator( + ), + readonly taxesButton = page.locator( "[data-test-id*='configuration-menu-taxes']", - ); + ), + ) { + this.page = page; } async openShippingMethods() { diff --git a/playwright/pages/contentPage.ts b/playwright/pages/contentPage.ts index 6c1d981dfa4..8ff56578875 100644 --- a/playwright/pages/contentPage.ts +++ b/playwright/pages/contentPage.ts @@ -1,11 +1,12 @@ -import type { Locator, Page } from "@playwright/test"; +import type { Page } from "@playwright/test"; export class ContentPage { readonly page: Page; - readonly createContentButton: Locator; - constructor(page: Page) { + constructor( + page: Page, + readonly createContentButton = page.getByTestId("create-page"), + ) { this.page = page; - this.createContentButton = page.getByTestId("create-page"); } } diff --git a/playwright/pages/customersPage.ts b/playwright/pages/customersPage.ts index 89825a949ff..c1724f4c51d 100644 --- a/playwright/pages/customersPage.ts +++ b/playwright/pages/customersPage.ts @@ -1,11 +1,12 @@ -import type { Locator, Page } from "@playwright/test"; +import type { Page } from "@playwright/test"; export class CustomersPage { readonly page: Page; - readonly createCustomerButton: Locator; - constructor(page: Page) { + constructor( + page: Page, + readonly createCustomerButton = page.getByTestId("create-customer"), + ) { this.page = page; - this.createCustomerButton = page.getByTestId("create-customer"); } } diff --git a/playwright/pages/dialogs/addPostalCodeDialog.ts b/playwright/pages/dialogs/addPostalCodeDialog.ts index 65ee9a4dd33..fe91d38cf91 100644 --- a/playwright/pages/dialogs/addPostalCodeDialog.ts +++ b/playwright/pages/dialogs/addPostalCodeDialog.ts @@ -1,24 +1,21 @@ -import { Locator, Page } from "@playwright/test"; +import { Page } from "@playwright/test"; export class AddPostalCodeDialog { readonly page: Page; - readonly zipCodeStartsWithInput: Locator; - readonly zipCodeEndsWithInput: Locator; - readonly backButton: Locator; - readonly addButton: Locator; + constructor( + page: Page, - constructor(page: Page) { - this.page = page; - - this.zipCodeStartsWithInput = page + readonly zipCodeStartsWithInput = page .getByTestId("zip-code-starts-with-input") - .locator("input"); - this.zipCodeEndsWithInput = page + .locator("input"), + readonly zipCodeEndsWithInput = page .getByTestId("zip-code-ends-with-input") - .locator("input"); - this.backButton = page.getByTestId("back"); - this.addButton = page.getByTestId("submit"); + .locator("input"), + readonly backButton = page.getByTestId("back"), + readonly addButton = page.getByTestId("submit"), + ) { + this.page = page; } async addStartAndEndZipCodesRange(startsWith = "10", endsWith = "09") { diff --git a/playwright/pages/dialogs/addProductsDialog.ts b/playwright/pages/dialogs/addProductsDialog.ts index 95a598f93b2..ee4ccdb35ae 100644 --- a/playwright/pages/dialogs/addProductsDialog.ts +++ b/playwright/pages/dialogs/addProductsDialog.ts @@ -1,22 +1,18 @@ -import { expect, Locator, Page } from "@playwright/test"; +import { expect, Page } from "@playwright/test"; export class AddProductsDialog { readonly page: Page; - readonly productRow: Locator; - readonly variantRow: Locator; - readonly productRowCheckbox: Locator; - readonly backButton: Locator; - readonly confirmButton: Locator; - readonly assignAndSaveButton: Locator; - constructor(page: Page) { + constructor( + page: Page, + readonly productRow = page.getByTestId("product"), + readonly variantRow = page.getByTestId("variant"), + readonly backButton = page.getByTestId("back-button"), + readonly confirmButton = page.getByTestId("confirm-button"), + readonly productRowCheckbox = page.getByTestId("checkbox"), + readonly assignAndSaveButton = page.getByTestId("assign-and-save-button"), + ) { this.page = page; - this.productRow = page.getByTestId("product"); - this.variantRow = page.getByTestId("variant"); - this.backButton = page.getByTestId("back-button"); - this.confirmButton = page.getByTestId("confirm-button"); - this.productRowCheckbox = page.getByTestId("checkbox"); - this.assignAndSaveButton = page.getByTestId("assign-and-save-button"); } async clickConfirmButton() { diff --git a/playwright/pages/dialogs/addValueDialog.ts b/playwright/pages/dialogs/addValueDialog.ts index 15bcbf35ce1..2cee65d2dcb 100644 --- a/playwright/pages/dialogs/addValueDialog.ts +++ b/playwright/pages/dialogs/addValueDialog.ts @@ -1,14 +1,14 @@ -import type { Locator, Page } from "@playwright/test"; +import type { Page } from "@playwright/test"; export class AddValueDialog { readonly page: Page; - readonly nameInput: Locator; - readonly saveButton: Locator; - constructor(page: Page) { + constructor( + page: Page, + readonly nameInput = page.getByTestId("value-name").locator("input"), + readonly saveButton = page.getByTestId("submit"), + ) { this.page = page; - this.nameInput = page.getByTestId("value-name").locator("input"); - this.saveButton = page.getByTestId("submit"); } async typeAndSaveAttributeValue(value = "XXL") { diff --git a/playwright/pages/dialogs/assignCountriesDialog.ts b/playwright/pages/dialogs/assignCountriesDialog.ts index 4148cc43e2d..41af44f17e3 100644 --- a/playwright/pages/dialogs/assignCountriesDialog.ts +++ b/playwright/pages/dialogs/assignCountriesDialog.ts @@ -1,22 +1,18 @@ -import { Locator, Page } from "@playwright/test"; +import { Page } from "@playwright/test"; export class AssignCountriesDialog { readonly page: Page; - readonly searchCountryInput: Locator; - readonly countryRow: Locator; - readonly restOfTheWorldRow: Locator; - readonly assignAndSaveButton: Locator; - readonly backButton: Locator; - readonly rowCheckBox: Locator; - constructor(page: Page) { + constructor( + page: Page, + readonly searchCountryInput = page.getByTestId("search-country-input"), + readonly countryRow = page.getByTestId("country-row"), + readonly restOfTheWorldRow = page.getByTestId("rest-of-the-world-row"), + readonly assignAndSaveButton = page.getByTestId("assign-and-save-button"), + readonly backButton = page.getByTestId("back-button"), + readonly rowCheckBox = page.getByTestId("checkbox"), + ) { this.page = page; - this.searchCountryInput = page.getByTestId("search-country-input"); - this.countryRow = page.getByTestId("country-row"); - this.restOfTheWorldRow = page.getByTestId("rest-of-the-world-row"); - this.assignAndSaveButton = page.getByTestId("assign-and-save-button"); - this.backButton = page.getByTestId("back-button"); - this.rowCheckBox = page.getByTestId("checkbox"); } async searchCountry(countryName = "Canada") { diff --git a/playwright/pages/dialogs/changePasswordDialog.ts b/playwright/pages/dialogs/changePasswordDialog.ts index 697e359a6e5..76106719a9a 100644 --- a/playwright/pages/dialogs/changePasswordDialog.ts +++ b/playwright/pages/dialogs/changePasswordDialog.ts @@ -1,20 +1,19 @@ -import type { Locator, Page } from "@playwright/test"; +import type { Page } from "@playwright/test"; export class ChangePasswordDialog { readonly page: Page; - readonly newPasswordInput: Locator; - readonly oldPasswordInput: Locator; - readonly saveButton: Locator; - constructor(page: Page) { - this.page = page; - this.saveButton = page.getByTestId("submit"); - this.newPasswordInput = page + constructor( + page: Page, + readonly saveButton = page.getByTestId("submit"), + readonly newPasswordInput = page .getByTestId("new-password-input") - .locator("input"); - this.oldPasswordInput = page + .locator("input"), + readonly oldPasswordInput = page .getByTestId("old-password-input") - .locator("input"); + .locator("input"), + ) { + this.page = page; } async clickSaveButton() { diff --git a/playwright/pages/dialogs/channelSelectDialog.ts b/playwright/pages/dialogs/channelSelectDialog.ts index a7c8931766d..6c28246f796 100644 --- a/playwright/pages/dialogs/channelSelectDialog.ts +++ b/playwright/pages/dialogs/channelSelectDialog.ts @@ -1,18 +1,16 @@ -import type { Locator, Page } from "@playwright/test"; +import type { Page } from "@playwright/test"; export class ChannelSelectDialog { readonly page: Page; - readonly allChannelsCheckbox: Locator; - readonly displayedChannels: Locator; - readonly confirmButton: Locator; - readonly displayedChannelsCheckboxes: Locator; - constructor(page: Page) { + constructor( + page: Page, + readonly allChannelsCheckbox = page.locator("[name='allChannels']"), + readonly displayedChannels = page.getByTestId("channel-row"), + readonly displayedChannelsCheckboxes = page.locator("[type=checkbox]"), + readonly confirmButton = page.getByTestId("submit"), + ) { this.page = page; - this.allChannelsCheckbox = page.locator("[name='allChannels']"); - this.displayedChannels = page.getByTestId("channel-row"); - this.displayedChannelsCheckboxes = page.locator("[type=checkbox]"); - this.confirmButton = page.getByTestId("submit"); } async clickAllChannelsCheckbox() { diff --git a/playwright/pages/dialogs/deleteChannelDialog.ts b/playwright/pages/dialogs/deleteChannelDialog.ts deleted file mode 100644 index 04c932f62e8..00000000000 --- a/playwright/pages/dialogs/deleteChannelDialog.ts +++ /dev/null @@ -1,18 +0,0 @@ -import type { Locator, Page } from "@playwright/test"; - -export class DeleteChannelDialog { - readonly page: Page; - - readonly deleteButton: Locator; - - constructor(page: Page) { - this.page = page; - - this.deleteButton = page.getByTestId("submit"); - } - - async clickDeleteButton() { - await this.deleteButton.first().click(); - await this.deleteButton.waitFor({ state: "hidden" }); - } -} diff --git a/playwright/pages/dialogs/deleteWarehouseDialog.ts b/playwright/pages/dialogs/deleteDialog.ts similarity index 78% rename from playwright/pages/dialogs/deleteWarehouseDialog.ts rename to playwright/pages/dialogs/deleteDialog.ts index ea1122d515b..5da29f5c34a 100644 --- a/playwright/pages/dialogs/deleteWarehouseDialog.ts +++ b/playwright/pages/dialogs/deleteDialog.ts @@ -1,6 +1,6 @@ import type { Page } from "@playwright/test"; -export class DeleteWarehouseDialog { +export class DeleteDialog { readonly page: Page; constructor(page: Page, readonly deleteButton = page.getByTestId("submit")) { @@ -8,7 +8,7 @@ export class DeleteWarehouseDialog { } async clickDeleteButton() { - await this.deleteButton.click(); + await this.deleteButton.first().click(); await this.deleteButton.waitFor({ state: "hidden" }); } } diff --git a/playwright/pages/dialogs/deleteDraftOrdersDialog.ts b/playwright/pages/dialogs/deleteDraftOrdersDialog.ts deleted file mode 100644 index 9b902cf8663..00000000000 --- a/playwright/pages/dialogs/deleteDraftOrdersDialog.ts +++ /dev/null @@ -1,17 +0,0 @@ -import type { Locator, Page } from "@playwright/test"; - -export class DeleteDraftOrdersDialog { - readonly page: Page; - - readonly deleteButton: Locator; - - constructor(page: Page) { - this.page = page; - - this.deleteButton = page.getByTestId("submit"); - } - - async clickDeleteButton() { - await this.deleteButton.first().click(); - } -} diff --git a/playwright/pages/dialogs/deleteProductDialog.ts b/playwright/pages/dialogs/deleteProductDialog.ts deleted file mode 100644 index 4c851059143..00000000000 --- a/playwright/pages/dialogs/deleteProductDialog.ts +++ /dev/null @@ -1,17 +0,0 @@ -import type { Locator, Page } from "@playwright/test"; - -export class DeleteProductDialog { - readonly page: Page; - - readonly deleteButton: Locator; - - constructor(page: Page) { - this.page = page; - - this.deleteButton = page.getByTestId("submit"); - } - - async clickDeleteButton() { - await this.deleteButton.first().click(); - } -} diff --git a/playwright/pages/dialogs/deleteVoucherDialog.ts b/playwright/pages/dialogs/deleteVoucherDialog.ts deleted file mode 100644 index bb63c292e45..00000000000 --- a/playwright/pages/dialogs/deleteVoucherDialog.ts +++ /dev/null @@ -1,13 +0,0 @@ -import type { Page } from "@playwright/test"; - -export class DeleteVoucherDialog { - readonly page: Page; - - constructor(page: Page, readonly deleteButton = page.getByTestId("submit")) { - this.page = page; - } - - async clickDeleteButton() { - await this.deleteButton.first().click(); - } -} diff --git a/playwright/pages/dialogs/deleteVouchersDialog.ts b/playwright/pages/dialogs/deleteVouchersDialog.ts deleted file mode 100644 index 31f4cefae80..00000000000 --- a/playwright/pages/dialogs/deleteVouchersDialog.ts +++ /dev/null @@ -1,13 +0,0 @@ -import type { Page } from "@playwright/test"; - -export class DeleteVouchersDialog { - readonly page: Page; - - constructor(page: Page, readonly deleteButton = page.getByTestId("submit")) { - this.page = page; - } - - async clickDeleteButton() { - await this.deleteButton.first().click(); - } -} diff --git a/playwright/pages/dialogs/draftOrderCreateDialog.ts b/playwright/pages/dialogs/draftOrderCreateDialog.ts index 70a6ebae6d0..e201e9a98e1 100644 --- a/playwright/pages/dialogs/draftOrderCreateDialog.ts +++ b/playwright/pages/dialogs/draftOrderCreateDialog.ts @@ -1,16 +1,17 @@ -import type { Locator, Page } from "@playwright/test"; +import type { Page } from "@playwright/test"; export class DraftOrderCreateDialog { readonly page: Page; - readonly channelNameInput: Locator; - readonly channelOption: Locator; - readonly confirmButton: Locator; - constructor(page: Page) { + constructor( + page: Page, + readonly channelNameInput = page.getByTestId("channel-autocomplete"), + readonly confirmButton = page.getByTestId("submit"), + readonly channelOption = page.locator( + "[data-test-id*='select-field-option']", + ), + ) { this.page = page; - this.channelNameInput = page.getByTestId("channel-autocomplete"); - this.confirmButton = page.getByTestId("submit"); - this.channelOption = page.locator("[data-test-id*='select-field-option']"); } async expandChannelsSearchList() { diff --git a/playwright/pages/dialogs/inviteStaffMemberDialog.ts b/playwright/pages/dialogs/inviteStaffMemberDialog.ts index 939a2c36647..11ae75b5291 100644 --- a/playwright/pages/dialogs/inviteStaffMemberDialog.ts +++ b/playwright/pages/dialogs/inviteStaffMemberDialog.ts @@ -1,18 +1,20 @@ -import type { Locator, Page } from "@playwright/test"; +import type { Page } from "@playwright/test"; export class InviteStaffMembersDialog { readonly page: Page; - readonly firstNameInput: Locator; - readonly lastNameInput: Locator; - readonly emailInput: Locator; - readonly sendInviteButton: Locator; - constructor(page: Page) { + constructor( + page: Page, + readonly firstNameInput = page + .getByTestId("first-name-input") + .locator("input"), + readonly lastNameInput = page + .getByTestId("last-name-input") + .locator("input"), + readonly emailInput = page.getByTestId("email-input").locator("input"), + readonly sendInviteButton = page.getByTestId("submit"), + ) { this.page = page; - this.firstNameInput = page.getByTestId("first-name-input").locator("input"); - this.lastNameInput = page.getByTestId("last-name-input").locator("input"); - this.emailInput = page.getByTestId("email-input").locator("input"); - this.sendInviteButton = page.getByTestId("submit"); } async clickSendInviteButton() { diff --git a/playwright/pages/dialogs/manageProductsChannelAvailability.ts b/playwright/pages/dialogs/manageProductsChannelAvailability.ts deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/playwright/pages/dialogs/orderCreateDialog.ts b/playwright/pages/dialogs/orderCreateDialog.ts index 987f120282a..58327b74546 100644 --- a/playwright/pages/dialogs/orderCreateDialog.ts +++ b/playwright/pages/dialogs/orderCreateDialog.ts @@ -1,16 +1,17 @@ -import type { Locator, Page } from "@playwright/test"; +import type { Page } from "@playwright/test"; export class OrderCreateDialog { readonly page: Page; - readonly channelNameInput: Locator; - readonly channelOption: Locator; - readonly confirmButton: Locator; - constructor(page: Page) { + constructor( + page: Page, + readonly channelNameInput = page.getByTestId("channel-autocomplete"), + readonly confirmButton = page.getByTestId("submit"), + readonly channelOption = page.locator( + "[data-test-id*='select-field-option']", + ), + ) { this.page = page; - this.channelNameInput = page.getByTestId("channel-autocomplete"); - this.confirmButton = page.getByTestId("submit"); - this.channelOption = page.locator("[data-test-id*='select-field-option']"); } async expandChannelsSearchList() { diff --git a/playwright/pages/dialogs/productCreateDialog.ts b/playwright/pages/dialogs/productCreateDialog.ts index 5b8fb491605..0536a471b6e 100644 --- a/playwright/pages/dialogs/productCreateDialog.ts +++ b/playwright/pages/dialogs/productCreateDialog.ts @@ -1,19 +1,19 @@ -import type { Locator, Page } from "@playwright/test"; +import type { Page } from "@playwright/test"; export class ProductCreateDialog { readonly page: Page; - readonly dialogProductTypeInput: Locator; - readonly promptedOptions: Locator; - readonly confirmButton: Locator; - constructor(page: Page) { - this.page = page; - this.dialogProductTypeInput = page.locator( + + constructor( + page: Page, + readonly dialogProductTypeInput = page.locator( "[data-test-id='dialog-product-type'] input", - ); - this.promptedOptions = page.getByTestId( + ), + readonly promptedOptions = page.getByTestId( "single-autocomplete-select-option", - ); - this.confirmButton = page.getByTestId("submit"); + ), + readonly confirmButton = page.getByTestId("submit"), + ) { + this.page = page; } async selectProductTypeWithVariants() { await this.dialogProductTypeInput.fill("beer"); diff --git a/playwright/pages/dialogs/shippingMethodDialog.ts b/playwright/pages/dialogs/shippingMethodDialog.ts index ff3906d1855..8625edff601 100644 --- a/playwright/pages/dialogs/shippingMethodDialog.ts +++ b/playwright/pages/dialogs/shippingMethodDialog.ts @@ -1,24 +1,20 @@ -import { expect, Locator, Page } from "@playwright/test"; +import { expect, Page } from "@playwright/test"; export class ShippingAddressDialog { readonly page: Page; - readonly selectShippingMethodInput: Locator; - readonly confirmButton: Locator; - readonly backButton: Locator; - readonly shippingMethodOption: Locator; - - constructor(page: Page) { - this.page = page; - - this.selectShippingMethodInput = page.locator( + constructor( + page: Page, + readonly selectShippingMethodInput = page.locator( '[id="mui-component-select-shippingMethod"]', - ); - this.confirmButton = page.getByTestId("confirm-button"); - this.backButton = page.getByTestId("back"); - this.shippingMethodOption = page.locator( + ), + readonly confirmButton = page.getByTestId("confirm-button"), + readonly backButton = page.getByTestId("back"), + readonly shippingMethodOption = page.locator( "[data-test-id*='select-field-option']", - ); + ), + ) { + this.page = page; } async pickAndConfirmFirstShippingMethod() { diff --git a/playwright/pages/discountsPage.ts b/playwright/pages/discountsPage.ts index fbccee51e69..46453a5af49 100644 --- a/playwright/pages/discountsPage.ts +++ b/playwright/pages/discountsPage.ts @@ -1,11 +1,12 @@ -import type { Locator, Page } from "@playwright/test"; +import type { Page } from "@playwright/test"; export class DiscountsPage { readonly page: Page; - readonly createDiscountButton: Locator; - constructor(page: Page) { + constructor( + page: Page, + readonly createDiscountButton = page.getByTestId("create-sale"), + ) { this.page = page; - this.createDiscountButton = page.getByTestId("create-sale"); } } diff --git a/playwright/pages/draftOrdersPage.ts b/playwright/pages/draftOrdersPage.ts index f54617791a4..15011096852 100644 --- a/playwright/pages/draftOrdersPage.ts +++ b/playwright/pages/draftOrdersPage.ts @@ -1,7 +1,7 @@ import { URL_LIST } from "@data/url"; import { AddProductsDialog } from "@dialogs/addProductsDialog"; import { AddressDialog } from "@dialogs/addressDialog"; -import { DeleteDraftOrdersDialog } from "@dialogs/deleteDraftOrdersDialog"; +import { DeleteDialog } from "@dialogs/deleteDialog"; import { DraftOrderCreateDialog } from "@dialogs/draftOrderCreateDialog"; import { ShippingAddressDialog } from "@dialogs/shippingMethodDialog"; import { RightSideDetailsPage } from "@pageElements/rightSideDetailsSection"; @@ -10,7 +10,7 @@ import type { Page } from "@playwright/test"; export class DraftOrdersPage extends BasePage { readonly page: Page; - readonly deleteDraftOrdersDialog: DeleteDraftOrdersDialog; + readonly deleteDraftOrdersDialog: DeleteDialog; readonly draftOrderCreateDialog: DraftOrderCreateDialog; readonly addProductsDialog: AddProductsDialog; readonly rightSideDetailsPage: RightSideDetailsPage; @@ -28,7 +28,7 @@ export class DraftOrdersPage extends BasePage { ) { super(page); this.page = page; - this.deleteDraftOrdersDialog = new DeleteDraftOrdersDialog(page); + this.deleteDraftOrdersDialog = new DeleteDialog(page); this.draftOrderCreateDialog = new DraftOrderCreateDialog(page); this.addProductsDialog = new AddProductsDialog(page); this.rightSideDetailsPage = new RightSideDetailsPage(page); diff --git a/playwright/pages/homePage.ts b/playwright/pages/homePage.ts index b57e386c4a8..0966fb08da7 100644 --- a/playwright/pages/homePage.ts +++ b/playwright/pages/homePage.ts @@ -1,31 +1,25 @@ import { URL_LIST } from "@data/url"; -import { expect, Locator, Page } from "@playwright/test"; +import { expect, Page } from "@playwright/test"; export class HomePage { readonly page: Page; - readonly welcomeMessage: Locator; - readonly sales: Locator; - readonly orders: Locator; - readonly activity: Locator; - readonly topProducts: Locator; - readonly ordersReadyToFulfill: Locator; - readonly paymentsWaitingForCapture: Locator; - readonly productsOutOfStock: Locator; - readonly channelSelect: Locator; - readonly channelOptions: Locator; - constructor(page: Page) { + constructor( + page: Page, + readonly channelSelect = page.getByTestId("app-channel-select"), + readonly channelOptions = page.locator( + "[data-test-id*='select-field-option']", + ), + readonly welcomeMessage = page.getByTestId("home-header"), + readonly sales = page.getByTestId("sales-analytics"), + readonly orders = page.getByTestId("orders-analytics"), + readonly activity = page.getByTestId("activity-card"), + readonly topProducts = page.getByTestId("top-products"), + readonly ordersReadyToFulfill = page.getByTestId("orders-to-fulfill"), + readonly paymentsWaitingForCapture = page.getByTestId("orders-to-capture"), + readonly productsOutOfStock = page.getByTestId("out-of-stock-analytics"), + ) { this.page = page; - this.channelSelect = page.getByTestId("app-channel-select"); - this.channelOptions = page.locator("[data-test-id*='select-field-option']"); - this.welcomeMessage = page.getByTestId("home-header"); - this.sales = page.getByTestId("sales-analytics"); - this.orders = page.getByTestId("orders-analytics"); - this.activity = page.getByTestId("activity-card"); - this.topProducts = page.getByTestId("top-products"); - this.ordersReadyToFulfill = page.getByTestId("orders-to-fulfill"); - this.paymentsWaitingForCapture = page.getByTestId("orders-to-capture"); - this.productsOutOfStock = page.getByTestId("out-of-stock-analytics"); } async goto() { await this.page.goto(URL_LIST.homePage); diff --git a/playwright/pages/loginPage.ts b/playwright/pages/loginPage.ts index 68a7e6b71de..2815a2865e2 100644 --- a/playwright/pages/loginPage.ts +++ b/playwright/pages/loginPage.ts @@ -1,24 +1,21 @@ import { HomePage } from "@pages/homePage"; -import { expect, Locator, Page } from "@playwright/test"; +import { expect, Page } from "@playwright/test"; export class LoginPage { readonly page: Page; - readonly emailInput: Locator; - readonly passwordInput: Locator; - readonly signInButton: Locator; - readonly resetPasswordLink: Locator; - readonly sendEmailWithResetLinkButton: Locator; - readonly backToLoginPageButton: Locator; - homePage: HomePage; - constructor(page: Page) { + + readonly homePage: HomePage; + constructor( + page: Page, + readonly emailInput = page.getByTestId("email"), + readonly passwordInput = page.getByTestId("password"), + readonly signInButton = page.getByTestId("submit"), + readonly resetPasswordLink = page.getByTestId("reset-password-link"), + readonly sendEmailWithResetLinkButton = page.getByTestId("submit"), + readonly backToLoginPageButton = page.getByTestId("back-to-login-button"), + ) { this.page = page; this.homePage = new HomePage(page); - this.emailInput = page.getByTestId("email"); - this.passwordInput = page.getByTestId("password"); - this.signInButton = page.getByTestId("submit"); - this.resetPasswordLink = page.getByTestId("reset-password-link"); - this.sendEmailWithResetLinkButton = page.getByTestId("submit"); - this.backToLoginPageButton = page.getByTestId("back-to-login-button"); } async clickBackToLoginPageButton() { diff --git a/playwright/pages/mainMenuPage.ts b/playwright/pages/mainMenuPage.ts index 061537c7fbf..a026725bbf8 100644 --- a/playwright/pages/mainMenuPage.ts +++ b/playwright/pages/mainMenuPage.ts @@ -1,52 +1,33 @@ -import type { Locator, Page } from "@playwright/test"; +import type { Page } from "@playwright/test"; import { expect } from "@playwright/test"; export class MainMenuPage { readonly page: Page; - readonly catalog: Locator; - readonly content: Locator; - readonly categories: Locator; - readonly configuration: Locator; - readonly home: Locator; - readonly orders: Locator; - readonly discounts: Locator; - readonly appSection: Locator; - readonly vouchers: Locator; - readonly app: Locator; - readonly translations: Locator; - readonly customers: Locator; - readonly list: Locator; - readonly listItem: Locator; - readonly products: Locator; - readonly menuItem: Locator; - readonly drafts: Locator; - readonly collections: Locator; - readonly accountSettings: Locator; - readonly userMenu: Locator; - - constructor(page: Page) { + constructor( + page: Page, + readonly userMenu = page.getByTestId("userMenu"), + readonly accountSettings = page.getByTestId("account-settings-button"), + readonly catalog = page.getByTestId("menu-item-label-catalogue"), + readonly content = page.getByTestId("menu-item-label-pages"), + readonly categories = page.getByTestId("menu-item-label-categories"), + readonly collections = page.getByTestId("menu-item-label-collections"), + readonly configuration = page.getByTestId("menu-item-label-configure"), + readonly home = page.getByTestId("menu-item-label-home"), + readonly orders = page.getByTestId("menu-item-label-orders"), + readonly drafts = page.getByTestId("menu-item-label-order-drafts"), + readonly discounts = page.getByTestId("menu-item-label-discounts"), + readonly vouchers = page.getByTestId("menu-item-label-vouchers"), + readonly appSection = page.getByTestId("menu-item-label-apps_section"), + readonly app = page.getByTestId("menu-item-label-apps"), + readonly translations = page.getByTestId("menu-item-label-translations"), + readonly customers = page.getByTestId("menu-item-label-customers"), + readonly list = page.getByTestId("menu-list"), + readonly listItem = page.getByTestId("menu-list-item"), + readonly products = page.getByTestId("menu-item-label-products"), + readonly menuItem = page.locator("[data-test-id*='menu-item-label-']"), + ) { this.page = page; - this.userMenu = page.getByTestId("userMenu"); - this.accountSettings = page.getByTestId("account-settings-button"); - this.catalog = page.getByTestId("menu-item-label-catalogue"); - this.content = page.getByTestId("menu-item-label-pages"); - this.categories = page.getByTestId("menu-item-label-categories"); - this.collections = page.getByTestId("menu-item-label-collections"); - this.configuration = page.getByTestId("menu-item-label-configure"); - this.home = page.getByTestId("menu-item-label-home"); - this.orders = page.getByTestId("menu-item-label-orders"); - this.drafts = page.getByTestId("menu-item-label-order-drafts"); - this.discounts = page.getByTestId("menu-item-label-discounts"); - this.vouchers = page.getByTestId("menu-item-label-vouchers"); - this.appSection = page.getByTestId("menu-item-label-apps_section"); - this.app = page.getByTestId("menu-item-label-apps"); - this.translations = page.getByTestId("menu-item-label-translations"); - this.customers = page.getByTestId("menu-item-label-customers"); - this.list = page.getByTestId("menu-list"); - this.listItem = page.getByTestId("menu-list-item"); - this.products = page.getByTestId("menu-item-label-products"); - this.menuItem = page.locator("[data-test-id*='menu-item-label-']"); } async gotoAccountSettings() { diff --git a/playwright/pages/pageElements/metadataSeoPage.ts b/playwright/pages/pageElements/metadataSeoPage.ts index 40049a329f5..7a7f9a8322d 100644 --- a/playwright/pages/pageElements/metadataSeoPage.ts +++ b/playwright/pages/pageElements/metadataSeoPage.ts @@ -1,6 +1,6 @@ import * as faker from "faker"; -import type { Locator, Page } from "@playwright/test"; +import type { Page } from "@playwright/test"; const metaDataName = `e2e-metaDataName-${faker.datatype.number()}`; const metaDataValue = `e2e-metaDataValue-${faker.datatype.number()}`; @@ -12,58 +12,44 @@ const seoDescriptionText = `e2e-seoSlugDescription-${faker.datatype.number()}`; export class MetadataSeoPage { readonly page: Page; readonly seoSlugName: string; - readonly productNameInput: Locator; - readonly editSeoSettings: Locator; - readonly slugInput: Locator; - readonly seoTitleInput: Locator; - readonly seoDescriptionInput: Locator; - readonly expandMetadataButton: Locator; - readonly metadataForm: Locator; - readonly addMetaButton: Locator; - readonly addPrivateMetaButton: Locator; - readonly metaDataNameInput: Locator; - readonly privateMetaDataNameInput: Locator; - readonly metadataValueField: Locator; - readonly privateMetadataValueField: Locator; - readonly metaExpandButton: Locator; - readonly metaDeletedButton: Locator; - readonly privateMetaSection: Locator; - readonly publicMetaSection: Locator; - readonly fulfillmentMetaSection: Locator; - constructor(page: Page) { - this.page = page; - this.seoSlugName = `e2e-seoSlug-${Math.random().toString().substring(2)}`; - this.productNameInput = page.locator("[name='name']"); - this.editSeoSettings = page.getByTestId("edit-seo"); - this.slugInput = page.locator("[name='slug']"); - this.seoTitleInput = page.locator("[name='seoTitle']"); - this.seoDescriptionInput = page.locator("[name='seoDescription']"); - this.expandMetadataButton = page.getByTestId("expand"); - this.metadataForm = page.locator("[data-test-id='metadata-editor']"); - this.addMetaButton = page + constructor( + page: Page, + readonly productNameInput = page.locator("[name='name']"), + readonly editSeoSettings = page.getByTestId("edit-seo"), + readonly slugInput = page.locator("[name='slug']"), + readonly seoTitleInput = page.locator("[name='seoTitle']"), + readonly seoDescriptionInput = page.locator("[name='seoDescription']"), + readonly expandMetadataButton = page.getByTestId("expand"), + readonly metadataForm = page.locator("[data-test-id='metadata-editor']"), + readonly metaExpandButton = page.getByTestId("expand"), + readonly metaDeletedButton = page.getByTestId("delete-field-0"), + readonly privateMetaSection = page.locator("[data-test-is-private='true']"), + readonly publicMetaSection = page.locator("[data-test-is-private='false']"), + readonly fulfillmentMetaSection = page.getByTestId( + "fulfilled-order-section", + ), + readonly addMetaButton = page .locator("[data-test-is-private='false']") - .getByTestId("add-field"); - this.addPrivateMetaButton = page + .getByTestId("add-field"), + readonly addPrivateMetaButton = page .locator("[data-test-is-private='true']") - .getByTestId("add-field"); - this.metaDataNameInput = page + .getByTestId("add-field"), + readonly metaDataNameInput = page .locator("[data-test-is-private='false']") - .locator("[name*='name']"); - this.privateMetaDataNameInput = page + .locator("[name*='name']"), + readonly privateMetaDataNameInput = page .locator("[data-test-is-private='true']") - .locator("[name*='name']"); - this.metadataValueField = page + .locator("[name*='name']"), + readonly metadataValueField = page .locator("[data-test-is-private='false']") - .locator("[name*='value']"); - this.privateMetadataValueField = page + .locator("[name*='value']"), + readonly privateMetadataValueField = page .locator("[data-test-is-private='true']") - .locator("[name*='value']"); - this.metaExpandButton = page.getByTestId("expand"); - this.metaDeletedButton = page.getByTestId("delete-field-0"); - this.privateMetaSection = page.locator("[data-test-is-private='true']"); - this.publicMetaSection = page.locator("[data-test-is-private='false']"); - this.fulfillmentMetaSection = page.getByTestId("fulfilled-order-section"); + .locator("[name*='value']"), + ) { + this.page = page; + this.seoSlugName = `e2e-seoSlug-${Math.random().toString().substring(2)}`; } async expandAndAddAllMetadata( diff --git a/playwright/pages/pageTypesPage.ts b/playwright/pages/pageTypesPage.ts index 8c5441ae476..7bb1dd69ed7 100644 --- a/playwright/pages/pageTypesPage.ts +++ b/playwright/pages/pageTypesPage.ts @@ -1,11 +1,12 @@ -import type { Locator, Page } from "@playwright/test"; +import type { Page } from "@playwright/test"; export class PageTypesPage { readonly page: Page; - readonly createPageTypeButton: Locator; - constructor(page: Page) { + constructor( + page: Page, + readonly createPageTypeButton = page.getByTestId("create-page-type"), + ) { this.page = page; - this.createPageTypeButton = page.getByTestId("create-page-type"); } } diff --git a/playwright/pages/permissionGroupsPage.ts b/playwright/pages/permissionGroupsPage.ts index d83f75f43af..3b1061690f5 100644 --- a/playwright/pages/permissionGroupsPage.ts +++ b/playwright/pages/permissionGroupsPage.ts @@ -1,13 +1,14 @@ -import type { Locator, Page } from "@playwright/test"; +import type { Page } from "@playwright/test"; export class PermissionGroupsPage { readonly page: Page; - readonly createPermissionGroupButton: Locator; - constructor(page: Page) { - this.page = page; - this.createPermissionGroupButton = page.getByTestId( + constructor( + page: Page, + readonly createPermissionGroupButton = page.getByTestId( "create-permission-group", - ); + ), + ) { + this.page = page; } } diff --git a/playwright/pages/pluginsPage.ts b/playwright/pages/pluginsPage.ts index 6b88d05097a..7e56f9ef23b 100644 --- a/playwright/pages/pluginsPage.ts +++ b/playwright/pages/pluginsPage.ts @@ -1,11 +1,9 @@ -import type { Locator, Page } from "@playwright/test"; +import type { Page } from "@playwright/test"; export class PluginsPage { readonly page: Page; - readonly pluginRow: Locator; - constructor(page: Page) { + constructor(page: Page, readonly pluginRow = page.getByTestId("plugin")) { this.page = page; - this.pluginRow = page.getByTestId("plugin"); } } diff --git a/playwright/pages/productPage.ts b/playwright/pages/productPage.ts index e2a1ed86ba7..fe86ba21664 100644 --- a/playwright/pages/productPage.ts +++ b/playwright/pages/productPage.ts @@ -2,16 +2,15 @@ import * as faker from "faker"; import path from "path"; import { URL_LIST } from "@data/url"; +import { DeleteDialog } from "@dialogs/deleteDialog"; +import { FiltersPage } from "@pageElements/filtersPage"; +import { BasePage } from "@pages/basePage"; import { ChannelSelectDialog } from "@pages/dialogs/channelSelectDialog"; import { ExportProductsDialog } from "@pages/dialogs/exportProductsDialog"; import { MetadataSeoPage } from "@pages/pageElements/metadataSeoPage"; import { RightSideDetailsPage } from "@pages/pageElements/rightSideDetailsSection"; import { expect, Page } from "@playwright/test"; -import { BasePage } from "./basePage"; -import { DeleteProductDialog } from "./dialogs/deleteProductDialog"; -import { FiltersPage } from "./pageElements/filtersPage"; - const productName = `e2e-productName-${faker.datatype.number()}`; const productDescription = `e2e-productDescription-${faker.datatype.number()}`; @@ -21,7 +20,7 @@ export class ProductPage extends BasePage { readonly rightSideDetailsPage: RightSideDetailsPage; readonly basePage: BasePage; readonly channelSelectDialog: ChannelSelectDialog; - readonly deleteProductDialog: DeleteProductDialog; + readonly deleteProductDialog: DeleteDialog; readonly filtersPage: FiltersPage; constructor( @@ -79,7 +78,7 @@ export class ProductPage extends BasePage { super(page); this.basePage = new BasePage(page); this.exportProductsDialog = new ExportProductsDialog(page); - this.deleteProductDialog = new DeleteProductDialog(page); + this.deleteProductDialog = new DeleteDialog(page); this.channelSelectDialog = new ChannelSelectDialog(page); this.metadataSeoPage = new MetadataSeoPage(page); this.rightSideDetailsPage = new RightSideDetailsPage(page); @@ -87,17 +86,16 @@ export class ProductPage extends BasePage { } async gotoCreateProductPage(productTypeId: string) { - await this.page.goto( - `${URL_LIST.products}${URL_LIST.productsAdd}${productTypeId}`, - ); + const createProductUrl = `${URL_LIST.products}${URL_LIST.productsAdd}${productTypeId}`; + await console.log("Navigating to create product view: " + createProductUrl); + await this.page.goto(createProductUrl); await expect(this.basePage.pageHeader).toBeVisible({ timeout: 10000 }); } async gotoExistingProductPage(productId: string) { - console.log( - `Navigating to existing product: ${URL_LIST.products}${productId}`, - ); - await this.page.goto(`${URL_LIST.products}${productId}`); + const existingProductUrl = `${URL_LIST.products}${productId}`; + console.log(`Navigating to existing product: ${existingProductUrl}`); + await this.page.goto(existingProductUrl); await expect(this.basePage.pageHeader).toBeVisible({ timeout: 10000 }); } diff --git a/playwright/pages/productTypePage.ts b/playwright/pages/productTypePage.ts index 7fb66a19ca9..cb484bd4126 100644 --- a/playwright/pages/productTypePage.ts +++ b/playwright/pages/productTypePage.ts @@ -1,41 +1,32 @@ import { URL_LIST } from "@data/url"; -import type { Locator, Page } from "@playwright/test"; - -import { BasePage } from "./basePage"; +import { BasePage } from "@pages/basePage"; +import type { Page } from "@playwright/test"; export class ProductTypePage { readonly page: Page; basePage: BasePage; - readonly nameInput: Locator; - readonly isShippingRequired: Locator; - readonly assignProductAttributeButton: Locator; - readonly hasVariantsButton: Locator; - readonly shippingWeightInput: Locator; - readonly giftCardKindCheckbox: Locator; - readonly variantSelectionCheckbox: Locator; - readonly saveButton: Locator; - readonly notificationSuccess: Locator; - readonly addProductTypeButton: Locator; - constructor(page: Page) { - this.page = page; - this.basePage = new BasePage(page); - this.addProductTypeButton = page.getByTestId("add-product-type"); - this.notificationSuccess = page.getByTestId("notification-message"); - this.nameInput = page.locator("[name='name']"); - this.isShippingRequired = page.locator("[name='isShippingRequired']"); - this.assignProductAttributeButton = page.getByTestId( + constructor( + page: Page, + readonly addProductTypeButton = page.getByTestId("add-product-type"), + readonly notificationSuccess = page.getByTestId("notification-message"), + readonly nameInput = page.locator("[name='name']"), + readonly isShippingRequired = page.locator("[name='isShippingRequired']"), + readonly assignProductAttributeButton = page.getByTestId( "assign-products-attributes", - ); - this.hasVariantsButton = page.locator("[name='hasVariants']"); - this.shippingWeightInput = page.locator("[name='weight']"); - this.giftCardKindCheckbox = page.getByTestId( + ), + readonly hasVariantsButton = page.locator("[name='hasVariants']"), + readonly shippingWeightInput = page.locator("[name='weight']"), + readonly giftCardKindCheckbox = page.getByTestId( "product-type-kind-option-GIFT_CARD", - ); - this.variantSelectionCheckbox = page.getByTestId( + ), + readonly variantSelectionCheckbox = page.getByTestId( "variant-selection-checkbox", - ); - this.saveButton = page.getByTestId("button-bar-confirm"); + ), + readonly saveButton = page.getByTestId("button-bar-confirm"), + ) { + this.page = page; + this.basePage = new BasePage(page); } async typeProductTypeName(name: string) { @@ -52,6 +43,9 @@ export class ProductTypePage { await this.giftCardKindCheckbox.click(); } async gotoAddProductTypePage() { + console.log( + `Navigating to add product type page: ${URL_LIST.productTypesAdd}`, + ); await this.page.goto(URL_LIST.productTypesAdd); } async expectSuccessBanner() { diff --git a/playwright/pages/setUpNewPasswordPage.ts b/playwright/pages/setUpNewPasswordPage.ts index e6921179380..f79f78456fa 100644 --- a/playwright/pages/setUpNewPasswordPage.ts +++ b/playwright/pages/setUpNewPasswordPage.ts @@ -1,19 +1,20 @@ import { MailpitService } from "@api/mailpit"; -import type { APIRequestContext, Locator, Page } from "@playwright/test"; +import type { APIRequestContext, Page } from "@playwright/test"; export class SetUpNewPasswordPage { readonly page: Page; - readonly passwordInput: Locator; - readonly confirmPasswordInput: Locator; - readonly setNewPasswordButton: Locator; + readonly mailpitService: MailpitService; - constructor(page: Page, request: APIRequestContext) { + constructor( + page: Page, + request: APIRequestContext, + readonly passwordInput = page.getByTestId("password"), + readonly confirmPasswordInput = page.getByTestId("confirm-password"), + readonly setNewPasswordButton = page.getByTestId("button-bar-confirm"), + ) { this.page = page; this.mailpitService = new MailpitService(request); - this.passwordInput = page.getByTestId("password"); - this.confirmPasswordInput = page.getByTestId("confirm-password"); - this.setNewPasswordButton = page.getByTestId("button-bar-confirm"); } async typePassword(password: string) { diff --git a/playwright/pages/shippingMethodsPage.ts b/playwright/pages/shippingMethodsPage.ts index a1a894ddb9d..f5897afdc0d 100644 --- a/playwright/pages/shippingMethodsPage.ts +++ b/playwright/pages/shippingMethodsPage.ts @@ -1,37 +1,31 @@ import { URL_LIST } from "@data/url"; +import { BasePage } from "@pages/basePage"; import { AssignCountriesDialog } from "@pages/dialogs/assignCountriesDialog"; import { RightSideDetailsPage } from "@pages/pageElements/rightSideDetailsSection"; -import type { Locator, Page } from "@playwright/test"; - -import { BasePage } from "./basePage"; +import type { Page } from "@playwright/test"; export class ShippingMethodsPage { readonly page: Page; readonly basePage: BasePage; readonly rightSideDetailsPage: RightSideDetailsPage; readonly assignCountriesDialog: AssignCountriesDialog; - readonly createShippingZoneButton: Locator; - readonly shippingZoneNameInput: Locator; - readonly shippingZoneDescriptionField: Locator; - readonly saveButton: Locator; - readonly assignCountryButton: Locator; - readonly addPriceRateButton: Locator; - readonly addWeightRateButton: Locator; - constructor(page: Page) { + constructor( + page: Page, + readonly assignCountryButton = page.getByTestId("assign-country"), + readonly addPriceRateButton = page.getByTestId("add-price-rate"), + readonly addWeightRateButton = page.getByTestId("add-weight-rate"), + readonly createShippingZoneButton = page.getByTestId("add-shipping-zone"), + readonly shippingZoneNameInput = page.getByTestId("shipping-zone-name"), + readonly shippingZoneDescriptionField = page + .getByTestId("shipping-zone-description") + .locator("textarea"), + readonly saveButton = page.getByTestId("button-bar-confirm"), + ) { this.page = page; this.basePage = new BasePage(page); this.rightSideDetailsPage = new RightSideDetailsPage(page); this.assignCountriesDialog = new AssignCountriesDialog(page); - this.assignCountryButton = page.getByTestId("assign-country"); - this.addPriceRateButton = page.getByTestId("add-price-rate"); - this.addWeightRateButton = page.getByTestId("add-weight-rate"); - this.createShippingZoneButton = page.getByTestId("add-shipping-zone"); - this.shippingZoneNameInput = page.getByTestId("shipping-zone-name"); - this.shippingZoneDescriptionField = page - .getByTestId("shipping-zone-description") - .locator("textarea"); - this.saveButton = page.getByTestId("button-bar-confirm"); } async clickAddWeightRateButton() { @@ -67,8 +61,12 @@ export class ShippingMethodsPage { timeout: 10000, }); } - async gotoShippingMethod(shippingMethodId: string) { - await this.page.goto(`${URL_LIST.shippingMethods}${shippingMethodId}`); + async gotoExistingShippingMethod(shippingMethodId: string) { + const existingShippingMethodUrl = `${URL_LIST.shippingMethods}${shippingMethodId}`; + await console.log( + `Navigates to existing shipping method page: ${existingShippingMethodUrl}`, + ); + await this.page.goto(existingShippingMethodUrl); await this.shippingZoneNameInput.waitFor({ state: "visible", timeout: 10000, diff --git a/playwright/pages/shippingRatesPage.ts b/playwright/pages/shippingRatesPage.ts index 7137fc27268..f1ef9859044 100644 --- a/playwright/pages/shippingRatesPage.ts +++ b/playwright/pages/shippingRatesPage.ts @@ -2,7 +2,7 @@ import { BasePage } from "@pages/basePage"; import { AddPostalCodeDialog } from "@pages/dialogs/addPostalCodeDialog"; import { AddProductsDialog } from "@pages/dialogs/addProductsDialog"; import { RightSideDetailsPage } from "@pages/pageElements/rightSideDetailsSection"; -import type { Locator, Page } from "@playwright/test"; +import type { Page } from "@playwright/test"; export class ShippingRatesPage { readonly page: Page; @@ -10,57 +10,46 @@ export class ShippingRatesPage { readonly rightSideDetailsPage: RightSideDetailsPage; readonly addProductsDialog: AddProductsDialog; readonly addPostalCodeDialog: AddPostalCodeDialog; - readonly shippingRateNameInput: Locator; - readonly shippingRateDescriptionField: Locator; - readonly minDeliveryTimeInput: Locator; - readonly maxDeliveryTimeInput: Locator; - readonly priceInput: Locator; - readonly minValueInput: Locator; - readonly minWeightInput: Locator; - readonly maxValueInput: Locator; - readonly maxWeightInput: Locator; - readonly addPostalCodeRangeButton: Locator; - readonly saveButton: Locator; - readonly assignProductButton: Locator; - readonly includePostalCodesRadioButton: Locator; - readonly excludedProductsRows: Locator; - readonly assignedPostalCodesRows: Locator; - constructor(page: Page) { - this.page = page; - this.basePage = new BasePage(page); - this.addProductsDialog = new AddProductsDialog(page); - this.addPostalCodeDialog = new AddPostalCodeDialog(page); - this.rightSideDetailsPage = new RightSideDetailsPage(page); - this.shippingRateNameInput = page + constructor( + page: Page, + readonly shippingRateNameInput = page .getByTestId("shipping-rate-name-input") - .locator("input"); - this.shippingRateDescriptionField = page + .locator("input"), + readonly shippingRateDescriptionField = page .getByTestId("rich-text-editor-description") - .locator('[contenteditable="true"]'); - this.maxDeliveryTimeInput = page + .locator('[contenteditable="true"]'), + readonly maxDeliveryTimeInput = page .getByTestId("max-delivery-time-input") - .locator("input"); - this.minDeliveryTimeInput = page + .locator("input"), + readonly minDeliveryTimeInput = page .getByTestId("min-delivery-time-input") - .locator("input"); - this.addPostalCodeRangeButton = page.getByTestId("add-postal-code-range"); - this.saveButton = page.getByTestId("button-bar-confirm"); - this.assignProductButton = page.getByTestId("assign-product-button"); - this.priceInput = page.getByTestId("price-input"); - this.minValueInput = page.getByTestId("min-value-price-input"); - this.minWeightInput = page + .locator("input"), + readonly addPostalCodeRangeButton = page.getByTestId( + "add-postal-code-range", + ), + readonly saveButton = page.getByTestId("button-bar-confirm"), + readonly assignProductButton = page.getByTestId("assign-product-button"), + readonly priceInput = page.getByTestId("price-input"), + readonly minValueInput = page.getByTestId("min-value-price-input"), + readonly minWeightInput = page .getByTestId("min-order-weight-input") - .locator("input"); - this.maxValueInput = page.getByTestId("max-value-price-input"); - this.maxWeightInput = page + .locator("input"), + readonly maxValueInput = page.getByTestId("max-value-price-input"), + readonly maxWeightInput = page .getByTestId("max-order-weight-input") - .locator("input"); - this.excludedProductsRows = page.getByTestId("excluded-products-rows"); - this.includePostalCodesRadioButton = page.getByTestId("INCLUDE"); - this.assignedPostalCodesRows = page.getByTestId( + .locator("input"), + readonly excludedProductsRows = page.getByTestId("excluded-products-rows"), + readonly includePostalCodesRadioButton = page.getByTestId("INCLUDE"), + readonly assignedPostalCodesRows = page.getByTestId( "assigned-postal-codes-rows", - ); + ), + ) { + this.page = page; + this.basePage = new BasePage(page); + this.addProductsDialog = new AddProductsDialog(page); + this.addPostalCodeDialog = new AddPostalCodeDialog(page); + this.rightSideDetailsPage = new RightSideDetailsPage(page); } async addFirstAvailableExcludedProduct() { diff --git a/playwright/pages/siteSettingsPage.ts b/playwright/pages/siteSettingsPage.ts index 70ab1bd8c8f..0bb2ff98320 100644 --- a/playwright/pages/siteSettingsPage.ts +++ b/playwright/pages/siteSettingsPage.ts @@ -1,11 +1,12 @@ -import type { Locator, Page } from "@playwright/test"; +import type { Page } from "@playwright/test"; export class SiteSettingsPage { readonly page: Page; - readonly companyInfoSection: Locator; - constructor(page: Page) { + constructor( + page: Page, + readonly companyInfoSection = page.locator('[data-test-id="company-info"]'), + ) { this.page = page; - this.companyInfoSection = page.locator('[data-test-id="company-info"]'); } } diff --git a/playwright/pages/staffMembersPage.ts b/playwright/pages/staffMembersPage.ts index 4cc1d596b2e..7a52e0d29da 100644 --- a/playwright/pages/staffMembersPage.ts +++ b/playwright/pages/staffMembersPage.ts @@ -1,8 +1,7 @@ import { MailpitService } from "@api/mailpit"; +import { BasePage } from "@pages/basePage"; import { InviteStaffMembersDialog } from "@pages/dialogs/inviteStaffMemberDialog"; -import type { APIRequestContext, Locator, Page } from "@playwright/test"; - -import { BasePage } from "./basePage"; +import type { APIRequestContext, Page } from "@playwright/test"; export class StaffMembersPage { readonly page: Page; @@ -10,31 +9,30 @@ export class StaffMembersPage { readonly basePage: BasePage; readonly mailpitService: MailpitService; readonly inviteStaffMembersDialog: InviteStaffMembersDialog; - readonly inviteStaffMembersButton: Locator; - readonly saveButton: Locator; - readonly permissionsGroupSelectButton: Locator; - readonly permissionGroupOptions: Locator; - readonly assignedPermissionGroups: Locator; - readonly isActiveCheckbox: Locator; - constructor(page: Page, request: APIRequestContext) { + constructor( + page: Page, + request: APIRequestContext, + readonly inviteStaffMembersButton = page.getByTestId("invite-staff-member"), + readonly saveButton = page.getByTestId("button-bar-confirm"), + readonly permissionsGroupSelectButton = page.getByTestId( + "permission-groups", + ), + readonly permissionGroupOptions = page.getByTestId( + "multi-autocomplete-select-option", + ), + readonly assignedPermissionGroups = page.getByTestId( + "assigned-permission-group", + ), + readonly isActiveCheckbox = page + .getByTestId("is-active-checkbox") + .locator("input"), + ) { this.page = page; this.request = request; this.basePage = new BasePage(page); this.mailpitService = new MailpitService(request); this.inviteStaffMembersDialog = new InviteStaffMembersDialog(page); - this.inviteStaffMembersButton = page.getByTestId("invite-staff-member"); - this.saveButton = page.getByTestId("button-bar-confirm"); - this.permissionsGroupSelectButton = page.getByTestId("permission-groups"); - this.permissionGroupOptions = page.getByTestId( - "multi-autocomplete-select-option", - ); - this.assignedPermissionGroups = page.getByTestId( - "assigned-permission-group", - ); - this.isActiveCheckbox = page - .getByTestId("is-active-checkbox") - .locator("input"); } async clickIsActiveCheckbox() { diff --git a/playwright/pages/variantsPage.ts b/playwright/pages/variantsPage.ts index 99c09e3d3c1..75f67d8c2cd 100644 --- a/playwright/pages/variantsPage.ts +++ b/playwright/pages/variantsPage.ts @@ -1,11 +1,10 @@ import { URL_LIST } from "@data/url"; import { ChannelSelectDialog } from "@dialogs/channelSelectDialog"; import { DeleteVariantDialog } from "@dialogs/deleteVariantDialog"; +import { MetadataSeoPage } from "@pageElements/metadataSeoPage"; +import { BasePage } from "@pages/basePage"; import type { Page } from "@playwright/test"; -import { BasePage } from "./basePage"; -import { MetadataSeoPage } from "./pageElements/metadataSeoPage"; - export class VariantsPage { readonly page: Page; channelSelectDialog: ChannelSelectDialog; @@ -134,12 +133,9 @@ export class VariantsPage { } async gotoExistingVariantPage(productId: string, variantId: string) { - console.log( - `Navigating to existing variant: ${URL_LIST.products}${productId}/${URL_LIST.variant}${variantId}`, - ); - await this.page.goto( - `${URL_LIST.products}${productId}/${URL_LIST.variant}${variantId}`, - ); + const existingVariantUrl = `${URL_LIST.products}${productId}/${URL_LIST.variant}${variantId}`; + console.log(`Navigating to existing variant: ${existingVariantUrl}`); + await this.page.goto(existingVariantUrl); await this.variantNameInput.waitFor({ state: "visible" }); } } diff --git a/playwright/pages/vouchersPage.ts b/playwright/pages/vouchersPage.ts index 26bed48b838..60ce998f6bc 100644 --- a/playwright/pages/vouchersPage.ts +++ b/playwright/pages/vouchersPage.ts @@ -1,18 +1,17 @@ import { URL_LIST } from "@data/url"; import { AddVoucherCodeDialog } from "@dialogs/addVoucherCodeDialog"; import { AssignSpecificProductsDialog } from "@dialogs/assignSpecificProductsDialog"; -import { DeleteVoucherDialog } from "@dialogs/deleteVoucherDialog"; -import { DeleteVouchersDialog } from "@dialogs/deleteVouchersDialog"; import { RightSideDetailsPage } from "@pageElements/rightSideDetailsSection"; import { BasePage } from "@pages/basePage"; import type { Page } from "@playwright/test"; +import { DeleteDialog } from "./dialogs/deleteDialog"; + export class VouchersPage extends BasePage { readonly page: Page; readonly addVoucherCodeDialog: AddVoucherCodeDialog; readonly rightSideDetailsPage: RightSideDetailsPage; - readonly deleteVoucherDialog: DeleteVoucherDialog; - readonly deleteVouchersDialog: DeleteVouchersDialog; + readonly deleteVoucherDialog: DeleteDialog; readonly assignSpecificProductsDialog: AssignSpecificProductsDialog; constructor( @@ -78,8 +77,7 @@ export class VouchersPage extends BasePage { this.page = page; this.addVoucherCodeDialog = new AddVoucherCodeDialog(page); this.rightSideDetailsPage = new RightSideDetailsPage(page); - this.deleteVoucherDialog = new DeleteVoucherDialog(page); - this.deleteVouchersDialog = new DeleteVouchersDialog(page); + this.deleteVoucherDialog = new DeleteDialog(page); this.assignSpecificProductsDialog = new AssignSpecificProductsDialog(page); } @@ -164,9 +162,12 @@ export class VouchersPage extends BasePage { await this.page.goto(URL_LIST.vouchers); } async gotoExistingVoucherPage(voucherId: string) { - await this.page.goto(`${URL_LIST.vouchers}${voucherId}`); + const existingVoucherUrl = `${URL_LIST.vouchers}${voucherId}`; + console.log(`Navigating to existing variant: ${existingVoucherUrl}`); + await this.page.goto(existingVoucherUrl); } async gotoVoucherAddPage() { + console.log(`Navigating to voucher add page: ${URL_LIST.vouchersAddPage}`); await this.page.goto(URL_LIST.vouchersAddPage); } diff --git a/playwright/pages/warehousePage.ts b/playwright/pages/warehousePage.ts index 2e8a369ce46..620f6f54604 100644 --- a/playwright/pages/warehousePage.ts +++ b/playwright/pages/warehousePage.ts @@ -1,5 +1,5 @@ import { URL_LIST } from "@data/url"; -import { DeleteWarehouseDialog } from "@dialogs/deleteWarehouseDialog"; +import { DeleteDialog } from "@dialogs/deleteDialog"; import { BasePage } from "@pages/basePage"; import type { Page } from "@playwright/test"; @@ -8,7 +8,7 @@ import { RightSideDetailsPage } from "./pageElements/rightSideDetailsSection"; export class WarehousePage extends BasePage { readonly page: Page; readonly basePage: BasePage; - readonly deleteWarehouseDialog: DeleteWarehouseDialog; + readonly deleteWarehouseDialog: DeleteDialog; readonly rightSideDetailsPage: RightSideDetailsPage; constructor( @@ -48,7 +48,7 @@ export class WarehousePage extends BasePage { super(page); this.page = page; this.basePage = new BasePage(page); - this.deleteWarehouseDialog = new DeleteWarehouseDialog(page); + this.deleteWarehouseDialog = new DeleteDialog(page); this.rightSideDetailsPage = new RightSideDetailsPage(page); } diff --git a/playwright/pages/webhooksEventsPage.ts b/playwright/pages/webhooksEventsPage.ts index 94129864a30..c8810c0e809 100644 --- a/playwright/pages/webhooksEventsPage.ts +++ b/playwright/pages/webhooksEventsPage.ts @@ -1,11 +1,12 @@ -import type { Locator, Page } from "@playwright/test"; +import type { Page } from "@playwright/test"; export class WebhooksEventsPage { readonly page: Page; - readonly createAppButton: Locator; - constructor(page: Page) { + constructor( + page: Page, + readonly createAppButton = page.getByTestId("create-app"), + ) { this.page = page; - this.createAppButton = page.getByTestId("create-app"); } } diff --git a/playwright/tests/discountAndVouchers.spec.ts b/playwright/tests/discountAndVouchers.spec.ts index ee46e0b9705..f29b7cd68b6 100644 --- a/playwright/tests/discountAndVouchers.spec.ts +++ b/playwright/tests/discountAndVouchers.spec.ts @@ -204,7 +204,7 @@ test("TC: SALEOR_93 Bulk delete voucher @vouchers @e2e", async () => { ); await vouchersPage.clickBulkDeleteButton(); - await vouchersPage.deleteVouchersDialog.clickDeleteButton(); + await vouchersPage.deleteVoucherDialog.clickDeleteButton(); await vouchersPage.expectSuccessBanner(); await vouchersPage.waitForGrid(); await expect( diff --git a/playwright/tests/shippingMethods.spec.ts b/playwright/tests/shippingMethods.spec.ts index cbd8ae5f840..61933578eb1 100644 --- a/playwright/tests/shippingMethods.spec.ts +++ b/playwright/tests/shippingMethods.spec.ts @@ -32,7 +32,7 @@ test("TC: SALEOR_32 Add price rate to shipping method - with excluded zip codes const shippingMethodsPage = new ShippingMethodsPage(page); const shippingRatesPage = new ShippingRatesPage(page); - await shippingMethodsPage.gotoShippingMethod( + await shippingMethodsPage.gotoExistingShippingMethod( SHIPPING_METHODS.shippingMethodWithoutRates.id, ); await shippingMethodsPage.clickAddPriceRateButton(); @@ -61,7 +61,7 @@ test("TC: SALEOR_33 Add weight rate to shipping method - with included zip codes const shippingMethodsPage = new ShippingMethodsPage(page); const shippingRatesPage = new ShippingRatesPage(page); - await shippingMethodsPage.gotoShippingMethod( + await shippingMethodsPage.gotoExistingShippingMethod( SHIPPING_METHODS.shippingMethodWithoutRates.id, ); await shippingMethodsPage.clickAddWeightRateButton();