From 5936a2042c98a007ab5a14e5f0819adbe0eca4b5 Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Mon, 21 Nov 2022 11:43:09 +0800 Subject: [PATCH] feat(playwright): add saveAndExitMode logic in expanded form --- .../pages/Dashboard/ExpandedForm/index.ts | 18 ++++++++++++++++-- .../tests/tableColumnOperation.spec.ts | 14 +++++++++++++- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/tests/playwright/pages/Dashboard/ExpandedForm/index.ts b/tests/playwright/pages/Dashboard/ExpandedForm/index.ts index df73b29a4a..c5039f86d8 100644 --- a/tests/playwright/pages/Dashboard/ExpandedForm/index.ts +++ b/tests/playwright/pages/Dashboard/ExpandedForm/index.ts @@ -54,10 +54,21 @@ export class ExpandedFormPage extends BasePage { async save({ waitForRowsData = true, + saveAndExitMode = true, }: { 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) { await this.waitForResponse({ 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.verifyToast({ message: `updated successfully.` }); await this.rootPage.locator('[data-testid="grid-load-spinner"]').waitFor({ state: 'hidden' }); diff --git a/tests/playwright/tests/tableColumnOperation.spec.ts b/tests/playwright/tests/tableColumnOperation.spec.ts index 6c921d3b6b..8042af8ebe 100644 --- a/tests/playwright/tests/tableColumnOperation.spec.ts +++ b/tests/playwright/tests/tableColumnOperation.spec.ts @@ -36,13 +36,25 @@ test.describe('Table Column Operations', () => { columnTitle: 'Title', value: 'value_a', }); - await dashboard.expandedForm.save(); + await dashboard.expandedForm.save({ saveAndExitMode: true }); await grid.cell.verify({ index: 0, columnHeader: 'Title', 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.verifyRowDoesNotExist({ index: 0 });