ci/woodpecker/pr/ci Pipeline failed
- M1: E2E_REQUIRE_SEEDED_AUTH=1 in the CI e2e step makes login failures hard failures (loginAs throws, guards disabled, globalSetup refuses a pre-populated DB); auth.spec redirect test asserts outright under the flag; non-admin /admin test is now a real authorization assertion - M2: ci.yml build step depends_on test — never two concurrent turbo builds on the shared workspace - M3: unknown /assets/* paths 404 from the SPA catch-all instead of serving index.html with an immutable cache header; spec arm added - minors: e2e step gets when: *image_build_when, health poll uses GATEWAY_PORT + AbortSignal.timeout, BETTER_AUTH_SECRET generated per run (no literal in tree), failure echoes artifact path, dev-guide documents the gate, stale verify-release comment fixed
65 lines
2.5 KiB
TypeScript
65 lines
2.5 KiB
TypeScript
import { test, expect } from '@playwright/test';
|
|
import { loginAs, ADMIN_USER, REQUIRE_SEEDED_AUTH, TEST_USER } from './helpers/auth.js';
|
|
|
|
test.describe('Admin page — admin user', () => {
|
|
test.beforeEach(async ({ page }) => {
|
|
await loginAs(page, ADMIN_USER.email, ADMIN_USER.password);
|
|
const url = page.url();
|
|
test.skip(
|
|
!REQUIRE_SEEDED_AUTH && !url.includes('/chat'),
|
|
'No seeded admin user — skipping admin tests',
|
|
);
|
|
});
|
|
|
|
test('admin page loads with the Admin Panel heading', async ({ page }) => {
|
|
await page.goto('/admin');
|
|
await expect(page.getByRole('heading', { name: /admin panel/i })).toBeVisible({
|
|
timeout: 10_000,
|
|
});
|
|
});
|
|
|
|
test('shows User Management and System Health tabs', async ({ page }) => {
|
|
await page.goto('/admin');
|
|
await expect(page.getByRole('button', { name: /user management/i })).toBeVisible();
|
|
await expect(page.getByRole('button', { name: /system health/i })).toBeVisible();
|
|
});
|
|
|
|
test('User Management tab is active by default', async ({ page }) => {
|
|
await page.goto('/admin');
|
|
// The users tab shows a "+ New User" button
|
|
await expect(page.getByRole('button', { name: /new user/i })).toBeVisible({ timeout: 10_000 });
|
|
});
|
|
|
|
test('clicking System Health tab switches to health view', async ({ page }) => {
|
|
await page.goto('/admin');
|
|
await page.getByRole('button', { name: /system health/i }).click();
|
|
// Health cards or loading indicator should appear
|
|
const loadingOrCard = page
|
|
.getByText(/loading health/i)
|
|
.or(page.getByText(/database/i))
|
|
.first();
|
|
await expect(loadingOrCard).toBeVisible({ timeout: 10_000 });
|
|
});
|
|
});
|
|
|
|
test.describe('Admin page — non-admin user', () => {
|
|
test.beforeEach(async ({ page }) => {
|
|
await loginAs(page, TEST_USER.email, TEST_USER.password);
|
|
const url = page.url();
|
|
test.skip(
|
|
!REQUIRE_SEEDED_AUTH && !url.includes('/chat'),
|
|
'No seeded test user — skipping non-admin tests',
|
|
);
|
|
});
|
|
|
|
test('non-admin visiting /admin never sees the admin panel', async ({ page }) => {
|
|
await page.goto('/admin');
|
|
// Wait for the app shell to render (redirect and access-denied views both
|
|
// keep the sidebar), then assert the panel itself is absent. globalSetup
|
|
// seeds TEST_USER with role 'member', so this is a real authorization
|
|
// assertion, not environment-dependent.
|
|
await expect(page.getByRole('img', { name: /mosaic logo/i })).toBeVisible({ timeout: 10_000 });
|
|
await expect(page.getByRole('heading', { name: /admin panel/i })).not.toBeVisible();
|
|
});
|
|
});
|