返回 CodeWhale
app-page.test.ts
根目录 / web / lib / content / app-page.test.ts
1 import { describe, expect, it } from "vitest";
2 import { APP_COPY } from "./app-page";
3 import { AVAILABILITY_ROWS } from "./availability";
4 import desktopMedia from "../../data/desktop-media.json";
5
6 function strings(value: unknown): string[] {
7 if (typeof value === "string") return [value];
8 if (Array.isArray(value)) return value.flatMap(strings);
9 if (value && typeof value === "object") return Object.values(value).flatMap(strings);
10 return [];
11 }
12
13 describe("/app copy", () => {
14 const text = strings([APP_COPY, AVAILABILITY_ROWS.filter((row) => row.pages.includes("app"))]).join("\n");
15
16 it("offers no download and never links the hosted app", () => {
17 expect(text).not.toMatch(/downloads\.codewhale\.net|app\.codewhale\.net/);
18 expect(text).not.toMatch(/\.dmg|\.exe|\.msi|waitlist/i);
19 });
20
21 it("names no price, plan, hours, date or UI toolkit", () => {
22 expect(text).not.toMatch(/\$\d|per month|hours|GPUI|figma/i);
23 expect(text).not.toMatch(/\bplans?\b|pricing/);
24 });
25
26 it("shows the four required surfaces plus the terminal and local browser", () => {
27 const ids = AVAILABILITY_ROWS.filter((row) => row.pages.includes("app")).map((row) => row.id);
28 expect(ids).toEqual(["terminal", "local-browser", "hosted-web", "desktop", "phone"]);
29 });
30
31 it("pairs every capture with alt text and a caption, under a scope that names the build and the model", () => {
32 expect(APP_COPY.shotsScope.en).toContain("development build of the desktop app");
33 expect(APP_COPY.shotsScope.en).toContain(desktopMedia.capture.provider);
34 for (const shot of APP_COPY.shots) {
35 expect(shot.alt.en.length).toBeGreaterThan(40);
36 expect(shot.caption.en.length).toBeGreaterThan(20);
37 }
38 });
39 });
40
40 lines TYPESCRIPT