web: adopt Cache Components, Partial Prefetching and ensureStatic
web / ci (push) Successful in 2m2s

This commit is contained in:
ponas committed 2026-10-13 23:59:14 +02:00
1 parent 3a0c2fd82b
commit db286434ba
70 files changed
+1285 -316

No files matched your search

+11 -7
View File
@@ -1,7 +1,7 @@
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
// sever the server-only @/app/client import chain; the network functions are not under test
vi.mock("@/app/client", () => ({ getClient: vi.fn() }));
vi.mock("@/app/client", () => ({ cmsQuery: vi.fn() }));
import type {
OpeningHoursRangeBlockFragment,
@@ -13,6 +13,10 @@ import {
getTodaysOpeningHoursForFunction,
groupOpeningHours,
} from "./openinghours.ts";
import { osloDay, startOfOsloDay } from "./date.ts";
// what getToday()/useToday() hand to the helpers
const today = () => startOfOsloDay(osloDay());
const range = (
timeFrom: string | null,
@@ -138,28 +142,28 @@ describe("getTodaysOpeningHoursForFunction", () => {
it("returns today's hours", () => {
vi.setSystemTime(new Date("2026-07-07T10:00:00Z")); // tirsdag
expect(getTodaysOpeningHoursForFunction(openingHours, "bar")).toBe(
expect(getTodaysOpeningHoursForFunction(openingHours, "bar", today())).toBe(
"16:00—23:00"
);
});
it("returns Stengt for a null day", () => {
vi.setSystemTime(new Date("2026-07-11T10:00:00Z")); // lørdag
expect(getTodaysOpeningHoursForFunction(openingHours, "bar")).toBe(
expect(getTodaysOpeningHoursForFunction(openingHours, "bar", today())).toBe(
"Stengt"
);
});
it("returns the custom text when set", () => {
vi.setSystemTime(new Date("2026-07-12T10:00:00Z")); // søndag
expect(getTodaysOpeningHoursForFunction(openingHours, "bar")).toBe(
expect(getTodaysOpeningHoursForFunction(openingHours, "bar", today())).toBe(
"Kun ved arrangement"
);
});
it("returns ? for unknown functions", () => {
vi.setSystemTime(new Date("2026-07-07T10:00:00Z"));
expect(getTodaysOpeningHoursForFunction(openingHours, "kafé")).toBe("?");
expect(getTodaysOpeningHoursForFunction(openingHours, "kafé", today())).toBe("?");
});
it("uses the Oslo weekday when the server runs in UTC", () => {
@@ -168,12 +172,12 @@ describe("getTodaysOpeningHoursForFunction", () => {
try {
// 22:20 UTC on torsdag is 00:20 fredag in Oslo (CEST)
vi.setSystemTime(new Date("2026-07-09T22:20:00Z"));
expect(getTodaysOpeningHoursForFunction(openingHours, "bar")).toBe(
expect(getTodaysOpeningHoursForFunction(openingHours, "bar", today())).toBe(
"15:00—01:00"
);
// 23:20 UTC on torsdag is 00:20 fredag in Oslo (CET)
vi.setSystemTime(new Date("2026-01-08T23:20:00Z"));
expect(getTodaysOpeningHoursForFunction(openingHours, "bar")).toBe(
expect(getTodaysOpeningHoursForFunction(openingHours, "bar", today())).toBe(
"15:00—01:00"
);
} finally {