Files
radicle-explorer/http-client/tests/release.test.ts
T
Daniel NormanandRūdolfs Ošiņš b1acb3eb4d Integrate radicle-artifact into explorer
- Add release read API to httpd as cargo feature enabled by default
- Add Releases and Release views to the UI
- Filter out redacted artifacts and mark delegate authors
- Degrade releases UI gracefully with older radicle-httpd versions
- Hide fully redacted releases
- Skip releases in the list endpoint when every artifact was redacted by
  its author or a delegate, so no empty release entries are shown
- Keep them reachable with showRedacted=true and by release id
- Add e2e tests for the release routes

Co-Authored-By: Rūdolfs Ošiņš <rudolfs@osins.org>
2026-08-28 16:33:14 +02:00

64 lines
2.1 KiB
TypeScript

import * as Fs from "node:fs/promises";
import * as Path from "node:path";
import { describe, expect } from "vitest";
import { testFixture } from "@http-client/tests/support/fixtures.js";
import { createRepo } from "@tests/support/repo.js";
import { useLocalHttpd } from "@tests/support/support.js";
describe("release", () => {
// The release read API only exists in the local httpd build, so skip these
// against the stable pre-built binary the default suite runs. Releases are
// seeded on an isolated peer to avoid perturbing the shared fixtures.
testFixture.skipIf(!useLocalHttpd)(
"#getAllReleases(rid) + #getReleaseById(rid, id)",
async ({ httpd: { api, peer } }) => {
const { rid, repoFolder } = await createRepo(peer, {
name: "releases",
defaultBranch: "main",
});
const { stdout: head } = await peer.git(["rev-parse", "HEAD"], {
cwd: repoFolder,
});
// Register an artifact from a local file so the CID is computed for us.
const artifactPath = Path.join(repoFolder, "artifact.bin");
await Fs.writeFile(artifactPath, "hello release\n");
const { stdout: receipt } = await peer.spawn(
"rad-artifact",
["--no-announce", "--no-input", "create", head, "--json"],
{ cwd: repoFolder },
);
const { releaseId } = JSON.parse(receipt);
await peer.spawn(
"rad-artifact",
[
"--no-announce",
"--no-input",
"register",
artifactPath,
"--release",
releaseId,
"--name",
"binary",
],
{ cwd: repoFolder },
);
// The sole delegate created the release, so it shows under the default
// delegate-scoped view.
const releases = await api.repo.getAllReleases(rid);
expect(releases.length).toBe(1);
expect(releases[0].id).toBe(releaseId);
expect(releases[0].oid).toBe(head);
expect(releases[0].artifacts[0].name).toBe("binary");
const release = await api.repo.getReleaseById(rid, releaseId);
expect(release.id).toBe(releaseId);
expect(release.artifacts.length).toBe(1);
},
);
});