Skip to content

Commit

Permalink
Merge branch 'main' into MERX-1262-onboarding-component-accordion
Browse files Browse the repository at this point in the history
  • Loading branch information
michalina-graczyk authored Nov 21, 2024
2 parents b821746 + c6fd962 commit 9a31df0
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 29 deletions.
5 changes: 5 additions & 0 deletions .changeset/eighty-apricots-flow.md
Original file line number Diff line number Diff line change
@@ -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.
21 changes: 11 additions & 10 deletions playwright/pages/basePage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 });

Check failure on line 117 in playwright/pages/basePage.ts

View workflow job for this annotation

GitHub Actions / run-tests (2/2)

[e2e] › staffMembers.spec.ts:33:5 › TC: SALEOR_211 Create a staff member @e2e @staff-members

1) [e2e] › staffMembers.spec.ts:33:5 › TC: SALEOR_211 Create a staff member @e2e @staff-members ── Error: locator.waitFor: Timeout 20000ms exceeded. Call log: - waiting for locator('[data-test-type="success"]').first() to be visible at ../pages/basePage.ts:117 115 | .waitFor({ state: "visible", timeout: options.timeout }); 116 | } else { > 117 | await this.successBanner.first().waitFor({ state: "visible", timeout: options.timeout }); | ^ 118 | } 119 | 120 | await expect(this.errorBanner, "No error banner should be visible").not.toBeVisible(); at StaffMembersPage.expectSuccessBanner (/home/runner/work/saleor-dashboard/saleor-dashboard/playwright/pages/basePage.ts:117:40) at /home/runner/work/saleor-dashboard/saleor-dashboard/playwright/tests/staffMembers.spec.ts:48:26
}

await expect(this.errorBanner, "No error banner should be visible").not.toBeVisible();
}

Expand Down
4 changes: 2 additions & 2 deletions playwright/tests/apps.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand All @@ -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(() =>
Expand Down
2 changes: 1 addition & 1 deletion playwright/tests/customers.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`);
});
4 changes: 2 additions & 2 deletions playwright/tests/giftCards.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`)
Expand All @@ -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(
Expand Down
26 changes: 13 additions & 13 deletions playwright/tests/orders.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand All @@ -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 () => {
Expand All @@ -74,15 +74,15 @@ 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");

expect(await transactionsMadeRows.count()).toEqual(1);
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");
});

Expand Down Expand Up @@ -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",
);
Expand All @@ -150,15 +150,15 @@ 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",
);

await ordersPage.clickFulfillButton();
await fulfillmentPage.clickFulfillButton();
await ordersPage.expectSuccessBannerMessage("fulfilled");
await ordersPage.expectSuccessBanner({ message: "fulfilled" });
expect(await ordersPage.pageHeaderStatusInfo).toContainText("Fulfilled");
});

Expand All @@ -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);
});

Expand Down Expand Up @@ -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 () => {
Expand Down Expand Up @@ -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 () => {
Expand All @@ -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");
Expand Down Expand Up @@ -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" });
});
2 changes: 1 addition & 1 deletion playwright/tests/product.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 9a31df0

Please sign in to comment.