S16 postgresql opslag added
All checks were successful
Build, test and publish / verify (push) Successful in 7m31s

This commit is contained in:
2026-11-04 17:10:25 +01:00
parent f59cad115a
commit 694bf3fa86
89 changed files with 3087 additions and 252 deletions

View File

@@ -1,4 +1,4 @@
import { test, expect, Page } from '@playwright/test';
import { test, expect, Page, APIRequestContext } from '@playwright/test';
import type { School } from '../src/app/core/api-models';
const backend = process.env['PLAYWRIGHT_BASE_URL'] || 'http://127.0.0.1:8080';
@@ -6,11 +6,23 @@ let schoolToDelete: number | undefined;
test.afterEach(async ({ request }) => {
if (schoolToDelete !== undefined) {
await request.delete(`${backend}/api/dance-schools/${schoolToDelete}`);
await request.delete(`${backend}/api/dance-schools/${schoolToDelete}`, {
headers: await revision(request, schoolToDelete),
});
schoolToDelete = undefined;
}
});
async function revision(
request: APIRequestContext,
schoolId: number,
): Promise<Record<string, string>> {
const school = (await (
await request.get(`${backend}/api/dance-schools/${schoolId}`)
).json()) as School;
return { 'X-School-Revision': String(school.revision) };
}
async function tab(page: Page, label: string) {
await page
.getByRole('navigation', { name: 'Dansschool onderdelen' })
@@ -113,6 +125,7 @@ test('manages a school, shared memberships and shows through the real REST API',
const dancerResponse = await request.post(
`${backend}/api/dance-schools/${schoolToDelete}/dancers`,
{
headers: await revision(request, schoolToDelete),
data: { name, birthDate: '1990-01-01' },
},
);
@@ -120,14 +133,17 @@ test('manages a school, shared memberships and shows through the real REST API',
const groupResponse = await request.post(
`${backend}/api/dance-schools/${schoolToDelete}/dance-groups`,
{
headers: await revision(request, schoolToDelete),
data: { category: name, type: 'REGULAR', startAge: 0, endAge: 99, styles: ['MODERN'] },
},
);
const group = (await groupResponse.json()) as { id: number };
await request.put(
`${backend}/api/dance-schools/${schoolToDelete}/dance-groups/${group.id}/dancers/${dancer.id}`,
{ headers: await revision(request, schoolToDelete) },
);
}
await page.reload();
await tab(page, 'Shows');
await page.getByRole('button', { name: 'Show toevoegen' }).click();
await page.getByRole('dialog').getByLabel('Naam', { exact: true }).fill('Zomershow');
@@ -214,12 +230,14 @@ test('links a coach and finalizes performances spread across multiple dates', as
schoolToDelete = school.id;
const base = `${backend}/api/dance-schools/${school.id}`;
const dancerResponse = await request.post(`${base}/dancers`, {
headers: await revision(request, school.id),
data: { name: 'Dancing coach', birthDate: '1990-01-01' },
});
const dancer = (await dancerResponse.json()) as { id: number };
const groupIds: number[] = [];
for (const name of ['Preschool', 'Adults']) {
const response = await request.post(`${base}/dance-groups`, {
headers: await revision(request, school.id),
data: {
category: name,
type: name === 'Preschool' ? 'PRE_SCHOOLER' : 'REGULAR',
@@ -230,9 +248,12 @@ test('links a coach and finalizes performances spread across multiple dates', as
});
const group = (await response.json()) as { id: number };
groupIds.push(group.id);
await request.put(`${base}/dance-groups/${group.id}/dancers/${dancer.id}`);
await request.put(`${base}/dance-groups/${group.id}/dancers/${dancer.id}`, {
headers: await revision(request, school.id),
});
}
const showResponse = await request.post(`${base}/shows`, {
headers: await revision(request, school.id),
data: {
name: 'Coach across dates',
preferredDayParts: 1,
@@ -244,6 +265,7 @@ test('links a coach and finalizes performances spread across multiple dates', as
});
const show = (await showResponse.json()) as { id: number };
await request.put(`${base}/shows/${show.id}/assignments`, {
headers: await revision(request, school.id),
data: { assignments: groupIds.map((id) => [id]) },
});
await page.goto(`/schools/${school.id}/shows`);
@@ -271,3 +293,39 @@ test('shows a useful connection error and recovers on retry', async ({ page }) =
await page.getByRole('button', { name: 'Opnieuw proberen' }).click();
await expect(page.getByRole('heading', { name: /Mijn dansscholen/ })).toBeVisible();
});
test('rejects a stale editor in another screen and allows reload and retry', async ({
page,
request,
}) => {
const response = await request.post(`${backend}/api/dance-schools`, {
data: { name: `Concurrent school ${Date.now()}` },
});
const school = (await response.json()) as School;
schoolToDelete = school.id;
const other = await page.context().newPage();
try {
for (const screen of [page, other]) {
await screen.goto(`/schools/${school.id}/overview`);
await screen.getByRole('button', { name: 'School bewerken' }).click();
}
await page.getByRole('dialog').getByLabel('Naam', { exact: true }).fill('First confirmed edit');
await other.getByRole('dialog').getByLabel('Naam', { exact: true }).fill('Stale edit');
await save(page);
await other.getByRole('dialog').getByRole('button', { name: 'Opslaan', exact: true }).click();
await expect(other.getByRole('dialog').getByRole('alert')).toContainText('Herlaad');
await expect(other.getByRole('dialog').getByLabel('Naam', { exact: true })).toHaveValue(
'Stale edit',
);
await other.reload();
await expect(
other.getByRole('heading', { name: 'First confirmed edit', exact: true }),
).toBeVisible();
await other.getByRole('button', { name: 'School bewerken' }).click();
await other.getByRole('dialog').getByLabel('Naam', { exact: true }).fill('Reloaded edit');
await save(other);
await expect(other.getByRole('heading', { name: 'Reloaded edit', exact: true })).toBeVisible();
} finally {
await other.close();
}
});