Files
Metamorph/e2e/tests/m1-db.spec.ts
2026-05-11 06:05:27 +02:00

51 lines
2.0 KiB
TypeScript

import { expect, test } from '@playwright/test';
/**
* M1 — DB schema visibility checks.
* Validates that the diagnostic endpoint reflects an applied migration and
* that the SPA renders the resulting state in the Database card.
*/
test.describe('M1 — DB schema', () => {
test('GET /api/v1/diag/db returns alembic revision and table count', async ({ request }) => {
const resp = await request.get('/api/v1/diag/db');
expect(resp.status()).toBe(200);
const body = (await resp.json()) as {
reachable: boolean;
alembic_revision: string | null;
table_count: number;
};
expect(body.reachable).toBe(true);
expect(body.alembic_revision).toMatch(/^[0-9a-f]{8,}$/);
// 26 application tables + alembic_version. Allow ≥26 to be tolerant of future migrations.
expect(body.table_count).toBeGreaterThanOrEqual(26);
});
test('Database card shows the revision short-hash and the table count', async ({ page }) => {
await page.goto('/');
const dbCard = page.locator('h3', { hasText: /^Database$/ }).locator('..');
// Wait for the probing state to resolve.
await expect(dbCard).toContainText(/revision\s+[0-9a-f]{8}/i, { timeout: 10_000 });
const count = await dbCard.getByTestId('db-table-count').innerText();
expect(Number(count)).toBeGreaterThanOrEqual(26);
await expect(dbCard).toContainText('Alembic head reached');
});
test('Roadmap card reflects M1 done', async ({ page }) => {
await page.goto('/');
const roadmap = page.locator('h3', { hasText: /^Roadmap$/ }).locator('..');
// Tolerate trailing "+ M2 done" / "+ M3 done" — the contract is "M1 is past, next is named".
await expect(roadmap).toContainText(/M1.*done/i);
await expect(roadmap).toContainText(/Next:/i);
});
test('Footer mentions M1', async ({ page }) => {
await page.goto('/');
const footer = page.locator('footer');
await expect(footer).toContainText(/M0\s+bootstrap/i);
await expect(footer).toContainText(/M1\s+db\s+schema/i);
});
});