Expand moderation case workflows
CI / checks (push) Successful in 6m49s

This commit is contained in:
2026-10-17 16:19:33 -04:00
parent 4501eba873
commit 7f2205e9c4
22 changed files with 2815 additions and 167 deletions
+29 -12
View File
@@ -290,21 +290,38 @@ describe('browser authentication guard', () => {
}
}
);
it('protects moderation pages and Svelte page-data requests with the same role checks', async () => {
for (const role of ['viewer', 'super_viewer', 'operator', 'moderator', 'admin'] as const) {
signIn(role);
for (const path of ['/moderation', '/moderation/__data.json']) {
const call = requestFor('/moderation', { path });
if (role === 'viewer' || role === 'operator') {
await expect(call.invoke()).rejects.toMatchObject({ status: 403 });
expect(call.resolve).not.toHaveBeenCalled();
} else {
expect((await call.invoke()).status).toBe(200);
expect(call.resolve).toHaveBeenCalledOnce();
it.each([
['/moderation', '/moderation'],
['/moderation/cases/[id]', '/moderation/cases/case-123']
])(
'protects %s pages and Svelte page-data requests with the same role checks',
async (route, path) => {
for (const role of [
'viewer',
'super_viewer',
'operator',
'moderator',
'admin'
] as const) {
const session = signIn(role);
for (const requestPath of [path, `${path}/__data.json`]) {
for (const method of ['GET', 'HEAD']) {
const call = requestFor(route, { path: requestPath, method });
if (role === 'viewer' || role === 'operator') {
await expect(call.invoke()).rejects.toMatchObject({ status: 403 });
expect(call.resolve).not.toHaveBeenCalled();
} else {
const response = await call.invoke();
expect(response.status).toBe(200);
expect(response.headers.get('Cache-Control')).toContain('no-store');
expect(call.resolve).toHaveBeenCalledOnce();
expect(call.event.locals.user).toEqual(session.user);
}
}
}
}
}
});
);
it.each(['GET', 'HEAD', 'POST', 'PATCH', 'DELETE'])(
'permits only administrators to write settings and Super Viewers to read them',
async (method) => {