Skip to content

Snapshot-test assembler navigation ahead of the domain model refactor - #4880

Merged
Mpdreamz merged 1 commit into
mainfrom
snap/assembler-navigation
Nov 17, 2026
Merged

Mpdreamz merged 1 commit into
mainfrom
snap/assembler-navigation

Conversation

@Mpdreamz

Copy link
Copy Markdown
Member

Adds snapshot tests that record how the assembler builds its site navigation and resolves mounts today, so #4530 can prove it changes none of it.

Affects: Internals only

Prompt summary: Lock in current assembler navigation behaviour with snapshot tests before the large domain model refactor in #4530 lands. The tests record what the code does now, including cases that look wrong, and fix nothing.

Why

The refactor in #4530 must keep behaviour identical, but nothing pins the assembled navigation, the private-repository filtering, the top nav, the cross-link resolver or the version order. A silent change there would reach the published site.

What

Frozen real-shape config

Baseline/ holds copies of assembler.yml, navigation.yml and navigation_preview.yml with private repositories renamed to private-repo-N, comments removed and volatile values (versions, tag manager ids) replaced. One stub docset per repository is generated from the navigation file. Tests read them through the real ConfigurationFileProvider, including its --skip-private-repositories filtering.

Navigation snapshots

Full tree, diagnostics and top nav of the shipped shape with the navigation preview off and on, with private repositories skipped, and with an API floating section. Small hand-written layouts cover path-prefix mounts, nested tocs, hidden pages, duplicate and missing mounts, islands, site prefixes, sections and every top-nav tab shape.

Resolver and version tables

PublishEnvironmentUriResolver is recorded for the real mappings and for prefixes such as reference/apm and reference/apm-agents. SemVersion is recorded as a full pairwise matrix plus parse and operator tables.

Private-name scrubbing

PrivateRepositoryScrubbing derives the names from the loaded config's private: true flag and replaces them in snapshots. A guard test fails when a frozen copy or verified file names a private repository of the shipped config, without printing the name. A similar scrubber is being added on branch snap/config-global for config goldens; the two can be unified later.

Out of scope: product code is untouched. Recorded oddities are not fixed here: prefix over-matching in the resolver, SemVersion metadata comparison that is not symmetric, a double slash for an environment prefix with a trailing slash, and an empty section whose URL ignores the site prefix.

Verify

dotnet test --project tests/Navigation.Tests
mise run test
mise run lint
mise run snap:orphans

Mutation checked: breaking PromoteSectionListingIslands, the top-nav external flag, resolver prefix matching, SemVersion metadata comparison and the private-navigation re-indent each fails the matching tests.

Adds frozen, scrubbed copies of the shipped assembler and navigation config, stub docsets for every repository, and snapshots of the site navigation with flags on and off, private repositories skipped, top nav, mount resolution and SemVersion order. They record today's behaviour, including cases that look wrong, ahead of the domain model refactor.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@Mpdreamz
Mpdreamz requested a review from a team as a code owner November 16, 2026 21:11
@Mpdreamz Mpdreamz added the chore label Nov 16, 2026
@Mpdreamz
Mpdreamz requested a review from theletterf November 16, 2026 21:11
@Mpdreamz Mpdreamz added the chore label Nov 16, 2026
Comment on lines +84 to +107
public void FrozenBaseline_ContainsNoPrivateRepositoryOfTheShippedConfig()
{
var root = Paths.GetSolutionDirectory() ?? throw new InvalidOperationException("solution root not found");
var shipped = AssemblyConfiguration.Deserialize(File.ReadAllText(Path.Join(root.FullName, "config", "assembler.yml")));
var scrub = PrivateRepositoryScrubbing.For(shipped.AllPrivateRepositoryNames);
shipped.AllPrivateRepositoryNames.Should().NotBeEmpty("the check below would pass vacuously");

var files = Directory
.EnumerateFiles(Path.Join(root.FullName, "tests", "Navigation.Tests", "Assembler", "Baseline"))
.Concat(
Directory.EnumerateFiles(
Path.Join(root.FullName, "tests", "Navigation.Tests", ".snapshots", "Assembler"),
"*",
SearchOption.AllDirectories
)
)
.ToArray();
files.Should().NotBeEmpty();

var leaking = files.Count(f => scrub(File.ReadAllText(f)) != File.ReadAllText(f));

// the names are not part of the message on purpose
leaking.Should().Be(0, "a frozen copy or a verified file names a private repository");
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Severity: P3 (Low)

The leak guard can miss a single-word private repository name. It reuses the snapshot scrubber, which only matches a single-word name right before :// or right after elastic/. The frozen assembler.yml names each repository as a bare key ( name:), so if a re-frozen copy keeps an unrenamed single-word private repo there, the guard still passes. That is most likely for repos marked skip: true, which never show up in navigation as name://. To close the gap, the guard could do a whole-token match for every private name, or parse the frozen assembler.yml and assert that every private: true key starts with private-repo-.

Generated by Libra. Specialist: libra-complexity. React with 👍 or 👎 to give feedback on this comment.

@github-actions

Copy link
Copy Markdown
Contributor

@Mpdreamz
Mpdreamz merged commit 46ccb1b into main Nov 17, 2026
56 checks passed
@Mpdreamz
Mpdreamz deleted the snap/assembler-navigation branch November 17, 2026 09:47
Mpdreamz added a commit to nullean/snapshots that referenced this pull request Nov 17, 2026
## Why
Agents migrating docs-builder tests wanted a check that a snapshot or
fixture contains none of a set of values (private repository names,
secrets) and fails without printing them. They built it by hand
(elastic/docs-builder#4880).

## What
\`SnapshotOptions.Forbid(IEnumerable<string>)\` and
\`SnapshotDefaults.Forbid(IEnumerable<string>)\` (with
\`ClearForbidden\`).

- Checks the scrubbed value and the verified file (a secret already
committed is caught); inline snapshots check the expected literal too.
- The message gives line numbers only, never the values. It fails before
a received file is written, so a forbidden value does not land on disk.
Accepting does not get around it, and \`IgnoreDefaultScrubbers\` does
not skip the default list.
- The values are held internally; no property exposes them.
- Public API snapshot: three additions (minor). Docs, core skill and
DECISIONS.md updated.
- Tests: 8, including a CsCheck property for the line numbers. Mutating
the verified-file check fails 2 of them.

Independent of #110; pairs well with \`Scrubbers.Values\`.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Sonnet 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant