testRegistryCreditsContributors
Contributors on the registry: alice lists her codebase and adds maya to its server; maya signs in, contributes, and alice merges it. The registry reads the credit from the codebase's history as it mirrors it: the codebase's page lists maya among its contributors, and maya's page lists alice's codebase under Contributed to.
import { fakeNetworkEnv, networkedCodebase, startServer } from "#codebase/tcmts/cli/test/e2e/contributions"; import { startFakeAtproto } from "#codebase/tcmts/cli/test/e2e/examples"; import { tempDir, withChildren } from "#codebase/tcmts/cli/test/e2e/harness"; import { registryOn } from "#codebase/tcmts/cli/test/e2e/registry"; import { onFakeNetwork } from "#codebase/tcmts/cli/test/e2e/releases"; import assert from "node:assert/strict"; export const testRegistryCreditsContributors = () => withChildren(async (keep) => { const alice = { did: "did:plc:aliceaaaaaaaaaaaaaaaaaaa", handle: "alice.test", password: "a-pass", }; const maya = { did: "did:plc:mayaaaaaaaaaaaaaaaaaaaaa", handle: "maya.test", password: "m-pass", }; const net = await startFakeAtproto(keep, [alice, maya]); const network = onFakeNetwork(keep, net); const root = tempDir("registry credits"); const notes = await networkedCodebase(network, root, "notes"); notes.write(`// tcm: namespace notes\nexport const title = "Notes";\n`); await notes.tcm("add"); const url = await startServer(keep, notes.dir, "tok", ["--public"], fakeNetworkEnv(net)); await notes.tcm( "announce", url, "--name", "notes", "--description", "Notes.", "--as", "alice.test", ); await notes.tcm("remote", "add", "origin", url, "--token", "tok"); await notes.tcm("user", "add", "maya.test"); const mine = await networkedCodebase(network, root, "maya"); await mine.tcm("remote", "add", "origin", url, "--as", "maya.test"); await mine.tcm("pull"); await mine.tcm("branch", "heading"); await mine.tcm("switch", "heading"); mine.write(`// tcm: namespace notes\nexport const heading = "All notes";\n`); await mine.tcm("add"); await mine.tcm("contribute", "--title", "A heading"); assert.match(await notes.tcm("contribution", "merge", "1"), /merged #1 on origin/); const { until, page } = await registryOn(keep, net); await until("maya to be credited on the codebase's page", async () => /Contributors/.test(await page("/codebases/@alice.test/notes")), ); const listed = await page("/codebases/@alice.test/notes"); assert.match(listed, /href="\/@maya\.test"[^>]*>@maya\.test<\/a>/); assert.match(listed.replace(/<!--.*?-->/g, ""), /1 contribution</); const hers = await page("/@maya.test?tab=contributed"); assert.match(hers, /Contributed to<span class="count">1<\/span>/); assert.match(hers, /@alice\.test\/notes<\/a>/); assert.match(hers.replace(/<!--.*?-->/g, ""), /1 contribution merged, the last/); assert.match(await page("/@alice.test?tab=contributed"), /No contributions merged yet\./); })
uses
- tcmts.cli.test.e2e.contributions.fakeNetworkEnv
- tcmts.cli.test.e2e.contributions.networkedCodebase
- tcmts.cli.test.e2e.contributions.startServer
- tcmts.cli.test.e2e.examples.startFakeAtproto
- tcmts.cli.test.e2e.harness.tempDir
- tcmts.cli.test.e2e.harness.withChildren
- tcmts.cli.test.e2e.registry.registryOn
- tcmts.cli.test.e2e.releases.onFakeNetwork