Browse Source

Merge pull request #5937 from nocodb/test/pg-meta-db

test: pg-meta-db for pw
pull/5962/head
Raju Udava 1 year ago committed by GitHub
parent
commit
8b334b55f6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 7
      .github/workflows/playwright-test-workflow.yml
  2. 1
      packages/nocodb/package.json
  3. 21
      packages/nocodb/src/controllers/test/TestResetService/index.ts
  4. 1
      packages/nocodb/src/models/Column.ts
  5. 14
      packages/nocodb/src/models/Model.ts
  6. 4
      tests/playwright/pages/Dashboard/common/Cell/index.ts
  7. 1
      tests/playwright/tests/db/filters.spec.ts
  8. 14
      tests/playwright/tests/db/timezone.spec.ts

7
.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

1
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\"",

21
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') {

1
packages/nocodb/src/models/Column.ts

@ -760,6 +760,7 @@ export default class Column<T = any> implements ColumnType {
});
}
for (const filter of filters) {
if (filter.fk_parent_id) continue;
await Filter.delete(filter.id, ncMeta);
}
}

14
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;
@ -402,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, {

4
tests/playwright/pages/Dashboard/common/Cell/index.ts

@ -288,7 +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 expect(await chips.nth(i).locator('.name')).toHaveText(value[i]);
await chips.nth(i).locator('.name').waitFor({ state: 'visible' });
const chipText = await chips.nth(i).locator('.name').textContent();
expect(value).toContain(chipText);
}
if (verifyChildList) {

1
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;

14
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)) {

Loading…
Cancel
Save