From a6ed4570f0c562b70fa6e20ff3076327337d5b47 Mon Sep 17 00:00:00 2001 From: Renata Date: Tue, 7 May 2024 11:40:06 +0200 Subject: [PATCH] [QA] Removing skips from Playwright tests (#4840) * Removing skips from Playwright tests * fixing flaky test --- .changeset/shy-spoons-explain.md | 5 ++++ playwright.config.ts | 14 ++++++----- playwright/api/mailpit.ts | 2 +- .../pages/dialogs/exportProductsDialog.ts | 12 +++++++++- .../pages/dialogs/shippingMethodDialog.ts | 4 +--- playwright/pages/draftOrdersPage.ts | 1 + playwright/tests/giftCards.spec.ts | 24 +++++++++---------- playwright/tests/navigation.spec.ts | 2 +- playwright/tests/product.spec.ts | 5 ++-- playwright/tests/vouchers.spec.ts | 3 +-- 10 files changed, 42 insertions(+), 30 deletions(-) create mode 100644 .changeset/shy-spoons-explain.md diff --git a/.changeset/shy-spoons-explain.md b/.changeset/shy-spoons-explain.md new file mode 100644 index 00000000000..a8bc9d7d9fb --- /dev/null +++ b/.changeset/shy-spoons-explain.md @@ -0,0 +1,5 @@ +--- +"saleor-dashboard": minor +--- + +Removing skips from e2e tests diff --git a/playwright.config.ts b/playwright.config.ts index d430a116f8b..4dae581e47d 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -1,17 +1,19 @@ -import dotenv from "dotenv"; import { defineConfig, devices } from "@playwright/test"; +import dotenv from "dotenv"; dotenv.config(); + const env = process.env; -const DEFAULT_RETRIES = '1'; -const DEFAULT_WORKERS = '2'; +const DEFAULT_RETRIES = "1"; +const DEFAULT_WORKERS = "2"; + export default defineConfig({ testDir: "playwright/tests", fullyParallel: true, forbidOnly: !!env.CI, retries: parseInt(env.RETRIES || DEFAULT_RETRIES), workers: parseInt(env.WORKERS || DEFAULT_WORKERS), - reporter: process.env.CI + reporter: process.env.CI ? [ ["blob"], ["github"], @@ -33,7 +35,7 @@ export default defineConfig({ maxFailures: 5, timeout: env.CI ? 45000 : 60000, use: { - baseURL: env.BASE_URL || '', + baseURL: env.BASE_URL || "", trace: env.CI ? "on-all-retries" : "on", screenshot: "only-on-failure", testIdAttribute: "data-test-id", @@ -43,7 +45,7 @@ export default defineConfig({ projects: [ { name: "setup", - testMatch: /.*\.setup\.ts/ + testMatch: /.*\.setup\.ts/, }, { name: "chromium", diff --git a/playwright/api/mailpit.ts b/playwright/api/mailpit.ts index 7645f979c6e..dcef5965e72 100644 --- a/playwright/api/mailpit.ts +++ b/playwright/api/mailpit.ts @@ -102,7 +102,7 @@ export class MailpitService { { message: `Message with subject: ${mailSubject} was not found`, intervals: [2000, 3000, 5000, 5000], - timeout: 15000, + timeout: 30000, }, ) .toBe(true); diff --git a/playwright/pages/dialogs/exportProductsDialog.ts b/playwright/pages/dialogs/exportProductsDialog.ts index bcd9d2325ba..8363378b881 100644 --- a/playwright/pages/dialogs/exportProductsDialog.ts +++ b/playwright/pages/dialogs/exportProductsDialog.ts @@ -8,7 +8,9 @@ export class ExportProductsDialog { readonly channelsAccordion = page.getByTestId("channel-expand-button"), readonly nextButton = page.getByTestId("next"), readonly submitButton = page.getByTestId("submit"), - readonly exportSearchedProductsRadioButton = page.locator("input[value='FILTER']"), + readonly exportSearchedProductsRadioButton = page.getByTestId("FILTER"), + readonly exportSelectedProductsRadioButton = page.getByTestId("IDS"), + readonly exportAllProductsRadioButton = page.getByTestId("ALL"), ) { this.page = page; } @@ -29,6 +31,14 @@ export class ExportProductsDialog { await this.exportSearchedProductsRadioButton.click(); } + async clickExportSelectedProductsRadioButton() { + await this.exportSelectedProductsRadioButton.click(); + } + + async clickExportAllProductsRadioButton() { + await this.exportAllProductsRadioButton.click(); + } + async checkChannelCheckbox(channel = "PLN") { await this.page.locator(`[name="Channel-${channel}"]`).click(); } diff --git a/playwright/pages/dialogs/shippingMethodDialog.ts b/playwright/pages/dialogs/shippingMethodDialog.ts index b510d09b7a8..0a8e7c76cfd 100644 --- a/playwright/pages/dialogs/shippingMethodDialog.ts +++ b/playwright/pages/dialogs/shippingMethodDialog.ts @@ -13,9 +13,7 @@ export class ShippingAddressDialog extends BasePage { } async pickAndConfirmFirstShippingMethod() { - await this.waitForNetworkIdle(async () => { - await this.selectShippingMethodInput.click(); - }); + await this.selectShippingMethodInput.click(); await this.shippingMethodOption.first().click(); await this.confirmButton.click(); await expect(this.selectShippingMethodInput).not.toBeVisible(); diff --git a/playwright/pages/draftOrdersPage.ts b/playwright/pages/draftOrdersPage.ts index b2c93f9ef10..d86d9cfddb5 100644 --- a/playwright/pages/draftOrdersPage.ts +++ b/playwright/pages/draftOrdersPage.ts @@ -60,6 +60,7 @@ export class DraftOrdersPage extends BasePage { async clickAddShippingCarrierButton() { await this.addShippingCarrierLink.click(); + await this.waitForDOMToFullyLoad(); } async clickFinalizeButton() { diff --git a/playwright/tests/giftCards.spec.ts b/playwright/tests/giftCards.spec.ts index 9b0d48f6e6b..57d018daaaf 100644 --- a/playwright/tests/giftCards.spec.ts +++ b/playwright/tests/giftCards.spec.ts @@ -1,4 +1,4 @@ -// import { MailpitService } from "@api/mailpit"; +import { MailpitService } from "@api/mailpit"; import { GIFT_CARDS } from "@data/e2eTestData"; import { GiftCardsPage } from "@pages/giftCardsPage"; import { expect, test } from "@playwright/test"; @@ -6,11 +6,11 @@ import { expect, test } from "@playwright/test"; test.use({ storageState: "./playwright/.auth/admin.json" }); let giftCardsPage: GiftCardsPage; -// let mailpitService: MailpitService; +let mailpitService: MailpitService; test.beforeEach(async ({ page, request }) => { giftCardsPage = new GiftCardsPage(page); - // mailpitService = new MailpitService(request); + mailpitService = new MailpitService(request); await giftCardsPage.gotoGiftCardsListView(); await giftCardsPage.waitForDOMToFullyLoad(); }); @@ -122,11 +122,10 @@ test("TC: SALEOR_182 Export gift card codes in XLSX file @e2e @gift", async () = state: "hidden", timeout: 30000, }); - // To be uncommented https://linear.app/saleor/issue/QAG-94/remove-skip-from-app-tests - // await mailpitService.checkDoesUserReceivedExportedData( - // process.env.E2E_USER_NAME!, - // "Your exported gift cards data is ready", - // ); + await mailpitService.checkDoesUserReceivedExportedData( + process.env.E2E_USER_NAME!, + "Your exported gift cards data is ready", + ); }); test("TC: SALEOR_183 Export gift card codes in CSV file @e2e @gift", async () => { await giftCardsPage.clickShowMoreMenu(); @@ -136,9 +135,8 @@ test("TC: SALEOR_183 Export gift card codes in CSV file @e2e @gift", async () => state: "hidden", timeout: 30000, }); - // To be uncommented https://linear.app/saleor/issue/QAG-94/remove-skip-from-app-tests - // await mailpitService.checkDoesUserReceivedExportedData( - // process.env.E2E_USER_NAME!, - // "Your exported gift cards data is ready", - // ); + await mailpitService.checkDoesUserReceivedExportedData( + process.env.E2E_USER_NAME!, + "Your exported gift cards data is ready", + ); }); diff --git a/playwright/tests/navigation.spec.ts b/playwright/tests/navigation.spec.ts index 5c9d0b5a5f4..8db3a5ec746 100644 --- a/playwright/tests/navigation.spec.ts +++ b/playwright/tests/navigation.spec.ts @@ -48,7 +48,7 @@ test("TC: SALEOR_194 Should create a new menu navigation with menu item @navigat await expect(navigationDetailsPage.menuItemList).toContainText(menuItemName); }); // TODO: To be updated after https://linear.app/saleor/issue/MERX-307 is fixed -test("TC: SALEOR_198 Should update existing menu @navigation @e2e", async () => { +test.skip("TC: SALEOR_198 Should update existing menu @navigation @e2e", async () => { await navigationDetailsPage.goToExistingMenuView(NAVIGATION_ITEMS.navigationMenuToBeUpdated.id); const menuItemToBeUpdated = NAVIGATION_ITEMS.navigationMenuToBeUpdated.menuItems[0]; diff --git a/playwright/tests/product.spec.ts b/playwright/tests/product.spec.ts index 20dc4cfe953..0bcfe098a84 100644 --- a/playwright/tests/product.spec.ts +++ b/playwright/tests/product.spec.ts @@ -161,8 +161,7 @@ test("TC: SALEOR_46 As an admin, I should be able to update a product by uploadi "Newly added single image should be present", ).toEqual(1); }); -// blocked by bug https://github.com/saleor/saleor-dashboard/issues/4368 -test.skip("TC: SALEOR_56 As an admin, I should be able to export products from single channel as CSV file @basic-regression @product @e2e", async () => { +test("TC: SALEOR_56 As an admin, I should be able to export products from single channel as CSV file @basic-regression @product @e2e", async () => { await productPage.gotoProductListPage(); await productPage.waitForDOMToFullyLoad(); await productPage.clickCogShowMoreButtonButton(); @@ -170,7 +169,7 @@ test.skip("TC: SALEOR_56 As an admin, I should be able to export products from s await productPage.exportProductsDialog.clickChannelsAccordion(); await productPage.exportProductsDialog.checkChannelCheckbox("PLN"); await productPage.exportProductsDialog.clickNextButton(); - await productPage.exportProductsDialog.clickExportSearchedProductsRadioButton(); + await productPage.exportProductsDialog.clickExportAllProductsRadioButton(); await productPage.exportProductsDialog.clickSubmitButton(); await productPage.expectInfoBanner(); await mailpitService.checkDoesUserReceivedExportedData( diff --git a/playwright/tests/vouchers.spec.ts b/playwright/tests/vouchers.spec.ts index a6d3844b533..1f9672e1a2c 100644 --- a/playwright/tests/vouchers.spec.ts +++ b/playwright/tests/vouchers.spec.ts @@ -178,8 +178,7 @@ test("TC: SALEOR_93 Bulk delete voucher @vouchers @e2e", async () => { `Given vouchers: ${VOUCHERS.vouchers.voucherToBeBulkDeleted.names} should be deleted from the list`, ).toEqual([]); }); -// TODO: https://github.com/saleor/saleor-dashboard/issues/4590 -test.skip("TC: SALEOR_94 Edit voucher - assign voucher to specific category @vouchers @e2e", async () => { +test("TC: SALEOR_94 Edit voucher - assign voucher to specific category @vouchers @e2e", async () => { const categoryToBeAssigned = "Accessories"; await vouchersPage.gotoExistingVoucherPage(