85453da49f
regression / regression-shards (style-16-prod style-9-prod style-17-prod iframe-render-compat variables-prod mp4-h265-sdr, shard-4) (push) Has been cancelled
regression / regression-shards (style-4-prod style-11-prod style-2-prod animejs-adapter typegpu-adapter parallel-capture-regression, shard-5) (push) Has been cancelled
regression / regression-shards (style-7-prod style-8-prod style-10-prod css-spinner-render-compat webm-transparency mp4-h264-sdr webm-vp9, shard-3) (push) Has been cancelled
regression / regression-shards (sub-composition-video style-18-prod raf-ball-render-compat font-variant-numeric sub-comp-t0 sub-comp-id-selector, shard-7) (push) Has been cancelled
Windows render verification / Detect changes (push) Has been cancelled
Windows render verification / Preflight (lint + format) (push) Has been cancelled
Windows render verification / Render on windows-latest (push) Has been cancelled
Windows render verification / Tests on windows-latest (push) Has been cancelled
CI / Detect changes (push) Has been cancelled
CI / Build (push) Has been cancelled
CI / Lint (push) Has been cancelled
CI / Fallow audit (push) Has been cancelled
CI / Format (push) Has been cancelled
CI / Typecheck (push) Has been cancelled
CI / Test (push) Has been cancelled
CI / Producer: integration tests (push) Has been cancelled
CI / Producer: unit tests (push) Has been cancelled
CI / File size check (push) Has been cancelled
CI / Test: skills (push) Has been cancelled
CI / Skills: manifest in sync (push) Has been cancelled
CI / CLI: npx shim (macos-latest) (push) Has been cancelled
CI / CLI: npx shim (ubuntu-latest) (push) Has been cancelled
CI / CLI: npx shim (windows-latest) (push) Has been cancelled
CI / SDK: unit + contract + smoke (push) Has been cancelled
CI / Test: runtime contract (push) Has been cancelled
CI / Studio: load smoke (push) Has been cancelled
CI / Smoke: global install (push) Has been cancelled
CI / CLI smoke (required) (push) Has been cancelled
CI / Semantic PR title (push) Has been cancelled
Player perf / Detect changes (push) Has been cancelled
Player perf / Preflight (lint + format) (push) Has been cancelled
Player perf / player-perf (push) Has been cancelled
Player perf / Perf: drift (push) Has been cancelled
Player perf / Perf: fps (push) Has been cancelled
Player perf / Perf: parity (push) Has been cancelled
Player perf / Perf: scrub (push) Has been cancelled
Player perf / Perf: load (push) Has been cancelled
preview-regression / Detect changes (push) Has been cancelled
preview-regression / Preflight (lint + format) (push) Has been cancelled
preview-regression / Preview parity (push) Has been cancelled
preview-regression / preview-regression (push) Has been cancelled
regression / regression (push) Has been cancelled
regression / Detect changes (push) Has been cancelled
regression / Preflight (lint + format) (push) Has been cancelled
regression / regression-shards (hdr-regression style-5-prod style-3-prod mov-prores, shard-1) (push) Has been cancelled
regression / regression-shards (overlay-montage-prod style-12-prod chat missing-host-comp-id png-sequence portrait-edge-bleed, shard-6) (push) Has been cancelled
regression / regression-shards (style-13-prod style-6-prod vignelli-stacking gsap-letters-render-compat audio-mux-parity, shard-8) (push) Has been cancelled
regression / regression-shards (style-15-prod hdr-hlg-regression style-1-prod many-cuts vfr-screen-recording render-symlinked-assets, shard-2) (push) Has been cancelled
CodeQL / Analyze (actions) (push) Has been cancelled
CodeQL / Analyze (javascript-typescript) (push) Has been cancelled
CodeQL / Analyze (python) (push) Has been cancelled
Docs / Validate docs (push) Has been cancelled
Sync skills to ClawHub / Publish changed skills (push) Has been cancelled
138 lines
5.7 KiB
JavaScript
138 lines
5.7 KiB
JavaScript
import test from "node:test";
|
|
import assert from "node:assert";
|
|
import { readFileSync } from "node:fs";
|
|
import {
|
|
entityFrom,
|
|
titleMatches,
|
|
svglQueriesFor,
|
|
simpleIconSlugsFor,
|
|
githubOrgFor,
|
|
faviconDomainFor,
|
|
svglSearch,
|
|
simpleIconsSearch,
|
|
githubAvatarSearch,
|
|
faviconSearch,
|
|
} from "./logo-provider.mjs";
|
|
import { getProviders, runProviders } from "./registry.mjs";
|
|
|
|
test("entityFrom strips filler words from the intent; --entity wins", () => {
|
|
assert.equal(entityFrom("LinkedIn logo"), "linkedin");
|
|
assert.equal(entityFrom("official Slack brand mark"), "slack");
|
|
assert.equal(entityFrom("anything", "Notion"), "notion");
|
|
});
|
|
|
|
test("titleMatches ignores case, spacing, punctuation — and rejects lookalikes", () => {
|
|
assert.ok(titleMatches("Next.js", "nextjs"));
|
|
assert.ok(titleMatches("Coca-Cola", "coca cola"));
|
|
assert.ok(!titleMatches("Slackware", "slack"));
|
|
});
|
|
|
|
test("svgl queries include the alias forms the raw entity can't match", () => {
|
|
assert.ok(svglQueriesFor("nextjs").includes("next.js"));
|
|
assert.ok(svglQueriesFor("aws").includes("amazon web services"));
|
|
assert.deepEqual(svglQueriesFor("figma"), ["figma"]);
|
|
});
|
|
|
|
test("simple-icons slugs cover the renamed entries", () => {
|
|
assert.ok(simpleIconSlugsFor("nextjs").includes("nextdotjs"));
|
|
assert.ok(simpleIconSlugsFor("aws").includes("amazonwebservices"));
|
|
assert.deepEqual(simpleIconSlugsFor("nike"), ["nike"]);
|
|
});
|
|
|
|
test("github avatar tier never guesses an org", () => {
|
|
assert.equal(githubOrgFor("slack"), "slackhq");
|
|
assert.equal(githubOrgFor("heygen"), "heygen-com");
|
|
assert.equal(githubOrgFor("some-random-startup"), null);
|
|
});
|
|
|
|
test("favicon domain defaults to <entity>.com with explicit overrides", () => {
|
|
assert.equal(faviconDomainFor("cocacola"), "coca-cola.com");
|
|
assert.equal(faviconDomainFor("stripe"), "stripe.com");
|
|
});
|
|
|
|
// --- async tiers, network mocked -------------------------------------------
|
|
// The 54-brand stress test is a manual snapshot; these pin the same behavior
|
|
// as CI gates: descriptor shape, alias retry, error→null fallthrough, the
|
|
// placeholder filter, and the real cascade order under a mocked network.
|
|
|
|
const json = (data) => new Response(JSON.stringify(data), { status: 200 });
|
|
const status = (code) => new Response(null, { status: code });
|
|
const bin = (n) => new Response(new Uint8Array(n), { status: 200 });
|
|
|
|
test("svglSearch returns the descriptor shape on an exact title hit", async (t) => {
|
|
t.mock.method(globalThis, "fetch", async () =>
|
|
json([{ title: "Figma", route: "https://svgl.app/library/figma.svg" }]),
|
|
);
|
|
const res = await svglSearch("Figma logo", {});
|
|
assert.equal(res.url, "https://svgl.app/library/figma.svg");
|
|
assert.equal(res.ext, ".svg");
|
|
assert.equal(res.metadata.provider, "svgl");
|
|
});
|
|
|
|
test("svglSearch skips a non-array payload and retries with the alias query", async (t) => {
|
|
const seen = [];
|
|
t.mock.method(globalThis, "fetch", async (url) => {
|
|
seen.push(decodeURIComponent(String(url)));
|
|
return seen.length === 1
|
|
? json({ error: "unexpected shape" })
|
|
: json([{ title: "Next.js", route: "https://svgl.app/library/nextjs.svg" }]);
|
|
});
|
|
const res = await svglSearch("nextjs logo", {});
|
|
assert.equal(res.metadata.provenance.query, "next.js", "hit came from the alias query");
|
|
assert.ok(seen.length >= 2, "raw query then alias");
|
|
});
|
|
|
|
test("svglSearch returns null when the network is down — the cascade falls through", async (t) => {
|
|
t.mock.method(globalThis, "fetch", async () => {
|
|
throw new Error("network down");
|
|
});
|
|
assert.equal(await svglSearch("figma logo", {}), null);
|
|
});
|
|
|
|
test("simpleIconsSearch falls to the next slug on a 404", async (t) => {
|
|
const seen = [];
|
|
t.mock.method(globalThis, "fetch", async (url) => {
|
|
seen.push(String(url));
|
|
return String(url).includes("amazonwebservices") ? status(200) : status(404);
|
|
});
|
|
const res = await simpleIconsSearch("aws logo", {});
|
|
assert.ok(res.url.endsWith("amazonwebservices.svg"));
|
|
assert.equal(seen.length, 2, "plain slug 404s first, alias slug hits");
|
|
});
|
|
|
|
test("faviconSearch rejects DDG's sub-500B placeholder with null", async (t) => {
|
|
t.mock.method(globalThis, "fetch", async () => bin(120));
|
|
assert.equal(await faviconSearch("someco logo", {}), null);
|
|
});
|
|
|
|
test("faviconSearch hands verified bytes over as a local file — one fetch, no re-download", async (t) => {
|
|
const fetchMock = t.mock.method(globalThis, "fetch", async () => bin(600));
|
|
const res = await faviconSearch("someco logo", {});
|
|
assert.ok(res.localPath, "returns a localPath, not a url");
|
|
assert.equal(readFileSync(res.localPath).byteLength, 600, "frozen bytes are the verified bytes");
|
|
assert.equal(fetchMock.mock.callCount(), 1, "single network round-trip");
|
|
assert.equal(res.metadata.provenance.low_res, true);
|
|
});
|
|
|
|
test("githubAvatarSearch never touches the network for an unmapped entity", async (t) => {
|
|
const fetchMock = t.mock.method(globalThis, "fetch", async () => status(200));
|
|
assert.equal(await githubAvatarSearch("some-random-startup logo", {}), null);
|
|
assert.equal(fetchMock.mock.callCount(), 0);
|
|
});
|
|
|
|
test("the real logo cascade falls through tier by tier to the first hit", async (t) => {
|
|
t.mock.method(globalThis, "fetch", async (url) => {
|
|
const u = String(url);
|
|
if (u.includes("api.svgl.app")) return json([]); // tier 1: no hit
|
|
if (u.includes("jsdelivr")) return status(404); // tier 2: no such slug
|
|
// tier 3 (github) is never called: entity is unmapped
|
|
if (u.includes("duckduckgo")) return bin(600); // tier 4: real favicon
|
|
throw new Error(`unexpected fetch: ${u}`);
|
|
});
|
|
const res = await runProviders(getProviders("logo"), "search", "zzzbrand logo", {
|
|
entity: "zzzbrand",
|
|
});
|
|
assert.ok(res, "cascade must land on the favicon tier");
|
|
assert.equal(res.metadata.provider, "favicon.ddg");
|
|
});
|