feat: add opt-in daily Discord reminders with quiet hours
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import { ReminderSettings } from "./components/ReminderSettings";
|
||||
import {
|
||||
afterAll,
|
||||
afterEach,
|
||||
@@ -662,3 +663,23 @@ describe("design system tabs", () => {
|
||||
expect(fetchMock).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
test("reminder form submits native time values and explicit opt-out", async () => {
|
||||
const saved: unknown[] = [];
|
||||
fetchMock.mockImplementation((async (_input, init) => {
|
||||
if (init?.method === "PUT") { saved.push(JSON.parse(String(init.body))); return Response.json({}); }
|
||||
return Response.json({ enabled: false, time: "20:00", quietStart: "22:00", quietEnd: "08:00", available: true, lastDelivery: null });
|
||||
}) as typeof fetch);
|
||||
await act(async () => root.render(<ReminderSettings timezone="Europe/Belgrade" />));
|
||||
const time = container.querySelector<HTMLInputElement>('input[name="time"]')!;
|
||||
await act(async () => {
|
||||
time.value = "14:30";
|
||||
container.querySelector<HTMLInputElement>('input[type="checkbox"]')!.click();
|
||||
});
|
||||
await act(async () => container.querySelector("form")!.dispatchEvent(new dom.Event("submit", { bubbles: true, cancelable: true }) as unknown as Event));
|
||||
expect(saved[0]).toEqual({ enabled: true, time: "14:30", quietStart: "22:00", quietEnd: "08:00" });
|
||||
await act(async () => container.querySelector<HTMLInputElement>('input[type="checkbox"]')!.click());
|
||||
await act(async () => container.querySelector("form")!.dispatchEvent(new dom.Event("submit", { bubbles: true, cancelable: true }) as unknown as Event));
|
||||
expect(saved[1]).toEqual({ enabled: false, time: "14:30", quietStart: "22:00", quietEnd: "08:00" });
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user