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. 41
      scripts/playwright/pages/Dashboard/Grid/index.ts
  2. 12
      scripts/playwright/tests/tableColumnOperation.spec.ts

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

@ -41,21 +41,32 @@ export class GridPage extends BasePage {
async addNewRow({
index = 0,
title,
}: { index?: number; title?: string } = {}) {
title = "Title",
value,
}: { index?: number; title?: string; value?: string } = {}) {
const rowCount = await this.get().locator(".nc-grid-row").count();
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({
index,
columnHeader: "Title",
columnHeader: title,
});
await cell.locator("input").fill(title ?? `Row ${index}`);
await this.cell.grid.get().locator('[data-title="Title"]').locator('span[title="Title"]').click();
if (value) {
await cell.locator("input").fill(value);
} else {
await cell.locator("input").fill(title ?? `Row ${index}`);
}
await this.cell.grid
.get()
.locator(`[data-title="${title}"]`)
.locator(`span[title="${title}"]`)
.click();
}
async verifyRow({ index }: { index: number }) {
@ -107,6 +118,10 @@ export class GridPage extends BasePage {
async selectAll() {
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()
.locator('[pw-data="nc-check-all"]')
.locator('input[type="checkbox"]')
@ -115,12 +130,9 @@ export class GridPage extends BasePage {
async deleteAll() {
await this.selectAll();
await this.get()
.locator('[pw-data="nc-check-all"]')
.locator('input[type="checkbox"]')
.click({
button: "right",
});
await this.get().locator('[pw-data="nc-check-all"]').nth(0).click({
button: "right",
});
await this.rootPage.locator("text=Delete Selected Rows").click();
}
@ -149,7 +161,8 @@ export class GridPage extends BasePage {
}
async waitLoading() {
await this.dashboard.get()
await this.dashboard
.get()
.locator('[pw-data="grid-load-spinner"]')
.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.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.openExpandedRow({ index: 0 });
@ -46,11 +46,11 @@ test.describe("Table Column Operations", () => {
await grid.deleteRow(0);
await grid.verifyRowDoesNotExist({ index: 0 });
await grid.addNewRow({ index: 0 });
await grid.addNewRow({ index: 1 });
await grid.addNewRow({ index: 2 });
await grid.addNewRow({ index: 3 });
await grid.addNewRow({ index: 4 });
await grid.addNewRow({ index: 0, value: `Row 0` });
await grid.addNewRow({ index: 1, value: `Row 1` });
await grid.addNewRow({ index: 2, value: `Row 2` });
await grid.addNewRow({ index: 3, value: `Row 3` });
await grid.addNewRow({ index: 4, value: `Row 4` });
await grid.deleteAll();
await grid.verifyRowDoesNotExist({ index: 0 });

Loading…
Cancel
Save