Repository navigation
Snapshot how docset.yml and toc.yml resolve - #4883
Conversation
| var pattern = new Regex($"(?<![\\w.\\-])(?:{alternatives})(?![\\w\\-])", RegexOptions.IgnoreCase, RegexTimeouts.MatchTimeout); | ||
| PrivateRepositoryNames.Value = text => pattern.Replace(text, m => placeholders[m.Value]); |
There was a problem hiding this comment.
Severity: P3 (Low)
AddPrivateRepositories replaces the scrubber that a previous call in the same test installed, so names from that earlier call stop being scrubbed. The scrubber runs when the snapshot is matched, at the end of the test. If a test loads two configurations with different private sets (GoldenConfig.Outcome/LoadAssembler call RegisterPrivateRepositories on every load), only the last set is scrubbed, and the first set's real names can land in a committed snapshot. Numbering is also recomputed from the last set alone. The doc comment promises that a snapshot never records one of these names, which only holds if each test makes a single call. Merging new names into the names already registered for the test would keep that promise.
Generated by Libra. Specialist: libra-complexity. React with 👍 or 👎 to give feedback on this comment.
| new DocFile("posts/one.md", "---\nlisting_group: news\n---\n# One\n"), | ||
| new DocFile("posts/two.md", "---\nlisting_group: how-to\n---\n# Two\n"), | ||
| new DocFile("posts/three.md", "# Three\n"), | ||
| new DocFile("posts/archive/deep.md", "---\nlisting_group: news\n---\n# Deep\n"), |
There was a problem hiding this comment.
Severity: P3 (Low)
The listing fixtures use listing_group, but ListingFrontMatterReader only recognizes listing: news or listing: { group: news }. These pages therefore all resolve as ungrouped, and the golden snapshot never exercises group creation or the explicit groups ordering. Use the supported frontmatter syntax so this construct test actually pins grouped-listing behavior.
Generated by Libra. React with 👍 or 👎 to give feedback on this comment.
| [Test] | ||
| public void LinkOrderIsKept_Loaded_Outcome() => | ||
| Load("links:\n z:\n title: Z\n url: https://example.com/z\n a:\n title: A\n url: https://example.com/a\n") | ||
| .Should() | ||
| .MatchInlineSnapshot( | ||
| """ | ||
| model <RelatedLearningConfiguration>: | ||
| Links: | ||
| a <RelatedLearningLink>: | ||
| Id: "a" | ||
| Title: "A" | ||
| Url: "https://example.com/a" | ||
| z <RelatedLearningLink>: | ||
| Id: "z" | ||
| Title: "Z" | ||
| Url: "https://example.com/z" | ||
| """ | ||
| ); |
There was a problem hiding this comment.
Severity: P3 (Low)
LinkOrderIsKept_Loaded_Outcome can't detect a change in link order. RelatedLearningConfiguration.Links is a FrozenDictionary, and ModelDump sorts hashed collections by key before writing them. That is why the snapshot lists a before z, even though the YAML declares z first. The test passes whatever order the loader keeps, and its name says the opposite of what the snapshot records. Either rename it to describe what it actually checks (for example, that links are keyed by id), or assert on Links.Keys in declaration order if declaration order is meant to be part of the contract.
Generated by Libra. Specialist: libra-complexity. 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/4883/ Sample changed pages: |
Every table of contents construct, the docset options and this repository's own docs/ docset now resolve into verified snapshots, and a table of malformed inputs records the diagnostics or exception each produces today, including results that look like bugs. This stacks on the global config snapshots and locks behaviour ahead of the domain-model refactor in #4530. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
The scoped file system did not recognise a bare /docs root on Windows, so every docset test threw there. The root now comes from the current drive, and argument exception messages, which the runtime words differently per operating system, are left out of the snapshots. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
0ec0789 to
0b7ed94
Compare
| } | ||
|
|
||
| _ = sb.Append(ModelDump.ToText(config, Summarize, "Substitutions")); | ||
| _ = sb.AppendLine("substitutions:"); |
There was a problem hiding this comment.
Severity: P3 (Low)
The full ConfigurationFile dump includes every FeatureFlags property. FeatureFlags.IsEnabled checks FEATURE_* process environment variables before it looks at the docset value, so these goldens depend on the environment. If a developer or CI job exports a variable such as FEATURE_PRIMARY_NAV or FEATURE_DIAGNOSTICS_PANEL, DocsetSettings, ApiConfigurations, Branding, Redirects and BaselineDocs_Configured fail even though the loader has not changed. That undercuts their purpose as a refactor safety net. Either clear or pin FEATURE_* for these tests, or summarise FeatureFlags from the docset input rather than the resolved getters.
Generated by Libra. Specialist: libra-complexity. React with 👍 or 👎 to give feedback on this comment.
Adds golden snapshots of how
docset.yml,toc.ymland_redirects.ymlresolve today, so the domain-model refactor in #4530 can prove it changes no behaviour.Affects: Configuration, Authoring
Stack: 2 of 2, on top of #4879. The branch reuses its dump helper and scrubber, so the diff against
mainincludes that PR's commit until it merges. Review the last commit only.Prompt summary: Lock in the current behaviour of docset and table of contents loading with snapshot tests ahead of a large domain-model refactor. Record what the loaders do today, including odd results, and change no product code.
Why
#4530 must not change how a docset resolves, but only a few hand-picked cases pin that today. A changed path rule, a dropped option or a different diagnostic would pass the current tests.
What
Every construct, resolved
Each table of contents construct resolves in a mock file system and is written as the resolved tree plus the full model: files, folders, nested
toc.yml, islands, cross links,cli,detection_rules, listings, sorting and excludes. The docset options go throughConfigurationFileagainst the frozen global config:subs,cta,features,registry,products,api,release_notes,branding,storybookand redirects.This repository's own docs
A frozen copy of the
docs/docset, itstoc.ymlfiles and an empty page for each other file, so later edits todocs/do not churn the snapshots. The copy holds no private repository names.Tables of malformed input
About 80 cases record the diagnostics and the surviving tree, or the exception. Missing files,
..paths, duplicate files and unknown keys are covered. So are toc cycles, hidden cross links and bad redirects. Several results look like bugs and are recorded unchanged.Out of scope
A root
toc.ymlthat includes itself (toc: .) overflows the stack and ends the test process, so that case has a comment instead of a test.Verify
I broke the resolvers on purpose and confirmed each new test class fails.