Browse Source

test: duplicate & delete from expanded form

Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com>
pull/5035/head
Raju Udava 2 years ago
parent
commit
92b9b1b9b3
  1. 33
      tests/playwright/pages/Dashboard/ExpandedForm/index.ts
  2. 48
      tests/playwright/tests/expandedFormUrl.spec.ts

33
tests/playwright/pages/Dashboard/ExpandedForm/index.ts

@ -7,6 +7,7 @@ export class ExpandedFormPage extends BasePage {
readonly addNewTableButton: Locator;
readonly copyUrlButton: Locator;
readonly toggleCommentsButton: Locator;
readonly moreOptionsButton: Locator;
constructor(dashboard: DashboardPage) {
super(dashboard.rootPage);
@ -14,12 +15,44 @@ export class ExpandedFormPage extends BasePage {
this.addNewTableButton = this.dashboard.get().locator('.nc-add-new-table');
this.copyUrlButton = this.dashboard.get().locator('.nc-copy-row-url:visible');
this.toggleCommentsButton = this.dashboard.get().locator('.nc-toggle-comments:visible');
this.moreOptionsButton = this.dashboard.get().locator('.nc-actions-menu-btn:visible').last();
}
get() {
return this.dashboard.get().locator(`.nc-drawer-expanded-form`);
}
async clickDuplicateRow() {
await this.moreOptionsButton.click();
// wait for the menu to appear
await this.rootPage.waitForTimeout(1000);
await this.rootPage.locator('.nc-menu-item:has-text("Duplicate Row")').click();
// wait for loader to disappear
// await this.dashboard.waitForLoaderToDisappear();
await this.rootPage.waitForTimeout(2000);
}
async clickDeleteRow() {
await this.moreOptionsButton.click();
// wait for the menu to appear
await this.rootPage.waitForTimeout(1000);
await this.rootPage.locator('.nc-menu-item:has-text("Delete Row")').click();
await this.rootPage.locator('.ant-btn-primary:has-text("OK")').click();
}
async isDisabledDuplicateRow() {
await this.moreOptionsButton.click();
const isDisabled = await this.rootPage.locator('.nc-menu-item.disabled:has-text("Duplicate Row")');
return await isDisabled.count();
}
async isDisabledDeleteRow() {
await this.moreOptionsButton.click();
const isDisabled = await this.rootPage.locator('.nc-menu-item.disabled:has-text("Delete Row")');
return await isDisabled.count();
}
async getShareRowUrl() {
await this.copyUrlButton.click();
await this.verifyToast({ message: 'Copied to clipboard' });

48
tests/playwright/tests/expandedFormUrl.spec.ts

@ -1,8 +1,9 @@
import { test } from '@playwright/test';
import { expect, test } from '@playwright/test';
import { DashboardPage } from '../pages/Dashboard';
import { GalleryPage } from '../pages/Dashboard/Gallery';
import { GridPage } from '../pages/Dashboard/Grid';
import setup from '../setup';
import { ToolbarPage } from '../pages/Dashboard/common/Toolbar';
test.describe('Expanded form URL', () => {
let dashboard: DashboardPage;
@ -132,3 +133,48 @@ test.describe('Expanded form URL', () => {
await viewTestTestTable('gallery');
});
});
test.describe('Expanded record duplicate & delete options', () => {
let dashboard: DashboardPage, toolbar: ToolbarPage;
let context: any;
test.beforeEach(async ({ page }) => {
context = await setup({ page });
dashboard = new DashboardPage(page, context.project);
toolbar = dashboard.grid.toolbar;
});
test('Grid', async () => {
await dashboard.closeTab({ title: 'Team & Auth' });
await dashboard.treeView.openTable({ title: 'Actor' });
// create filter to narrow down the number of records
await toolbar.clickFilter();
await toolbar.filter.add({
columnTitle: 'FirstName',
opType: 'is equal',
value: 'NICK',
isLocallySaved: false,
});
await toolbar.clickFilter();
await dashboard.grid.verifyRowCount({ count: 3 });
// expand row & duplicate
await dashboard.grid.openExpandedRow({ index: 0 });
await dashboard.expandedForm.clickDuplicateRow();
await dashboard.expandedForm.save();
await dashboard.grid.verifyRowCount({ count: 4 });
// expand row & delete
await dashboard.grid.openExpandedRow({ index: 3 });
await dashboard.expandedForm.clickDeleteRow();
await dashboard.grid.verifyRowCount({ count: 3 });
// expand row, duplicate & verify menu
await dashboard.grid.openExpandedRow({ index: 0 });
await dashboard.expandedForm.clickDuplicateRow();
expect(await dashboard.expandedForm.isDisabledDeleteRow()).toBe(1);
expect(await dashboard.expandedForm.isDisabledDuplicateRow()).toBe(1);
});
});

Loading…
Cancel
Save