tcmts.cli.test.e2e.prod

Server

setUp () => { dir: string; tcm: (...args: string[]) => string; scratch: (text: string) => void; }
A new codebase, with no scratch file: its directory, a way to run tcm in it and to write its scratch file.

Shared

CACHED_CALLS "// tcm: namespace counted\nimport { cache, cacheSignal } from \"react\";\n\nexport const calls = {…
Two server components on a page, each asking a cached function the same thing.
CACHED_SITE "// tcm: namespace shop\nimport { table } from \"#codebase/lib/server\";\nimport { useAppLinks, use…
An app with a server component that renders the same for the same props, and one that reads a table.
PAGES_SITE "// tcm: namespace site\nimport { useAppLinks, useLocation } from \"#codebase/site/lib/react\";\n\n…
A site of a few pages, each a server component's: what testStaticSitesRenderEveryPage builds.
SHELL_SITE "// tcm: namespace news\nimport { Suspense } from \"react\";\nimport { table } from \"#codebase/lib…
A page with a part that renders the same each time, and a slow live part (it reads and writes a table).
UNDER_A_BASE "// tcm: namespace ui\nimport { setCookie } from \"#codebase/lib/server\";\nimport { href, match, u…
An app under a path of a site: links, its server and its cookies are under it, from the server's first paint on.
call (url: string, hash: string, args: unknown[]) => Promise<{ status: number; body: string; }>
get (url: string | URL, init?: RequestInit | undefined) => Promise<Response>
fetch, retried once on a keep-alive connection reset (see web.ts).
loadTab (url: string) => Promise<{ asset: string; assets: string[]; endpoint: string; js: string; }>
What a browser tab loads: the page's scripts (its entry and the chunks it preloads), and the server function hash they call. `asset` is the chunk that calls it: the app's own code.
waitFor (cond: () => boolean | Promise<boolean>, ms?: number) => Promise<void>

Tests

testAppUnderABase () => Promise<void>
tcm start --base, behind tcm serve --proxy: the app is served under a path of the site, its page, assets, server functions and cookies under it, and its links (the react library's href) too, rendered on the server and followed in the browser
testAssetsKeepTheirUrlsAcrossDeploys () => Promise<void>
A build's browser code is a few chunks, named by their content, in a directory builds share: a deploy that changes the app's code leaves tcm's runtime chunk at the same URL (a browser keeps it), and assets are served compressed.
testBuildDuringStart () => Promise<void>
A build of the app `tcm start` serves, while it serves it (two at once, each replacing it), doesn't break serving: it reads the build before or the one after, whole; and pruning leaves the build it serves
testBuildStartDeployRollBack () => Promise<void>
tcm build / start: deploy and roll back by moving a name; open tabs keep working
testBuildsByAnotherTcmAreMadeAgain () => void
A build is of the app and of what tcm puts beside it in the browser, so one another tcm made (an older runtime) is made again, not reused: upgrading tcm reaches apps whose code didn't change
testBuildsOfOneAppAtOnce () => Promise<void>
Builds of one app at once (two verifies, say) all succeed and give the same build: each is made in a directory of its own and put in place whole, and nothing of either is left behind
testBundlesHoldOnlyWhatTheAppReaches () => void
No dead code to eliminate: a production build holds only the definitions the app reaches, never the rest of a namespace it uses (what isn't reached was never in it to shake out)
testDeployedChunksArriveAsDifferences () => Promise<void>
After a deploy, a browser that has the app's previous chunk gets the new one as the difference from it (Compression Dictionary Transport): Chrome asks with the old chunk's hash, and the server sends `dcb`, a few hundred bytes for a chunk of thousands.
testKeptBuildWithoutItsCode () => Promise<void>
a kept build whose code the codebase no longer has (the web UI's, its codebase copied in again when tcm changes): its tabs are told to reload (410), and the server keeps answering
testModuleStatePlacement () => void
module-level state is placed by who uses it, and split state is flagged
testPagesShellsAreKept () => Promise<void>
tcm start renders a page's shell once and sends it at once: what renders the same every time (worked out from the code), with the fallbacks of what's live; then what's live, rendered for each request, streams in after it
testPushDeploys () => Promise<void>
tcm push deploys: a running `tcm start` on the other side builds and switches
testReactCacheLastsARequest () => Promise<void>
React's cache in server components tcm renders: what one keeps is kept for the request, shared by everything it renders, and asked again in the next; cacheSignal is the request's
testRuntimeReloadsRetiredBuild () => Promise<void>
the browser runtime reloads a page whose build was retired
testServerComponentsKeptAndRenderedAhead () => Promise<void>
tcm start: a server component that renders the same for the same props (worked out from its code) is asked for with GET and kept for good, by the server and the browser, and through server function calls; and what a page shows is rendered before the browser goes there, when a link to it is pressed
testStaticSitesAndPwas () => Promise<void>
tcm build --static, and PWAs: an app with a `pwa` beside it gets a manifest, its icons and a service worker, which tcm start serves too; changing the pwa alone is a new build; and an app that calls the server can't be a static site, which has none
testStaticSitesRenderEveryPage () => Promise<void>
tcm build --static renders every page an app links to, from /, as it's built: server components run then, their trees kept as files, so the pages are there before any code runs, and the app goes from one to another in the browser with no server