Files
clawhub/server/og/fetchPluginOgMeta.test.ts
T
Vyctor H. Brzezowski 6f537bf7ad fix(og): org profile images and Downloads metric in OG cards (#2840)
* fix(og): render org profile images in publisher OG cards

Pass publisher avatar, kind, and installs into OG meta URLs and allow
safely fetching public HTTPS org logos when generating profile images.

* fix: render org profile images in publisher OG cards

Org logos use public HTTPS URLs outside the GitHub/gravatar allowlist, so OG
generation fell back to the default mark. Allow SSRF-safe public fetches for
publisher profile avatars and embed avatar/kind metadata in OG URLs.

* fix(og): show Downloads instead of Installs on OG cards

Switch skill, plugin, and publisher OG image generators to read and
label download counts, with legacy installs query param fallback.

* fix(og): type skill API payload for canonical stat reads

Export SkillStatReadable so fetchSkillOgMeta can pass API skill stats
through readCanonicalStat without a TypeScript error.

* fix(og): format compact downloads in OG cards

Query-param download counts were rendered as raw integers on publisher
OG images. Reuse formatCompactStat, add download icon + lowercase label,
bump layout versions, and refresh org profile visual proof.

* fix(og): use Downloads label without icon on OG cards

Remove the download SVG from OG stat blocks and show only a muted
"Downloads" label above compact values. Bump skill/plugin/publisher
layout versions to bust cached social previews.
2026-06-24 14:08:49 -07:00

37 lines
1.1 KiB
TypeScript

/* @vitest-environment node */
import { afterEach, describe, expect, it, vi } from "vitest";
import { fetchPluginOgMeta } from "./fetchPluginOgMeta";
describe("fetchPluginOgMeta", () => {
afterEach(() => {
vi.unstubAllGlobals();
});
it("reads downloads from package API stats", async () => {
const fetchMock = vi.fn(async () => ({
ok: true,
json: async () => ({
package: {
name: "@openclaw/codex",
displayName: "Codex",
summary: "OpenClaw Codex harness.",
latestVersion: "1.0.0",
stats: { downloads: 99, installs: 1200 },
verification: { scanStatus: "clean" },
},
owner: { handle: "openclaw", image: null },
}),
}));
vi.stubGlobal("fetch", fetchMock);
const meta = await fetchPluginOgMeta("@openclaw/codex", "https://clawhub.ai");
expect(fetchMock).toHaveBeenCalledWith(
"https://clawhub.ai/api/v1/packages/%40openclaw%2Fcodex",
{ headers: { Accept: "application/json" } },
);
expect(meta?.stats.downloads).toBe(99);
});
});