mirror of
https://github.com/nocodb/nocodb.git
synced 2026-04-25 01:46:09 +00:00
test: playwright test corrections
This commit is contained in:
@@ -1,15 +1,27 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { ConfigService } from '@nestjs/config';
|
||||
import type { NestMiddleware } from '@nestjs/common';
|
||||
import type { AppConfig } from '~/interface/config';
|
||||
import Noco from '~/Noco';
|
||||
|
||||
@Injectable()
|
||||
export class GlobalMiddleware implements NestMiddleware {
|
||||
constructor(protected readonly config: ConfigService<AppConfig>) {}
|
||||
|
||||
use(req: any, res: any, next: () => void) {
|
||||
req.ncSiteUrl =
|
||||
Noco.config?.envs?.[Noco.env]?.publicUrl ||
|
||||
Noco.config?.publicUrl ||
|
||||
req.protocol + '://' + req.get('host');
|
||||
req.ncFullUrl = req.protocol + '://' + req.get('host') + req.originalUrl;
|
||||
|
||||
const dashboardPath = this.config.get('dashboardPath', {
|
||||
infer: true,
|
||||
});
|
||||
|
||||
// used for playwright tests so env is not documented
|
||||
req.dashboardUrl =
|
||||
process.env.NC_DASHBOARD_URL || req.ncSiteUrl + dashboardPath;
|
||||
next();
|
||||
}
|
||||
}
|
||||
|
||||
1
packages/nocodb/src/types/express.d.ts
vendored
1
packages/nocodb/src/types/express.d.ts
vendored
@@ -10,5 +10,6 @@ declare module 'express-serve-static-core' {
|
||||
};
|
||||
ncSiteUrl: string;
|
||||
clientIp: string;
|
||||
dashboardUrl: string;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,14 +33,10 @@ export class OpenIDLoginPage extends BasePage {
|
||||
const authorize = this.get();
|
||||
|
||||
await Promise.all([
|
||||
this.rootPage.waitForNavigation({ url: /localhost:8080/ }),
|
||||
this.rootPage.waitForNavigation({ url: /localhost:3000/ }),
|
||||
authorize.locator(`[type="submit"]`).click(),
|
||||
]);
|
||||
|
||||
await this.rootPage.goto(`http://localhost:3000?` + this.rootPage.url().split('?')[1]);
|
||||
|
||||
await this.projectsPage.waitToBeRendered();
|
||||
|
||||
console.log('111');
|
||||
await this.rootPage.locator(`[data-testid="nc-sidebar-userinfo"]:has-text("${email.split('@')[0]}")`);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,14 +30,10 @@ export class SAMLLoginPage extends BasePage {
|
||||
await signIn.locator(`#userName`).fill(email);
|
||||
await signIn.locator(`#email`).fill(email);
|
||||
await Promise.all([
|
||||
this.rootPage.waitForNavigation({ url: /localhost:8080/ }),
|
||||
this.rootPage.waitForNavigation({ url: /localhost:3000/ }),
|
||||
signIn.locator(`#btn-sign-in`).click(),
|
||||
]);
|
||||
|
||||
await this.rootPage.goto(`http://localhost:3000?` + this.rootPage.url().split('?')[1]);
|
||||
|
||||
await this.projectsPage.waitToBeRendered();
|
||||
|
||||
console.log('111');
|
||||
await this.rootPage.locator(`[data-testid="nc-sidebar-userinfo"]:has-text("${email.split('@')[0]}")`);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -410,9 +410,9 @@ const setup = async ({
|
||||
// ignore error: some roles will not have permission for license reset
|
||||
// console.error(`Error resetting base: ${process.env.TEST_PARALLEL_INDEX}`, e);
|
||||
}
|
||||
|
||||
await page.addInitScript(
|
||||
async ({ token }) => {
|
||||
if (location.search?.match(/code=|short-token=/)) return;
|
||||
try {
|
||||
let initialLocalStorage = {};
|
||||
try {
|
||||
@@ -420,6 +420,9 @@ const setup = async ({
|
||||
} catch (e) {
|
||||
console.error('Failed to parse local storage', e);
|
||||
}
|
||||
|
||||
if (initialLocalStorage?.token) return;
|
||||
|
||||
window.localStorage.setItem(
|
||||
'nocodb-gui-v2',
|
||||
JSON.stringify({
|
||||
|
||||
Reference in New Issue
Block a user