tcmts.hub.test

Server

codebaseHolding (name: string, code: string, ns: string) => { cb: Codebase; dir: string; namespace: () => Promise<s…
A codebase of its own, in a directory of its own, holding `code` (a scratch file's text); and `ns`'s namespace hash.
readFromTheStart () => Promise<void>
Forget where Jetstream was read to: tables are shared by a test run's tests, and each test has its own network.
served (keep: Keep, cb: Codebase) => Promise<string>
A codebase served (as `tcm serve --public` serves it, in this process) until the test ends: its URL.
withEnv <T>(vars: Record<string, string | undefined>, fn: () => Promise<T>) => Promise<T>
Run `fn` with these environment variables set (or, undefined, unset), and put them back after.

Tests

testCodebaseLibrariesByAuthor () => Promise<void>
A codebase's libraries are its records' outermost entries: an announced one by its author and package.
testComingBackStaysOnTheSite () => void
After signing in, the hub goes back only to a path of its own.
testCopiedCommandsAreWords () => void
A release record whose package or version isn't a name or a version (shell in it, say) isn't a release, and the line a page offers to copy is quoted however odd a handle is.
testHubChecksAttestations () => Promise<void>
The hub takes reviews, advisories and yanks from Jetstream, and shows one only once it checks against its writer's signed repository: a forged one, or one no repository holds, fails; a yank counts only from the release's author, as the releases the hub checked say it (someone announcing her namespace as theirs, which fails, takes nothing over); a deleted one goes. What's shown is what the signed record says: an event that lies about one changes nothing.
testHubClientMetadataFollowsTheAddress () => void
testHubCountsStars () => Promise<void>
Stars count once they check against their writer's repository (one per person per library, at the library's key); a forged one, one at another key or under a made-up DID, or a second row of one, doesn't count, and one taken back goes. A visitor's follows are the AppView's.
testHubMirrorsSignedReleases () => Promise<void>
The hub, against the fake network: Jetstream's events become rows (cursor kept), each release is checked against its author's signed record before its code is mirrored by hash, mounted by DID, with the libraries it holds noted (the libraries its author uses); a forged record, or one no repository holds, fails; a deleted one is withdrawn, its code kept. What an event says changes nothing until the repository says it too: a lying Jetstream can't change a release's notes or sources, nor withdraw it.
testHubSearchRanksByMatch () => Promise<void>
The hub's search scores names as their library shows them (not by where the hub mounts it: every name under `….react.v0_1_0` holds "react"), puts the library with the best match first, leaves tests and their helpers out, and says where each match runs.
testMountsAreNamedByDid () => void
testOwnNamesKeepTheReadme () => void
A mirrored release's own names include the files kept with its code (its README, which its page shows), but not the libraries it holds, nor their record.
testProfilesAreTheirSignedRecords () => Promise<void>
Someone's profile is their signed `app.bsky.actor.profile/self`: its name and bio, and its picture as their PDS serves it; what isn't a string or a CID isn't taken, and no profile is nothing.
testReachesInALine () => void
What a release reaches, in a line: nothing, one definition, a few, many; through a package, said once.
testVisitorCacheIsBounded () => Promise<void>
What's remembered of visitors stays bounded: the least lately used go past the limit.
testYankedVersionsAreNotLatest () => void
A release is yanked only by its own author's yank of its namespace (anyone else's yanks nothing), and a yanked version isn't a library's latest: the newest version left is, mirrored first, and, every one yanked, the newest.