Open History to see the last commit
1import { describe, expect, it } from "@effect/vitest";
2
3import { explicitFaviconUrl, faviconUrlForPage, toolActivityFaviconUrl } from "./favicon.ts";
4
5describe("faviconUrlForPage", () => {
6 it("uses the page origin instead of a third-party favicon service", () => {
7 expect(faviconUrlForPage("https://example.com/docs/page?q=1")).toBe(
8 "https://example.com/favicon.ico",
9 );
10 expect(faviconUrlForPage("http://localhost:5173/app")).toBe(
11 "http://localhost:5173/favicon.ico",
12 );
13 });
14
15 it("selects site-owned light and dark variants without filtering full-color icons", () => {
16 expect(toolActivityFaviconUrl({ pageUrl: "https://github.com/openai/codex" }, "light")).toBe(
17 "https://github.githubassets.com/favicons/favicon.svg",
18 );
19 expect(toolActivityFaviconUrl({ pageUrl: "https://github.com/openai/codex" }, "dark")).toBe(
20 "https://github.githubassets.com/favicons/favicon-dark.svg",
21 );
22
23 const fullColorIcon = {
24 pageUrl: "https://example.com/docs",
25 faviconUrl: "https://cdn.example.com/full-color.png",
26 };
27 expect(toolActivityFaviconUrl(fullColorIcon, "light")).toBe(fullColorIcon.faviconUrl);
28 expect(toolActivityFaviconUrl(fullColorIcon, "dark")).toBe(fullColorIcon.faviconUrl);
29 });
30
31 it("prefers a provider-supplied dark favicon", () => {
32 expect(
33 toolActivityFaviconUrl(
34 {
35 pageUrl: "https://example.com/docs",
36 faviconUrl: "https://example.com/light.svg",
37 faviconUrlDark: "https://example.com/dark.svg",
38 },
39 "dark",
40 ),
41 ).toBe("https://example.com/dark.svg");
42 });
43
44 it("accepts provider-supplied image URLs but rejects extension URLs", () => {
45 expect(explicitFaviconUrl("https://example.com/icon.png")).toBe("https://example.com/icon.png");
46 expect(explicitFaviconUrl("chrome-extension://example/_favicon/")).toBeNull();
47 });
48});