Browse Source

feat(testing): Fixed gallery expandedFormUrl

pull/3848/head
Muhammed Mustafa 2 years ago
parent
commit
a044482c26
  1. 12
      scripts/playwright/pages/Dashboard/Gallery/index.ts
  2. 156
      scripts/playwright/tests/expandedFormUrl.spec.ts

12
scripts/playwright/pages/Dashboard/Gallery/index.ts

@ -33,18 +33,6 @@ export class GalleryPage extends BasePage {
return; return;
} }
// kludge: move toolbar outside grid scope
async fields({ title }: { title: string }) {
await this.rootPage.locator(`.nc-fields-menu-btn`).click();
await this.rootPage.waitForTimeout(1000);
await this.rootPage
.locator(`[pw-data="nc-fields-menu-${title}"]`)
.locator('input[type="checkbox"]')
.click();
await this.rootPage.waitForTimeout(1000);
await this.rootPage.locator(`.nc-fields-menu-btn`).click();
}
// todo: Wait for render to complete // todo: Wait for render to complete
async waitLoading() { async waitLoading() {
await this.rootPage.waitForTimeout(1000); await this.rootPage.waitForTimeout(1000);

156
scripts/playwright/tests/expandedFormUrl.spec.ts

@ -1,5 +1,7 @@
import { expect, test } from "@playwright/test"; import { expect, test } from "@playwright/test";
import { DashboardPage } from "../pages/Dashboard"; import { DashboardPage } from "../pages/Dashboard";
import { GalleryPage } from "../pages/Dashboard/Gallery";
import { GridPage } from "../pages/Dashboard/Grid";
import setup from "../setup"; import setup from "../setup";
test.describe("Expanded form URL", () => { test.describe("Expanded form URL", () => {
@ -11,90 +13,94 @@ test.describe("Expanded form URL", () => {
dashboard = new DashboardPage(page, context.project); dashboard = new DashboardPage(page, context.project);
}); });
function viewTest(viewType: string) { async function viewTest(viewType: string) {
test(viewType, async () => { // close 'Team & Auth' tab
// close 'Team & Auth' tab await dashboard.closeTab({ title: "Team & Auth" });
await dashboard.closeTab({ title: "Team & Auth" }); await dashboard.treeView.openTable({ title: "Country" });
await dashboard.treeView.openTable({ title: "Country" });
let viewObj; let viewObj: GridPage | GalleryPage = dashboard.grid;
if (viewType === "grid") { if (viewType === "grid") {
viewObj = dashboard.grid; viewObj = dashboard.grid;
} else if (viewType === "gallery") { } else if (viewType === "gallery") {
viewObj = dashboard.gallery; viewObj = dashboard.gallery;
await viewObj.fields({ title: "City List" }); }
}
if (viewType === "grid") { if (viewType === "grid") {
await dashboard.viewSidebar.createGridView({ title: "CountryExpand" }); await dashboard.viewSidebar.createGridView({ title: "CountryExpand" });
} else if (viewType === "gallery") { } else if (viewType === "gallery") {
await dashboard.viewSidebar.createGalleryView({ await dashboard.viewSidebar.createGalleryView({
title: "CountryExpand", title: "CountryExpand",
});
}
// expand row & verify URL
await viewObj.openExpandedRow({ index: 0 });
await dashboard.expandedForm.verify({
header: "Afghanistan",
url: "rowId=1",
}); });
await viewObj.toolbar.clickFields();
await viewObj.toolbar.fields.click({ title: "City List" });
}
// // verify copied URL in clipboard // expand row & verify URL
// await dashboard.expandedForm.copyUrlButton.click(); await viewObj.openExpandedRow({ index: 0 });
// const expandedFormUrl = await dashboard.expandedForm.getClipboardText(); await dashboard.expandedForm.verify({
// expect(expandedFormUrl).toContain("rowId=1"); header: "Afghanistan",
url: "rowId=1",
});
// access a new rowID using URL // // verify copied URL in clipboard
let url = await dashboard.rootPage.url(); // await dashboard.expandedForm.copyUrlButton.click();
await dashboard.expandedForm.close(); // const expandedFormUrl = await dashboard.expandedForm.getClipboardText();
await dashboard.rootPage.goto( // expect(expandedFormUrl).toContain("rowId=1");
"/" + url.split("/").slice(3).join("/").split("?")[0] + "?rowId=2"
);
await dashboard.expandedForm.verify({
header: "Algeria",
url: "rowId=2",
});
await dashboard.expandedForm.close();
// visit invalid rowID // access a new rowID using URL
await dashboard.rootPage.goto( let url = await dashboard.rootPage.url();
"/" + url.split("/").slice(3).join("/").split("?")[0] + "?rowId=999" await dashboard.expandedForm.close();
); await dashboard.rootPage.goto(
await dashboard.toastWait({ message: "Record not found" }); "/" + url.split("/").slice(3).join("/").split("?")[0] + "?rowId=2"
// ensure grid is displayed after invalid URL access );
await viewObj.verifyRowCount({ count: 25 }); await dashboard.expandedForm.verify({
header: "Algeria",
url: "rowId=2",
});
await dashboard.expandedForm.close();
// Nested URL // visit invalid rowID
await dashboard.rootPage.goto( await dashboard.rootPage.goto(
"/" + url.split("/").slice(3).join("/").split("?")[0] + "?rowId=1" "/" + url.split("/").slice(3).join("/").split("?")[0] + "?rowId=999"
); );
await dashboard.expandedForm.verify({ await dashboard.toastWait({ message: "Record not found" });
header: "Afghanistan", // ensure grid is displayed after invalid URL access
url: "rowId=1", await viewObj.verifyRowCount({ count: 25 });
});
await dashboard.expandedForm.openChildCard({
column: "City List",
title: "Kabul",
});
await dashboard.rootPage.waitForTimeout(1000);
await dashboard.expandedForm.verify({
header: "Kabul",
url: "rowId=1",
});
let expandFormCount = await dashboard.expandedForm.count();
expect(expandFormCount).toBe(2);
// close child card // Nested URL
await dashboard.expandedForm.cancel(); await dashboard.rootPage.goto(
await dashboard.expandedForm.verify({ "/" + url.split("/").slice(3).join("/").split("?")[0] + "?rowId=1"
header: "Afghanistan", );
url: "rowId=1", await dashboard.expandedForm.verify({
}); header: "Afghanistan",
await dashboard.expandedForm.cancel(); url: "rowId=1",
}); });
await dashboard.expandedForm.openChildCard({
column: "City List",
title: "Kabul",
});
await dashboard.rootPage.waitForTimeout(1000);
await dashboard.expandedForm.verify({
header: "Kabul",
url: "rowId=1",
});
let expandFormCount = await dashboard.expandedForm.count();
expect(expandFormCount).toBe(2);
// close child card
await dashboard.expandedForm.cancel();
await dashboard.expandedForm.verify({
header: "Afghanistan",
url: "rowId=1",
});
await dashboard.expandedForm.cancel();
} }
viewTest("grid"); test("Grid", async () => {
// viewTest("gallery"); await viewTest("grid");
});
test("Gallery", async () => {
await viewTest("gallery");
});
}); });

Loading…
Cancel
Save