Files
EpicNext-Cms/src/components/shared/public-avatar-contract.test.ts
T
openhands 469f69ddd7
CI / check (push) Successful in 4m8s
CI / preflight (push) Skipped
CI / deploy (push) Successful in 2m0s
feat(home): two-column hero with live status panel, explore nav, featured news
2026-09-18 13:27:08 +02:00

47 lines
1.5 KiB
TypeScript

import { readFileSync } from "node:fs";
import { resolve } from "node:path";
import { describe, expect, it } from "vitest";
const compactCallSites = new Map<string, number>([
["src/components/top-header.tsx", 1],
["src/app/(site)/friends/page.tsx", 1],
["src/app/(site)/guilds/[id]/page.tsx", 1],
["src/app/(site)/leaderboard/page.tsx", 1],
["src/app/(site)/login/page.tsx", 2],
["src/app/(site)/me/page.tsx", 1],
["src/app/(site)/messages/page.tsx", 2],
["src/app/(site)/page.tsx", 2],
["src/app/(site)/radio/leaderboard/page.tsx", 1],
["src/app/(site)/radio/shouts/page.tsx", 1],
["src/app/(site)/rankings/page.tsx", 1],
["src/app/(site)/register/page.tsx", 2],
["src/app/(site)/search/page.tsx", 1],
["src/app/(site)/u/[username]/page.tsx", 2],
]);
function source(path: string): string {
return readFileSync(resolve(process.cwd(), path), "utf8");
}
describe("public avatar presentation contract", () => {
it.each([...compactCallSites])(
"uses the shared thumbnail in %s",
(path, expectedCount) => {
const matches = source(path).match(/<UserAvatarThumbnail\b/g) ?? [];
expect(matches).toHaveLength(expectedCount);
},
);
it("preserves explicit full-avatar previews", () => {
expect(source("src/app/(site)/me/page.tsx")).toContain(
"avatarImageUrl(user.look",
);
expect(source("src/app/(site)/settings/page.tsx")).toContain(
"avatarImageUrl(user.look",
);
expect(source("src/app/(site)/u/[username]/page.tsx")).toContain(
"avatarImageUrl(user.look",
);
});
});