From 478c347e92474c2421afdbc80eb421493319751b Mon Sep 17 00:00:00 2001 From: starbirdtech383 Date: Wed, 27 Dec 2023 17:32:31 +0530 Subject: [PATCH] update tests for invalid function error --- tests/playwright/pages/Base.ts | 6 ++---- .../playwright/pages/Dashboard/Grid/Column/index.ts | 13 ++++--------- .../tests/db/columns/columnFormula.spec.ts | 7 ++++--- 3 files changed, 10 insertions(+), 16 deletions(-) diff --git a/tests/playwright/pages/Base.ts b/tests/playwright/pages/Base.ts index b2064df98d..a93a00cfa8 100644 --- a/tests/playwright/pages/Base.ts +++ b/tests/playwright/pages/Base.ts @@ -16,10 +16,8 @@ export default abstract class BasePage { await this.rootPage.locator('.ant-message .ant-message-notice-content', { hasText: message }).last().isVisible(); } - async verifyLastToast({ message }: { message: string }) { - await expect( - this.rootPage.locator('.ant-message .ant-message-notice-content', { hasText: message }).last() - ).toHaveText(message); + async verifyErrorMessage({ message }: { message: RegExp }) { + await expect(this.get().locator('.ant-form-item-explain-error', { hasText: message })).toBeVisible(); } async waitForResponse({ diff --git a/tests/playwright/pages/Dashboard/Grid/Column/index.ts b/tests/playwright/pages/Dashboard/Grid/Column/index.ts index d7b598fd79..bfb4679103 100644 --- a/tests/playwright/pages/Dashboard/Grid/Column/index.ts +++ b/tests/playwright/pages/Dashboard/Grid/Column/index.ts @@ -375,17 +375,12 @@ export class ColumnPageObject extends BasePage { await this.rootPage.waitForTimeout(200); } - async saveFail({ errorMessage }: { errorMessage?: string } = {}) { - await this.waitForResponse({ - uiAction: async () => await this.get().locator('button:has-text("Save")').click(), - requestUrlPathToMatch: 'api/v1/db/meta', - httpMethodsToMatch: ['GET', 'PATCH'], - responseStatusCodeToMatch: 400, - }); - await this.verifyLastToast({ + async checkMessageAndClose({ errorMessage }: { errorMessage?: RegExp } = {}) { + await this.verifyErrorMessage({ message: errorMessage, }); - await this.get().waitFor({ state: 'visible' }); + await this.get().locator('button:has-text("Cancel")').click(); + await this.get().waitFor({ state: 'hidden' }); await this.rootPage.waitForTimeout(200); } diff --git a/tests/playwright/tests/db/columns/columnFormula.spec.ts b/tests/playwright/tests/db/columns/columnFormula.spec.ts index fb6f06040d..3383778620 100644 --- a/tests/playwright/tests/db/columns/columnFormula.spec.ts +++ b/tests/playwright/tests/db/columns/columnFormula.spec.ts @@ -117,10 +117,12 @@ const formulaDataByDbType = (context: NcContext, index: number) => { { formula: 'ROUNDDOWN({CityId} + 2.49, 1)', result: ['3.4', '4.4', '5.4', '6.4', '7.4'], + unSupDbType: ['sqlite3'], }, { formula: 'ROUNDUP({CityId} + 2.49, 1)', result: ['3.5', '4.5', '5.5', '6.5', '7.5'], + unSupDbType: ['sqlite3'], }, { formula: 'RECORD_ID()', @@ -132,13 +134,11 @@ const formulaDataByDbType = (context: NcContext, index: number) => { unSupDbType: ['sqlite3'], }, { - // TODO: this is bug in mysql, its being case in-sensitive. formula: 'REGEX_EXTRACT({City}, "a[a-z]a")', result: ['', '', '', '', 'ana'], unSupDbType: ['sqlite3'], }, { - // TODO: this is bug in mysql, its being case in-sensitive. formula: 'REGEX_REPLACE({City}, "a[a-z]a","...")', result: ['A Corua (La Corua)', 'Abha', 'Abu Dhabi', 'Acua', 'Ad...'], unSupDbType: ['sqlite3'], @@ -277,9 +277,10 @@ test.describe('Virtual Columns', () => { type: 'Formula', formula: formulaData[i].formula, }); + console.log(`running test function: ${formulaData[i].formula}`); if (formulaData[i].unSupDbType?.includes(dbType)) { // assert for message not supported or greyed out save button. - await dashboard.grid.column.saveFail({ errorMessage: 'Invalid Formula' }); + await dashboard.grid.column.checkMessageAndClose({ errorMessage: new RegExp('Function .* is not available') }); continue; } await dashboard.grid.column.save({ isUpdated: true });