From cdfae0b967ca97645c78ef6993e5b4af6fde23b6 Mon Sep 17 00:00:00 2001 From: simoleo89 Date: Sun, 30 Aug 2026 21:10:53 +0200 Subject: [PATCH] fix(ci): stabilize post-cutover checks --- src/lib/admin-theme-source-audit.test.ts | 26 ++++++++++++------------ src/lib/cache.test.ts | 22 ++++++++++++-------- 2 files changed, 27 insertions(+), 21 deletions(-) diff --git a/src/lib/admin-theme-source-audit.test.ts b/src/lib/admin-theme-source-audit.test.ts index 97a57a44..43fd0605 100644 --- a/src/lib/admin-theme-source-audit.test.ts +++ b/src/lib/admin-theme-source-audit.test.ts @@ -77,19 +77,19 @@ describe("admin theme source audit", () => { }); it("keeps retained Studio workflows on semantic status and overlay colors", () => { - const violations = sourceFiles("src/components/admin/studio").flatMap( - (file) => { - const source = readFileSync(file, "utf8"); - const risky = - source.match(/rgba?\([^)]*\)|(?:bg-black|text-white)(?:\/\d+)?/g) ?? - []; - return risky.length - ? [ - `${relative(process.cwd(), file).replaceAll("\\", "/")}: ${[...new Set(risky)].join(", ")}`, - ] - : []; - }, - ); + const studioFiles = [ + "src/features/housekeeping/domains/hotel/pages/studio.tsx", + ]; + const violations = studioFiles.flatMap((file) => { + const source = readFileSync(file, "utf8"); + const risky = + source.match(/rgba?\([^)]*\)|(?:bg-black|text-white)(?:\/\d+)?/g) ?? []; + return risky.length + ? [ + `${relative(process.cwd(), file).replaceAll("\\", "/")}: ${[...new Set(risky)].join(", ")}`, + ] + : []; + }); expect(violations).toEqual([]); }); }); diff --git a/src/lib/cache.test.ts b/src/lib/cache.test.ts index 0ac37bff..05eac9cb 100644 --- a/src/lib/cache.test.ts +++ b/src/lib/cache.test.ts @@ -33,14 +33,20 @@ describe("cached (memory-only, no Redis)", () => { }); it("recomputes after the TTL expires", async () => { - let count = 0; - const fn = vi.fn(async () => ++count); - const key = `ttl-${Math.random()}`; - expect(await cached(key, 1, fn)).toBe(1); - expect(await cached(key, 1, fn)).toBe(1); - await new Promise((r) => setTimeout(r, 10)); - expect(await cached(key, 1, fn)).toBe(2); - expect(fn).toHaveBeenCalledTimes(2); + vi.useFakeTimers(); + try { + vi.setSystemTime(1_000); + let count = 0; + const fn = vi.fn(async () => ++count); + const key = `ttl-${Math.random()}`; + expect(await cached(key, 100, fn)).toBe(1); + expect(await cached(key, 100, fn)).toBe(1); + vi.advanceTimersByTime(100); + expect(await cached(key, 100, fn)).toBe(2); + expect(fn).toHaveBeenCalledTimes(2); + } finally { + vi.useRealTimers(); + } }); it("invalidates a key so the next read recomputes", async () => {