Repository navigation
Snapshot-test in-memory assembler and codex builds ahead of the refactor - #4884
Conversation
Builds an assembled site of four fake repositories in memory through the real assembler steps and snapshots the output tree, links.json, sitemap, redirects, llms.txt, navigation and the content section of five pages. A codex fixture does the same for navigation and the generated landing pages. Two small seams let the assembler read a non-physical file system and skip the link index. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
| internal static async Task<AssembleSources> AssembleOfflineAsync( | ||
| ILoggerFactory logFactory, | ||
| AssembleContext context, | ||
| Checkout[] checkouts, | ||
| IConfigurationContext configurationContext, | ||
| IReadOnlySet<Exporter> availableExporters, | ||
| FetchedCrossLinks crossLinks, | ||
| Cancel ctx | ||
| ) | ||
| { | ||
| var navigationTocMappings = GetTocMappings(context); | ||
| var uriResolver = new PublishEnvironmentUriResolver(navigationTocMappings, context.Environment); | ||
| var sources = new AssembleSources( | ||
| logFactory, | ||
| context, | ||
| checkouts, | ||
| configurationContext, | ||
| navigationTocMappings, | ||
| configurationContext.LegacyUrlMappings, | ||
| uriResolver, | ||
| new CrossLinkResolver(crossLinks, uriResolver), | ||
| new ReleaseNotesResolver(), | ||
| availableExporters | ||
| ); | ||
| foreach (var (_, set) in sources.AssembleSets) | ||
| await set.DocumentationSet.ResolveDirectoryTree(ctx); | ||
| return sources; | ||
| } |
There was a problem hiding this comment.
Severity: P3 (Low)
AssembleOfflineAsync copies the wiring from AssembleAsync (GetTocMappings, the PublishEnvironmentUriResolver, the constructor arguments, the ResolveDirectoryTree loop) instead of sharing it. The new snapshot tests only call the copy. If #4530 changes how AssembleAsync builds the sources (for example the resolver, legacy URL mappings or tree resolution), these tests won't notice, which defeats their stated purpose. Move the shared construction and resolve steps into one private helper that both methods call, so the only difference is where the cross links and release notes come from.
Generated by Libra. Specialist: libra-complexity. React with 👍 or 👎 to give feedback on this comment.
| DocumentationFileSystem.Resolve(Paths.WorkingDirectoryRoot.FullName), | ||
| CreateConfigurationContext() | ||
| ) | ||
| { UrlPathPrefix = "/docs" }; |
There was a problem hiding this comment.
Severity: P3 (Low)
Set BuildType = BuildType.Codex on this context. BuildContext defaults to Isolated, whereas production passes a Codex context to the generator, so these snapshots exercise different rendering branches. For example, the landing-page snapshot records /docs/_static/logo-elastic-horizontal-color.svg, while the current Codex-specific static-prefix logic produces /_static/logo-elastic-horizontal-color.svg. The fixture should record actual Codex output rather than isolated-mode output.
Generated by Libra. React with 👍 or 👎 to give feedback on this comment.
Docs preview (local build)Handbook preview: https://docs-v3-preview.elastic.dev/elastic/docs-builder/pull/4884/ |
Adds snapshot tests that build an assembled site and a codex in memory and record what they output today, so #4530 can prove it changes none of it.
Affects: Assembler builds, Codex builds
Prompt summary: Lock in the current output of in-memory assembler and codex builds with snapshot tests before the large domain model refactor in #4530 lands. The tests record behaviour, including nondeterminism, and scrub it in the snapshot, not in product code.
Why
Nothing builds a whole assembled site in a unit test, so a refactor of the domain model can change navigation, cross-link URLs, redirects, sitemap or llms.txt without a test noticing. The codex landing and group pages have no output snapshot either.
What
Assembled site fixture
Four fake repositories (a narrative repository and three references) go through the real
AssembleSources,SiteNavigation,AssemblerBuilder, sitemap and llms.txt steps. They carry cross links in both directions, redirects,applies_to, a hidden page, a nested toc and a repository mounted at a path prefix. The cross links the link index would serve are generated from the fake content, so no network is used.Snapshots of the assembled output
The output tree,
links.json,sitemap.xmlwith the build time scrubbed,redirects.json, the appendedllms.txtsections, the navigation tree and the Markdown export, plus the content section of five rendered pages.Codex fixture
Five documentation sets in two groups and one ungrouped repository. Snapshots cover the navigation with and without a site prefix, the group listings, the generated output tree, and the landing grid and group page.
Two product seams
AssembleSources.AssembleOfflineAsyncbuilds the sources from known cross links without a link index or release-notes fetch;AssembleAsyncis untouched.CheckoutsFileSystem.InnerFileSystemexposes the wrapped file system andAssemblerDocumentationSetpasses it to the documentation scope. Without it the assembler always reads the physical disk. Production passes the same physical file system as before.Out of scope: the assembler's API and CLI tocs need an OpenAPI spec fetch, and
AssemblerBuildService.BuildAllitself clones with git and reads the link registry from disk, so the test runs its later steps directly. The assembler never writes a documentation state, so none is snapshotted. Per-docset codex pages needCodexBuildServicecheckouts. Recorded oddities are not fixed: every repository writes the samedocs/links.json, so the last one wins.Verify
Mutation checked: hiding the hidden-page filter in the sitemap, changing the redirect output, the codex output path and the path prefix in cross-link resolution each fails the matching tests. Independent of #4880, which has a separate set of helpers.