mirror of
https://github.com/przeprogramowani/10x-cli.git
synced 2026-09-19 03:30:01 +08:00
b0c789af70
* docs(10xdevs4-cli-access): record membership gates and bootstrap context (p1) Add canonical access plan, accepted decisions and supporting context. Record phase 1 verification, Toolkit revision and remaining evidence gaps. * docs(10xdevs4-cli-access): record course access gates and scoped review (p2) Update canonical Progress, change status, evidence and implementation review. Record Toolkit revisions, inherited typecheck limitation and phase 3 prerequisites. * docs(10xdevs4-cli-access): persist reviewed revisions and phase 3 boundary Record final reviewed Toolkit and CLI context revisions. Persist Progress attribution and unresolved W04/W05/W08 prerequisites. Keep phases 3–6, phase 7 and Manual criteria open. * docs(10xdevs4-cli-access): record squash-safe source prerequisite Record PR #30, verified gates, permanent-pin lessons and the remaining merge dependency. Keep phase 3 and all manual rollout criteria pending. * docs(10xdevs4-cli-access): record source prerequisite review Record independent review of PR #30 and verified CI evidence. Keep the master pin and delivery phase completion pending. * docs(10xdevs4-cli-access): distinguish candidate checks from final master pins Record passing pre-merge v4 checks and defer workflow suspension. Keep the final v3 maintenance pin dependent on the resulting master SHA. * feat: prepare v4 course delivery and protected project sync Capture the reviewed implementation and manual rehearsal for draft PR review. Master source prerequisites, full clean verification and coordinated Windows CI remain open; production rollout is separate. * fix: keep paid CI evidence private and converge cumulative sync * docs: record merged source prerequisite and passing clean gate * fix: preserve generated API type line endings on Windows --------- Co-authored-by: Claude <noreply@anthropic.com>
86 lines
3.0 KiB
TypeScript
86 lines
3.0 KiB
TypeScript
import { describe, test, expect, beforeEach, afterEach } from "bun:test";
|
|
import {
|
|
fetchCatalog,
|
|
fetchModules,
|
|
fetchModuleDetail,
|
|
fetchLesson,
|
|
fetchArtifact,
|
|
fetchMigrationMap,
|
|
type ReleaseSelection,
|
|
} from "../src/lib/api-content";
|
|
const selected: ReleaseSelection = {
|
|
course: "10xdevs4",
|
|
releaseId: `r-${"a".repeat(64)}`,
|
|
releaseManifestHash: "b".repeat(64),
|
|
};
|
|
const actualFetch = globalThis.fetch;
|
|
const oldApi = process.env["API_BASE_URL"];
|
|
function mockFetch(
|
|
handler: (...args: Parameters<typeof fetch>) => ReturnType<typeof fetch>,
|
|
): typeof fetch {
|
|
return Object.assign(handler, { preconnect: actualFetch.preconnect });
|
|
}
|
|
beforeEach(() => {
|
|
process.env["API_BASE_URL"] = "http://localhost:8787";
|
|
});
|
|
afterEach(() => {
|
|
globalThis.fetch = actualFetch;
|
|
if (oldApi === undefined) delete process.env["API_BASE_URL"];
|
|
else process.env["API_BASE_URL"] = oldApi;
|
|
});
|
|
const calls: Array<[string, () => Promise<unknown>]> = [
|
|
["catalog", () => fetchCatalog("10xdevs4", "token", { release: selected })],
|
|
["modules", () => fetchModules("10xdevs4", "token", { release: selected })],
|
|
["module-detail", () => fetchModuleDetail("10xdevs4", 1, "token", { release: selected })],
|
|
["lesson", () => fetchLesson("10xdevs4", "m1l1", "token", { release: selected })],
|
|
[
|
|
"artifact",
|
|
() =>
|
|
fetchArtifact("10xdevs4", "m1l1", "prompts", "hello", "claude-code", "token", {
|
|
release: selected,
|
|
}),
|
|
],
|
|
["migration-map", () => fetchMigrationMap("10xdevs4", "token", selected)],
|
|
];
|
|
describe("selected release response verification", () => {
|
|
for (const [name, call] of calls)
|
|
for (const field of ["course", "releaseId", "releaseManifestHash"])
|
|
test(`${name} propagates selection and rejects wrong ${field}`, async () => {
|
|
let url = "";
|
|
globalThis.fetch = mockFetch(async (input) => {
|
|
url = String(input);
|
|
return Response.json({
|
|
...selected,
|
|
[field]:
|
|
field === "releaseId"
|
|
? `r-${"c".repeat(64)}`
|
|
: field === "releaseManifestHash"
|
|
? "d".repeat(64)
|
|
: "10xdevs3",
|
|
modules: [],
|
|
lessons: [],
|
|
});
|
|
});
|
|
expect(await call()).toMatchObject({ ok: false, code: "release_mismatch" });
|
|
expect(new URL(url).searchParams.get("release")).toBe(selected.releaseId);
|
|
});
|
|
test("v3 catalog remains compatible without release fields", async () => {
|
|
globalThis.fetch = mockFetch(async () =>
|
|
Response.json({ course: "10xdevs3", modules: [], lessons: [] }),
|
|
);
|
|
expect(await fetchCatalog("10xdevs3", "token")).toMatchObject({
|
|
ok: true,
|
|
data: { course: "10xdevs3" },
|
|
});
|
|
});
|
|
test("v4 cannot silently use a catalog missing release identity", async () => {
|
|
globalThis.fetch = mockFetch(async () =>
|
|
Response.json({ course: "10xdevs4", modules: [], lessons: [] }),
|
|
);
|
|
expect(await fetchCatalog("10xdevs4", "token")).toMatchObject({
|
|
ok: false,
|
|
code: "release_mismatch",
|
|
});
|
|
});
|
|
});
|