fix(e2e): интеграционные тесты на стендах без mocks.
ift-ui/stage-ui гоняют stand/integration против живого API; mock-suite остаётся в CI. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
import type { Page } from '@playwright/test';
|
||||
|
||||
/** Учётки superadmin со стенда (CI: load-stand-smoke-env.sh). */
|
||||
export function standAdminEmail(): string | undefined {
|
||||
return process.env.SMOKE_ADMIN_EMAIL || process.env.ADMIN_SUPER_EMAIL || process.env.E2E_ADMIN_EMAIL;
|
||||
}
|
||||
|
||||
export function standAdminPassword(): string | undefined {
|
||||
return (
|
||||
process.env.SMOKE_ADMIN_PASSWORD ||
|
||||
process.env.ADMIN_SUPER_PASSWORD ||
|
||||
process.env.E2E_ADMIN_PASSWORD
|
||||
);
|
||||
}
|
||||
|
||||
export function hasStandCredentials(): boolean {
|
||||
return Boolean(standAdminEmail() && standAdminPassword());
|
||||
}
|
||||
|
||||
/** Реальный login против admin-api стенда (без Playwright route mocks). */
|
||||
export async function loginAsStandAdmin(page: Page) {
|
||||
const email = standAdminEmail();
|
||||
const password = standAdminPassword();
|
||||
if (!email || !password) {
|
||||
throw new Error('Stand admin credentials missing (SMOKE_ADMIN_* / ADMIN_SUPER_*)');
|
||||
}
|
||||
await page.goto('/login');
|
||||
await page.getByLabel(/email/i).fill(email);
|
||||
await page.getByLabel(/пароль|password/i).fill(password);
|
||||
await page.getByTestId('btn-login').click();
|
||||
await page.getByTestId('layout-shell').waitFor({ state: 'visible', timeout: 30_000 });
|
||||
}
|
||||
@@ -134,12 +134,14 @@ export function createContentSeed() {
|
||||
{
|
||||
id: 'audit-e2e-1',
|
||||
admin_id: 'admin-e2e-1',
|
||||
action: 'user.update',
|
||||
target_type: 'user',
|
||||
target_id: 'user-e2e-1',
|
||||
details: { status: 'frozen' },
|
||||
email: 'e2e@eventhub.local',
|
||||
role: 'superadmin',
|
||||
action: 'update_user',
|
||||
entity_type: 'user',
|
||||
entity_id: 'user-e2e-1',
|
||||
timestamp: now,
|
||||
ip: '127.0.0.1',
|
||||
created_at: now,
|
||||
reason: 'e2e',
|
||||
},
|
||||
];
|
||||
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
import { test, expect } from '@playwright/test';
|
||||
import { hasStandCredentials, loginAsStandAdmin } from '../../helpers/standAuth';
|
||||
|
||||
/**
|
||||
* Интеграция UI ↔ admin-api на IFT/stage после деплоя.
|
||||
* Без page.route mocks — только живой SPA и API стенда.
|
||||
*/
|
||||
test.describe('stand integration (live API)', () => {
|
||||
test.skip(!hasStandCredentials(), 'SMOKE_ADMIN_* / ADMIN_SUPER_* from stand .env required');
|
||||
|
||||
test.beforeEach(async ({ page }) => {
|
||||
await loginAsStandAdmin(page);
|
||||
});
|
||||
|
||||
test('dashboard после login', async ({ page }) => {
|
||||
await expect(page.getByTestId('page-dashboard')).toBeVisible();
|
||||
});
|
||||
|
||||
test('audit: страница и таблица без ошибки рендера', async ({ page }) => {
|
||||
await page.goto('/audit');
|
||||
await expect(page.getByTestId('page-audit')).toBeVisible();
|
||||
await expect(page.getByTestId('filter-audit')).toBeVisible();
|
||||
await expect(page.getByText(/Ошибка отображения|Minified React error/i)).toHaveCount(0);
|
||||
await expect(page.locator('[data-testid="page-audit"] table tbody tr').first()).toBeVisible({
|
||||
timeout: 20_000,
|
||||
});
|
||||
});
|
||||
|
||||
test('users: список загружается', async ({ page }) => {
|
||||
await page.goto('/users');
|
||||
await expect(page.getByTestId('page-users')).toBeVisible();
|
||||
await expect(page.getByText(/Ошибка отображения|Minified React error/i)).toHaveCount(0);
|
||||
});
|
||||
|
||||
test('admins: superadmin видит список', async ({ page }) => {
|
||||
await page.goto('/admins');
|
||||
await expect(page.getByTestId('page-admins')).toBeVisible();
|
||||
await expect(page.getByTestId('page-forbidden')).toHaveCount(0);
|
||||
});
|
||||
|
||||
test('monitoring: страница загружается', async ({ page }) => {
|
||||
await page.goto('/monitoring');
|
||||
await expect(page.getByTestId('page-monitoring')).toBeVisible();
|
||||
});
|
||||
|
||||
test('logout', async ({ page }) => {
|
||||
await page.getByTestId('menu-user').click();
|
||||
await page.getByTestId('btn-logout').click();
|
||||
await expect(page.getByTestId('page-login')).toBeVisible();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user