Files
petvity/lib/development/records.test.ts
T
CatoandClaude cf6912e957 feat(records): public roadmap and changelog, from the repo through the fleet map (#103)
The fleet's building-in-public contract puts each product's record in its
own repository as two markdown files and renders it through Loki's fleet map
via bip-kit. Petvity had neither the files nor the pages.

- ROADMAP.md: Now / Next / Later / Shipped, derived from the phases in
  AGENTS.md and the merged history. Planned work is written as plans.
- CHANGELOG.md: Keep-a-Changelog dialect, user-facing, newest first, from
  merged PRs; today's homepage rewrite is the top entry.
- /[locale]/roadmap and /[locale]/changelog render bip-kit's DevelopmentPage
  inside the marketing nav/footer; the records are English by contract, the
  chrome and metadata stay localized (keys in all 9 locales, footer links).
- lib/config/development.ts is the SSOT for the map URL, slug and profile;
  lib/development/records.ts fetches with revalidate 300 and an 8s ceiling.
- The --bp-* theme scope already mapped for the blog (.pv-longform) covers
  the records; the page title and record name take the editorial faces.
- Vitest covers the data path with a fleet-map fixture, no network.
- Sitemap lists both pages.

Verified at 390px in de/en/ar: no horizontal overflow.


Claude-Session: https://claude.ai/code/session_01NJJp6XiUkeEVzjDaBmWjL3

Co-authored-by: Claude <noreply@anthropic.com>
2026-09-28 04:09:11 -07:00

134 lines
4.7 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* The data path from the fleet map to what the page renders, with no network:
* the same projection the page uses (`developmentProfileFromMap`) is run on a
* fixture shaped like `https://loki.orangecat.ch/api/fleet/map`, so a change
* in what the map emits — or in what bip-kit accepts — fails here first.
*/
import { describe, it, expect, vi } from "vitest";
import { developmentProfileFromMap, loadDevelopmentProfile } from "bip-kit";
import { DEVELOPMENT } from "@/lib/config/development";
const FIXTURE = {
generatedAt: "2026-09-28T10:00:00Z",
projects: [
{
slug: "loki",
name: "Loki",
what: "Fleet command",
roadmap: [],
changelog: [],
},
{
slug: "petvity",
name: "Petvity",
what: "Pet wellness in one place.",
secret: "must not leak",
roadmap: [
{
title: "Building in public",
status: "in progress",
progress: 67,
targetDate: null,
milestones: [
{ title: "ROADMAP.md and CHANGELOG.md at the repository root", done: true },
{ title: "/roadmap and /changelog pages read the fleet map", done: true },
{ title: "The fleet map ingests these files", done: false },
],
source: "https://github.com/bitbaum/petvity/blob/main/ROADMAP.md",
},
{
title: "Health tracking",
status: "done",
progress: 140,
targetDate: "2026-Q3",
milestones: ["Seven daily metrics"],
},
],
changelog: [
{
date: "2026-09-28",
done: "The homepage is short and mobile-first: one headline, one call to action, three benefits.",
},
],
},
],
};
describe("developmentProfileFromMap on a fleet-map fixture", () => {
const profile = developmentProfileFromMap(FIXTURE, DEVELOPMENT.slug);
it("selects this product and projects only the public fields", () => {
expect(profile).not.toBeNull();
expect(profile?.slug).toBe("petvity");
expect(profile?.name).toBe("Petvity");
expect(profile?.what).toBe("Pet wellness in one place.");
expect(profile).not.toHaveProperty("secret");
});
it("keeps milestones, status, target and source of every roadmap item", () => {
expect(profile?.roadmap).toHaveLength(2);
const [now, shipped] = profile!.roadmap;
expect(now.status).toBe("in progress");
expect(now.progress).toBe(67);
expect(now.milestones).toEqual([
{ title: "ROADMAP.md and CHANGELOG.md at the repository root", done: true },
{ title: "/roadmap and /changelog pages read the fleet map", done: true },
{ title: "The fleet map ingests these files", done: false },
]);
expect(now.source).toBe("https://github.com/bitbaum/petvity/blob/main/ROADMAP.md");
expect(shipped.targetDate).toBe("2026-Q3");
expect(shipped.milestones).toEqual(["Seven daily metrics"]);
});
it("clamps progress into 0–100", () => {
expect(profile?.roadmap[1].progress).toBe(100);
});
it("carries changelog entries as date + done text", () => {
expect(profile?.changelog).toEqual([
{
date: "2026-09-28",
done: "The homepage is short and mobile-first: one headline, one call to action, three benefits.",
},
]);
});
it("is null for a slug the map does not carry", () => {
expect(developmentProfileFromMap(FIXTURE, "not-a-product")).toBeNull();
});
it("is null for a map that is not a map", () => {
expect(developmentProfileFromMap({ projects: "nope" }, DEVELOPMENT.slug)).toBeNull();
expect(developmentProfileFromMap(null, DEVELOPMENT.slug)).toBeNull();
});
});
describe("loadDevelopmentProfile through an injected fetcher", () => {
it("passes the map URL to the fetcher and projects its JSON", async () => {
const fetcher = vi.fn<typeof fetch>(
async () => new Response(JSON.stringify(FIXTURE), { status: 200 }),
);
const profile = await loadDevelopmentProfile(DEVELOPMENT.mapUrl, DEVELOPMENT.slug, fetcher);
expect(fetcher).toHaveBeenCalledTimes(1);
expect(fetcher).toHaveBeenCalledWith(DEVELOPMENT.mapUrl, expect.anything());
expect(profile?.name).toBe("Petvity");
});
it("is null, not a throw, when the producer is down", async () => {
const down = vi.fn(async () => new Response("", { status: 503 }));
await expect(
loadDevelopmentProfile(DEVELOPMENT.mapUrl, DEVELOPMENT.slug, down as unknown as typeof fetch),
).resolves.toBeNull();
const throws = vi.fn(async () => {
throw new Error("ECONNREFUSED");
});
await expect(
loadDevelopmentProfile(
DEVELOPMENT.mapUrl,
DEVELOPMENT.slug,
throws as unknown as typeof fetch,
),
).resolves.toBeNull();
});
});