Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🎀 Refactor test to use waitForLoaderToDisappear 🎀 #5243

Merged
merged 8 commits into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/nasty-grapes-attend.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"saleor-dashboard": patch
---

Refactor tests to replace `waitForDOMToFullyLoad` with `waitForLoaderToDisappear`, making the test shorter by waiting only for the loader to disappear instead of the entire DOM to load.
2 changes: 1 addition & 1 deletion playwright/data/commonLocators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ export const LOCATORS = {
dataGridTable: '[data-testid="data-grid-canvas"]',
deleteButton: '[data-test-id="button-bar-delete"]',
bulkDeleteButton: '[data-test-id="bulk-delete-button"]',
loader: '[data-test-id="loader"]',
dataGridLoader: '[data-test-id="datagrid-loader"]',
};
7 changes: 5 additions & 2 deletions playwright/pages/basePage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
readonly errorBanner = page.locator(LOCATORS.errorBanner),
readonly saveButton = page.locator(LOCATORS.saveButton),
readonly infoBanner = page.locator(LOCATORS.infoBanner),
readonly loader = page.locator(LOCATORS.loader),
readonly dataGridLoader = page.locator(LOCATORS.dataGridLoader),
readonly previousPagePaginationButton = page.getByTestId("button-pagination-back"),
readonly rowNumberButton = page.getByTestId("PaginationRowNumberSelect"),
readonly rowNumberOption = page.getByTestId("rowNumberOption"),
Expand Down Expand Up @@ -110,7 +110,7 @@
}

async expectSuccessBanner() {
await this.successBanner.first().waitFor({ state: "visible", timeout: 15000 });

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

View workflow job for this annotation

GitHub Actions / run-tests (2/2)

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

2) [e2e] › staffMembers.spec.ts:24:5 › TC: SALEOR_211 Create a staff member @e2e @staff-members ── Error: locator.waitFor: Timeout 15000ms exceeded. Call log: - waiting for locator('[data-test-type="success"]').first() to be visible at ../pages/basePage.ts:113 111 | 112 | async expectSuccessBanner() { > 113 | await this.successBanner.first().waitFor({ state: "visible", timeout: 15000 }); | ^ 114 | await expect(this.errorBanner, "No error banner should be visible").not.toBeVisible(); 115 | } 116 | at StaffMembersPage.expectSuccessBanner (/home/runner/work/saleor-dashboard/saleor-dashboard/playwright/pages/basePage.ts:113:38) at /home/runner/work/saleor-dashboard/saleor-dashboard/playwright/tests/staffMembers.spec.ts:34:26
await expect(this.errorBanner, "No error banner should be visible").not.toBeVisible();
}

Expand Down Expand Up @@ -313,7 +313,6 @@

async waitForDOMToFullyLoad() {
await this.page.waitForLoadState("domcontentloaded", { timeout: 70000 });
await this.loader.waitFor({ state: "hidden" });
}

async expectElementIsHidden(locator: Locator) {
Expand All @@ -327,4 +326,8 @@
async waitForCanvasContainsText(text: string) {
await this.gridCanvas.getByText(text).waitFor({ state: "attached", timeout: 50000 });
}

async waitForDatagridLoaderToDisappear() {
await this.dataGridLoader.waitFor({ state: "hidden" });
}
}
2 changes: 1 addition & 1 deletion playwright/tests/categories.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ test.beforeEach(({ page }) => {
});
test("TC: SALEOR_102 Create basic category @e2e @category", async () => {
await categoriesPage.gotoCategoryListView();
await categoriesPage.waitForDOMToFullyLoad();
await categoriesPage.waitForDatagridLoaderToDisappear();
await categoriesPage.clickCreateNewCategoryButton();
await categoriesPage.typeCategoryName("Utils");
await categoriesPage.typeCategoryDescription("Utils description");
Expand Down
2 changes: 1 addition & 1 deletion src/components/Datagrid/Datagrid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ export const Datagrid: React.FC<DatagridProps> = ({

if (loading) {
return (
<Box data-test-id="loader" display="flex" justifyContent="center" marginY={9}>
<Box data-test-id="datagrid-loader" display="flex" justifyContent="center" marginY={9}>
<CircularProgress />
</Box>
);
Expand Down
Loading