test: add authenticated staging smoke helper
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
const { defineConfig, devices } = require('@playwright/test');
|
||||
|
||||
const baseURL = process.env.PLAYWRIGHT_BASE_URL || 'http://127.0.0.1:3300';
|
||||
const skipWebServer = process.env.PLAYWRIGHT_SKIP_WEB_SERVER === '1';
|
||||
|
||||
module.exports = defineConfig({
|
||||
testDir: './tests/e2e',
|
||||
fullyParallel: false,
|
||||
@@ -13,18 +16,20 @@ module.exports = defineConfig({
|
||||
? [['github'], ['html', { open: 'never' }]]
|
||||
: [['list'], ['html', { open: 'never' }]],
|
||||
use: {
|
||||
baseURL: process.env.PLAYWRIGHT_BASE_URL || 'http://127.0.0.1:3300',
|
||||
baseURL,
|
||||
trace: 'on-first-retry',
|
||||
screenshot: 'only-on-failure',
|
||||
video: 'retain-on-failure',
|
||||
},
|
||||
webServer: {
|
||||
command: 'bash scripts/playwright-stack.sh',
|
||||
cwd: __dirname,
|
||||
url: (process.env.PLAYWRIGHT_BASE_URL || 'http://127.0.0.1:3300') + '/login',
|
||||
timeout: 600_000,
|
||||
reuseExistingServer: false,
|
||||
},
|
||||
webServer: skipWebServer
|
||||
? undefined
|
||||
: {
|
||||
command: 'bash scripts/playwright-stack.sh',
|
||||
cwd: __dirname,
|
||||
url: `${baseURL}/login`,
|
||||
timeout: 600_000,
|
||||
reuseExistingServer: false,
|
||||
},
|
||||
projects: [
|
||||
{
|
||||
name: 'chromium',
|
||||
|
||||
@@ -44,6 +44,9 @@ function mapRoute(urlPath) {
|
||||
if (urlPath === '/api-keys') {
|
||||
return path.join(ROOT_DIR, 'html', 'api-keys.html');
|
||||
}
|
||||
if (urlPath === '/secrets') {
|
||||
return path.join(ROOT_DIR, 'html', 'secrets.html');
|
||||
}
|
||||
if (urlPath === '/logs') {
|
||||
return path.join(ROOT_DIR, 'html', 'logs.html');
|
||||
}
|
||||
@@ -156,6 +159,10 @@ const server = http.createServer((request, response) => {
|
||||
redirect(response, '/api-keys');
|
||||
return;
|
||||
}
|
||||
if (urlPath === '/html/secrets.html') {
|
||||
redirect(response, '/secrets');
|
||||
return;
|
||||
}
|
||||
if (urlPath === '/html/logs.html') {
|
||||
redirect(response, '/logs');
|
||||
return;
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
const { test, expect } = require('@playwright/test');
|
||||
const { getSession, localized, login } = require('./helpers');
|
||||
|
||||
const CORE_PAGES = [
|
||||
{ path: '/', heading: localized('Operations', 'Операции') },
|
||||
{ path: '/agents', heading: localized('Agents', 'Агенты') },
|
||||
{ path: '/api-keys', heading: localized('API Keys', 'API ключи') },
|
||||
{ path: '/secrets', heading: localized('Secrets', 'Секреты') },
|
||||
{ path: '/logs', heading: localized('Logs', 'Логи') },
|
||||
{ path: '/usage', heading: localized('Usage', 'Использование') },
|
||||
{ path: '/workspace-setup', heading: localized('Workspace', 'Воркспейс') },
|
||||
{ path: '/settings', heading: localized('Settings', 'Настройки') },
|
||||
{ path: '/stream-sessions', heading: localized('Stream Sessions', 'Stream Sessions') },
|
||||
{ path: '/async-jobs', heading: localized('Async Jobs', 'Async Jobs') },
|
||||
{ path: '/wizard/', heading: localized('Create', 'Создать') },
|
||||
];
|
||||
|
||||
test('authenticated staging smoke logs in and exposes session json', async ({ page }) => {
|
||||
await login(page);
|
||||
|
||||
const session = await getSession(page);
|
||||
expect(session.user).toBeTruthy();
|
||||
expect(Array.isArray(session.memberships)).toBe(true);
|
||||
expect(session.memberships.length).toBeGreaterThan(0);
|
||||
});
|
||||
|
||||
test('authenticated staging smoke opens core pages without console errors', async ({ page }) => {
|
||||
const pageErrors = [];
|
||||
page.on('pageerror', (error) => {
|
||||
pageErrors.push(error.message);
|
||||
});
|
||||
|
||||
await login(page);
|
||||
|
||||
for (const pageSpec of CORE_PAGES) {
|
||||
await page.goto(pageSpec.path);
|
||||
await expect(page.locator('#login-form')).toHaveCount(0);
|
||||
await expect(page.locator('body')).toContainText(pageSpec.heading);
|
||||
}
|
||||
|
||||
expect(pageErrors).toEqual([]);
|
||||
});
|
||||
Reference in New Issue
Block a user