Browse Source

test: enable share pwd, new content after share

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
97b3847c91
  1. 15
      scripts/playwright/pages/Dashboard/Grid/Toolbar/ShareView.ts
  2. 6
      scripts/playwright/pages/Dashboard/Grid/Toolbar/index.ts
  3. 120
      scripts/playwright/tests/gridViewShare.spec.ts

15
scripts/playwright/pages/Dashboard/Grid/Toolbar/ShareView.ts

@ -13,10 +13,17 @@ export class ToolbarShareViewPage extends BasePage {
return this.rootPage.locator(`.nc-modal-share-view`);
}
async enablePassword() {
async enablePassword(pwd: string) {
await this.get()
.locator(`[data-pw="nc-modal-share-view__with-password"`)
.locator(`[data-pw="nc-modal-share-view__with-password"]`)
.click();
await this.get()
.locator(`[data-pw="nc-modal-share-view__password"]`)
.fill(pwd);
await this.get()
.locator(`[data-pw="nc-modal-share-view__save-password"]`)
.click();
await this.toastWait({ message: "Successfully updated" });
}
async disablePassword() {
@ -36,4 +43,8 @@ export class ToolbarShareViewPage extends BasePage {
.locator(`[data-pw="nc-modal-share-view__link"]`)
.innerText();
}
async close() {
await this.get().locator(`.ant-modal-close-x`).click();
}
}

6
scripts/playwright/pages/Dashboard/Grid/Toolbar/index.ts

@ -87,4 +87,10 @@ export class ToolbarPage extends BasePage {
const file = fs.readFileSync("./at.txt", "utf8");
await expect(file).toEqual(expectedData);
}
async verifyDownloadDisabled() {
await this.get()
.locator(`.nc-toolbar-btn.nc-actions-menu-btn`)
.waitFor({ state: "hidden" });
}
}

120
scripts/playwright/tests/gridViewShare.spec.ts

@ -6,12 +6,26 @@ test.describe("Shared view", () => {
let dashboard: DashboardPage;
let context: any;
let mainPageLink: string;
let sharedLink: string;
test.beforeEach(async ({ page }) => {
context = await setup({ page });
dashboard = new DashboardPage(page, context.project);
});
test("Grid share", async ({ page }) => {
test("Grid share ", async ({ page }) => {
/**
* 1. Create Shared view
* - hide column
* - add sort
* - add filter
* - enable download
* - disable password
* - generate shared view link
* - copy link
**/
// close 'Team & Auth' tab
await dashboard.closeTab({ title: "Team & Auth" });
await dashboard.treeView.openTable({ title: "Address" });
@ -30,13 +44,21 @@ test.describe("Shared view", () => {
opType: "is like",
});
const mainPageLink = page.url();
mainPageLink = page.url();
// share with password disabled, download enabled
await dashboard.grid.toolbar.clickShareView();
let link = await dashboard.grid.toolbar.shareView.getShareLink();
sharedLink = await dashboard.grid.toolbar.shareView.getShareLink();
/**
* 2. Access shared view: verify
* - access without password
* - column order
* - data order (sort & filter)
* - virtual columns (hm, bt)
**/
await page.goto(link);
await page.goto(sharedLink);
const sharedPage = new DashboardPage(page, context.project);
let expectedColumns = [
@ -78,6 +100,24 @@ test.describe("Shared view", () => {
for (const record of expectedRecords) {
await sharedPage.grid.cell.verify(record);
}
const expectedVirtualRecords = [
{ index: 0, columnHeader: "Customer List", count: 1, value: ["2"] },
{ index: 1, columnHeader: "Customer List", count: 1, value: ["2"] },
{ index: 0, columnHeader: "City", count: 1, value: ["Kanchrapara"] },
{ index: 1, columnHeader: "City", count: 1, value: ["Tafuna"] },
];
// verify virtual records
for (const record of expectedVirtualRecords) {
await sharedPage.grid.cell.verifyVirtualCell(record);
}
/**
* 3. Shared view: verify
* - new sort
* - new filter
* - new column hidden
**/
// create new sort & filter criteria in shared view
await sharedPage.grid.toolbar.sort.addSort({
@ -117,12 +157,82 @@ test.describe("Shared view", () => {
await sharedPage.grid.cell.verify(record);
}
/**
* 4. Download
* - Verify download data (order, filter, sort)
**/
// verify download
await sharedPage.grid.toolbar.clickDownload(
"Download as CSV",
"./expectedData.txt"
);
// await dashboard.closeTab({ title: "Address" });
/**
* 5. Enable shared view password, disable download: verify
* - Incorrect password
* - Correct password
* - Download disabled
* - Add new record & column after shared view creation; verify
**/
// visit main page
await page.goto(mainPageLink);
await dashboard.closeTab({ title: "Address" });
await dashboard.treeView.openTable({ title: "Country" });
// enable password & verify share link
await dashboard.grid.toolbar.clickShareView();
await dashboard.grid.toolbar.shareView.enablePassword("p@ssword");
// disable download
await dashboard.grid.toolbar.shareView.toggleDownload();
sharedLink = await dashboard.grid.toolbar.shareView.getShareLink();
await dashboard.grid.toolbar.shareView.close();
// add new column, record after share view creation
await dashboard.grid.column.create({
title: "New Column",
});
await dashboard.grid.addNewRow({
index: 25,
columnHeader: "Country",
value: "New Country",
});
await page.goto(sharedLink);
// verify if password request modal exists
const sharedPage2 = new DashboardPage(page, context.project);
await sharedPage2.rootPage
.locator('input[placeholder="Enter password"]')
.fill("incorrect p@ssword");
await sharedPage2.rootPage.click('button:has-text("Unlock")');
await sharedPage2.toastWait({ message: "INVALID_SHARED_VIEW_PASSWORD" });
// correct password
await sharedPage2.rootPage
.locator('input[placeholder="Enter password"]')
.fill("p@ssword");
await sharedPage2.rootPage.click('button:has-text("Unlock")');
// verify if download button is disabled
await sharedPage2.grid.toolbar.verifyDownloadDisabled();
// verify new column & record
await sharedPage2.grid.column.verify({
title: "New Column",
isVisible: true,
});
await sharedPage2.grid.toolbar.filter.addNew({
columnTitle: "Country",
value: "New Country",
opType: "is like",
});
await sharedPage2.grid.cell.verify({
index: 0,
columnHeader: "Country",
value: "New Country",
});
});
});

Loading…
Cancel
Save