Files
radicle-explorer/explorer/tests/e2e/repo/withoutProject.spec.ts
T
Daniel Norman 0dc1e557a5 Move repo facts outside the project payload
Repos need not carry a `xyz.radicle.project` payload; the default
branch can come from `xyz.radicle.crefs` alone. Such repos got no
counts and no default branch, and failed schema validation in
explorer, which broke the parse of a whole listing.

httpd:
- Add top-level `cobs` with issue, patch and bucketed release counts
- Add top-level `defaultBranch`, qualified like the crefs payload
- Omit a count the node cannot determine instead of reporting zero
- Drop `head`: the tip is `refs[defaultBranch]`
- Keep counts in the project payload for older clients until a
  major release
- Keep the project payload when a COB read fails
- Keep `meta.releases` a single count: delegate + other
- Log and skip canonical ref rules and refs that fail to read,
  so one bad ref doesn't drop the default branch tip

explorer:
- Model `cobs` and `defaultBranch`, adapting older nodes to one shape
- Resolve the default branch from the crefs HEAD on older nodes
- Collect the shims for older httpd in http-client/lib/compat.ts,
  each naming the httpd release that the client can drop it with
- Add `defaultBranchTip`, replacing `head`, with a fallback to the
  legacy `meta.head`
- Make the project payload and its legacy meta optional
- Fall back to the RID for the repo name, and show a placeholder
  for a missing name in repo cards and the header
- Hide a counter instead of reading a missing count as zero
- Fall back to a full-page check for "More" without counts
- Add a `repo.sourceUnavailable` route for repos without a
  default branch or tip
- Browse explicit revisions and offer the branch selector without
  a default branch
- List these repos in repo grids and on the landing page
- Say the node is older or built without releases
- Scope release pages in the client, so views never call the shims
- Read OG worker repos through the same compat shims
- Share the repo name and default branch helpers with the OG worker

CI:
- Add check:open-graph, a wrangler deploy dry run
- Run it in GitHub CI, Buildkite and check:ci
- Install explorer's dependencies first: the worker
  resolves compat.ts imports, such as zod, from there

Tests:
- Test that a build without releases omits the count
- Test that one failing rule keeps the others
- Test the repo shape across httpd versions and the release shims
- Test `hasMorePages` and `repoName`
- Test repos without a project payload end to end
2026-10-29 18:21:09 +01:00

62 lines
2.2 KiB
TypeScript

import { expect, test } from "@tests/support/fixtures.js";
import { createRepo, dropProjectPayload } from "@tests/support/repo.js";
test("list a repo without a name", async ({ page, peer }) => {
const name = "no-project-card";
const { rid, repoFolder } = await createRepo(peer, { name });
await dropProjectPayload(peer, repoFolder);
await page.goto(peer.uiUrl());
const card = page.locator(".repo-card", { hasText: rid.slice(-6) });
await expect(card.getByTitle("This repository has no name")).toBeVisible();
await expect(card.getByText(name)).toBeHidden();
});
test("open a repo at its canonical refs default branch", async ({
page,
peer,
}) => {
const { rid, repoFolder } = await createRepo(peer, {
name: "no-project-source",
});
await dropProjectPayload(peer, repoFolder);
await page.goto(`${peer.uiUrl()}/${rid}`);
await expect(page.getByRole("button", { name: "Commits 1" })).toBeVisible();
await expect(page.getByTitle("This repository has no name")).toBeVisible();
await page.getByRole("link", { name: "Issues" }).click();
await expect(page).toHaveURL(`${peer.uiUrl()}/${rid}/issues`);
});
test("offer branches when the node reports no default branch", async ({
page,
peer,
}) => {
const { rid, repoFolder } = await createRepo(peer, {
name: "no-project-unavailable",
});
await dropProjectPayload(peer, repoFolder);
// Newer nodes report the default branch, and the client resolves it on older
// ones from the canonical refs payload, so leave out both.
await page.route(
({ pathname }) => /^\/api(\/v1)?\/repos\/[^/]+$/.test(pathname),
async route => {
const response = await route.fetch();
const repo = await response.json();
delete repo.defaultBranch;
delete repo.payloads["xyz.radicle.crefs"];
await route.fulfill({ response, json: repo });
},
);
await page.goto(`${peer.uiUrl()}/${rid}`);
await expect(page.getByRole("button", { name: /^Commits/ })).toBeHidden();
await page.getByTitle("Change branch").click();
await page.getByText("main", { exact: true }).click();
await expect(page).toHaveURL(`${peer.uiUrl()}/${rid}/tree/main`);
await expect(page.getByRole("button", { name: "Commits 1" })).toBeVisible();
});