Browse Source

test: delete-all stability

Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com>
pull/3848/head
Raju Udava 2 years ago committed by Muhammed Mustafa
parent
commit
d6f9422585
  1. 35
      scripts/playwright/pages/Dashboard/Grid/index.ts
  2. 12
      scripts/playwright/tests/tableColumnOperation.spec.ts

35
scripts/playwright/pages/Dashboard/Grid/index.ts

@ -41,21 +41,32 @@ export class GridPage extends BasePage {
async addNewRow({ async addNewRow({
index = 0, index = 0,
title, title = "Title",
}: { index?: number; title?: string } = {}) { value,
}: { index?: number; title?: string; value?: string } = {}) {
const rowCount = await this.get().locator(".nc-grid-row").count(); const rowCount = await this.get().locator(".nc-grid-row").count();
await this.get().locator(".nc-grid-add-new-cell").click(); await this.get().locator(".nc-grid-add-new-cell").click();
expect.poll(async () => await this.get().locator(".nc-grid-row").count()).toBe(rowCount + 1) expect
.poll(async () => await this.get().locator(".nc-grid-row").count())
.toBe(rowCount + 1);
const cell = this.cell.get({ index, columnHeader: "Title" }); const cell = this.cell.get({ index, columnHeader: title });
await this.cell.dblclick({ await this.cell.dblclick({
index, index,
columnHeader: "Title", columnHeader: title,
}); });
if (value) {
await cell.locator("input").fill(value);
} else {
await cell.locator("input").fill(title ?? `Row ${index}`); await cell.locator("input").fill(title ?? `Row ${index}`);
await this.cell.grid.get().locator('[data-title="Title"]').locator('span[title="Title"]').click(); }
await this.cell.grid
.get()
.locator(`[data-title="${title}"]`)
.locator(`span[title="${title}"]`)
.click();
} }
async verifyRow({ index }: { index: number }) { async verifyRow({ index }: { index: number }) {
@ -107,6 +118,10 @@ export class GridPage extends BasePage {
async selectAll() { async selectAll() {
await this.get().locator('[pw-data="nc-check-all"]').hover(); await this.get().locator('[pw-data="nc-check-all"]').hover();
// fix me! without this, elements are getting de-checked after select-all
await this.rootPage.waitForTimeout(1000);
await this.get() await this.get()
.locator('[pw-data="nc-check-all"]') .locator('[pw-data="nc-check-all"]')
.locator('input[type="checkbox"]') .locator('input[type="checkbox"]')
@ -115,10 +130,7 @@ export class GridPage extends BasePage {
async deleteAll() { async deleteAll() {
await this.selectAll(); await this.selectAll();
await this.get() await this.get().locator('[pw-data="nc-check-all"]').nth(0).click({
.locator('[pw-data="nc-check-all"]')
.locator('input[type="checkbox"]')
.click({
button: "right", button: "right",
}); });
await this.rootPage.locator("text=Delete Selected Rows").click(); await this.rootPage.locator("text=Delete Selected Rows").click();
@ -149,7 +161,8 @@ export class GridPage extends BasePage {
} }
async waitLoading() { async waitLoading() {
await this.dashboard.get() await this.dashboard
.get()
.locator('[pw-data="grid-load-spinner"]') .locator('[pw-data="grid-load-spinner"]')
.waitFor({ state: "hidden" }); .waitFor({ state: "hidden" });
} }

12
scripts/playwright/tests/tableColumnOperation.spec.ts

@ -28,7 +28,7 @@ test.describe("Table Column Operations", () => {
await grid.column.delete({ title: "column_name_b" }); await grid.column.delete({ title: "column_name_b" });
await grid.column.verify({ title: "column_name_b", isVisible: true }); await grid.column.verify({ title: "column_name_b", isVisible: true });
await grid.addNewRow({ index: 0 }); await grid.addNewRow({ index: 0, value: `Row 0` });
await grid.verifyRow({ index: 0 }); await grid.verifyRow({ index: 0 });
await grid.openExpandedRow({ index: 0 }); await grid.openExpandedRow({ index: 0 });
@ -46,11 +46,11 @@ test.describe("Table Column Operations", () => {
await grid.deleteRow(0); await grid.deleteRow(0);
await grid.verifyRowDoesNotExist({ index: 0 }); await grid.verifyRowDoesNotExist({ index: 0 });
await grid.addNewRow({ index: 0 }); await grid.addNewRow({ index: 0, value: `Row 0` });
await grid.addNewRow({ index: 1 }); await grid.addNewRow({ index: 1, value: `Row 1` });
await grid.addNewRow({ index: 2 }); await grid.addNewRow({ index: 2, value: `Row 2` });
await grid.addNewRow({ index: 3 }); await grid.addNewRow({ index: 3, value: `Row 3` });
await grid.addNewRow({ index: 4 }); await grid.addNewRow({ index: 4, value: `Row 4` });
await grid.deleteAll(); await grid.deleteAll();
await grid.verifyRowDoesNotExist({ index: 0 }); await grid.verifyRowDoesNotExist({ index: 0 });

Loading…
Cancel
Save