From 853ad3afa1c6b591b720f419fe026446df8a14b4 Mon Sep 17 00:00:00 2001 From: Raju Udava <86527202+dstala@users.noreply.github.com> Date: Wed, 21 Jun 2023 12:18:07 +0530 Subject: [PATCH 1/9] test: pg-meta-db for pw Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com> --- .github/workflows/playwright-test-workflow.yml | 7 +++++++ packages/nocodb/package.json | 1 + 2 files changed, 8 insertions(+) diff --git a/.github/workflows/playwright-test-workflow.yml b/.github/workflows/playwright-test-workflow.yml index c9e8244c8f..fef81cebcf 100644 --- a/.github/workflows/playwright-test-workflow.yml +++ b/.github/workflows/playwright-test-workflow.yml @@ -69,10 +69,17 @@ jobs: working-directory: ./packages/nc-gui run: npm run ci:run - name: Run backend + if: ${{ inputs.db != 'pg' }} working-directory: ./packages/nocodb run: | npm install npm run watch:run:playwright > ${{ inputs.db }}_${{ inputs.shard }}_test_backend.log & + - name: Run backend:pg + if: ${{ inputs.db == 'pg' }} + working-directory: ./packages/nocodb + run: | + npm install + npm run watch:run:playwright:pg > ${{ inputs.db }}_${{ inputs.shard }}_test_backend.log & - name: Cache playwright npm modules uses: actions/cache@v3 id: playwright-cache diff --git a/packages/nocodb/package.json b/packages/nocodb/package.json index cad93f1793..f431bd9ac9 100644 --- a/packages/nocodb/package.json +++ b/packages/nocodb/package.json @@ -34,6 +34,7 @@ "watch:run": "cross-env NC_DISABLE_TELE=true EE=true nodemon -e ts,js -w ./src -x \"ts-node src/run/docker --log-error --project tsconfig.json\"", "watch:run:mysql": "cross-env NC_DISABLE_TELE=true EE=true nodemon -e ts,js -w ./src -x \"ts-node src/run/dockerRunMysql --log-error --project tsconfig.json\"", "watch:run:pg": "cross-env NC_DISABLE_TELE=true EE=true nodemon -e ts,js -w ./src -x \"ts-node src/run/dockerRunPG --log-error --project tsconfig.json\"", + "watch:run:playwright:pg": "rm -f ./test_noco.db; cross-env NC_DB=pg://localhost:5432?u=postgres&p=password&d=pw_ncdb PLAYWRIGHT_TEST=true NC_DISABLE_TELE=true EE=true nodemon -e ts,js -w ./src -x \"ts-node src/run/testDocker --log-error --project tsconfig.json\"", "watch:run:playwright": "rm -f ./test_noco.db; cross-env DATABASE_URL=sqlite:./test_noco.db PLAYWRIGHT_TEST=true NC_DISABLE_TELE=true EE=true nodemon -e ts,js -w ./src -x \"ts-node src/run/testDocker --log-error --project tsconfig.json\"", "watch:run:playwright:quick": "rm -f ./test_noco.db; cp ../../tests/playwright/fixtures/noco_0_91_7.db ./test_noco.db; cross-env DATABASE_URL=sqlite:./test_noco.db NC_DISABLE_TELE=true EE=true nodemon -e ts,js -w ./src -x \"ts-node src/run/docker --log-error --project tsconfig.json\"", "watch:run:playwright:pg:cyquick": "rm -f ./test_noco.db; cp ../../tests/playwright/fixtures/noco_0_91_7.db ./test_noco.db; cross-env NC_DISABLE_TELE=true EE=true nodemon -e ts,js -w ./src -x \"ts-node src/run/dockerRunPG_CyQuick.ts --log-error --project tsconfig.json\"", From 08568fa2d978f63099e507bc541379f6600b3947 Mon Sep 17 00:00:00 2001 From: Raju Udava <86527202+dstala@users.noreply.github.com> Date: Sat, 24 Jun 2023 12:34:37 +0530 Subject: [PATCH 2/9] test: NC_DB in quotes Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com> --- packages/nocodb/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/nocodb/package.json b/packages/nocodb/package.json index 1bed1bcafd..e657bd17f8 100644 --- a/packages/nocodb/package.json +++ b/packages/nocodb/package.json @@ -34,7 +34,7 @@ "watch:run": "cross-env NC_DISABLE_TELE=true EE=true nodemon -e ts,js -w ./src -x \"ts-node src/run/docker --log-error --project tsconfig.json\"", "watch:run:mysql": "cross-env NC_DISABLE_TELE=true EE=true nodemon -e ts,js -w ./src -x \"ts-node src/run/dockerRunMysql --log-error --project tsconfig.json\"", "watch:run:pg": "cross-env NC_DISABLE_TELE=true EE=true nodemon -e ts,js -w ./src -x \"ts-node src/run/dockerRunPG --log-error --project tsconfig.json\"", - "watch:run:playwright:pg": "rm -f ./test_noco.db; cross-env NC_DB=pg://localhost:5432?u=postgres&p=password&d=pw_ncdb PLAYWRIGHT_TEST=true NC_DISABLE_TELE=true EE=true nodemon -e ts,js -w ./src -x \"ts-node src/run/testDocker --log-error --project tsconfig.json\"", + "watch:run:playwright:pg": "rm -f ./test_noco.db; cross-env NC_DB=\"pg://localhost:5432?u=postgres&p=password&d=pw_ncdb\" PLAYWRIGHT_TEST=true NC_DISABLE_TELE=true EE=true nodemon -e ts,js -w ./src -x \"ts-node src/run/testDocker --log-error --project tsconfig.json\"", "watch:run:playwright": "rm -f ./test_noco.db; cross-env DATABASE_URL=sqlite:./test_noco.db PLAYWRIGHT_TEST=true NC_DISABLE_TELE=true EE=true nodemon -e ts,js -w ./src -x \"ts-node src/run/testDocker --log-error --project tsconfig.json\"", "watch:run:playwright:quick": "rm -f ./test_noco.db; cp ../../tests/playwright/fixtures/noco_0_91_7.db ./test_noco.db; cross-env DATABASE_URL=sqlite:./test_noco.db NC_DISABLE_TELE=true EE=true nodemon -e ts,js -w ./src -x \"ts-node src/run/docker --log-error --project tsconfig.json\"", "watch:run:playwright:pg:cyquick": "rm -f ./test_noco.db; cp ../../tests/playwright/fixtures/noco_0_91_7.db ./test_noco.db; cross-env NC_DISABLE_TELE=true EE=true nodemon -e ts,js -w ./src -x \"ts-node src/run/dockerRunPG_CyQuick.ts --log-error --project tsconfig.json\"", From 764cd102aafed686d8b6a0fcab19e86046bf0d1f Mon Sep 17 00:00:00 2001 From: Raju Udava <86527202+dstala@users.noreply.github.com> Date: Sat, 24 Jun 2023 13:22:14 +0530 Subject: [PATCH 3/9] test: clear hooks during project reset Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com> --- packages/nocodb/src/models/Model.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/nocodb/src/models/Model.ts b/packages/nocodb/src/models/Model.ts index 9ed0b189ca..5fa4ac4ae9 100644 --- a/packages/nocodb/src/models/Model.ts +++ b/packages/nocodb/src/models/Model.ts @@ -14,6 +14,7 @@ import { import { NcError } from '../helpers/catchError'; import { sanitize } from '../helpers/sqlSanitize'; import { extractProps } from '../helpers/extractProps'; +import Hook from './Hook'; import Audit from './Audit'; import View from './View'; import Column from './Column'; @@ -376,6 +377,11 @@ export default class Model implements TableType { await view.delete(ncMeta); } + // delete associated hooks + for (const hook of await Hook.list({ fk_model_id: this.id }, ncMeta)) { + await Hook.delete(hook.id, ncMeta); + } + for (const col of await this.getColumns(ncMeta)) { let colOptionTableName = null; let cacheScopeName = null; From 3a4036f8ac6b9a6fcb97da3aa5b26a39e42d10aa Mon Sep 17 00:00:00 2001 From: Raju Udava <86527202+dstala@users.noreply.github.com> Date: Sat, 24 Jun 2023 15:24:18 +0530 Subject: [PATCH 4/9] test: cleanup for barcode & Qr code meta Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com> --- packages/nocodb/src/models/Model.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/packages/nocodb/src/models/Model.ts b/packages/nocodb/src/models/Model.ts index 5fa4ac4ae9..00eed04002 100644 --- a/packages/nocodb/src/models/Model.ts +++ b/packages/nocodb/src/models/Model.ts @@ -408,6 +408,14 @@ export default class Model implements TableType { colOptionTableName = MetaTable.COL_FORMULA; cacheScopeName = CacheScope.COL_FORMULA; break; + case UITypes.QrCode: + colOptionTableName = MetaTable.COL_QRCODE; + cacheScopeName = CacheScope.COL_QRCODE; + break; + case UITypes.Barcode: + colOptionTableName = MetaTable.COL_BARCODE; + cacheScopeName = CacheScope.COL_BARCODE; + break; } if (colOptionTableName && cacheScopeName) { await ncMeta.metaDelete(null, null, colOptionTableName, { From 018f69948ab9867ffecd24da0fa0f47156910bd0 Mon Sep 17 00:00:00 2001 From: Raju Udava <86527202+dstala@users.noreply.github.com> Date: Sat, 24 Jun 2023 15:55:18 +0530 Subject: [PATCH 5/9] test: filter delete only if its parent Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com> --- packages/nocodb/src/models/Column.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/nocodb/src/models/Column.ts b/packages/nocodb/src/models/Column.ts index 78ae4edc9f..1695d1b4db 100644 --- a/packages/nocodb/src/models/Column.ts +++ b/packages/nocodb/src/models/Column.ts @@ -760,6 +760,7 @@ export default class Column implements ColumnType { }); } for (const filter of filters) { + if (filter.fk_parent_id) continue; await Filter.delete(filter.id, ncMeta); } } From b0fa9278ef9c4fb5bf289c7cb74fdaec3fbcbca7 Mon Sep 17 00:00:00 2001 From: Raju Udava <86527202+dstala@users.noreply.github.com> Date: Sat, 24 Jun 2023 16:53:19 +0530 Subject: [PATCH 6/9] test: temporarily disable filter group tests Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com> --- tests/playwright/tests/db/filters.spec.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/playwright/tests/db/filters.spec.ts b/tests/playwright/tests/db/filters.spec.ts index 55ec5c7e7c..4a56c34d4d 100644 --- a/tests/playwright/tests/db/filters.spec.ts +++ b/tests/playwright/tests/db/filters.spec.ts @@ -7,6 +7,7 @@ import { Api } from 'nocodb-sdk'; import { rowMixedValue } from '../../setup/xcdb-records'; import dayjs from 'dayjs'; import { createDemoTable } from '../../setup/demoTable'; +import { isPg } from '../../setup/db'; let dashboard: DashboardPage, toolbar: ToolbarPage; let context: any; @@ -1162,6 +1163,10 @@ test.describe('Filter Tests: Filter groups', () => { }); test('Filter: Empty filters', async () => { + if (isPg(context)) { + test.skip(); + } + await dashboard.closeTab({ title: 'Team & Auth' }); await dashboard.treeView.openTable({ title: 'Country', networkResponse: false }); From 8fe8449071e51b93fd341ca464ce4886f67ea2c8 Mon Sep 17 00:00:00 2001 From: Raju Udava <86527202+dstala@users.noreply.github.com> Date: Sat, 24 Jun 2023 17:13:26 +0530 Subject: [PATCH 7/9] test: trigger soft delete instead of full project delete Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com> --- .../test/TestResetService/index.ts | 21 ++++++++++++------- tests/playwright/tests/db/filters.spec.ts | 4 ---- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/packages/nocodb/src/controllers/test/TestResetService/index.ts b/packages/nocodb/src/controllers/test/TestResetService/index.ts index 6a5d67ec46..ddf1d8d108 100644 --- a/packages/nocodb/src/controllers/test/TestResetService/index.ts +++ b/packages/nocodb/src/controllers/test/TestResetService/index.ts @@ -116,14 +116,19 @@ export class TestResetService { if (project) { await removeProjectUsersFromCache(project); - const bases = await project.getBases(); - - for (const base of bases) { - await NcConnectionMgrv2.deleteAwait(base); - await base.delete(Noco.ncMeta, { force: true }); - } - - await Project.delete(project.id); + // Kludge: Soft reset to support PG as root DB in PW tests + // Revisit to fix this later + + // const bases = await project.getBases(); + // + // for (const base of bases) { + // await NcConnectionMgrv2.deleteAwait(base); + // await base.delete(Noco.ncMeta, { force: true }); + // } + // + // await Project.delete(project.id); + + await Project.softDelete(project.id); } if (dbType == 'sqlite') { diff --git a/tests/playwright/tests/db/filters.spec.ts b/tests/playwright/tests/db/filters.spec.ts index 4a56c34d4d..162cfda00e 100644 --- a/tests/playwright/tests/db/filters.spec.ts +++ b/tests/playwright/tests/db/filters.spec.ts @@ -1163,10 +1163,6 @@ test.describe('Filter Tests: Filter groups', () => { }); test('Filter: Empty filters', async () => { - if (isPg(context)) { - test.skip(); - } - await dashboard.closeTab({ title: 'Team & Auth' }); await dashboard.treeView.openTable({ title: 'Country', networkResponse: false }); From 77adb45f03e31cda6168ca9bc4c660f0d6609d51 Mon Sep 17 00:00:00 2001 From: Raju Udava <86527202+dstala@users.noreply.github.com> Date: Sat, 24 Jun 2023 21:29:03 +0530 Subject: [PATCH 8/9] test: link order scattered in pg Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com> --- .../pages/Dashboard/common/Cell/index.ts | 3 ++- tests/playwright/tests/db/timezone.spec.ts | 14 ++++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/tests/playwright/pages/Dashboard/common/Cell/index.ts b/tests/playwright/pages/Dashboard/common/Cell/index.ts index dcab70063e..2462ad8184 100644 --- a/tests/playwright/pages/Dashboard/common/Cell/index.ts +++ b/tests/playwright/pages/Dashboard/common/Cell/index.ts @@ -288,7 +288,8 @@ export class CellPageObject extends BasePage { for (let i = 0; i < value.length; ++i) { await chips.nth(i).locator('.name').waitFor({ state: 'visible' }); await chips.nth(i).locator('.name').scrollIntoViewIfNeeded(); - await expect(await chips.nth(i).locator('.name')).toHaveText(value[i]); + const chipText = await chips.nth(i).locator('.name').textContent(); + expect(value.includes(chipText)).toBe(true); } if (verifyChildList) { diff --git a/tests/playwright/tests/db/timezone.spec.ts b/tests/playwright/tests/db/timezone.spec.ts index 269c1781ce..562914cec3 100644 --- a/tests/playwright/tests/db/timezone.spec.ts +++ b/tests/playwright/tests/db/timezone.spec.ts @@ -539,6 +539,8 @@ test.describe.serial('Timezone- ExtDB : DateTime column, Browser Timezone same a let dashboard: DashboardPage; let context: any; + let counter = 0; + const expectedDisplayValues = { pg: { // PG ignores timezone information for datetime without timezone @@ -587,8 +589,8 @@ test.describe.serial('Timezone- ExtDB : DateTime column, Browser Timezone same a 'xc-auth': context.token, }, }); - - await createTableWithDateTimeColumn(context.dbType, 'datetimetable01'); + counter++; + await createTableWithDateTimeColumn(context.dbType, `datetimetable01${counter}`); }); // ExtDB : DateAdd, DateTime_Diff verification @@ -596,13 +598,13 @@ test.describe.serial('Timezone- ExtDB : DateTime column, Browser Timezone same a // - verify API response value // test('Formula, verify display value', async () => { - await connectToExtDb(context, 'datetimetable01'); + await connectToExtDb(context, `datetimetable01${counter}`); await dashboard.rootPage.reload(); await dashboard.rootPage.waitForTimeout(2000); // insert a record to work with formula experiments // - await dashboard.treeView.openBase({ title: 'datetimetable01' }); + await dashboard.treeView.openBase({ title: `datetimetable01${counter}` }); await dashboard.treeView.openTable({ title: 'MyTable' }); // Create formula column (dummy) @@ -756,14 +758,14 @@ test.describe.serial('Timezone- ExtDB : DateTime column, Browser Timezone same a }); test('Verify display value, UI insert, API response', async () => { - await connectToExtDb(context, 'datetimetable01'); + await connectToExtDb(context, `datetimetable01${counter}`); await dashboard.rootPage.reload(); await dashboard.rootPage.waitForTimeout(2000); // get timezone offset const formattedOffset = getBrowserTimezoneOffset(); - await dashboard.treeView.openBase({ title: 'datetimetable01' }); + await dashboard.treeView.openBase({ title: `datetimetable01${counter}` }); await dashboard.treeView.openTable({ title: 'MyTable' }); if (isSqlite(context)) { From c49b5946b77f1c42ef897b8e6178bf9274b3133a Mon Sep 17 00:00:00 2001 From: Raju Udava <86527202+dstala@users.noreply.github.com> Date: Sat, 24 Jun 2023 22:24:22 +0530 Subject: [PATCH 9/9] test: wait for chip to render before check Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com> --- tests/playwright/pages/Dashboard/common/Cell/index.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/playwright/pages/Dashboard/common/Cell/index.ts b/tests/playwright/pages/Dashboard/common/Cell/index.ts index 2462ad8184..ad3daaedb6 100644 --- a/tests/playwright/pages/Dashboard/common/Cell/index.ts +++ b/tests/playwright/pages/Dashboard/common/Cell/index.ts @@ -288,8 +288,9 @@ export class CellPageObject extends BasePage { for (let i = 0; i < value.length; ++i) { await chips.nth(i).locator('.name').waitFor({ state: 'visible' }); await chips.nth(i).locator('.name').scrollIntoViewIfNeeded(); + await chips.nth(i).locator('.name').waitFor({ state: 'visible' }); const chipText = await chips.nth(i).locator('.name').textContent(); - expect(value.includes(chipText)).toBe(true); + expect(value).toContain(chipText); } if (verifyChildList) {