From e30b377aabd16aad3fbf9d632abb1e4f19a48fc4 Mon Sep 17 00:00:00 2001 From: "M.Graczyk" Date: Wed, 20 Nov 2024 14:12:18 +0100 Subject: [PATCH 1/3] Remove expect from Saleor_211 (#5269) * remove expect * Update breezy-forks-share.md Update changeset --- .changeset/breezy-forks-share.md | 5 +++++ playwright/tests/staffMembers.spec.ts | 1 - 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 .changeset/breezy-forks-share.md diff --git a/.changeset/breezy-forks-share.md b/.changeset/breezy-forks-share.md new file mode 100644 index 0000000000..fddead0a6c --- /dev/null +++ b/.changeset/breezy-forks-share.md @@ -0,0 +1,5 @@ +--- +"saleor-dashboard": patch +--- + +Removed unnecessary expect that was waiting for the success banner, as it was causing delays on CI. Instead, the test rely on other assertions to verify that changes have been applied diff --git a/playwright/tests/staffMembers.spec.ts b/playwright/tests/staffMembers.spec.ts index ff887acd5d..6500061115 100644 --- a/playwright/tests/staffMembers.spec.ts +++ b/playwright/tests/staffMembers.spec.ts @@ -58,7 +58,6 @@ test("TC: SALEOR_211 Create a staff member @e2e @staff-members", async () => { await staffMembersPage.assignUserToPermissionGroup("Channels Management"); await staffMembersPage.clickSaveButton(); - await staffMembersPage.expectSuccessBanner(); await staffMembersPage.verifyAssignedPermission("Customer Support"); await staffMembersPage.verifyAssignedPermission("Channels Management"); From c6fd9625f9298b6a182130b5708fd0fc310822db Mon Sep 17 00:00:00 2001 From: "M.Graczyk" Date: Thu, 21 Nov 2024 13:01:59 +0100 Subject: [PATCH 2/3] removed the redundant method (#5272) --- .changeset/eighty-apricots-flow.md | 5 +++++ playwright/pages/basePage.ts | 21 +++++++++++---------- playwright/tests/apps.spec.ts | 4 ++-- playwright/tests/customers.spec.ts | 2 +- playwright/tests/giftCards.spec.ts | 4 ++-- playwright/tests/orders.spec.ts | 26 +++++++++++++------------- playwright/tests/product.spec.ts | 2 +- 7 files changed, 35 insertions(+), 29 deletions(-) create mode 100644 .changeset/eighty-apricots-flow.md diff --git a/.changeset/eighty-apricots-flow.md b/.changeset/eighty-apricots-flow.md new file mode 100644 index 0000000000..3d9f88b3b2 --- /dev/null +++ b/.changeset/eighty-apricots-flow.md @@ -0,0 +1,5 @@ +--- +"saleor-dashboard": patch +--- + +Merged expectSuccessBannerMessage and expectSuccessBanner into a single method, removed the redundant method, and updated tests to use the new unified method. diff --git a/playwright/pages/basePage.ts b/playwright/pages/basePage.ts index 614b9988d3..e720faea4e 100644 --- a/playwright/pages/basePage.ts +++ b/playwright/pages/basePage.ts @@ -102,20 +102,21 @@ export class BasePage { await this.saveButton.click(); } - async expectSuccessBannerMessage(msg: string) { - await this.successBanner.locator(`text=${msg}`).waitFor({ state: "visible", timeout: 10000 }); - await expect(this.errorBanner, "No error banner should be visible").not.toBeVisible(); - } - async expectErrorBannerMessage(msg: string) { await this.errorBanner.locator(`text=${msg}`).waitFor({ state: "visible", timeout: 10000 }); } - async expectSuccessBanner(timeout = SUCCESS_BANNER_TIMEOUT) { - await this.successBanner.first().waitFor({ - state: "visible", - timeout, - }); + async expectSuccessBanner( + options: { message?: string; timeout?: number } = { timeout: SUCCESS_BANNER_TIMEOUT }, + ) { + if (options.message) { + await this.successBanner + .locator(`text=${options.message}`) + .waitFor({ state: "visible", timeout: options.timeout }); + } else { + await this.successBanner.first().waitFor({ state: "visible", timeout: options.timeout }); + } + await expect(this.errorBanner, "No error banner should be visible").not.toBeVisible(); } diff --git a/playwright/tests/apps.spec.ts b/playwright/tests/apps.spec.ts index 46b6d34330..930681b5e2 100644 --- a/playwright/tests/apps.spec.ts +++ b/playwright/tests/apps.spec.ts @@ -38,7 +38,7 @@ test("TC: SALEOR_119 User should be able to install and configure app from manif ); await installationPage.installAppButton.click(); - await expect(appsPage.successBanner).toBeVisible({ timeout: INSTALLATION_PENDING_TIMEOUT }); + await appsPage.expectSuccessBanner({ timeout: INSTALLATION_PENDING_TIMEOUT }); await expect(appsPage.installedAppRow.first()).toBeVisible(); await expect(appsPage.installationPendingLabel).not.toBeVisible(); @@ -54,7 +54,7 @@ test("TC: SALEOR_119 User should be able to install and configure app from manif }); await iframeLocator.getByLabel("PUBLIC_TOKEN").fill("test_token"); await iframeLocator.getByText("Save").click(); - await appsPage.expectSuccessBanner(); + await appsPage.expectSuccessBanner({ timeout: INSTALLATION_PENDING_TIMEOUT }); }); test("TC: SALEOR_120 User should be able to delete thirdparty app @e2e", async () => { await appPage.waitForNetworkIdleAfterAction(() => diff --git a/playwright/tests/customers.spec.ts b/playwright/tests/customers.spec.ts index 6ac152c4ea..7ee59185bc 100644 --- a/playwright/tests/customers.spec.ts +++ b/playwright/tests/customers.spec.ts @@ -231,7 +231,7 @@ test("TC: SALEOR_207 Issue a new gift card for the customer @e2e @customer", asy await giftCardsPage.expectSuccessBanner(); await giftCardsPage.issueGiftCardDialog.clickOkButton(); await giftCardsPage.expectElementIsHidden(giftCardsPage.giftCardDialog); - await giftCardsPage.expectSuccessBannerMessage("Successfully created gift card"); + await giftCardsPage.expectSuccessBanner({ message: "Successfully created gift card" }); await giftCardsPage.gotoGiftCardsListView(); await giftCardsPage.waitForCanvasContainsText(`Code ending with ${code}`); }); diff --git a/playwright/tests/giftCards.spec.ts b/playwright/tests/giftCards.spec.ts index cfbece2eed..23582b4c1c 100644 --- a/playwright/tests/giftCards.spec.ts +++ b/playwright/tests/giftCards.spec.ts @@ -29,7 +29,7 @@ test("TC: SALEOR_105 Issue gift card @e2e @gift", async () => { await giftCardsPage.expectSuccessBanner(); await giftCardsPage.issueGiftCardDialog.clickOkButton(); await giftCardsPage.giftCardDialog.waitFor({ state: "hidden" }); - await giftCardsPage.expectSuccessBannerMessage("Successfully created gift card"); + await giftCardsPage.expectSuccessBanner({ message: "Successfully created gift card" }); await giftCardsPage.gotoGiftCardsListView(); await giftCardsPage.gridCanvas .getByText(`Code ending with ${code}`) @@ -49,7 +49,7 @@ test("TC: SALEOR_106 Issue gift card with specific customer and expiry date @e2e await giftCardsPage.issueGiftCardDialog.clickOkButton(); await giftCardsPage.giftCardDialog.waitFor({ state: "hidden" }); - await giftCardsPage.expectSuccessBannerMessage("Successfully created gift card"); + await giftCardsPage.expectSuccessBanner({ message: "Successfully created gift card" }); await giftCardsPage.gotoGiftCardsListView(); await giftCardsPage.searchAndFindRowIndexes(fullCode); expect( diff --git a/playwright/tests/orders.spec.ts b/playwright/tests/orders.spec.ts index b8464f131c..5ce96be6b9 100644 --- a/playwright/tests/orders.spec.ts +++ b/playwright/tests/orders.spec.ts @@ -47,7 +47,7 @@ test("TC: SALEOR_28 Create basic order @e2e @order", async () => { await ordersPage.clickAddShippingCarrierButton(); await ordersPage.shippingAddressDialog.pickAndConfirmFirstShippingMethod(); await ordersPage.clickFinalizeButton(); - await draftOrdersPage.expectSuccessBannerMessage("finalized"); + await draftOrdersPage.expectSuccessBanner({ message: "finalized" }); }); test("TC: SALEOR_76 Create order with transaction flow activated @e2e @order", async () => { @@ -65,7 +65,7 @@ test("TC: SALEOR_76 Create order with transaction flow activated @e2e @order", a await ordersPage.clickAddShippingCarrierButton(); await ordersPage.shippingAddressDialog.pickAndConfirmFirstShippingMethod(); await ordersPage.clickFinalizeButton(); - await draftOrdersPage.expectSuccessBannerMessage("finalized"); + await draftOrdersPage.expectSuccessBanner({ message: "finalized" }); }); test("TC: SALEOR_77 Mark order as paid and fulfill it with transaction flow activated @e2e @order", async () => { @@ -74,7 +74,7 @@ test("TC: SALEOR_77 Mark order as paid and fulfill it with transaction flow acti ); await ordersPage.clickMarkAsPaidButton(); await ordersPage.markOrderAsPaidDialog.typeAndSaveOrderReference(); - await ordersPage.expectSuccessBannerMessage("paid"); + await ordersPage.expectSuccessBanner({ message: "paid" }); const transactionsMadeRows = await ordersPage.orderTransactionsList.locator("tr"); @@ -82,7 +82,7 @@ test("TC: SALEOR_77 Mark order as paid and fulfill it with transaction flow acti await expect(transactionsMadeRows).toContainText("Success"); await ordersPage.clickFulfillButton(); await fulfillmentPage.clickFulfillButton(); - await ordersPage.expectSuccessBannerMessage("fulfilled"); + await ordersPage.expectSuccessBanner({ message: "fulfilled" }); expect(await ordersPage.pageHeaderStatusInfo).toContainText("Fulfilled"); }); @@ -140,7 +140,7 @@ test("TC: SALEOR_78 Capture partial amounts by manual transactions and fulfill o ); await ordersPage.clickFulfillButton(); await fulfillmentPage.clickFulfillButton(); - await ordersPage.expectSuccessBannerMessage("fulfilled"); + await ordersPage.expectSuccessBanner({ message: "fulfilled" }); expect(await ordersPage.pageHeaderStatusInfo, "Order should be yet fulfilled").toContainText( "Fulfilled", ); @@ -150,7 +150,7 @@ test("TC: SALEOR_79 Mark order as paid and fulfill it with regular flow @e2e @or await ordersPage.goToExistingOrderPage(ORDERS.orderToMarkAsPaidAndFulfill.id); await ordersPage.clickMarkAsPaidButton(); await ordersPage.markOrderAsPaidDialog.typeAndSaveOrderReference(); - await ordersPage.expectSuccessBannerMessage("paid"); + await ordersPage.expectSuccessBanner({ message: "paid" }); await expect(ordersPage.balanceStatusInfo).toHaveText("Settled"); expect(await ordersPage.paymentStatusInfo, "Order should be fully paid").toContainText( "Fully paid", @@ -158,7 +158,7 @@ test("TC: SALEOR_79 Mark order as paid and fulfill it with regular flow @e2e @or await ordersPage.clickFulfillButton(); await fulfillmentPage.clickFulfillButton(); - await ordersPage.expectSuccessBannerMessage("fulfilled"); + await ordersPage.expectSuccessBanner({ message: "fulfilled" }); expect(await ordersPage.pageHeaderStatusInfo).toContainText("Fulfilled"); }); @@ -168,7 +168,7 @@ test("TC: SALEOR_80 Add tracking to order @e2e @order", async () => { await ordersPage.goToExistingOrderPage(ORDERS.orderToAddTrackingNumberTo.id); await ordersPage.clickAddTrackingButton(); await ordersPage.addTrackingDialog.typeTrackingNumberAndSave(trackingNumber); - await ordersPage.expectSuccessBannerMessage("updated"); + await ordersPage.expectSuccessBanner({ message: "updated" }); await expect(ordersPage.setTrackingNumber).toContainText(trackingNumber); }); @@ -253,9 +253,9 @@ test("TC: SALEOR_84 Create draft order @e2e @draft", async () => { await draftOrdersPage.expectSuccessBanner(); await draftOrdersPage.clickAddShippingCarrierButton(); await draftOrdersPage.shippingAddressDialog.pickAndConfirmFirstShippingMethod(); - await draftOrdersPage.expectSuccessBanner(); + //await draftOrdersPage.expectSuccessBanner(); await draftOrdersPage.clickFinalizeButton(); - await draftOrdersPage.expectSuccessBannerMessage("finalized"); + await draftOrdersPage.expectSuccessBanner({ message: "finalized" }); }); test("TC: SALEOR_191 Refund products from the fully paid order @e2e @refunds", async () => { @@ -293,7 +293,7 @@ test("TC: SALEOR_191 Refund products from the fully paid order @e2e @refunds", a await ordersPage.clickEditRefundButton(refundReason); await refundPage.waitForDOMToFullyLoad(); await refundPage.transferFunds(); - await refundPage.expectSuccessBannerMessage("Refund has been sent"); + await refundPage.expectSuccessBanner({ message: "Refund has been sent" }); }); test("TC: SALEOR_192 Should create a manual refund with a custom amount @e2e @refunds", async () => { @@ -313,7 +313,7 @@ test("TC: SALEOR_192 Should create a manual refund with a custom amount @e2e @re ); await refundPage.provideRefundAmount("10"); await refundPage.transferFunds(); - await refundPage.expectSuccessBannerMessage("Transaction action requested successfully"); + await refundPage.expectSuccessBanner({ message: "Transaction action requested successfully" }); await ordersPage.goToExistingOrderPage(order.id); await ordersPage.orderRefundSection.waitFor({ state: "visible" }); await ordersPage.assertRefundOnList("Manual refund"); @@ -475,5 +475,5 @@ test("TC: SALEOR_217 Complete basic order for non existing customer @e2e @order" await ordersPage.clickAddShippingCarrierButton(); await ordersPage.shippingAddressDialog.pickAndConfirmFirstShippingMethod(); await ordersPage.clickFinalizeButton(); - await draftOrdersPage.expectSuccessBannerMessage("finalized"); + await ordersPage.expectSuccessBanner({ message: "finalized" }); }); diff --git a/playwright/tests/product.spec.ts b/playwright/tests/product.spec.ts index d9df63c8d7..7d3b348c7d 100644 --- a/playwright/tests/product.spec.ts +++ b/playwright/tests/product.spec.ts @@ -118,7 +118,7 @@ test("TC: SALEOR_45 As an admin I should be able to delete a single products @ba ); await productPage.clickDeleteProductButton(); await productPage.deleteProductDialog.clickDeleteButton(); - await productPage.expectSuccessBannerMessage("Product Removed"); + await productPage.expectSuccessBanner({ message: "Product Removed" }); await productPage.waitForGrid(); await productPage.searchforProduct(PRODUCTS.productWithOneVariantToBeDeletedFromDetails.name); await expect( From 7290aca15ea7c76619d6dec45f524089ccee6bcf Mon Sep 17 00:00:00 2001 From: "M.Graczyk" Date: Thu, 21 Nov 2024 14:58:05 +0100 Subject: [PATCH 3/3] Removed waitForNetworkIdleAfterAction - Saleor_128 (#5273) * Removed waitForNetworkIdleAfterAction and replaced it with a direct navigation call. * Update purple-pumpkins-drive.md --- .changeset/purple-pumpkins-drive.md | 5 +++++ playwright/tests/attributes.spec.ts | 8 +++----- 2 files changed, 8 insertions(+), 5 deletions(-) create mode 100644 .changeset/purple-pumpkins-drive.md diff --git a/.changeset/purple-pumpkins-drive.md b/.changeset/purple-pumpkins-drive.md new file mode 100644 index 0000000000..c36c189b30 --- /dev/null +++ b/.changeset/purple-pumpkins-drive.md @@ -0,0 +1,5 @@ +--- +"saleor-dashboard": patch +--- + +Removed waitForNetworkIdleAfterAction and replaced it with a direct navigation call.Added blur actions on metadataKeyInput and metadataValueInput to ensure input stability before saving in scope of SALEOR_128 diff --git a/playwright/tests/attributes.spec.ts b/playwright/tests/attributes.spec.ts index e5f5510f86..c4706b057e 100644 --- a/playwright/tests/attributes.spec.ts +++ b/playwright/tests/attributes.spec.ts @@ -163,22 +163,20 @@ for (const attribute of attributesWithValuesToBeUpdated) { for (const attr of ATTRIBUTES.attributesToBeUpdated) { test(`TC: SALEOR_128 User should be able to edit existing ${attr.name} attribute @e2e @attributes`, async () => { - await attributesPage.waitForNetworkIdleAfterAction(() => - attributesPage.gotoExistingAttributePage(attr.id, attr.name), - ); + await attributesPage.gotoExistingAttributePage(attr.id, attr.name); + await attributesPage.attributeDefaultLabelInput.waitFor({ state: "visible" }); await attributesPage.attributeDefaultLabelInput.clear(); await attributesPage.typeAttributeDefaultLabel(`updated ${attr.name}`); await attributesPage.expandMetadataSection(); await attributesPage.metadataAddFieldButton.click(); - await attributesPage.metadataKeyInput.waitFor({ state: "visible" }); await attributesPage.metadataValueInput.waitFor({ state: "visible" }); await attributesPage.fillMetadataFields("new key", "new value"); + await attributesPage.metadataValueInput.blur(); await attributesPage.clickSaveButton(); await attributesPage.expectSuccessBanner(); await attributesPage.expectElementIsHidden(attributesPage.successBanner); await attributesPage.attributeSelect.waitFor({ state: "visible" }); - await expect(attributesPage.attributeSelect).toHaveAttribute("aria-disabled", "true"); await expect(attributesPage.metadataKeyInput).toHaveValue("new key"); await expect(attributesPage.metadataValueInput).toHaveValue("new value");