Browse Source

feat(testing): Fixed CI config for playwright

pull/3848/head
Muhammed Mustafa 2 years ago
parent
commit
3c39515f63
  1. 46
      packages/nocodb/src/lib/services/test/TestResetService/createProjects.ts
  2. 7
      packages/nocodb/src/lib/services/test/TestResetService/index.ts
  3. 2
      scripts/playwright/playwright.config.ts
  4. 1
      scripts/playwright/setup/index.ts

46
packages/nocodb/src/lib/services/test/TestResetService/createProjects.ts

@ -1,27 +1,27 @@
import axios from 'axios'; import axios from 'axios';
const extPgProject = { // const extPgProject = {
title: 'pgExtREST', // title: 'pgExtREST',
bases: [ // bases: [
{ // {
type: 'pg', // type: 'pg',
config: { // config: {
client: 'pg', // client: 'pg',
connection: { // connection: {
host: 'localhost', // host: 'localhost',
port: '5432', // port: '5432',
user: 'postgres', // user: 'postgres',
password: 'password', // password: 'password',
database: 'postgres', // database: 'postgres',
}, // },
searchPath: ['public'], // searchPath: ['public'],
}, // },
inflection_column: 'camelize', // inflection_column: 'camelize',
inflection_table: 'camelize', // inflection_table: 'camelize',
}, // },
], // ],
external: true, // external: true,
}; // };
const extMysqlProject = { const extMysqlProject = {
title: 'externalREST', title: 'externalREST',
@ -47,7 +47,7 @@ const extMysqlProject = {
const createProjects = async (token) => { const createProjects = async (token) => {
return await Promise.all( return await Promise.all(
[extPgProject, extMysqlProject].map(async (projectAttr) => { [extMysqlProject].map(async (projectAttr) => {
const response = await axios.post( const response = await axios.post(
'http://localhost:8080/api/v1/db/meta/projects/', 'http://localhost:8080/api/v1/db/meta/projects/',
projectAttr, projectAttr,

7
packages/nocodb/src/lib/services/test/TestResetService/index.ts

@ -4,7 +4,6 @@ import Knex from 'knex';
import NocoCache from '../../../cache/NocoCache'; import NocoCache from '../../../cache/NocoCache';
import NcConnectionMgrv2 from '../../../utils/common/NcConnectionMgrv2'; import NcConnectionMgrv2 from '../../../utils/common/NcConnectionMgrv2';
import createProjects from './createProjects'; import createProjects from './createProjects';
import { isPgSakilaToBeReset, resetPgSakila } from './resetPgSakila';
import createUser from './createUser'; import createUser from './createUser';
import resetMeta from './resetMeta'; import resetMeta from './resetMeta';
import { isMysqlSakilaToBeReset, resetMysqlSakila } from './resetMysqlSakila'; import { isMysqlSakilaToBeReset, resetMysqlSakila } from './resetMysqlSakila';
@ -20,9 +19,9 @@ export class TestResetService {
try { try {
await NcConnectionMgrv2.destroyAll(); await NcConnectionMgrv2.destroyAll();
if (await isPgSakilaToBeReset()) { // if (await isPgSakilaToBeReset()) {
await resetPgSakila(); // await resetPgSakila();
} // }
if (await isMysqlSakilaToBeReset()) { if (await isMysqlSakilaToBeReset()) {
await resetMysqlSakila(); await resetMysqlSakila();

2
scripts/playwright/playwright.config.ts

@ -96,7 +96,7 @@ const config: PlaywrightTestConfig = {
], ],
/* Folder for test artifacts such as screenshots, videos, traces, etc. */ /* Folder for test artifacts such as screenshots, videos, traces, etc. */
outputDir: './playwright-report', outputDir: './output',
/* Run your local dev server before starting the tests */ /* Run your local dev server before starting the tests */
// webServer: { // webServer: {

1
scripts/playwright/setup/index.ts

@ -4,6 +4,7 @@ import { DashboardPage } from '../pages/Dashboard';
const setup = async ({page}: {page: Page}) => { const setup = async ({page}: {page: Page}) => {
const response = await axios.get('http://localhost:8080/api/v1/meta/test/reset'); const response = await axios.get('http://localhost:8080/api/v1/meta/test/reset');
console.log("setup:res:", response);
if(response.status !== 200) { if(response.status !== 200) {
console.error('Failed to reset test data', response); console.error('Failed to reset test data', response);
throw new Error('Failed to reset test data'); throw new Error('Failed to reset test data');

Loading…
Cancel
Save