Skip to content

Commit

Permalink
🎀 Refactor test to use waitForLoaderToDisappear 🎀 (#5243)
Browse files Browse the repository at this point in the history
* Refactor test to use waitForLoaderToDisappear

* add changeset

* add not commitet changes

* remove unused import

* Change loader name to datagrid-loader

* fix for lost loader

* remove unnecessary function from DOM
  • Loading branch information
michalina-graczyk committed Nov 14, 2024
1 parent 9436450 commit abdd791
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 5 deletions.
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 @@ export class BasePage {
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 @@ -313,7 +313,6 @@ export class BasePage {

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 @@ export class BasePage {
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

0 comments on commit abdd791

Please sign in to comment.