Browse Source

feat(playwright): add saveAndExitMode logic in expanded form

pull/4436/head
Wing-Kam Wong 2 years ago
parent
commit
5936a2042c
  1. 18
      tests/playwright/pages/Dashboard/ExpandedForm/index.ts
  2. 14
      tests/playwright/tests/tableColumnOperation.spec.ts

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

@ -54,10 +54,21 @@ export class ExpandedFormPage extends BasePage {
async save({ async save({
waitForRowsData = true, waitForRowsData = true,
saveAndExitMode = true,
}: { }: {
waitForRowsData?: boolean; waitForRowsData?: boolean;
saveAndExitMode?: boolean;
} = {}) { } = {}) {
const saveRowAction = this.get().locator('button:has-text("Save & Exit")').click(); if (!saveAndExitMode) {
await this.get().locator('.nc-expand-form-save-btn .ant-dropdown-trigger').click();
const dropdownList = this.rootPage.locator('.nc-expand-form-save-dropdown-menu');
await dropdownList.locator('.ant-dropdown-menu-item:has-text("Save & Stay")').click();
}
const saveRowAction = saveAndExitMode
? this.get().locator('button:has-text("Save & Exit")').click()
: this.get().locator('button:has-text("Save & Stay")').click();
if (waitForRowsData) { if (waitForRowsData) {
await this.waitForResponse({ await this.waitForResponse({
uiAction: saveRowAction, uiAction: saveRowAction,
@ -73,7 +84,10 @@ export class ExpandedFormPage extends BasePage {
}); });
} }
await this.get().press('Escape'); if (!saveAndExitMode) {
await this.get().press('Escape');
}
await this.get().waitFor({ state: 'hidden' }); await this.get().waitFor({ state: 'hidden' });
await this.verifyToast({ message: `updated successfully.` }); await this.verifyToast({ message: `updated successfully.` });
await this.rootPage.locator('[data-testid="grid-load-spinner"]').waitFor({ state: 'hidden' }); await this.rootPage.locator('[data-testid="grid-load-spinner"]').waitFor({ state: 'hidden' });

14
tests/playwright/tests/tableColumnOperation.spec.ts

@ -36,13 +36,25 @@ test.describe('Table Column Operations', () => {
columnTitle: 'Title', columnTitle: 'Title',
value: 'value_a', value: 'value_a',
}); });
await dashboard.expandedForm.save(); await dashboard.expandedForm.save({ saveAndExitMode: true });
await grid.cell.verify({ await grid.cell.verify({
index: 0, index: 0,
columnHeader: 'Title', columnHeader: 'Title',
value: 'value_a', value: 'value_a',
}); });
await grid.openExpandedRow({ index: 0 });
await dashboard.expandedForm.fillField({
columnTitle: 'Title',
value: 'value_a_a',
});
await dashboard.expandedForm.save({ saveAndExitMode: false });
await grid.cell.verify({
index: 0,
columnHeader: 'Title',
value: 'value_a_a',
});
await grid.deleteRow(0); await grid.deleteRow(0);
await grid.verifyRowDoesNotExist({ index: 0 }); await grid.verifyRowDoesNotExist({ index: 0 });

Loading…
Cancel
Save