test(api): verify regressions over HTTP and document UI readiness
This commit is contained in:
@@ -40,11 +40,22 @@ try {
|
||||
await boot();
|
||||
const date = (await request('/today')).date;
|
||||
const h = await request('/habits', 'POST', { name: 'HTTP hydration', method: 'count', target: 8 }, 201);
|
||||
const t = await request('/habits', 'POST', { name: 'HTTP tasks', method: 'tasks', tasks: [{ name: 'Check' }] }, 201);
|
||||
const schedule = { type: 'weekdays', days: [new Date(`${date}T00:00:00Z`).getUTCDay()] };
|
||||
const t = await request('/habits', 'POST', { name: 'HTTP tasks', method: 'tasks', tasks: [{ name: 'Check', schedule }] }, 201);
|
||||
const renamedTask = await request(`/habits/${t.id}/tasks/${t.tasks[0].id}`, 'PATCH', { name: 'Renamed task' });
|
||||
check(JSON.stringify(renamedTask.schedule) === JSON.stringify(schedule), 'Task rename reset recurrence');
|
||||
await Promise.all([request(`/habits/${h.id}`, 'PATCH', { name: 'Concurrent hydration' }), request(`/habits/${h.id}`, 'PATCH', { unit: 'glasses' })]);
|
||||
const updated = await request(`/habits/${h.id}`);
|
||||
check(updated.name === 'Concurrent hydration' && updated.unit === 'glasses', 'Overlapping patches lost unrelated settings');
|
||||
await request(`/habits/${h.id}/days/${date}/progress`, 'PUT', { count: 7 });
|
||||
await request(`/habits/${t.id}/days/${date}/tasks/${t.tasks[0].id}`, 'PUT', { done: true });
|
||||
const c = await request('/charts', 'POST', { name: 'HTTP combined', habitIds: [h.id, t.id] }, 201);
|
||||
const c = await request('/charts', 'POST', { name: 'HTTP combined', habitIds: [h.id, t.id], settings: { mainColor: '#ff0000', shadeCount: 8 } }, 201);
|
||||
check((await request(`/charts/${c.id}/days/${date}`)).ratio === 0.5, 'Partial habit incorrectly contributed to combined score');
|
||||
const renamedChart = await request(`/charts/${c.id}`, 'PATCH', { name: 'Renamed chart' });
|
||||
check(renamedChart.settings.mainColor === '#ff0000' && renamedChart.settings.shadeCount === 8, 'Chart rename reset settings');
|
||||
await request(`/habits/${t.id}`, 'PATCH', { archived: true });
|
||||
await request(`/habits/${t.id}`, 'PATCH', { archived: false });
|
||||
check((await request(`/habits/${t.id}/days/${date}`)).complete, 'Archive and restore lost task completion');
|
||||
await stop(); await boot();
|
||||
check((await request(`/habits/${h.id}/days/${date}`)).value === 7, 'Count did not survive restart');
|
||||
check((await request(`/charts/${c.id}/days/${date}`)).ratio === 0.5, 'Tasks or membership did not survive restart');
|
||||
@@ -53,5 +64,5 @@ try {
|
||||
check(result.days[0].ratio === 1, 'Correction did not update combined calendar');
|
||||
check((await fetch(`${origin}/api/habits`)).status === 401, 'HTTP authentication was bypassed');
|
||||
check((await fetch(`${origin}/api/habits`, { method: 'POST', headers: { Cookie: `minabot_session=${token}`, Origin: 'https://evil.example', 'Content-Type': 'application/json' }, body: '{}' })).status === 403, 'HTTP Origin enforcement was bypassed');
|
||||
console.log('Production HTTP smoke passed: migrations, count/task logs, combined scores, correction, authentication, CSRF, and persistence across restart.');
|
||||
console.log('Production HTTP smoke passed: migrations, count/task logs, combined scores, correction, PATCH preservation, overlapping writes, archive/restore, authentication, CSRF, and persistence across restart.');
|
||||
} finally { await stop(); rmSync(directory, { recursive: true, force: true }); }
|
||||
|
||||
Reference in New Issue
Block a user