feat: let the quick schedule changes target any day, not just today

Opening later and closing earlier were fixed to today, which was an
assumption rather than a requirement: closing next Thursday afternoon is
the same decision as closing this one, and the shop knows about it in
advance more often than not.

The date is a single control and still defaults to today, so the
two-click path for the most frequent case is unchanged.

The usual hours differ from one weekday to the next, and "opens later"
is late relative to them, so the whole sixty-day window is resolved on
the server and handed over at once. Sixty small entries cost less than a
round trip per change of date.

The date control's accessible name is explicit: "du" alone collided with
the "Du" field of the range form below it, which the end-to-end run
caught as an ambiguous locator — and an ambiguous locator is an
ambiguous label for anyone using a screen reader.

The end-to-end suite ran before this was pushed, unlike last time.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012cSY9pVhZmJUKNN7wf1Myd
This commit is contained in:
2026-09-22 23:17:26 +02:00
co-authored by Claude Opus 5
parent 3146e29ffb
commit 7312a121df
3 changed files with 118 additions and 64 deletions
+21 -1
View File
@@ -18,7 +18,7 @@ test('changing today’s hours reaches the panel', async ({ page, request }) =>
await page.goto('/admin/exceptions');
await page.getByRole('button', { name: /Fermé aujourd’hui/ }).click();
await expect(page.getByText(/La boutique est fermée aujourd’hui/)).toBeVisible();
await expect(page.getByRole('status')).toContainText(/sera fermée aujourd’hui/);
// Stored as a manual exception for today, in the shop's timezone.
// Read as text: node-postgres parses a DATE column into a local-midnight
@@ -37,6 +37,26 @@ test('changing today’s hours reaches the panel', async ({ page, request }) =>
await expect(page.getByText(/aujourd’hui/).first()).toBeVisible();
});
test('a quick change can target a day other than today', async ({ page }) => {
const target = today(3);
await signIn(page, 'admin');
await page.goto('/admin/exceptions');
// The date defaults to today; closing next Thursday must not cost more
// clicks than closing this afternoon.
await page.getByLabel('Jour à modifier').selectOption(target);
await page.getByRole('button', { name: /^Fermé le / }).click();
await expect(page.getByRole('status')).toContainText(/sera fermée/);
const [exception] = await query<{ date: string; isClosed: boolean }>(
'SELECT date::text AS date, "isClosed" FROM schedule_exceptions',
);
expect(exception?.date).toBe(target);
expect(exception?.isClosed).toBe(true);
});
test('the reference week can be edited and shows what will change', async ({ page }) => {
await signIn(page, 'admin');
await page.goto('/admin/horaires');