diff --git a/tests/Elastic.Markdown.Tests/.snapshots/Directives/AdmonitionAppliesToTests/RendersHtml.verified.html b/tests/Elastic.Markdown.Tests/.snapshots/Directives/AdmonitionAppliesToTests/RendersHtml.verified.html new file mode 100644 index 0000000000..c6be56cf00 --- /dev/null +++ b/tests/Elastic.Markdown.Tests/.snapshots/Directives/AdmonitionAppliesToTests/RendersHtml.verified.html @@ -0,0 +1,13 @@ +
+
+ Custom Admonition + + + + +
+
+

This is a custom admonition with applies_to information

+
+
+

A regular paragraph.

diff --git a/tests/Elastic.Markdown.Tests/.snapshots/Directives/AgentSkillNoSkillNameTests/RendersHtml.verified.html b/tests/Elastic.Markdown.Tests/.snapshots/Directives/AgentSkillNoSkillNameTests/RendersHtml.verified.html new file mode 100644 index 0000000000..bdb7a52031 --- /dev/null +++ b/tests/Elastic.Markdown.Tests/.snapshots/Directives/AgentSkillNoSkillNameTests/RendersHtml.verified.html @@ -0,0 +1,23 @@ +
+
+ + + + Agent skill available +
+
+
+

A skill is available to help AI agents with this topic.

+

+ Learn more about agent skills for Elastic +

+
+ + Get the skill + + + + +
+
+

A regular paragraph.

diff --git a/tests/Elastic.Markdown.Tests/.snapshots/Directives/AgentSkillTests/RendersHtml.verified.html b/tests/Elastic.Markdown.Tests/.snapshots/Directives/AgentSkillTests/RendersHtml.verified.html new file mode 100644 index 0000000000..ec0c0fe6af --- /dev/null +++ b/tests/Elastic.Markdown.Tests/.snapshots/Directives/AgentSkillTests/RendersHtml.verified.html @@ -0,0 +1,23 @@ +
+
+ + + + Agent skill available +
+
+
+

A skill is available to help AI agents with this topic.

+

+ Learn more about agent skills for Elastic +

+
+ +
+
+

A regular paragraph.

diff --git a/tests/Elastic.Markdown.Tests/.snapshots/Directives/AgentSkillWithBodyTests/RendersHtml.verified.html b/tests/Elastic.Markdown.Tests/.snapshots/Directives/AgentSkillWithBodyTests/RendersHtml.verified.html new file mode 100644 index 0000000000..688457a4e6 --- /dev/null +++ b/tests/Elastic.Markdown.Tests/.snapshots/Directives/AgentSkillWithBodyTests/RendersHtml.verified.html @@ -0,0 +1,24 @@ +
+
+ + + + Agent skill available +
+
+
+

A skill is available to help AI agents with this topic.

+

This skill helps agents write and optimize ES|QL queries.

+

+ Learn more about agent skills for Elastic +

+
+ +
+
+

A regular paragraph.

diff --git a/tests/Elastic.Markdown.Tests/.snapshots/Directives/ApplicabilitySwitchTests/RendersHtml.verified.html b/tests/Elastic.Markdown.Tests/.snapshots/Directives/ApplicabilitySwitchTests/RendersHtml.verified.html new file mode 100644 index 0000000000..425255841a --- /dev/null +++ b/tests/Elastic.Markdown.Tests/.snapshots/Directives/ApplicabilitySwitchTests/RendersHtml.verified.html @@ -0,0 +1,50 @@ +
+ + +
+
+
+ Tip +
+
+

This feature is in preview for Elastic Stack 9.1.

+
+
+
+ + +
+
+
+ Note +
+
+

This feature is available for Elastic Cloud.

+
+
+
+ + +
+
+
+ Warning +
+
+

This feature has been removed from Elastic Cloud Enterprise.

+
+
+
+
diff --git a/tests/Elastic.Markdown.Tests/.snapshots/Directives/ApplicabilitySwitchWithCommentTests/RendersHtml.verified.html b/tests/Elastic.Markdown.Tests/.snapshots/Directives/ApplicabilitySwitchWithCommentTests/RendersHtml.verified.html new file mode 100644 index 0000000000..d5ea0d5208 --- /dev/null +++ b/tests/Elastic.Markdown.Tests/.snapshots/Directives/ApplicabilitySwitchWithCommentTests/RendersHtml.verified.html @@ -0,0 +1,20 @@ +
+ + +
+

Content A

+
+ + +
+

Content B

+
+
diff --git a/tests/Elastic.Markdown.Tests/.snapshots/Directives/BibliographyDirectiveTests/EmitsUnsupportedWarnings.verified.txt b/tests/Elastic.Markdown.Tests/.snapshots/Directives/BibliographyDirectiveTests/EmitsUnsupportedWarnings.verified.txt new file mode 100644 index 0000000000..e3819442b5 --- /dev/null +++ b/tests/Elastic.Markdown.Tests/.snapshots/Directives/BibliographyDirectiveTests/EmitsUnsupportedWarnings.verified.txt @@ -0,0 +1 @@ +warning {repo}/docs/index.md:1 Directive block 'bibliography' is unsupported. See https://github.com/elastic/docs-builder/issues/5 for more information. diff --git a/tests/Elastic.Markdown.Tests/.snapshots/Directives/BlockQuoteDirectiveTests/EmitsUnsupportedWarnings.verified.txt b/tests/Elastic.Markdown.Tests/.snapshots/Directives/BlockQuoteDirectiveTests/EmitsUnsupportedWarnings.verified.txt new file mode 100644 index 0000000000..c49b50927b --- /dev/null +++ b/tests/Elastic.Markdown.Tests/.snapshots/Directives/BlockQuoteDirectiveTests/EmitsUnsupportedWarnings.verified.txt @@ -0,0 +1 @@ +warning {repo}/docs/index.md:1 Directive block 'blockquote' is unsupported. See https://github.com/elastic/docs-builder/issues/6 for more information. diff --git a/tests/Elastic.Markdown.Tests/.snapshots/Directives/ChangelogBasicTests/RendersHtml.verified.html b/tests/Elastic.Markdown.Tests/.snapshots/Directives/ChangelogBasicTests/RendersHtml.verified.html new file mode 100644 index 0000000000..2c4dbafab2 --- /dev/null +++ b/tests/Elastic.Markdown.Tests/.snapshots/Directives/ChangelogBasicTests/RendersHtml.verified.html @@ -0,0 +1,25 @@ +
+

+ 9.3.0 +

+
+
+

+ Features and enhancements +

+
+ +
+

+ Fixes +

+
+ diff --git a/tests/Elastic.Markdown.Tests/.snapshots/Directives/ChangelogCombinedFiltersFilterTocTests/RendersHtml.verified.html b/tests/Elastic.Markdown.Tests/.snapshots/Directives/ChangelogCombinedFiltersFilterTocTests/RendersHtml.verified.html new file mode 100644 index 0000000000..a8b453c084 --- /dev/null +++ b/tests/Elastic.Markdown.Tests/.snapshots/Directives/ChangelogCombinedFiltersFilterTocTests/RendersHtml.verified.html @@ -0,0 +1,25 @@ +
+

+ 9.3.0 +

+
+
+

+ Features and enhancements +

+
+ +
+

+ Documentation +

+
+ diff --git a/tests/Elastic.Markdown.Tests/.snapshots/Directives/ChangelogConfigAndBundlesRelativePathsTests/RendersHtml.verified.html b/tests/Elastic.Markdown.Tests/.snapshots/Directives/ChangelogConfigAndBundlesRelativePathsTests/RendersHtml.verified.html new file mode 100644 index 0000000000..decd978f97 --- /dev/null +++ b/tests/Elastic.Markdown.Tests/.snapshots/Directives/ChangelogConfigAndBundlesRelativePathsTests/RendersHtml.verified.html @@ -0,0 +1,25 @@ +
+

+ 1.0.0 +

+
+
+

+ Features and enhancements +

+
+ +
+

+ Other changes +

+
+ diff --git a/tests/Elastic.Markdown.Tests/.snapshots/Directives/ChangelogConfigLoadAutoDiscoverTests/RendersHtml.verified.html b/tests/Elastic.Markdown.Tests/.snapshots/Directives/ChangelogConfigLoadAutoDiscoverTests/RendersHtml.verified.html new file mode 100644 index 0000000000..48387d6986 --- /dev/null +++ b/tests/Elastic.Markdown.Tests/.snapshots/Directives/ChangelogConfigLoadAutoDiscoverTests/RendersHtml.verified.html @@ -0,0 +1,48 @@ +
+

+ 9.3.0 +

+
+
+

+ Known issues +

+
+ +
+

+ Deprecations +

+
+ +
+

+ Features and enhancements +

+
+ diff --git a/tests/Elastic.Markdown.Tests/.snapshots/Directives/ChangelogConfigLoadExplicitPathTests/RendersHtml.verified.html b/tests/Elastic.Markdown.Tests/.snapshots/Directives/ChangelogConfigLoadExplicitPathTests/RendersHtml.verified.html new file mode 100644 index 0000000000..c0e028afaf --- /dev/null +++ b/tests/Elastic.Markdown.Tests/.snapshots/Directives/ChangelogConfigLoadExplicitPathTests/RendersHtml.verified.html @@ -0,0 +1,25 @@ +
+

+ 9.3.0 +

+
+
+

+ Features and enhancements +

+
+ +
+

+ Documentation +

+
+ diff --git a/tests/Elastic.Markdown.Tests/.snapshots/Directives/ChangelogConfigLoadFromDocsSubfolderTests/RendersHtml.verified.html b/tests/Elastic.Markdown.Tests/.snapshots/Directives/ChangelogConfigLoadFromDocsSubfolderTests/RendersHtml.verified.html new file mode 100644 index 0000000000..c166523232 --- /dev/null +++ b/tests/Elastic.Markdown.Tests/.snapshots/Directives/ChangelogConfigLoadFromDocsSubfolderTests/RendersHtml.verified.html @@ -0,0 +1,25 @@ +
+

+ 9.3.0 +

+
+
+

+ Features and enhancements +

+
+ +
+

+ Other changes +

+
+ diff --git a/tests/Elastic.Markdown.Tests/.snapshots/Directives/ChangelogConfigMixedBlockersTests/RendersHtml.verified.html b/tests/Elastic.Markdown.Tests/.snapshots/Directives/ChangelogConfigMixedBlockersTests/RendersHtml.verified.html new file mode 100644 index 0000000000..74d64b0c4b --- /dev/null +++ b/tests/Elastic.Markdown.Tests/.snapshots/Directives/ChangelogConfigMixedBlockersTests/RendersHtml.verified.html @@ -0,0 +1,46 @@ +
+

+ 9.3.0 +

+
+
+

+ Deprecations +

+
+ +
+

+ Features and enhancements +

+
+ +
+

+ Fixes +

+
+ diff --git a/tests/Elastic.Markdown.Tests/.snapshots/Directives/ChangelogConfigPriorityTests/RendersHtml.verified.html b/tests/Elastic.Markdown.Tests/.snapshots/Directives/ChangelogConfigPriorityTests/RendersHtml.verified.html new file mode 100644 index 0000000000..cc61daced0 --- /dev/null +++ b/tests/Elastic.Markdown.Tests/.snapshots/Directives/ChangelogConfigPriorityTests/RendersHtml.verified.html @@ -0,0 +1,43 @@ +
+

+ 9.3.0 +

+
+
+

+ Deprecations +

+
+ +
+

+ Features and enhancements +

+
+ +
+

+ Other changes +

+
+ diff --git a/tests/Elastic.Markdown.Tests/.snapshots/Directives/ChangelogConfigRelativePathTests/RendersHtml.verified.html b/tests/Elastic.Markdown.Tests/.snapshots/Directives/ChangelogConfigRelativePathTests/RendersHtml.verified.html new file mode 100644 index 0000000000..aa149a419a --- /dev/null +++ b/tests/Elastic.Markdown.Tests/.snapshots/Directives/ChangelogConfigRelativePathTests/RendersHtml.verified.html @@ -0,0 +1,33 @@ +
+

+ 1.0.0 +

+
+
+

+ Deprecations +

+
+ +
+

+ Features and enhancements +

+
+ diff --git a/tests/Elastic.Markdown.Tests/.snapshots/Directives/ChangelogDateVersionedBundlesTests/RendersHtml.verified.html b/tests/Elastic.Markdown.Tests/.snapshots/Directives/ChangelogDateVersionedBundlesTests/RendersHtml.verified.html new file mode 100644 index 0000000000..0541309213 --- /dev/null +++ b/tests/Elastic.Markdown.Tests/.snapshots/Directives/ChangelogDateVersionedBundlesTests/RendersHtml.verified.html @@ -0,0 +1,45 @@ +
+

+ August 15, 2025 +

+
+
+

+ Features and enhancements +

+
+ +
+

+ August 5, 2025 +

+
+
+

+ Features and enhancements +

+
+ +
+

+ August 1, 2025 +

+
+
+

+ Features and enhancements +

+
+ diff --git a/tests/Elastic.Markdown.Tests/.snapshots/Directives/ChangelogDedicatedPageWithSubsectionsTests/RendersHtml.verified.html b/tests/Elastic.Markdown.Tests/.snapshots/Directives/ChangelogDedicatedPageWithSubsectionsTests/RendersHtml.verified.html new file mode 100644 index 0000000000..e9a78c39cc --- /dev/null +++ b/tests/Elastic.Markdown.Tests/.snapshots/Directives/ChangelogDedicatedPageWithSubsectionsTests/RendersHtml.verified.html @@ -0,0 +1,37 @@ +
+

+ 9.3.0 +

+
+

+ Indexing +

+ +

+ Search +

+ diff --git a/tests/Elastic.Markdown.Tests/.snapshots/Directives/ChangelogDropdownsDefaultTests/RendersHtml.verified.html b/tests/Elastic.Markdown.Tests/.snapshots/Directives/ChangelogDropdownsDefaultTests/RendersHtml.verified.html new file mode 100644 index 0000000000..841d1b8b15 --- /dev/null +++ b/tests/Elastic.Markdown.Tests/.snapshots/Directives/ChangelogDropdownsDefaultTests/RendersHtml.verified.html @@ -0,0 +1,29 @@ +
+

+ 9.3.0 +

+
+ diff --git a/tests/Elastic.Markdown.Tests/.snapshots/Directives/ChangelogDropdownsEnabledTests/RendersHtml.verified.html b/tests/Elastic.Markdown.Tests/.snapshots/Directives/ChangelogDropdownsEnabledTests/RendersHtml.verified.html new file mode 100644 index 0000000000..7767361084 --- /dev/null +++ b/tests/Elastic.Markdown.Tests/.snapshots/Directives/ChangelogDropdownsEnabledTests/RendersHtml.verified.html @@ -0,0 +1,28 @@ +
+

+ 9.3.0 +

+
+ diff --git a/tests/Elastic.Markdown.Tests/.snapshots/Directives/ChangelogDropdownsEnabledWithHiddenDescriptionsTests/RendersHtml.verified.html b/tests/Elastic.Markdown.Tests/.snapshots/Directives/ChangelogDropdownsEnabledWithHiddenDescriptionsTests/RendersHtml.verified.html new file mode 100644 index 0000000000..5252390011 --- /dev/null +++ b/tests/Elastic.Markdown.Tests/.snapshots/Directives/ChangelogDropdownsEnabledWithHiddenDescriptionsTests/RendersHtml.verified.html @@ -0,0 +1,27 @@ +
+

+ 9.3.0 +

+
+ diff --git a/tests/Elastic.Markdown.Tests/.snapshots/Directives/ChangelogDropdownsExplicitWithDifferentTypesTests/RendersHtml.verified.html b/tests/Elastic.Markdown.Tests/.snapshots/Directives/ChangelogDropdownsExplicitWithDifferentTypesTests/RendersHtml.verified.html new file mode 100644 index 0000000000..9c29887a47 --- /dev/null +++ b/tests/Elastic.Markdown.Tests/.snapshots/Directives/ChangelogDropdownsExplicitWithDifferentTypesTests/RendersHtml.verified.html @@ -0,0 +1,69 @@ +
+

+ 9.3.0 +

+
+
+

+ Breaking changes +

+
+ +
+

+ Known issues +

+
+ +
+

+ Features and enhancements +

+
+ diff --git a/tests/Elastic.Markdown.Tests/.snapshots/Directives/ChangelogDropdownsPlainTextTitleTests/RendersHtml.verified.html b/tests/Elastic.Markdown.Tests/.snapshots/Directives/ChangelogDropdownsPlainTextTitleTests/RendersHtml.verified.html new file mode 100644 index 0000000000..4969e776d3 --- /dev/null +++ b/tests/Elastic.Markdown.Tests/.snapshots/Directives/ChangelogDropdownsPlainTextTitleTests/RendersHtml.verified.html @@ -0,0 +1,28 @@ +
+

+ 9.3.0 +

+
+ diff --git a/tests/Elastic.Markdown.Tests/.snapshots/Directives/ChangelogDropdownsWithDifferentTypesTests/RendersHtml.verified.html b/tests/Elastic.Markdown.Tests/.snapshots/Directives/ChangelogDropdownsWithDifferentTypesTests/RendersHtml.verified.html new file mode 100644 index 0000000000..f44377a563 --- /dev/null +++ b/tests/Elastic.Markdown.Tests/.snapshots/Directives/ChangelogDropdownsWithDifferentTypesTests/RendersHtml.verified.html @@ -0,0 +1,69 @@ +
+

+ 9.3.0 +

+
+
+

+ Breaking changes +

+
+ +
+

+ Known issues +

+
+ +
+

+ Deprecations +

+
+ +
+

+ Features and enhancements +

+
+ diff --git a/tests/Elastic.Markdown.Tests/.snapshots/Directives/ChangelogHeaderLevelsTests/RendersHtml.verified.html b/tests/Elastic.Markdown.Tests/.snapshots/Directives/ChangelogHeaderLevelsTests/RendersHtml.verified.html new file mode 100644 index 0000000000..7810fca245 --- /dev/null +++ b/tests/Elastic.Markdown.Tests/.snapshots/Directives/ChangelogHeaderLevelsTests/RendersHtml.verified.html @@ -0,0 +1,25 @@ +
+

+ 9.3.0 +

+
+
+

+ Features and enhancements +

+
+ +
+

+ Fixes +

+
+ diff --git a/tests/Elastic.Markdown.Tests/.snapshots/Directives/ChangelogHighlightsLegacyTypeHighlightTests/RendersHtml.verified.html b/tests/Elastic.Markdown.Tests/.snapshots/Directives/ChangelogHighlightsLegacyTypeHighlightTests/RendersHtml.verified.html new file mode 100644 index 0000000000..de65823ef9 --- /dev/null +++ b/tests/Elastic.Markdown.Tests/.snapshots/Directives/ChangelogHighlightsLegacyTypeHighlightTests/RendersHtml.verified.html @@ -0,0 +1,28 @@ +
+

+ 9.3.0 +

+
+
+

+ Features and enhancements +

+
+ +
+

+ Fixes +

+
+ diff --git a/tests/Elastic.Markdown.Tests/.snapshots/Directives/ChangelogHighlightsOptionDefaultOffTests/RendersHtml.verified.html b/tests/Elastic.Markdown.Tests/.snapshots/Directives/ChangelogHighlightsOptionDefaultOffTests/RendersHtml.verified.html new file mode 100644 index 0000000000..de65823ef9 --- /dev/null +++ b/tests/Elastic.Markdown.Tests/.snapshots/Directives/ChangelogHighlightsOptionDefaultOffTests/RendersHtml.verified.html @@ -0,0 +1,28 @@ +
+

+ 9.3.0 +

+
+
+

+ Features and enhancements +

+
+ +
+

+ Fixes +

+
+ diff --git a/tests/Elastic.Markdown.Tests/.snapshots/Directives/ChangelogHighlightsOptionEnabledTests/RendersHtml.verified.html b/tests/Elastic.Markdown.Tests/.snapshots/Directives/ChangelogHighlightsOptionEnabledTests/RendersHtml.verified.html new file mode 100644 index 0000000000..79289fea48 --- /dev/null +++ b/tests/Elastic.Markdown.Tests/.snapshots/Directives/ChangelogHighlightsOptionEnabledTests/RendersHtml.verified.html @@ -0,0 +1,38 @@ +
+

+ 9.3.0 +

+
+
+

+ Highlights +

+
+ +
+

+ Features and enhancements +

+
+ +
+

+ Fixes +

+
+ diff --git a/tests/Elastic.Markdown.Tests/.snapshots/Directives/ChangelogHighlightsOptionTypeAllWithoutFlagTests/TypeAllAloneDoesNotEmitHighlightsSection.verified.html b/tests/Elastic.Markdown.Tests/.snapshots/Directives/ChangelogHighlightsOptionTypeAllWithoutFlagTests/TypeAllAloneDoesNotEmitHighlightsSection.verified.html new file mode 100644 index 0000000000..241b76e6a9 --- /dev/null +++ b/tests/Elastic.Markdown.Tests/.snapshots/Directives/ChangelogHighlightsOptionTypeAllWithoutFlagTests/TypeAllAloneDoesNotEmitHighlightsSection.verified.html @@ -0,0 +1,46 @@ +
+

+ 9.3.0 +

+
+
+

+ Breaking changes +

+
+ +
+

+ Features and enhancements +

+
+ +
+

+ Fixes +

+
+ diff --git a/tests/Elastic.Markdown.Tests/.snapshots/Directives/ChangelogHighlightsOptionWithDescriptionsTests/RendersHtml.verified.html b/tests/Elastic.Markdown.Tests/.snapshots/Directives/ChangelogHighlightsOptionWithDescriptionsTests/RendersHtml.verified.html new file mode 100644 index 0000000000..7a952f6693 --- /dev/null +++ b/tests/Elastic.Markdown.Tests/.snapshots/Directives/ChangelogHighlightsOptionWithDescriptionsTests/RendersHtml.verified.html @@ -0,0 +1,43 @@ +
+

+ 9.3.0 +

+
+
+

+ Highlights +

+
+ +
+

+ Features and enhancements +

+
+ +
+

+ Fixes +

+
+ diff --git a/tests/Elastic.Markdown.Tests/.snapshots/Directives/ChangelogHighlightsOptionWithTypeAllTests/RendersHtml.verified.html b/tests/Elastic.Markdown.Tests/.snapshots/Directives/ChangelogHighlightsOptionWithTypeAllTests/RendersHtml.verified.html new file mode 100644 index 0000000000..6dd7cf3495 --- /dev/null +++ b/tests/Elastic.Markdown.Tests/.snapshots/Directives/ChangelogHighlightsOptionWithTypeAllTests/RendersHtml.verified.html @@ -0,0 +1,56 @@ +
+

+ 9.3.0 +

+
+
+

+ Breaking changes +

+
+ +
+

+ Highlights +

+
+ +
+

+ Features and enhancements +

+
+ +
+

+ Fixes +

+
+ diff --git a/tests/Elastic.Markdown.Tests/.snapshots/Directives/ChangelogKeepHighlightDescriptionsTests/RendersHtml.verified.html b/tests/Elastic.Markdown.Tests/.snapshots/Directives/ChangelogKeepHighlightDescriptionsTests/RendersHtml.verified.html new file mode 100644 index 0000000000..2f51d2b72e --- /dev/null +++ b/tests/Elastic.Markdown.Tests/.snapshots/Directives/ChangelogKeepHighlightDescriptionsTests/RendersHtml.verified.html @@ -0,0 +1,28 @@ +
+

+ 9.3.0 +

+
+
+

+ Highlights +

+
+ +
+

+ Features and enhancements +

+
+ diff --git a/tests/Elastic.Markdown.Tests/.snapshots/Directives/ChangelogMergeDifferentTargetsTests/RendersHtml.verified.html b/tests/Elastic.Markdown.Tests/.snapshots/Directives/ChangelogMergeDifferentTargetsTests/RendersHtml.verified.html new file mode 100644 index 0000000000..a120562468 --- /dev/null +++ b/tests/Elastic.Markdown.Tests/.snapshots/Directives/ChangelogMergeDifferentTargetsTests/RendersHtml.verified.html @@ -0,0 +1,45 @@ +
+

+ 9.3.0 +

+
+
+

+ Features and enhancements +

+
+ +
+

+ 9.2.0 +

+
+
+

+ Features and enhancements +

+
+ +
+

+ 9.1.0 +

+
+
+

+ Features and enhancements +

+
+ diff --git a/tests/Elastic.Markdown.Tests/.snapshots/Directives/ChangelogMergeMixedVersionTypesTests/RendersHtml.verified.html b/tests/Elastic.Markdown.Tests/.snapshots/Directives/ChangelogMergeMixedVersionTypesTests/RendersHtml.verified.html new file mode 100644 index 0000000000..5fdb52403d --- /dev/null +++ b/tests/Elastic.Markdown.Tests/.snapshots/Directives/ChangelogMergeMixedVersionTypesTests/RendersHtml.verified.html @@ -0,0 +1,30 @@ +
+

+ 9.3.0 +

+
+
+

+ Features and enhancements +

+
+ +
+

+ August 5, 2025 +

+
+
+

+ Features and enhancements +

+
+ diff --git a/tests/Elastic.Markdown.Tests/.snapshots/Directives/ChangelogMergeSameTargetTests/RendersHtml.verified.html b/tests/Elastic.Markdown.Tests/.snapshots/Directives/ChangelogMergeSameTargetTests/RendersHtml.verified.html new file mode 100644 index 0000000000..6bcf77e793 --- /dev/null +++ b/tests/Elastic.Markdown.Tests/.snapshots/Directives/ChangelogMergeSameTargetTests/RendersHtml.verified.html @@ -0,0 +1,46 @@ +
+

+ August 5, 2025 +

+
+
+

+ Features and enhancements +

+
+ +
+

+ Fixes +

+
+ +
+

+ August 1, 2025 +

+
+
+

+ Features and enhancements +

+
+ diff --git a/tests/Elastic.Markdown.Tests/.snapshots/Directives/ChangelogMergeSingleBundleTests/RendersHtml.verified.html b/tests/Elastic.Markdown.Tests/.snapshots/Directives/ChangelogMergeSingleBundleTests/RendersHtml.verified.html new file mode 100644 index 0000000000..78fcba1ade --- /dev/null +++ b/tests/Elastic.Markdown.Tests/.snapshots/Directives/ChangelogMergeSingleBundleTests/RendersHtml.verified.html @@ -0,0 +1,25 @@ +
+

+ 9.3.0 +

+
+
+

+ Features and enhancements +

+
+ +
+

+ Fixes +

+
+ diff --git a/tests/Elastic.Markdown.Tests/.snapshots/Directives/ChangelogMixedVersionTypesTests/RendersHtml.verified.html b/tests/Elastic.Markdown.Tests/.snapshots/Directives/ChangelogMixedVersionTypesTests/RendersHtml.verified.html new file mode 100644 index 0000000000..6a92f4994a --- /dev/null +++ b/tests/Elastic.Markdown.Tests/.snapshots/Directives/ChangelogMixedVersionTypesTests/RendersHtml.verified.html @@ -0,0 +1,60 @@ +
+

+ 9.3.0 +

+
+
+

+ Features and enhancements +

+
+ +
+

+ 9.2.0 +

+
+
+

+ Features and enhancements +

+
+ +
+

+ August 5, 2025 +

+
+
+

+ Features and enhancements +

+
+ +
+

+ July 1, 2025 +

+
+
+

+ Features and enhancements +

+
+ diff --git a/tests/Elastic.Markdown.Tests/.snapshots/Directives/ChangelogMultipleBundlesTests/RendersHtml.verified.html b/tests/Elastic.Markdown.Tests/.snapshots/Directives/ChangelogMultipleBundlesTests/RendersHtml.verified.html new file mode 100644 index 0000000000..b475506cca --- /dev/null +++ b/tests/Elastic.Markdown.Tests/.snapshots/Directives/ChangelogMultipleBundlesTests/RendersHtml.verified.html @@ -0,0 +1,45 @@ +
+

+ 9.10.0 +

+
+
+

+ Features and enhancements +

+
+ +
+

+ 9.3.0 +

+
+
+

+ Features and enhancements +

+
+ +
+

+ 9.2.0 +

+
+
+

+ Features and enhancements +

+
+ diff --git a/tests/Elastic.Markdown.Tests/.snapshots/Directives/ChangelogProductExplicitOptionOverridesDocsetTests/RendersHtml.verified.html b/tests/Elastic.Markdown.Tests/.snapshots/Directives/ChangelogProductExplicitOptionOverridesDocsetTests/RendersHtml.verified.html new file mode 100644 index 0000000000..e0a70ea13f --- /dev/null +++ b/tests/Elastic.Markdown.Tests/.snapshots/Directives/ChangelogProductExplicitOptionOverridesDocsetTests/RendersHtml.verified.html @@ -0,0 +1,21 @@ +
+

+ 9.3.0 +

+
+
+

+ Features and enhancements +

+
+ diff --git a/tests/Elastic.Markdown.Tests/.snapshots/Directives/ChangelogProductFallbackSingleProductTests/RendersHtml.verified.html b/tests/Elastic.Markdown.Tests/.snapshots/Directives/ChangelogProductFallbackSingleProductTests/RendersHtml.verified.html new file mode 100644 index 0000000000..d66e89d74f --- /dev/null +++ b/tests/Elastic.Markdown.Tests/.snapshots/Directives/ChangelogProductFallbackSingleProductTests/RendersHtml.verified.html @@ -0,0 +1,21 @@ +
+

+ 9.3.0 +

+
+
+

+ Features and enhancements +

+
+ diff --git a/tests/Elastic.Markdown.Tests/.snapshots/Directives/ChangelogPublishBlockerFiltersTocTests/RendersHtml.verified.html b/tests/Elastic.Markdown.Tests/.snapshots/Directives/ChangelogPublishBlockerFiltersTocTests/RendersHtml.verified.html new file mode 100644 index 0000000000..23c242f583 --- /dev/null +++ b/tests/Elastic.Markdown.Tests/.snapshots/Directives/ChangelogPublishBlockerFiltersTocTests/RendersHtml.verified.html @@ -0,0 +1,35 @@ +
+

+ 9.3.0 +

+
+
+

+ Features and enhancements +

+
+ +
+

+ Documentation +

+
+ +
+

+ Other changes +

+
+ diff --git a/tests/Elastic.Markdown.Tests/.snapshots/Directives/ChangelogRawVersionFallbackTests/RendersHtml.verified.html b/tests/Elastic.Markdown.Tests/.snapshots/Directives/ChangelogRawVersionFallbackTests/RendersHtml.verified.html new file mode 100644 index 0000000000..a5316b2553 --- /dev/null +++ b/tests/Elastic.Markdown.Tests/.snapshots/Directives/ChangelogRawVersionFallbackTests/RendersHtml.verified.html @@ -0,0 +1,30 @@ +
+

+ release-beta +

+
+
+

+ Features and enhancements +

+
+ +
+

+ release-alpha +

+
+
+

+ Features and enhancements +

+
+ diff --git a/tests/Elastic.Markdown.Tests/.snapshots/Directives/ChangelogSubsectionsEnabledTests/RendersHtml.verified.html b/tests/Elastic.Markdown.Tests/.snapshots/Directives/ChangelogSubsectionsEnabledTests/RendersHtml.verified.html new file mode 100644 index 0000000000..137366d96b --- /dev/null +++ b/tests/Elastic.Markdown.Tests/.snapshots/Directives/ChangelogSubsectionsEnabledTests/RendersHtml.verified.html @@ -0,0 +1,26 @@ +
+

+ 9.3.0 +

+
+
+

+ Features and enhancements +

+
+

+ Indexing +

+ +

+ Search +

+ diff --git a/tests/Elastic.Markdown.Tests/.snapshots/Directives/ChangelogTypeFilterAllTests/RendersHtml.verified.html b/tests/Elastic.Markdown.Tests/.snapshots/Directives/ChangelogTypeFilterAllTests/RendersHtml.verified.html new file mode 100644 index 0000000000..777aa8ea61 --- /dev/null +++ b/tests/Elastic.Markdown.Tests/.snapshots/Directives/ChangelogTypeFilterAllTests/RendersHtml.verified.html @@ -0,0 +1,79 @@ +
+

+ 9.3.0 +

+
+
+

+ Breaking changes +

+
+ +
+

+ Known issues +

+
+ +
+

+ Deprecations +

+
+ +
+

+ Features and enhancements +

+
+ +
+

+ Fixes +

+
+ diff --git a/tests/Elastic.Markdown.Tests/.snapshots/Directives/ChangelogTypeFilterCaseInsensitiveTests/RendersHtml.verified.html b/tests/Elastic.Markdown.Tests/.snapshots/Directives/ChangelogTypeFilterCaseInsensitiveTests/RendersHtml.verified.html new file mode 100644 index 0000000000..d3ae5b2f2d --- /dev/null +++ b/tests/Elastic.Markdown.Tests/.snapshots/Directives/ChangelogTypeFilterCaseInsensitiveTests/RendersHtml.verified.html @@ -0,0 +1,33 @@ +
+

+ 9.3.0 +

+
+
+

+ Breaking changes +

+
+ +
+

+ Features and enhancements +

+
+ diff --git a/tests/Elastic.Markdown.Tests/.snapshots/Directives/ChangelogTypeFilterDefaultTests/RendersHtml.verified.html b/tests/Elastic.Markdown.Tests/.snapshots/Directives/ChangelogTypeFilterDefaultTests/RendersHtml.verified.html new file mode 100644 index 0000000000..7810fca245 --- /dev/null +++ b/tests/Elastic.Markdown.Tests/.snapshots/Directives/ChangelogTypeFilterDefaultTests/RendersHtml.verified.html @@ -0,0 +1,25 @@ +
+

+ 9.3.0 +

+
+
+

+ Features and enhancements +

+
+ +
+

+ Fixes +

+
+ diff --git a/tests/Elastic.Markdown.Tests/.snapshots/Directives/ChangelogTypeFilterDeprecationTests/RendersHtml.verified.html b/tests/Elastic.Markdown.Tests/.snapshots/Directives/ChangelogTypeFilterDeprecationTests/RendersHtml.verified.html new file mode 100644 index 0000000000..029e3f94af --- /dev/null +++ b/tests/Elastic.Markdown.Tests/.snapshots/Directives/ChangelogTypeFilterDeprecationTests/RendersHtml.verified.html @@ -0,0 +1,29 @@ +
+

+ 9.3.0 +

+
+ diff --git a/tests/Elastic.Markdown.Tests/.snapshots/Directives/ChangelogTypeFilterKnownIssueTests/RendersHtml.verified.html b/tests/Elastic.Markdown.Tests/.snapshots/Directives/ChangelogTypeFilterKnownIssueTests/RendersHtml.verified.html new file mode 100644 index 0000000000..3904bff7b9 --- /dev/null +++ b/tests/Elastic.Markdown.Tests/.snapshots/Directives/ChangelogTypeFilterKnownIssueTests/RendersHtml.verified.html @@ -0,0 +1,29 @@ +
+

+ 9.3.0 +

+
+ diff --git a/tests/Elastic.Markdown.Tests/.snapshots/Directives/ChangelogTypeFilterWithSubsectionsTests/RendersHtml.verified.html b/tests/Elastic.Markdown.Tests/.snapshots/Directives/ChangelogTypeFilterWithSubsectionsTests/RendersHtml.verified.html new file mode 100644 index 0000000000..aa4709810f --- /dev/null +++ b/tests/Elastic.Markdown.Tests/.snapshots/Directives/ChangelogTypeFilterWithSubsectionsTests/RendersHtml.verified.html @@ -0,0 +1,44 @@ +
+

+ 9.3.0 +

+
+
+

+ Breaking changes +

+
+ +
+

+ Features and enhancements +

+
+

+ Indexing +

+ +

+ Search +

+ diff --git a/tests/Elastic.Markdown.Tests/.snapshots/Directives/ChangelogWithBreakingChangesTests/RendersHtml.verified.html b/tests/Elastic.Markdown.Tests/.snapshots/Directives/ChangelogWithBreakingChangesTests/RendersHtml.verified.html new file mode 100644 index 0000000000..6b9b96e5fd --- /dev/null +++ b/tests/Elastic.Markdown.Tests/.snapshots/Directives/ChangelogWithBreakingChangesTests/RendersHtml.verified.html @@ -0,0 +1,23 @@ +
+

+ 9.3.0 +

+
+
+

+ Breaking changes +

+
+ diff --git a/tests/Elastic.Markdown.Tests/.snapshots/Directives/ChangelogWithDeprecationsTests/RendersHtml.verified.html b/tests/Elastic.Markdown.Tests/.snapshots/Directives/ChangelogWithDeprecationsTests/RendersHtml.verified.html new file mode 100644 index 0000000000..424f70e222 --- /dev/null +++ b/tests/Elastic.Markdown.Tests/.snapshots/Directives/ChangelogWithDeprecationsTests/RendersHtml.verified.html @@ -0,0 +1,23 @@ +
+

+ 9.3.0 +

+
+
+

+ Deprecations +

+
+ diff --git a/tests/Elastic.Markdown.Tests/.snapshots/Directives/ChangelogYearMonthVersionTests/RendersHtml.verified.html b/tests/Elastic.Markdown.Tests/.snapshots/Directives/ChangelogYearMonthVersionTests/RendersHtml.verified.html new file mode 100644 index 0000000000..ce0ca09567 --- /dev/null +++ b/tests/Elastic.Markdown.Tests/.snapshots/Directives/ChangelogYearMonthVersionTests/RendersHtml.verified.html @@ -0,0 +1,55 @@ +
+

+ December 2025 +

+
+
+

+ Features and enhancements +

+
+ +
+

+ October 2025 +

+
+
+

+ Features and enhancements +

+
+ +
+

+ August 2025 +

+
+
+

+ Features and enhancements +

+
+ +
+

+ Fixes +

+
+ diff --git a/tests/Elastic.Markdown.Tests/.snapshots/Directives/CsvIncludeWithHtmlBreaksTests/RendersHtml.verified.html b/tests/Elastic.Markdown.Tests/.snapshots/Directives/CsvIncludeWithHtmlBreaksTests/RendersHtml.verified.html new file mode 100644 index 0000000000..bd9317b6ae --- /dev/null +++ b/tests/Elastic.Markdown.Tests/.snapshots/Directives/CsvIncludeWithHtmlBreaksTests/RendersHtml.verified.html @@ -0,0 +1,20 @@ +
+ + + + + + + + + + + + + +
NameTerms
OpenAI + Terms A +
+ Terms B +
+
diff --git a/tests/Elastic.Markdown.Tests/.snapshots/Directives/CsvTableDirectiveTests/EmitsUnsupportedWarnings.verified.txt b/tests/Elastic.Markdown.Tests/.snapshots/Directives/CsvTableDirectiveTests/EmitsUnsupportedWarnings.verified.txt new file mode 100644 index 0000000000..e3f5ac361f --- /dev/null +++ b/tests/Elastic.Markdown.Tests/.snapshots/Directives/CsvTableDirectiveTests/EmitsUnsupportedWarnings.verified.txt @@ -0,0 +1 @@ +warning {repo}/docs/index.md:1 Directive block 'csv-table' is unsupported. See https://github.com/elastic/docs-builder/issues/33 for more information. diff --git a/tests/Elastic.Markdown.Tests/.snapshots/Directives/DropdownNestedContentTests/RendersHtml.verified.html b/tests/Elastic.Markdown.Tests/.snapshots/Directives/DropdownNestedContentTests/RendersHtml.verified.html new file mode 100644 index 0000000000..31c1672cea --- /dev/null +++ b/tests/Elastic.Markdown.Tests/.snapshots/Directives/DropdownNestedContentTests/RendersHtml.verified.html @@ -0,0 +1,34 @@ + +

A regular paragraph.

diff --git a/tests/Elastic.Markdown.Tests/.snapshots/Directives/ExerciseDirectiveTest/EmitsUnsupportedWarnings.verified.txt b/tests/Elastic.Markdown.Tests/.snapshots/Directives/ExerciseDirectiveTest/EmitsUnsupportedWarnings.verified.txt new file mode 100644 index 0000000000..e0fd299fb6 --- /dev/null +++ b/tests/Elastic.Markdown.Tests/.snapshots/Directives/ExerciseDirectiveTest/EmitsUnsupportedWarnings.verified.txt @@ -0,0 +1 @@ +warning {repo}/docs/index.md:1 Directive block 'exercise' is unsupported. See https://github.com/elastic/docs-builder/issues/30 for more information. diff --git a/tests/Elastic.Markdown.Tests/.snapshots/Directives/FrameDirectiveTests/EmitsUnsupportedWarnings.verified.txt b/tests/Elastic.Markdown.Tests/.snapshots/Directives/FrameDirectiveTests/EmitsUnsupportedWarnings.verified.txt new file mode 100644 index 0000000000..5d2f16166c --- /dev/null +++ b/tests/Elastic.Markdown.Tests/.snapshots/Directives/FrameDirectiveTests/EmitsUnsupportedWarnings.verified.txt @@ -0,0 +1 @@ +warning {repo}/docs/index.md:1 Directive block 'iframe' is unsupported. See https://github.com/elastic/docs-builder/issues/14 for more information. diff --git a/tests/Elastic.Markdown.Tests/.snapshots/Directives/ImportantAppliesToTests/RendersHtml.verified.html b/tests/Elastic.Markdown.Tests/.snapshots/Directives/ImportantAppliesToTests/RendersHtml.verified.html new file mode 100644 index 0000000000..0b42684253 --- /dev/null +++ b/tests/Elastic.Markdown.Tests/.snapshots/Directives/ImportantAppliesToTests/RendersHtml.verified.html @@ -0,0 +1,13 @@ +
+
+ Important + + + + +
+
+

This is an important notice with applies_to information

+
+
+

A regular paragraph.

diff --git a/tests/Elastic.Markdown.Tests/.snapshots/Directives/MystDirectiveDirectiveTests/EmitsUnsupportedWarnings.verified.txt b/tests/Elastic.Markdown.Tests/.snapshots/Directives/MystDirectiveDirectiveTests/EmitsUnsupportedWarnings.verified.txt new file mode 100644 index 0000000000..3ce73c34dc --- /dev/null +++ b/tests/Elastic.Markdown.Tests/.snapshots/Directives/MystDirectiveDirectiveTests/EmitsUnsupportedWarnings.verified.txt @@ -0,0 +1 @@ +warning {repo}/docs/index.md:1 Directive block 'myst' is unsupported. See https://github.com/elastic/docs-builder/issues/22 for more information. diff --git a/tests/Elastic.Markdown.Tests/.snapshots/Directives/NoteAppliesToTests/RendersHtml.verified.html b/tests/Elastic.Markdown.Tests/.snapshots/Directives/NoteAppliesToTests/RendersHtml.verified.html new file mode 100644 index 0000000000..c7ff61d071 --- /dev/null +++ b/tests/Elastic.Markdown.Tests/.snapshots/Directives/NoteAppliesToTests/RendersHtml.verified.html @@ -0,0 +1,13 @@ +
+
+ Note + + + + +
+
+

This is a note with applies_to information

+
+
+

A regular paragraph.

diff --git a/tests/Elastic.Markdown.Tests/.snapshots/Directives/SolutionDirectiveTests/EmitsUnsupportedWarnings.verified.txt b/tests/Elastic.Markdown.Tests/.snapshots/Directives/SolutionDirectiveTests/EmitsUnsupportedWarnings.verified.txt new file mode 100644 index 0000000000..f9d85a108d --- /dev/null +++ b/tests/Elastic.Markdown.Tests/.snapshots/Directives/SolutionDirectiveTests/EmitsUnsupportedWarnings.verified.txt @@ -0,0 +1 @@ +warning {repo}/docs/index.md:1 Directive block 'solution' is unsupported. See https://github.com/elastic/docs-builder/issues/31 for more information. diff --git a/tests/Elastic.Markdown.Tests/.snapshots/Directives/StepperTocFalseKeepsInternalHeadingsTests/RendersHtml.verified.html b/tests/Elastic.Markdown.Tests/.snapshots/Directives/StepperTocFalseKeepsInternalHeadingsTests/RendersHtml.verified.html new file mode 100644 index 0000000000..ce7aa1031b --- /dev/null +++ b/tests/Elastic.Markdown.Tests/.snapshots/Directives/StepperTocFalseKeepsInternalHeadingsTests/RendersHtml.verified.html @@ -0,0 +1,20 @@ +
+

+ Section +

+
+
+
    +
  1. +
    + First +
    +
    +

    + Internal +

    +
    +

    Some content under the internal heading.

    +
  2. +
+
diff --git a/tests/Elastic.Markdown.Tests/.snapshots/Directives/StorybookBodyTests/RendersHtml.verified.html b/tests/Elastic.Markdown.Tests/.snapshots/Directives/StorybookBodyTests/RendersHtml.verified.html new file mode 100644 index 0000000000..82811d5e22 --- /dev/null +++ b/tests/Elastic.Markdown.Tests/.snapshots/Directives/StorybookBodyTests/RendersHtml.verified.html @@ -0,0 +1,6 @@ +
+ +
+

Supporting details for this story.

+
+
diff --git a/tests/Elastic.Markdown.Tests/.snapshots/Directives/StorybookInlineIdTests/RendersHtml.verified.html b/tests/Elastic.Markdown.Tests/.snapshots/Directives/StorybookInlineIdTests/RendersHtml.verified.html new file mode 100644 index 0000000000..40302d047f --- /dev/null +++ b/tests/Elastic.Markdown.Tests/.snapshots/Directives/StorybookInlineIdTests/RendersHtml.verified.html @@ -0,0 +1,4 @@ +
+ + +
diff --git a/tests/Elastic.Markdown.Tests/.snapshots/Directives/TableDirectiveDescriptionPresetTests/RendersHtml.verified.html b/tests/Elastic.Markdown.Tests/.snapshots/Directives/TableDirectiveDescriptionPresetTests/RendersHtml.verified.html new file mode 100644 index 0000000000..91ac8c298a --- /dev/null +++ b/tests/Elastic.Markdown.Tests/.snapshots/Directives/TableDirectiveDescriptionPresetTests/RendersHtml.verified.html @@ -0,0 +1,20 @@ +
+ + + + + + + + + + + + + + + + + +
TermDescription
fooA thing
+
diff --git a/tests/Elastic.Markdown.Tests/.snapshots/Directives/TableDirectiveFilterableWithMatrixAndWidthsTests/RendersHtml.verified.html b/tests/Elastic.Markdown.Tests/.snapshots/Directives/TableDirectiveFilterableWithMatrixAndWidthsTests/RendersHtml.verified.html new file mode 100644 index 0000000000..0148df6ebc --- /dev/null +++ b/tests/Elastic.Markdown.Tests/.snapshots/Directives/TableDirectiveFilterableWithMatrixAndWidthsTests/RendersHtml.verified.html @@ -0,0 +1,22 @@ + +
+ + + + + + + + + + + + + + + + + +
head ahead b
ab
+
+
diff --git a/tests/Elastic.Markdown.Tests/.snapshots/Directives/TableDirectiveWithWidthsTests/RendersHtml.verified.html b/tests/Elastic.Markdown.Tests/.snapshots/Directives/TableDirectiveWithWidthsTests/RendersHtml.verified.html new file mode 100644 index 0000000000..10697c2cda --- /dev/null +++ b/tests/Elastic.Markdown.Tests/.snapshots/Directives/TableDirectiveWithWidthsTests/RendersHtml.verified.html @@ -0,0 +1,20 @@ +
+ + + + + + + + + + + + + + + + + +
head ahead b
ab
+
diff --git a/tests/Elastic.Markdown.Tests/.snapshots/Directives/TipAppliesToTests/RendersHtml.verified.html b/tests/Elastic.Markdown.Tests/.snapshots/Directives/TipAppliesToTests/RendersHtml.verified.html new file mode 100644 index 0000000000..ce2e47ab2e --- /dev/null +++ b/tests/Elastic.Markdown.Tests/.snapshots/Directives/TipAppliesToTests/RendersHtml.verified.html @@ -0,0 +1,13 @@ +
+
+ Tip + + + + +
+
+

This is a tip with applies_to information

+
+
+

A regular paragraph.

diff --git a/tests/Elastic.Markdown.Tests/.snapshots/Directives/TocTreeDirectiveTests/EmitsUnsupportedWarnings.verified.txt b/tests/Elastic.Markdown.Tests/.snapshots/Directives/TocTreeDirectiveTests/EmitsUnsupportedWarnings.verified.txt new file mode 100644 index 0000000000..f9d85a108d --- /dev/null +++ b/tests/Elastic.Markdown.Tests/.snapshots/Directives/TocTreeDirectiveTests/EmitsUnsupportedWarnings.verified.txt @@ -0,0 +1 @@ +warning {repo}/docs/index.md:1 Directive block 'solution' is unsupported. See https://github.com/elastic/docs-builder/issues/31 for more information. diff --git a/tests/Elastic.Markdown.Tests/.snapshots/Directives/TopicDirectiveTests/EmitsUnsupportedWarnings.verified.txt b/tests/Elastic.Markdown.Tests/.snapshots/Directives/TopicDirectiveTests/EmitsUnsupportedWarnings.verified.txt new file mode 100644 index 0000000000..d3f15bfc78 --- /dev/null +++ b/tests/Elastic.Markdown.Tests/.snapshots/Directives/TopicDirectiveTests/EmitsUnsupportedWarnings.verified.txt @@ -0,0 +1 @@ +warning {repo}/docs/index.md:1 Directive block 'topic' is unsupported. See https://github.com/elastic/docs-builder/issues/24 for more information. diff --git a/tests/Elastic.Markdown.Tests/.snapshots/Directives/WarningAppliesToTests/RendersHtml.verified.html b/tests/Elastic.Markdown.Tests/.snapshots/Directives/WarningAppliesToTests/RendersHtml.verified.html new file mode 100644 index 0000000000..7e3616f91b --- /dev/null +++ b/tests/Elastic.Markdown.Tests/.snapshots/Directives/WarningAppliesToTests/RendersHtml.verified.html @@ -0,0 +1,13 @@ +
+
+ Warning + + + + +
+
+

This is a warning with applies_to information

+
+
+

A regular paragraph.

diff --git a/tests/Elastic.Markdown.Tests/Directives/AdmonitionTests.cs b/tests/Elastic.Markdown.Tests/Directives/AdmonitionTests.cs index d2e17e5c0a..b3998aeea6 100644 --- a/tests/Elastic.Markdown.Tests/Directives/AdmonitionTests.cs +++ b/tests/Elastic.Markdown.Tests/Directives/AdmonitionTests.cs @@ -3,7 +3,9 @@ // See the LICENSE file in the project root for more information using AwesomeAssertions; +using Elastic.Documentation.Testing; using Elastic.Markdown.Myst.Directives.Admonition; +using Nullean.Snapshots.Html; namespace Elastic.Markdown.Tests.Directives; @@ -120,11 +122,27 @@ Dropdown body content. public void StripsBackticksFromTitle() => Block!.Title.Should().Be("Deprecate elastic.apm settings"); [Test] - public void RendersPlainTextTitleInHtml() - { - Html.Should().Contain("Deprecate elastic.apm settings"); - Html.Should().NotContain("`elastic.apm`"); - } + public void RendersHtml() => + Html.Should().MatchInlineHtmlSnapshot( + html: DocsHtml.Body(), + expected: """ + + """ + ); } [InheritsTests] @@ -140,11 +158,27 @@ Dropdown body content. public void StripsBoldMarkersFromTitle() => Block!.Title.Should().Be("Disable Save button"); [Test] - public void RendersBoldTitleAsPlainTextInHtml() - { - Html.Should().Contain("Disable Save button"); - Html.Should().NotContain("**Save**"); - } + public void RendersHtml() => + Html.Should().MatchInlineHtmlSnapshot( + html: DocsHtml.Body(), + expected: """ + + """ + ); } [InheritsTests] @@ -160,11 +194,27 @@ Dropdown body content. public void StripsItalicMarkersFromTitle() => Block!.Title.Should().Be("Use italic emphasis"); [Test] - public void RendersItalicTitleAsPlainTextInHtml() - { - Html.Should().Contain("Use italic emphasis"); - Html.Should().NotContain("_italic_"); - } + public void RendersHtml() => + Html.Should().MatchInlineHtmlSnapshot( + html: DocsHtml.Body(), + expected: """ + + """ + ); } [InheritsTests] @@ -250,35 +300,7 @@ A regular paragraph. public void SetsDropdownOpen() => Block!.DropdownOpen.Should().BeTrue(); [Test] - public void ContainsContentWithColons() - { - var html = Html; - html.Should().Contain("Time: 10:30 AM"); - // URL with port is NOT autolinked (excluded by autolink rules) - html.Should().Contain("URL: https://example.com:8080/path"); - html.Should().NotContain(""" Html.Should().MatchHtmlSnapshot(DocsHtml.Body()); } [InheritsTests] @@ -330,13 +352,7 @@ A regular paragraph. public void ParsesAppliesTo() => Block!.AppliesTo.Should().NotBeNull(); [Test] - public void RendersAppliesToInHtml() - { - var html = Html; - html.Should().Contain("applies applies-admonition"); - html.Should().Contain("admonition-title__separator"); - html.Should().Contain("applies-to-popover"); - } + public void RendersHtml() => Html.Should().MatchHtmlSnapshot(DocsHtml.Body()); } [InheritsTests] @@ -363,13 +379,7 @@ A regular paragraph. public void ParsesAppliesTo() => Block!.AppliesTo.Should().NotBeNull(); [Test] - public void RendersAppliesToInHtml() - { - var html = Html; - html.Should().Contain("applies applies-admonition"); - html.Should().Contain("admonition-title__separator"); - html.Should().Contain("applies-to-popover"); - } + public void RendersHtml() => Html.Should().MatchHtmlSnapshot(DocsHtml.Body()); } [InheritsTests] @@ -396,13 +406,7 @@ A regular paragraph. public void ParsesAppliesTo() => Block!.AppliesTo.Should().NotBeNull(); [Test] - public void RendersAppliesToInHtml() - { - var html = Html; - html.Should().Contain("applies applies-admonition"); - html.Should().Contain("admonition-title__separator"); - html.Should().Contain("applies-to-popover"); - } + public void RendersHtml() => Html.Should().MatchHtmlSnapshot(DocsHtml.Body()); } [InheritsTests] @@ -429,13 +433,7 @@ A regular paragraph. public void ParsesAppliesTo() => Block!.AppliesTo.Should().NotBeNull(); [Test] - public void RendersAppliesToInHtml() - { - var html = Html; - html.Should().Contain("applies applies-admonition"); - html.Should().Contain("admonition-title__separator"); - html.Should().Contain("applies-to-popover"); - } + public void RendersHtml() => Html.Should().MatchHtmlSnapshot(DocsHtml.Body()); } [InheritsTests] @@ -462,11 +460,5 @@ A regular paragraph. public void ParsesAppliesTo() => Block!.AppliesTo.Should().NotBeNull(); [Test] - public void RendersAppliesToInHtml() - { - var html = Html; - html.Should().Contain("applies applies-admonition"); - html.Should().Contain("admonition-title__separator"); - html.Should().Contain("applies-to-popover"); - } + public void RendersHtml() => Html.Should().MatchHtmlSnapshot(DocsHtml.Body()); } diff --git a/tests/Elastic.Markdown.Tests/Directives/AgentSkillTests.cs b/tests/Elastic.Markdown.Tests/Directives/AgentSkillTests.cs index 12b0c7d2a6..8842e5c635 100644 --- a/tests/Elastic.Markdown.Tests/Directives/AgentSkillTests.cs +++ b/tests/Elastic.Markdown.Tests/Directives/AgentSkillTests.cs @@ -3,7 +3,10 @@ // See the LICENSE file in the project root for more information using AwesomeAssertions; +using Elastic.Documentation.Testing; using Elastic.Markdown.Myst.Directives.AgentSkill; +using Nullean.Snapshots; +using Nullean.Snapshots.Html; namespace Elastic.Markdown.Tests.Directives; @@ -33,36 +36,7 @@ A regular paragraph. public void SetsDirective() => Block!.Directive.Should().Be("agent-skill"); [Test] - public void RendersAgentSkillDiv() - { - Html.Should().Contain("class=\"agent-skill\""); - Html.Should().Contain("class=\"agent-skill-header\""); - Html.Should().Contain("class=\"agent-skill-content\""); - } - - [Test] - public void RendersTitle() => Html.Should().Contain("Agent skill available"); - - [Test] - public void RendersDefaultText() => Html.Should().Contain("A skill is available to help AI agents with this topic."); - - [Test] - public void RendersLearnMoreLink() - { - Html.Should().Contain("Learn more about agent skills for Elastic"); - Html.Should().Contain("href=\"https://www.elastic.co/docs/explore-analyze/ai-features/agent-skills#available-skills\""); - } - - [Test] - public void RendersCopyButton() - { - Html.Should().Contain("class=\"agent-skill-button\""); - Html.Should().Contain("Copy install command"); - Html.Should().Contain("data-copy-text=\"npx skills add elastic/agent-skills@elasticsearch-esql\""); - } - - [Test] - public void DoesNotRenderLinkButton() => Html.Should().NotContain("Get the skill"); + public void RendersHtml() => Html.Should().MatchHtmlSnapshot(DocsHtml.Body()); } [InheritsTests] @@ -78,16 +52,7 @@ A regular paragraph. ) { [Test] - public void RendersCustomBody() => Html.Should().Contain("This skill helps agents write and optimize ES|QL queries."); - - [Test] - public void StillRendersDefaultText() => Html.Should().Contain("A skill is available to help AI agents with this topic."); - - [Test] - public void StillRendersLearnMoreLink() => Html.Should().Contain("Learn more about agent skills for Elastic"); - - [Test] - public void StillRendersCopyButton() => Html.Should().Contain("Copy install command"); + public void RendersHtml() => Html.Should().MatchHtmlSnapshot(DocsHtml.Body()); } [InheritsTests] @@ -98,7 +63,12 @@ A regular paragraph. """) { [Test] - public void EmitsError() => Collector.Diagnostics.Should().Contain(d => d.Message.Contains("requires a :url: property")); + public void EmitsError() => + Collector + .Diagnostics + .ToSnapshotText() + .Should() + .MatchInlineSnapshot("error {repo}/docs/index.md:3 agent-skill directive requires a :url: property"); } [InheritsTests] @@ -112,7 +82,12 @@ A regular paragraph. ) { [Test] - public void EmitsError() => Collector.Diagnostics.Should().Contain(d => d.Message.Contains("must be an absolute URL")); + public void EmitsError() => + Collector + .Diagnostics + .ToSnapshotText() + .Should() + .MatchInlineSnapshot("error {repo}/docs/index.md:3 agent-skill :url: must be an absolute URL, got '/relative/path'"); } [InheritsTests] @@ -132,10 +107,5 @@ A regular paragraph. public void InstallCommandIsNull() => Block!.InstallCommand.Should().BeNull(); [Test] - public void FallsBackToLinkButton() - { - Html.Should().Contain("Get the skill"); - Html.Should().Contain("href=\"https://github.com/elastic/agent-skills\""); - Html.Should().NotContain("data-copy-text"); - } + public void RendersHtml() => Html.Should().MatchHtmlSnapshot(DocsHtml.Body()); } diff --git a/tests/Elastic.Markdown.Tests/Directives/ApplicabilitySwitchMalformedYamlTests.cs b/tests/Elastic.Markdown.Tests/Directives/ApplicabilitySwitchMalformedYamlTests.cs index b1fb4feeae..e324b99ce5 100644 --- a/tests/Elastic.Markdown.Tests/Directives/ApplicabilitySwitchMalformedYamlTests.cs +++ b/tests/Elastic.Markdown.Tests/Directives/ApplicabilitySwitchMalformedYamlTests.cs @@ -4,7 +4,9 @@ using AwesomeAssertions; using Elastic.Documentation.Diagnostics; +using Elastic.Documentation.Testing; using Elastic.Markdown.Myst.Directives.AppliesSwitch; +using Nullean.Snapshots; namespace Elastic.Markdown.Tests.Directives; @@ -28,8 +30,14 @@ This item has an applies_to definition that is not valid YAML. public void ReportsTheDefinitionAsAnError() => Collector .Diagnostics + .ToSnapshotText(firstLineOnly: true) .Should() - .Contain(d => d.Severity == Severity.Error && d.Message.Contains("Unable to parse applies_to definition: stack: [ga")); + .MatchInlineSnapshot( + """ + error {repo}/docs/index.md:5 Unable to parse applies_to definition: stack: [ga + error {repo}/docs/index.md:5 Unable to parse applies_to definition: stack: [ga + """ + ); [Test] public void KeepsTheExplicitSyncKey() => Block!.OfType().Single().SyncKey.Should().Be("explicit-key"); @@ -54,8 +62,14 @@ This item has an applies_to definition that is not valid YAML. public void ReportsTheDefinitionAsAnError() => Collector .Diagnostics + .ToSnapshotText(firstLineOnly: true) .Should() - .Contain(d => d.Severity == Severity.Error && d.Message.Contains("Unable to parse applies_to definition: stack: [ga")); + .MatchInlineSnapshot( + """ + error {repo}/docs/index.md:5 Unable to parse applies_to definition: stack: [ga + error {repo}/docs/index.md:5 Unable to parse applies_to definition: stack: [ga + """ + ); [Test] public void FallsBackToAKeyDerivedFromTheDefinition() => diff --git a/tests/Elastic.Markdown.Tests/Directives/ApplicabilitySwitchTests.cs b/tests/Elastic.Markdown.Tests/Directives/ApplicabilitySwitchTests.cs index 286f00ac9a..b886a5f642 100644 --- a/tests/Elastic.Markdown.Tests/Directives/ApplicabilitySwitchTests.cs +++ b/tests/Elastic.Markdown.Tests/Directives/ApplicabilitySwitchTests.cs @@ -3,7 +3,9 @@ // See the LICENSE file in the project root for more information using AwesomeAssertions; +using Elastic.Documentation.Testing; using Elastic.Markdown.Myst.Directives.AppliesSwitch; +using Nullean.Snapshots.Html; namespace Elastic.Markdown.Tests.Directives; @@ -47,7 +49,7 @@ public void ParsesApplicabilitySwitchItems() } [Test] - public void FirstItemRendersChecked() => Html.Should().Contain("applies-switch-input\" checked=\"checked\""); + public void RendersHtml() => Html.Should().MatchHtmlSnapshot(DocsHtml.Body()); [Test] public void ParsesAppliesToDefinitions() @@ -99,7 +101,7 @@ public void ItemIndicesAreZeroBased() } [Test] - public void FirstItemRendersChecked() => Html.Should().Contain("applies-switch-input\" checked=\"checked\""); + public void RendersHtml() => Html.Should().MatchHtmlSnapshot(DocsHtml.Body()); } [InheritsTests] diff --git a/tests/Elastic.Markdown.Tests/Directives/ButtonTests.cs b/tests/Elastic.Markdown.Tests/Directives/ButtonTests.cs index 6702e1ade7..577003f83e 100644 --- a/tests/Elastic.Markdown.Tests/Directives/ButtonTests.cs +++ b/tests/Elastic.Markdown.Tests/Directives/ButtonTests.cs @@ -3,7 +3,10 @@ // See the LICENSE file in the project root for more information using AwesomeAssertions; +using Elastic.Documentation.Testing; using Elastic.Markdown.Myst.Directives.Button; +using Nullean.Snapshots; +using Nullean.Snapshots.Html; namespace Elastic.Markdown.Tests.Directives; @@ -24,13 +27,17 @@ [Get Started](/get-started) public void DefaultsToLeftAlign() => Block!.Align.Should().Be("left"); [Test] - public void RendersPrimaryButtonClass() => Html.Should().Contain("doc-button-primary"); - - [Test] - public void RendersLinkHref() => Html.Should().Contain("href=\"/get-started\""); - - [Test] - public void RendersButtonText() => Html.Should().Contain("Get Started"); + public void RendersHtml() => + Html.Should().MatchInlineHtmlSnapshot( + html: DocsHtml.Body(), + expected: """ +
+

+ Get Started +

+
+ """ + ); } [InheritsTests] @@ -45,7 +52,17 @@ [Learn More](/learn-more) public void ParsesSecondaryType() => Block!.Type.Should().Be("secondary"); [Test] - public void RendersSecondaryClass() => Html.Should().Contain("doc-button-secondary"); + public void RendersHtml() => + Html.Should().MatchInlineHtmlSnapshot( + html: DocsHtml.Body(), + expected: """ +
+

+ Learn More +

+
+ """ + ); } [InheritsTests] @@ -62,10 +79,20 @@ [Browse All Docs](https://www.elastic.co/docs) public void ParsesNeutralType() => Block!.Type.Should().Be("neutral"); [Test] - public void RendersNeutralClass() => Html.Should().Contain("doc-button-neutral"); + public void RendersHtml() => + Html.Should().MatchInlineHtmlSnapshot( + html: DocsHtml.Body(), + expected: """ +
+

+ Browse All Docs +

+
+ """ + ); [Test] - public void EmitsNoErrors() => Collector.Diagnostics.Should().BeEmpty(); + public void EmitsNoErrors() => Collector.Diagnostics.ToSnapshotText().Should().MatchInlineSnapshot(""); } [InheritsTests] @@ -98,10 +125,24 @@ [Get Started](/get-started) ) { [Test] - public void RendersNeutralItemInsideGroup() => Html.Should().Contain("class=\"doc-button-item doc-button-neutral\""); - - [Test] - public void RendersPrimaryAlongsideNeutral() => Html.Should().Contain("doc-button-primary"); + public void RendersHtml() => + Html.Should().MatchInlineHtmlSnapshot( + html: DocsHtml.Body(), + expected: """ +
+ +

+ Get Started +

+
+ +

+ What's New +

+
+
+ """ + ); } [InheritsTests] @@ -116,7 +157,17 @@ [Centered Button](/centered) public void ParsesCenterAlign() => Block!.Align.Should().Be("center"); [Test] - public void RendersWrapperWithAlignClass() => Html.Should().Contain("doc-button-wrapper doc-button-primary doc-button-center"); + public void RendersHtml() => + Html.Should().MatchInlineHtmlSnapshot( + html: DocsHtml.Body(), + expected: """ +
+

+ Centered Button +

+
+ """ + ); } [InheritsTests] @@ -127,10 +178,17 @@ public class ButtonExternalTests() : DirectiveTest(""" """) { [Test] - public void RendersExternalAttributes() => Html.Should().Contain("target=\"_blank\""); - - [Test] - public void RendersNoopenerNoreferrer() => Html.Should().Contain("rel=\"noopener noreferrer\""); + public void RendersHtml() => + Html.Should().MatchInlineHtmlSnapshot( + html: DocsHtml.Body(), + expected: """ +
+

+ GitHub +

+
+ """ + ); } [InheritsTests] @@ -145,13 +203,20 @@ public class ButtonReferenceLinkTests() : DirectiveTest( ) { [Test] - public void RendersReferencedLinkHref() => Html.Should().Contain("href=\"https://foo.example.com\""); - - [Test] - public void RendersButtonText() => Html.Should().Contain(">Open<"); + public void RendersHtml() => + Html.Should().MatchInlineHtmlSnapshot( + html: DocsHtml.Body(), + expected: """ +
+

+ Open +

+
+ """ + ); [Test] - public void EmitsNoErrors() => Collector.Diagnostics.Should().BeEmpty(); + public void EmitsNoErrors() => Collector.Diagnostics.ToSnapshotText().Should().MatchInlineSnapshot(""); } [InheritsTests] @@ -164,7 +229,16 @@ [Invalid Type](/test) { [Test] public void EmitsWarningForInvalidType() => - Collector.Diagnostics.Should().ContainSingle(d => d.Message.Contains("Invalid button type")); + Collector + .Diagnostics + .ToSnapshotText() + .Should() + .MatchInlineSnapshot( + """ + warning {repo}/docs/index.md:3 Invalid button type 'invalid'. Valid types are: primary, secondary, neutral. Defaulting to 'primary'. + error {repo}/docs/index.md:5 `/test` does not exist. If it was recently removed add a redirect. resolved to `{repo}/docs/test` + """ + ); [Test] public void FallsBackToPrimary() => Block!.Type.Should().Be("primary"); @@ -190,16 +264,24 @@ public class ButtonGroupTests() : DirectiveTest( public void ParsesButtonGroup() => Block.Should().NotBeNull(); [Test] - public void RendersButtonGroupContainer() => Html.Should().Contain("class=\"doc-button-group"); - - [Test] - public void ContainsBothButtons() => Html.Should().Contain("Primary").And.Contain("Secondary"); - - [Test] - public void RendersPrimaryButton() => Html.Should().Contain("doc-button-primary"); - - [Test] - public void RendersSecondaryButton() => Html.Should().Contain("doc-button-secondary"); + public void RendersHtml() => + Html.Should().MatchInlineHtmlSnapshot( + html: DocsHtml.Body(), + expected: """ +
+ +

+ Primary +

+
+ +

+ Secondary +

+
+
+ """ + ); } [InheritsTests] @@ -218,7 +300,19 @@ public class ButtonGroupAlignmentTests() : DirectiveTest( public void ParsesGroupAlignment() => Block!.Align.Should().Be("center"); [Test] - public void RendersGroupAlignClass() => Html.Should().Contain("doc-button-group-center"); + public void RendersHtml() => + Html.Should().MatchInlineHtmlSnapshot( + html: DocsHtml.Body(), + expected: """ +
+ +

+ Centered +

+
+
+ """ + ); } [InheritsTests] @@ -234,10 +328,19 @@ [In Group](/in-group) public void DetectsButtonIsInGroup() => Block!.IsInGroup.Should().BeTrue(); [Test] - public void DoesNotRenderWrapperInGroup() => Html.Should().NotContain("doc-button-wrapper"); - - [Test] - public void RendersButtonItem() => Html.Should().Contain("doc-button-item"); + public void RendersHtml() => + Html.Should().MatchInlineHtmlSnapshot( + html: DocsHtml.Body(), + expected: """ +
+ +

+ In Group +

+
+
+ """ + ); } [InheritsTests] @@ -251,7 +354,17 @@ [Kibana Docs](kibana://api/index.md) public void ParsesBlock() => Block.Should().NotBeNull(); [Test] - public void RendersLinkHref() => Html.Should().Contain("href=\""); + public void RendersHtml() => + Html.Should().MatchInlineHtmlSnapshot( + html: DocsHtml.Body(), + expected: """ +
+

+ Kibana Docs +

+
+ """ + ); } [InheritsTests] @@ -267,10 +380,20 @@ [Install with Cursor](cursor://anysphere.cursor-deeplink/mcp/install?name=elasti public void ParsesBlock() => Block.Should().NotBeNull(); [Test] - public void RendersLinkHref() => Html.Should().Contain("href=\"cursor://"); + public void RendersHtml() => + Html.Should().MatchInlineHtmlSnapshot( + html: DocsHtml.Body(), + expected: """ + + """ + ); [Test] - public void EmitsNoErrors() => Collector.Diagnostics.Should().BeEmpty(); + public void EmitsNoErrors() => Collector.Diagnostics.ToSnapshotText().Should().MatchInlineSnapshot(""); } [InheritsTests] @@ -286,10 +409,20 @@ [Install with VS Code](vscode:extension/elastic.elasticsearch) public void ParsesBlock() => Block.Should().NotBeNull(); [Test] - public void RendersLinkHref() => Html.Should().Contain("href=\"vscode:"); + public void RendersHtml() => + Html.Should().MatchInlineHtmlSnapshot( + html: DocsHtml.Body(), + expected: """ + + """ + ); [Test] - public void EmitsNoErrors() => Collector.Diagnostics.Should().BeEmpty(); + public void EmitsNoErrors() => Collector.Diagnostics.ToSnapshotText().Should().MatchInlineSnapshot(""); } [InheritsTests] @@ -305,10 +438,20 @@ [Install with VS Code Insiders](vscode-insiders:mcp/install?%7B%22name%22%3A%22o public void ParsesBlock() => Block.Should().NotBeNull(); [Test] - public void RendersLinkHref() => Html.Should().Contain("href=\"vscode-insiders:"); + public void RendersHtml() => + Html.Should().MatchInlineHtmlSnapshot( + html: DocsHtml.Body(), + expected: """ + + """ + ); [Test] - public void EmitsNoErrors() => Collector.Diagnostics.Should().BeEmpty(); + public void EmitsNoErrors() => Collector.Diagnostics.ToSnapshotText().Should().MatchInlineSnapshot(""); } [InheritsTests] @@ -318,7 +461,21 @@ public class ButtonEmptyTests() : DirectiveTest(""" """) { [Test] - public void EmitsErrorForEmptyContent() => Collector.Diagnostics.Should().ContainSingle(d => d.Message.Contains("requires a link")); + public void EmitsErrorForEmptyContent() => + Collector + .Diagnostics + .ToSnapshotText() + .Should() + .MatchInlineSnapshot( + """ + error {repo}/docs/index.md:3 Button directive requires a link. Use: :::{button} + [text](url) + ::: + Or: :::{button} + [text][ref] + ::: + """ + ); } [InheritsTests] @@ -330,7 +487,20 @@ Just some text without a link { [Test] public void EmitsErrorForPlainText() => - Collector.Diagnostics.Should().ContainSingle(d => d.Message.Contains("must contain only a single Markdown link")); + Collector + .Diagnostics + .ToSnapshotText() + .Should() + .MatchInlineSnapshot( + """ + error {repo}/docs/index.md:3 Button directive must contain only a single Markdown link. Use: :::{button} + [text](url) + ::: + Or: :::{button} + [text][ref] + ::: + """ + ); } [InheritsTests] @@ -342,7 +512,22 @@ [Link One](/one) and [Link Two](/two) { [Test] public void EmitsErrorForMultipleLinks() => - Collector.Diagnostics.Should().ContainSingle(d => d.Message.Contains("must contain only a single Markdown link")); + Collector + .Diagnostics + .ToSnapshotText() + .Should() + .MatchInlineSnapshot( + """ + error {repo}/docs/index.md:3 Button directive must contain only a single Markdown link. Use: :::{button} + [text](url) + ::: + Or: :::{button} + [text][ref] + ::: + error {repo}/docs/index.md:4 `/one` does not exist. If it was recently removed add a redirect. resolved to `{repo}/docs/one` + error {repo}/docs/index.md:4 `/two` does not exist. If it was recently removed add a redirect. resolved to `{repo}/docs/two` + """ + ); } [InheritsTests] @@ -356,5 +541,19 @@ This is nested { [Test] public void EmitsErrorForNestedDirective() => - Collector.Diagnostics.Should().ContainSingle(d => d.Message.Contains("cannot contain nested directives")); + Collector + .Diagnostics + .ToSnapshotText() + .Should() + .MatchInlineSnapshot( + """ + error {repo}/docs/index.md:3 Button directive cannot contain nested directives or blocks. Use only a single Markdown link. + error {repo}/docs/index.md:3 Button directive requires a link. Use: :::{button} + [text](url) + ::: + Or: :::{button} + [text][ref] + ::: + """ + ); } diff --git a/tests/Elastic.Markdown.Tests/Directives/ChangelogBasicTests.cs b/tests/Elastic.Markdown.Tests/Directives/ChangelogBasicTests.cs index 5f870e10c2..3dd4d97c98 100644 --- a/tests/Elastic.Markdown.Tests/Directives/ChangelogBasicTests.cs +++ b/tests/Elastic.Markdown.Tests/Directives/ChangelogBasicTests.cs @@ -9,7 +9,10 @@ using Elastic.Documentation.Configuration; using Elastic.Documentation.Configuration.ReleaseNotes; using Elastic.Documentation.ReleaseNotes; +using Elastic.Documentation.Testing; using Elastic.Markdown.Myst.Directives.Changelog; +using Nullean.Snapshots; +using Nullean.Snapshots.Html; namespace Elastic.Markdown.Tests.Directives; @@ -74,14 +77,7 @@ public void SetsCorrectBundlesFolderPath() => public void LoadsBundles() => Block!.LoadedBundles.Should().HaveCount(1); [Test] - public void RendersMarkdownContent() - { - Html.Should().Contain("9.3.0"); - Html.Should().Contain("Features and enhancements"); - Html.Should().Contain("Add new feature"); - Html.Should().Contain("Fixes"); - Html.Should().Contain("Fix important bug"); - } + public void RendersHtml() => Html.Should().MatchHtmlSnapshot(DocsHtml.Body()); } [InheritsTests] @@ -143,11 +139,27 @@ public ChangelogExcludeAmendTests() : base( } [Test] - public void RendersWithoutExcludedEntry() - { - Html.Should().Contain("Keep this feature"); - Html.Should().NotContain("Remove this feature"); - } + public void RendersHtml() => + Html.Should().MatchInlineHtmlSnapshot( + html: DocsHtml.Body(), + expected: """ +
+

+ 9.3.0 +

+
+ +
    +
  • Keep this feature. + #123456 +
  • +
+ """ + ); [Test] public void LoadsMergedEntryCount() @@ -247,12 +259,7 @@ public void RendersInSemverOrder() } [Test] - public void RendersAllVersions() - { - Html.Should().Contain("9.10.0"); - Html.Should().Contain("9.3.0"); - Html.Should().Contain("9.2.0"); - } + public void RendersHtml() => Html.Should().MatchHtmlSnapshot(DocsHtml.Body()); } /// @@ -319,11 +326,27 @@ public ChangelogVersionFilterTests() : base( public void LoadsOnlyMatchingBundle() => Block!.LoadedBundles.Should().ContainSingle().Which.Version.Should().Be("9.3.0"); [Test] - public void RendersOnlyMatchingVersion() - { - Html.Should().Contain("Feature in 9.3.0"); - Html.Should().NotContain("Feature in 9.2.0"); - } + public void RendersHtml() => + Html.Should().MatchInlineHtmlSnapshot( + html: DocsHtml.Body(), + expected: """ +
+

+ 9.3.0 +

+
+ +
    +
  • Feature in 9.3.0. + #222222 +
  • +
+ """ + ); } /// @@ -366,7 +389,11 @@ public ChangelogVersionFilterNoMatchTests() : base( [Test] public void EmitsWarningForUnmatchedVersion() => - Collector.Diagnostics.Should().Contain(d => d.Message.Contains("No changelog bundle matches :version:")); + Collector + .Diagnostics + .ToSnapshotText() + .Should() + .MatchInlineSnapshot("warning {repo}/docs/index.md:3 No changelog bundle matches :version: '1.2.3'."); } [InheritsTests] @@ -407,11 +434,27 @@ public void SetsCorrectBundlesFolderPath() => Block!.BundlesFolderPath.Should().EndWith("release-notes/bundles".Replace('/', Path.DirectorySeparatorChar)); [Test] - public void RendersContent() - { - Html.Should().Contain("1.0.0"); - Html.Should().Contain("First release"); - } + public void RendersHtml() => + Html.Should().MatchInlineHtmlSnapshot( + html: DocsHtml.Body(), + expected: """ +
+

+ 1.0.0 +

+
+ +
    +
  • First release. + #1 +
  • +
+ """ + ); } /// @@ -436,11 +479,14 @@ public class ChangelogCdnInvalidProductTests() : DirectiveTest( public void DoesNotSourceFromLocalFolder() => Block!.BundlesFolderPath.Should().BeNull(); [Test] - public void EmitsErrorForInvalidProduct() - { - Collector.Diagnostics.Should().NotBeNullOrEmpty(); - Collector.Diagnostics.Should().Contain(d => d.Message.Contains("Invalid :cdn: product")); - } + public void EmitsErrorForInvalidProduct() => + Collector + .Diagnostics + .ToSnapshotText() + .Should() + .MatchInlineSnapshot( + "error {repo}/docs/index.md:3 Invalid :cdn: product 'invalid$product'. Product names must match [a-zA-Z0-9_-]+." + ); } /// @@ -487,12 +533,27 @@ protected override IReleaseNotesResolver GetReleaseNotesResolver() => public void FoundFromCdn() => Block!.Found.Should().BeTrue(); [Test] - public void RendersCdnBundleBody() - { - Html.Should().Contain("9.4.0"); - Html.Should().Contain("Features and enhancements"); - Html.Should().Contain("Faster vector search on the CDN"); - } + public void RendersHtml() => + Html.Should().MatchInlineHtmlSnapshot( + html: DocsHtml.Body(), + expected: """ +
+

+ 9.4.0 +

+
+ +
    +
  • Faster vector search on the CDN. + #999 +
  • +
+ """ + ); } /// @@ -558,8 +619,26 @@ protected override IReleaseNotesResolver GetReleaseNotesResolver() => public void RendersOnlyMatchingVersion() { Block!.Found.Should().BeTrue(); - Html.Should().Contain("Selected version entry"); - Html.Should().NotContain("Filtered out entry"); + Html.Should().MatchInlineHtmlSnapshot( + html: DocsHtml.Body(), + expected: """ +
+

+ 9.4.0 +

+
+ +
    +
  • Selected version entry. + #999 +
  • +
+ """ + ); } } @@ -614,7 +693,26 @@ protected override IReleaseNotesResolver GetReleaseNotesResolver() => public void RendersInferredCdnBundleBody() { Block!.Found.Should().BeTrue(); - Html.Should().Contain("Inferred product from the repository"); + Html.Should().MatchInlineHtmlSnapshot( + html: DocsHtml.Body(), + expected: """ +
+

+ 9.4.0 +

+
+ +
    +
  • Inferred product from the repository. + #999 +
  • +
+ """ + ); } } @@ -639,7 +737,13 @@ public class ChangelogCdnInferredProductUnavailableTests() : DirectiveTest d.Message.Contains("could not be inferred")); + Collector + .Diagnostics + .ToSnapshotText() + .Should() + .MatchInlineSnapshot( + "error {repo}/docs/index.md:3 The :cdn: product could not be inferred from the repository; specify it explicitly, e.g. ':cdn: elasticsearch'." + ); } } @@ -663,8 +767,15 @@ public void EmitsErrorWhenProductIsNotDeclared() Block!.Found.Should().BeFalse(); Collector .Diagnostics + .ToSnapshotText() .Should() - .Contain(d => d.Message.Contains("not declared in docset.yml") && d.Message.Contains("release_notes")); + .MatchInlineSnapshot( + """ + error {repo}/docs/index.md:3 The :cdn: product 'not-declared' is not declared in docset.yml. Add it under 'release_notes:', for example: + release_notes: + - product: not-declared + """ + ); } } @@ -701,11 +812,12 @@ public class ChangelogNotFoundTests() : DirectiveTest( public void ReportsFolderNotFound() => Block!.Found.Should().BeFalse(); [Test] - public void EmitsErrorForMissingFolder() - { - Collector.Diagnostics.Should().NotBeNullOrEmpty(); - Collector.Diagnostics.Should().OnlyContain(d => d.Message.Contains("does not exist")); - } + public void EmitsErrorForMissingFolder() => + Collector + .Diagnostics + .ToSnapshotText() + .Should() + .MatchInlineSnapshot("error {repo}/docs/index.md:3 Changelog bundles folder `missing-bundles` does not exist."); } [InheritsTests] @@ -721,8 +833,11 @@ public class ChangelogDefaultPathMissingTests() : DirectiveTest( public void EmitsErrorForMissingDefaultFolder() { // No bundles folder created, so it should emit an error - Collector.Diagnostics.Should().NotBeNullOrEmpty(); - Collector.Diagnostics.Should().OnlyContain(d => d.Message.Contains("does not exist")); + Collector + .Diagnostics + .ToSnapshotText() + .Should() + .MatchInlineSnapshot("error {repo}/docs/index.md:3 Changelog bundles folder `changelog/bundles` does not exist."); } } @@ -765,20 +880,7 @@ public ChangelogWithBreakingChangesTests() : base( ); [Test] - public void RendersBreakingChangesSection() - { - Html.Should().Contain("Breaking changes"); - Html.Should().Contain("Breaking change in API"); - } - - [Test] - public void RendersImpactAndAction() - { - Html.Should().Contain("Impact"); - Html.Should().Contain("Users must update their code"); - Html.Should().Contain("Action"); - Html.Should().Contain("Follow the migration guide"); - } + public void RendersHtml() => Html.Should().MatchHtmlSnapshot(DocsHtml.Body()); } /// @@ -820,11 +922,7 @@ public ChangelogWithDeprecationsTests() : base( ); [Test] - public void RendersDeprecationsSection() - { - Html.Should().Contain("Deprecations"); - Html.Should().Contain("Deprecated old API"); - } + public void RendersHtml() => Html.Should().MatchHtmlSnapshot(DocsHtml.Body()); } [InheritsTests] @@ -853,8 +951,8 @@ public ChangelogEmptyBundleTests() : base( [Test] public void OmitsEmptyVersionBlock() { - Html.Should().NotContain("No new features, enhancements, or fixes"); - Html.Should().NotContain("9.3.0"); + Html.Should().MatchInlineHtmlSnapshot(html: DocsHtml.Body(), expected: ""); + Collector.Diagnostics.ToSnapshotText().Should().MatchInlineSnapshot(""); } } @@ -875,11 +973,12 @@ public ChangelogEmptyFolderTests() : base( public void ReportsFolderEmpty() => Block!.Found.Should().BeFalse(); [Test] - public void EmitsErrorForEmptyFolder() - { - Collector.Diagnostics.Should().NotBeNullOrEmpty(); - Collector.Diagnostics.Should().OnlyContain(d => d.Message.Contains("contains no YAML files")); - } + public void EmitsErrorForEmptyFolder() => + Collector + .Diagnostics + .ToSnapshotText() + .Should() + .MatchInlineSnapshot("error {repo}/docs/index.md:3 Changelog bundles folder `changelog/bundles` contains no YAML files."); } [InheritsTests] @@ -1078,12 +1177,7 @@ public ChangelogHeaderLevelsTests() : base( ); [Test] - public void VersionHeaderIsH2() - { - // Version should be h2 - Html.Should().Contain(" Html.Should().MatchHtmlSnapshot(DocsHtml.Body()); [Test] public void OnlyOneH2ForVersion() @@ -1152,13 +1246,28 @@ public ChangelogTitleDescriptionSpacingTests() : base( ); [Test] - public void RendersTitleText() => Html.Should().Contain("Added missing banner-related Kibana settings to the settings allowlist"); - - [Test] - public void RendersDescriptionText() => Html.Should().Contain("This PR introduces the following settings"); - - [Test] - public void DoesNotConcatenateTitleAndDescriptionWithoutSeparator() => Html.Should().NotContain("allowlist.This PR introduces"); + public void RendersHtml() => + Html.Should().MatchInlineHtmlSnapshot( + html: DocsHtml.Body(), + expected: """ +
+

+ 9.3.0 +

+
+ +
    +
  • +

    Added missing banner-related Kibana settings to the settings allowlist.

    +

    This PR introduces the following settings.

    +
  • +
+ """ + ); } /// @@ -1197,10 +1306,30 @@ public ChangelogReleaseDateTests() : base( ); [Test] - public void RendersReleaseDate() => Html.Should().Contain("Released: April 9, 2026"); - - [Test] - public void RendersEntries() => Html.Should().Contain("Add tracing improvements"); + public void RendersHtml() => + Html.Should().MatchInlineHtmlSnapshot( + html: DocsHtml.Body(), + expected: """ +
+

+ 1.34.0 +

+
+

+ Released: April 9, 2026 +

+ +
    +
  • Add tracing improvements. + #500 +
  • +
+ """ + ); } /// @@ -1237,7 +1366,27 @@ public ChangelogNoReleaseDateTests() : base( ); [Test] - public void DoesNotRenderReleaseDate() => Html.Should().NotContain("Released:"); + public void RendersHtml() => + Html.Should().MatchInlineHtmlSnapshot( + html: DocsHtml.Body(), + expected: """ +
+

+ 9.3.0 +

+
+ +
    +
  • New feature. + #100 +
  • +
+ """ + ); } /// @@ -1278,13 +1427,31 @@ This release includes tracing improvements and bug fixes. ); [Test] - public void RendersReleaseDate() => Html.Should().Contain("Released: April 9, 2026"); - - [Test] - public void RendersDescription() => Html.Should().Contain("This release includes tracing improvements and bug fixes."); - - [Test] - public void RendersEntries() => Html.Should().Contain("Add tracing improvements"); + public void RendersHtml() => + Html.Should().MatchInlineHtmlSnapshot( + html: DocsHtml.Body(), + expected: """ +
+

+ 1.34.0 +

+
+

+ Released: April 9, 2026 +

+

This release includes tracing improvements and bug fixes.

+ +
    +
  • Add tracing improvements. + #500 +
  • +
+ """ + ); } /// @@ -1326,8 +1493,28 @@ public ChangelogDoubleBraceEscapeTests() : base( ); [Test] - public void RendersWithoutErrors() => Collector.Errors.Should().Be(0); + public void RendersWithoutErrors() => Collector.Diagnostics.ToSnapshotText().Should().MatchInlineSnapshot(""); [Test] - public void RendersTitleWithLiteralBraces() => Html.Should().Contain("{{hostname}}"); + public void RendersHtml() => + Html.Should().MatchInlineHtmlSnapshot( + html: DocsHtml.Body(), + expected: """ +
+

+ 9.3.0 +

+
+
+

+ Fixes +

+
+
    +
  • Fix ECE API ingestion blocked by {{hostname}} template placeholder. + #123 +
  • +
+ """ + ); } diff --git a/tests/Elastic.Markdown.Tests/Directives/ChangelogConfigTests.cs b/tests/Elastic.Markdown.Tests/Directives/ChangelogConfigTests.cs index 16ed475190..e4b4c9f51a 100644 --- a/tests/Elastic.Markdown.Tests/Directives/ChangelogConfigTests.cs +++ b/tests/Elastic.Markdown.Tests/Directives/ChangelogConfigTests.cs @@ -4,7 +4,10 @@ using System.IO.Abstractions.TestingHelpers; using AwesomeAssertions; +using Elastic.Documentation.Testing; using Elastic.Markdown.Myst.Directives.Changelog; +using Nullean.Snapshots; +using Nullean.Snapshots.Html; namespace Elastic.Markdown.Tests.Directives; @@ -80,22 +83,7 @@ public ChangelogConfigLoadAutoDiscoverTests() : base( public void PublishBlockerIsNull() => Block!.PublishBlocker.Should().BeNull(); [Test] - public void RendersAllEntries_NoFiltering() - { - // Directive does not apply rules.publish; all entries are shown - Html.Should().Contain("Regular feature"); - Html.Should().Contain("Deprecation notice"); - Html.Should().Contain("Known issue"); - } - - [Test] - public void RendersFeaturesSection() => Html.Should().Contain("Features and enhancements"); - - [Test] - public void RendersDeprecationsSection() => Html.Should().Contain("Deprecations"); - - [Test] - public void RendersKnownIssuesSection() => Html.Should().Contain("Known issues"); + public void RendersHtml() => Html.Should().MatchHtmlSnapshot(DocsHtml.Body()); } [InheritsTests] @@ -161,12 +149,7 @@ public ChangelogConfigLoadExplicitPathTests() : base( public void PublishBlockerIsNull() => Block!.PublishBlocker.Should().BeNull(); [Test] - public void RendersAllEntries_NoFiltering() - { - // Directive does not apply rules.publish; all entries are shown - Html.Should().Contain("Regular feature"); - Html.Should().Contain("Internal docs"); - } + public void RendersHtml() => Html.Should().MatchHtmlSnapshot(DocsHtml.Body()); } [InheritsTests] @@ -226,12 +209,7 @@ public ChangelogConfigLoadFromDocsSubfolderTests() : base( public void PublishBlockerIsNull() => Block!.PublishBlocker.Should().BeNull(); [Test] - public void RendersAllEntries_NoFiltering() - { - // Directive does not apply rules.publish; all entries are shown - Html.Should().Contain("Regular feature"); - Html.Should().Contain("Other change"); - } + public void RendersHtml() => Html.Should().MatchHtmlSnapshot(DocsHtml.Body()); } [InheritsTests] @@ -268,10 +246,30 @@ public ChangelogConfigNotFoundTests() : base( public void PublishBlockerIsNullWhenNoConfig() => Block!.PublishBlocker.Should().BeNull(); [Test] - public void RendersAllEntriesWhenNoConfig() => Html.Should().Contain("Regular feature"); + public void RendersHtml() => + Html.Should().MatchInlineHtmlSnapshot( + html: DocsHtml.Body(), + expected: """ +
+

+ 9.3.0 +

+
+ + + """ + ); [Test] - public void NoErrorsEmittedForMissingConfig() => Collector.Diagnostics.Should().NotContain(d => d.Message.Contains("changelog.yml")); + public void NoErrorsEmittedForMissingConfig() => Collector.Diagnostics.ToSnapshotText().Should().MatchInlineSnapshot(""); } [InheritsTests] @@ -310,10 +308,34 @@ public ChangelogConfigExplicitPathNotFoundTests() : base( [Test] public void EmitsWarningForMissingExplicitConfig() => - Collector.Diagnostics.Should().Contain(d => d.Message.Contains("nonexistent/config.yml") && d.Message.Contains("not found")); + Collector + .Diagnostics + .ToSnapshotText() + .Should() + .MatchInlineSnapshot("warning {repo}/docs/index.md:3 Specified changelog config path 'nonexistent/config.yml' not found."); [Test] - public void RendersAllEntriesWhenConfigNotFound() => Html.Should().Contain("Regular feature"); + public void RendersHtml() => + Html.Should().MatchInlineHtmlSnapshot( + html: DocsHtml.Body(), + expected: """ +
+

+ 9.3.0 +

+
+ + + """ + ); } [InheritsTests] @@ -394,13 +416,7 @@ public ChangelogConfigPriorityTests() : base( } [Test] - public void RendersAllEntries_NoPublishFiltering() - { - // Directive does not apply rules.publish; all entries are shown - Html.Should().Contain("Regular feature"); - Html.Should().Contain("Deprecation notice"); - Html.Should().Contain("Other change"); - } + public void RendersHtml() => Html.Should().MatchHtmlSnapshot(DocsHtml.Body()); } [InheritsTests] @@ -454,7 +470,27 @@ public ChangelogConfigEmptyBlockTests() : base( public void PublishBlockerIsNullWhenNoBlockSection() => Block!.PublishBlocker.Should().BeNull(); [Test] - public void RendersAllEntriesWhenNoBlockSection() => Html.Should().Contain("Regular feature"); + public void RendersHtml() => + Html.Should().MatchInlineHtmlSnapshot( + html: DocsHtml.Body(), + expected: """ +
+

+ 9.3.0 +

+
+ + + """ + ); } [InheritsTests] @@ -540,14 +576,7 @@ public ChangelogConfigMixedBlockersTests() : base( public void PublishBlockerIsNull() => Block!.PublishBlocker.Should().BeNull(); [Test] - public void RendersAllEntries_NoFiltering() - { - // Directive does not apply rules.publish; all entries are shown - Html.Should().Contain("Regular feature in Search"); - Html.Should().Contain("Deprecation in Search"); - Html.Should().Contain("Feature in Internal"); - Html.Should().Contain("Bug fix"); - } + public void RendersHtml() => Html.Should().MatchHtmlSnapshot(DocsHtml.Body()); } [InheritsTests] @@ -625,13 +654,7 @@ protected override void AddToFileSystem(MockFileSystem fileSystem) public void PublishBlockerIsNull() => Block!.PublishBlocker.Should().BeNull(); [Test] - public void RendersAllEntries_NoFiltering() - { - // Directive does not apply rules.publish; all entries are shown - Html.Should().Contain("Regular Kibana feature"); - Html.Should().Contain("Internal feature"); - Html.Should().Contain("Observability feature"); - } + public void RendersHtml() => Html.Should().MatchHtmlSnapshot(DocsHtml.Body()); } [InheritsTests] @@ -700,12 +723,30 @@ protected override void AddToFileSystem(MockFileSystem fileSystem) public void PublishBlockerIsNull() => Block!.PublishBlocker.Should().BeNull(); [Test] - public void RendersAllEntries_NoFiltering() - { - // Directive does not apply rules.publish; all entries are shown - Html.Should().Contain("Regular feature"); - Html.Should().Contain("Internal feature"); - } + public void RendersHtml() => + Html.Should().MatchInlineHtmlSnapshot( + html: DocsHtml.Body(), + expected: """ +
+

+ 9.3.0 +

+
+ + + """ + ); } [InheritsTests] @@ -789,14 +830,14 @@ protected override void AddToFileSystem(MockFileSystem fileSystem) [Test] public void EmitsDeprecationWarningForProductOption() => - Collector.Diagnostics.Should().Contain(d => d.Message.Contains(":product:") && d.Message.Contains("deprecated")); + Collector + .Diagnostics + .ToSnapshotText() + .Should() + .MatchInlineSnapshot( + "warning {repo}/docs/index.md:3 The :product: option is deprecated and has no effect. The directive does not apply rules.publish. Move type/area filtering to rules.bundle so it applies at bundle time." + ); [Test] - public void RendersAllEntries_NoFiltering() - { - // Directive does not apply rules.publish; all entries are shown - Html.Should().Contain("Regular feature"); - Html.Should().Contain("ES Internal feature"); - Html.Should().Contain("Kibana Internal feature"); - } + public void RendersHtml() => Html.Should().MatchHtmlSnapshot(DocsHtml.Body()); } diff --git a/tests/Elastic.Markdown.Tests/Directives/ChangelogDescriptionVisibilityTests.cs b/tests/Elastic.Markdown.Tests/Directives/ChangelogDescriptionVisibilityTests.cs index f47e201747..c746cd2444 100644 --- a/tests/Elastic.Markdown.Tests/Directives/ChangelogDescriptionVisibilityTests.cs +++ b/tests/Elastic.Markdown.Tests/Directives/ChangelogDescriptionVisibilityTests.cs @@ -4,8 +4,11 @@ using System.IO.Abstractions.TestingHelpers; using AwesomeAssertions; +using Elastic.Documentation.Testing; using Elastic.Markdown.Myst.Directives.Changelog; using Markdig.Syntax; +using Nullean.Snapshots; +using Nullean.Snapshots.Html; namespace Elastic.Markdown.Tests.Directives; @@ -149,10 +152,25 @@ protected override void AddToFileSystem(MockFileSystem fileSystem) => /// Public bundle with no assembler private repos ⇒ auto hides record bodies. [Test] - public void HtmlOmitsBodyTextForPublicBundle() => Html.Should().NotContain("BODY_DEFAULT_AUTO_VISIBILITY"); - - [Test] - public void HtmlStillRendersTitles() => Html.Should().Contain("Feature delta"); + public void RendersHtml() => + Html.Should().MatchInlineHtmlSnapshot( + html: DocsHtml.Body(), + expected: """ +
+

+ 9.3.0 +

+
+ +
    +
  • Feature delta.
  • +
+ """ + ); } [InheritsTests] @@ -230,7 +248,28 @@ protected override void AddToFileSystem(MockFileSystem fileSystem) => ); [Test] - public void KeepsBodyOnFullyPublicRepos() => Html.Should().Contain("BODY_KEEP_VISIBILITY"); + public void RendersHtml() => + Html.Should().MatchInlineHtmlSnapshot( + html: DocsHtml.Body(), + expected: """ +
+

+ 9.3.0 +

+
+ +
    +
  • +

    Feature keep.

    +

    BODY_KEEP_VISIBILITY

    +
  • +
+ """ + ); } [InheritsTests] @@ -262,7 +301,25 @@ protected override void AddToFileSystem(MockFileSystem fileSystem) => ); [Test] - public void OmitBody() => Html.Should().NotContain("BODY_HIDE_VISIBILITY"); + public void RendersHtml() => + Html.Should().MatchInlineHtmlSnapshot( + html: DocsHtml.Body(), + expected: """ +
+

+ 9.3.0 +

+
+ +
    +
  • Feature hide.
  • +
+ """ + ); [Test] public void MarkdownRendersTitlesWithoutBodies() @@ -305,8 +362,33 @@ protected override void AddToFileSystem(MockFileSystem fileSystem) => public void FallsBackToAuto() => Block!.DescriptionVisibility.Should().Be(ChangelogDescriptionVisibility.Auto); [Test] - public void EmitsWarning() => Collector.Warnings.Should().BeGreaterThan(0); + public void EmitsWarning() => + Collector + .Diagnostics + .ToSnapshotText() + .Should() + .MatchInlineSnapshot( + "warning {repo}/docs/index.md:3 Invalid :description-visibility: value 'nonsense-value'. Valid values are: auto, keep-descriptions, keep-highlight-descriptions, hide-descriptions. Using auto." + ); [Test] - public void AutoTreatsFullyPublic_AsHideBody() => Html.Should().NotContain("BODY_INVALID_VISIBILITY"); + public void RendersHtml() => + Html.Should().MatchInlineHtmlSnapshot( + html: DocsHtml.Body(), + expected: """ +
+

+ 9.3.0 +

+
+ +
    +
  • Feature warn.
  • +
+ """ + ); } diff --git a/tests/Elastic.Markdown.Tests/Directives/ChangelogDropdownsTests.cs b/tests/Elastic.Markdown.Tests/Directives/ChangelogDropdownsTests.cs index 9a5d80679b..2f096e28b0 100644 --- a/tests/Elastic.Markdown.Tests/Directives/ChangelogDropdownsTests.cs +++ b/tests/Elastic.Markdown.Tests/Directives/ChangelogDropdownsTests.cs @@ -4,7 +4,9 @@ using System.IO.Abstractions.TestingHelpers; using AwesomeAssertions; +using Elastic.Documentation.Testing; using Elastic.Markdown.Myst.Directives.Changelog; +using Nullean.Snapshots.Html; namespace Elastic.Markdown.Tests.Directives; @@ -63,34 +65,7 @@ public ChangelogDropdownsDefaultTests() : base( public void DefaultBehaviorDoesNotParseDropdownsOption() => Block!.DropdownsEnabled.Should().BeFalse(); [Test] - public void DefaultBehaviorRendersFlattened() - { - // Should NOT contain dropdown HTML structure - Html.Should().NotContain("
"); - Html.Should().NotContain("dropdown-title__summary-text"); - - // Should contain bulleted list format without bold titles (matching regular entries) - Html.Should().Contain("Breaking API change."); - Html.Should().Contain("Another breaking change."); - } - - [Test] - public void DefaultBehaviorIncludesImpactAndActionSections() - { - Html.Should().Contain("Impact: Existing API calls will fail."); - Html.Should().Contain("Action: Update your code to use the new API endpoints."); - Html.Should().Contain("Impact: Scripts using the old parameter will fail."); - Html.Should().Contain("Action: Remove references to the deprecated parameter."); - } - - [Test] - public void DefaultBehaviorIncludesDescriptions() - { - // Note: Descriptions may be hidden by default due to :description-visibility: auto behavior - // This test validates that when descriptions are shown, they appear in the correct format - Html.Should().Contain("API has been changed to improve performance."); - Html.Should().Contain("Removed deprecated parameter."); - } + public void RendersHtml() => Html.Should().MatchHtmlSnapshot(DocsHtml.Body()); } /// @@ -136,26 +111,7 @@ public ChangelogDropdownsEnabledTests() : base( public void ExplicitDropdownsParsesCorrectly() => Block!.DropdownsEnabled.Should().BeTrue(); [Test] - public void ExplicitDropdownsRendersDropdownFormat() - { - // Should contain dropdown HTML structure - Html.Should().Contain("
"); - Html.Should().Contain("dropdown-title__summary-text"); - Html.Should().Contain("Breaking API change."); - - // Should NOT contain bulleted list format - Html.Should().NotContain("
  • Breaking API change."); - } - - [Test] - public void ExplicitDropdownsIncludesDescriptionInDropdown() => Html.Should().Contain("API has been changed to improve performance."); - - [Test] - public void ExplicitDropdownsIncludesImpactAndActionInDropdown() - { - Html.Should().Contain("Impact
    Existing API calls will fail."); - Html.Should().Contain("Action
    Update your code to use the new API endpoints."); - } + public void RendersHtml() => Html.Should().MatchHtmlSnapshot(DocsHtml.Body()); } ///

    @@ -197,19 +153,30 @@ public ChangelogDropdownsWithHiddenDescriptionsTests() : base( ); [Test] - public void FlattendRenderingHidesDescriptionsButKeepsImpactAction() - { - // Should render as flattened (no dropdowns by default) - Html.Should().Contain("Breaking API change."); - Html.Should().NotContain("
    "); - - // Description should be hidden due to :description-visibility: hide-descriptions - Html.Should().NotContain("This description should be hidden."); - - // Impact and Action should still be shown in flattened format - Html.Should().Contain("Impact: Existing API calls will fail."); - Html.Should().Contain("Action: Update your code to use the new API endpoints."); - } + public void RendersHtml() => + Html.Should().MatchInlineHtmlSnapshot( + html: DocsHtml.Body(), + expected: """ +
    +

    + 9.3.0 +

    +
    +
      +
    • +

      Breaking API change. + #333333 +

      +

      + Impact: + Existing API calls will fail.

      +

      + Action: + Update your code to use the new API endpoints.

      +
    • +
    + """ + ); } /// @@ -252,20 +219,7 @@ public ChangelogDropdownsEnabledWithHiddenDescriptionsTests() : base( ); [Test] - public void DropdownRenderingHidesDescriptionsButKeepsImpactAction() - { - // Should render as dropdown due to explicit :dropdowns: - Html.Should().Contain("
    "); - Html.Should().Contain("Breaking API change."); - Html.Should().NotContain("
  • Breaking API change."); - - // Description should be hidden due to :description-visibility: hide-descriptions - Html.Should().NotContain("This description should be hidden."); - - // Impact and Action should still be shown in dropdown format - Html.Should().Contain("Impact
    Existing API calls will fail."); - Html.Should().Contain("Action
    Update your code to use the new API endpoints."); - } + public void RendersHtml() => Html.Should().MatchHtmlSnapshot(DocsHtml.Body()); } ///

    @@ -334,19 +288,7 @@ public ChangelogDropdownsWithDifferentTypesTests() : base( ); [Test] - public void DefaultRendersMixedTypesCorrectly() - { - // Regular types should render as bulleted lists (unchanged behavior) - Html.Should().Contain("Feature addition."); // Regular feature type (in
  • tags) - - // Separated types should render as flattened lists (new behavior) - no bold titles - Html.Should().Contain("Breaking API change."); - Html.Should().Contain("Known issue with search."); - Html.Should().Contain("Deprecated API."); - - // Should NOT contain dropdown HTML structure for separated types - Html.Should().NotContain("
    "); - } + public void RendersHtml() => Html.Should().MatchHtmlSnapshot(DocsHtml.Body()); } /// @@ -406,20 +348,7 @@ public ChangelogDropdownsExplicitWithDifferentTypesTests() : base( ); [Test] - public void ExplicitDropdownsRendersMixedTypesCorrectly() - { - // Regular types should still render as bulleted lists (unchanged behavior) - Html.Should().Contain("Feature addition."); // Regular feature type (in
  • tags) - - // Separated types should render as dropdowns (explicit :dropdowns:) - Html.Should().Contain("
    "); - Html.Should().Contain("Breaking API change."); - Html.Should().Contain("Known issue with search."); - - // Should NOT contain flattened format for separated types (check they're in dropdown, not flat list) - Html.Should().NotContain("
  • Breaking API change."); - Html.Should().NotContain("

  • Known issue with search."); - } + public void RendersHtml() => Html.Should().MatchHtmlSnapshot(DocsHtml.Body()); } ///

    @@ -462,9 +391,5 @@ public ChangelogDropdownsPlainTextTitleTests() : base( ); [Test] - public void ChangelogDropdownTitleStripsBackticksInHtml() - { - Html.Should().Contain("The ElasticAgentVersion parameter is malformed."); - Html.Should().NotContain("`ElasticAgentVersion`"); - } + public void RendersHtml() => Html.Should().MatchHtmlSnapshot(DocsHtml.Body()); } diff --git a/tests/Elastic.Markdown.Tests/Directives/ChangelogFlattenedLinksTests.cs b/tests/Elastic.Markdown.Tests/Directives/ChangelogFlattenedLinksTests.cs index 66268fe47c..664c06f732 100644 --- a/tests/Elastic.Markdown.Tests/Directives/ChangelogFlattenedLinksTests.cs +++ b/tests/Elastic.Markdown.Tests/Directives/ChangelogFlattenedLinksTests.cs @@ -4,7 +4,9 @@ using System.IO.Abstractions.TestingHelpers; using AwesomeAssertions; +using Elastic.Documentation.Testing; using Elastic.Markdown.Myst.Directives.Changelog; +using Nullean.Snapshots.Html; namespace Elastic.Markdown.Tests.Directives; @@ -59,11 +61,22 @@ public void FlattenedDeprecationRendersMultipleLinksWithoutOuterBrackets() } [Test] - public void FlattenedDeprecationRendersClickableLinkHtml() - { - Html.Should().Contain("href=\"https://github.com/elastic/elasticsearch/pull/268942\""); - Html.Should().Contain("href=\"https://github.com/elastic/elasticsearch/pull/202446\""); - Html.Should().Contain("href=\"https://github.com/elastic/elasticsearch/issues/199001\""); - Html.Should().NotContain("[#268942, #202446]"); - } + public void RendersHtml() => + Html.Should().MatchInlineHtmlSnapshot( + html: DocsHtml.Body(), + expected: """ +
    +

    + 9.3.0 +

    +
    + + """ + ); } diff --git a/tests/Elastic.Markdown.Tests/Directives/ChangelogHideLinksTests.cs b/tests/Elastic.Markdown.Tests/Directives/ChangelogHideLinksTests.cs index 73c2bd7cd5..31c2ed5153 100644 --- a/tests/Elastic.Markdown.Tests/Directives/ChangelogHideLinksTests.cs +++ b/tests/Elastic.Markdown.Tests/Directives/ChangelogHideLinksTests.cs @@ -5,8 +5,11 @@ using System.IO.Abstractions.TestingHelpers; using AwesomeAssertions; using Elastic.Documentation.Configuration.ReleaseNotes; +using Elastic.Documentation.Testing; using Elastic.Markdown.Myst.Directives.Changelog; using Markdig.Syntax; +using Nullean.Snapshots; +using Nullean.Snapshots.Html; namespace Elastic.Markdown.Tests.Directives; @@ -141,20 +144,29 @@ public void LoadPrivateRepositories_IncludesSkipTruePrivateRepos() } [Test] - public void RendersPrLinksForPublicRepo() - { - // elasticsearch is a public repo, so PR link should be visible in the output - Html.Should().Contain("123456"); - Html.Should().Contain("github.com"); - } - - [Test] - public void RendersIssueLinksForPublicRepo() - { - // elasticsearch is public, so issue links should be visible - Html.Should().Contain("78901"); - Html.Should().Contain("78902"); - } + public void RendersHtml() => + Html.Should().MatchInlineHtmlSnapshot( + html: DocsHtml.Body(), + expected: """ +
    +

    + 9.3.0 +

    +
    + + + """ + ); } /// @@ -772,7 +784,14 @@ public ChangelogLinkVisibilityInvalidTests() : base( public void LinkVisibilityFallsBackToAuto() => Block!.LinkVisibility.Should().Be(ChangelogLinkVisibility.Auto); [Test] - public void EmitsWarning() => Collector.Warnings.Should().BeGreaterThan(0); + public void EmitsWarning() => + Collector + .Diagnostics + .ToSnapshotText() + .Should() + .MatchInlineSnapshot( + "warning {repo}/docs/index.md:3 Invalid :link-visibility: value 'banana'. Valid values are: auto, keep-links, hide-links. Using auto." + ); } /// diff --git a/tests/Elastic.Markdown.Tests/Directives/ChangelogHighlightsOptionTests.cs b/tests/Elastic.Markdown.Tests/Directives/ChangelogHighlightsOptionTests.cs index ac0db68c88..501fc2a43e 100644 --- a/tests/Elastic.Markdown.Tests/Directives/ChangelogHighlightsOptionTests.cs +++ b/tests/Elastic.Markdown.Tests/Directives/ChangelogHighlightsOptionTests.cs @@ -4,7 +4,10 @@ using System.IO.Abstractions.TestingHelpers; using AwesomeAssertions; +using Elastic.Documentation.Testing; using Elastic.Markdown.Myst.Directives.Changelog; +using Nullean.Snapshots; +using Nullean.Snapshots.Html; namespace Elastic.Markdown.Tests.Directives; @@ -73,20 +76,7 @@ public ChangelogHighlightsOptionDefaultOffTests() : base( public void HighlightsDisabledByDefault() => Block!.HighlightsEnabled.Should().BeFalse(); [Test] - public void OmitsHighlightsSection() => Html.Should().NotContain("Highlights"); - - [Test] - public void StillRendersHighlightedEntryUnderTypeSection() - { - Html.Should().Contain("Features and enhancements"); - Html.Should().Contain("Highlighted feature"); - Html.Should().Contain("Regular feature"); - Html.Should().Contain("Fixes"); - Html.Should().Contain("Bug fix"); - } - - [Test] - public void ExcludesSeparatedTypesByDefault() => Html.Should().NotContain("Breaking changes"); + public void RendersHtml() => Html.Should().MatchHtmlSnapshot(DocsHtml.Body()); [Test] public void TocOmitsHighlights() @@ -113,18 +103,7 @@ public ChangelogHighlightsOptionEnabledTests() : base( public void HighlightsEnabledWhenFlagPresent() => Block!.HighlightsEnabled.Should().BeTrue(); [Test] - public void RendersHighlightsSection() => Html.Should().Contain("Highlights"); - - [Test] - public void DuplicatesHighlightedEntryInTypeSection() - { - Html.Should().Contain("Features and enhancements"); - Html.Should().Contain("Highlighted feature"); - Html.Should().Contain("Regular feature"); - } - - [Test] - public void ExcludesSeparatedTypesWithoutTypeAll() => Html.Should().NotContain("Breaking changes"); + public void RendersHtml() => Html.Should().MatchHtmlSnapshot(DocsHtml.Body()); [Test] public void TocIncludesHighlights() @@ -153,12 +132,7 @@ public ChangelogHighlightsOptionWithTypeAllTests() : base( ) => FileSystem.AddFile("docs/changelog/bundles/9.3.0.yaml", new MockFileData(ChangelogHighlightsFixtures.BundleYaml)); [Test] - public void RendersHighlightsAndSeparatedTypes() - { - Html.Should().Contain("Highlights"); - Html.Should().Contain("Breaking changes"); - Html.Should().Contain("Features and enhancements"); - } + public void RendersHtml() => Html.Should().MatchHtmlSnapshot(DocsHtml.Body()); } /// :type: all without :highlights: — no Highlights section (breaking change from prior All behavior). @@ -177,9 +151,7 @@ public ChangelogHighlightsOptionTypeAllWithoutFlagTests() : base( [Test] public void TypeAllAloneDoesNotEmitHighlightsSection() { - Html.Should().Contain("Breaking changes"); - Html.Should().Contain("Highlighted feature"); - Html.Should().NotContain("id=\"elasticsearch-9.3.0-highlights\""); + Html.Should().MatchHtmlSnapshot(DocsHtml.Body()); Block!.GeneratedTableOfContent.Should().NotContain(t => t.Heading == "Highlights"); } } @@ -207,21 +179,14 @@ public ChangelogHighlightsLegacyTypeHighlightTests() : base( public void EmitsWarningPointingToHighlightsOption() => Collector .Diagnostics + .ToSnapshotText() .Should() - .Contain( - d => d.Message.Contains("Invalid :type: value 'highlight'", StringComparison.Ordinal) && d.Message.Contains( - ":highlights:", - StringComparison.Ordinal - ) + .MatchInlineSnapshot( + "warning {repo}/docs/index.md:3 Invalid :type: value 'highlight'. Highlights are controlled with :highlights: (not :type:). Using default behavior." ); [Test] - public void RendersDefaultTypeSectionsNotHighlightsOnly() - { - Html.Should().Contain("Features and enhancements"); - Html.Should().Contain("Highlighted feature"); - Html.Should().NotContain("id=\"elasticsearch-9.3.0-highlights\""); - } + public void RendersHtml() => Html.Should().MatchHtmlSnapshot(DocsHtml.Body()); } /// :highlights: + :description-visibility: keep-descriptions shows bodies in the Highlights section. @@ -239,7 +204,7 @@ public ChangelogHighlightsOptionWithDescriptionsTests() : base( ) => FileSystem.AddFile("docs/changelog/bundles/9.3.0.yaml", new MockFileData(ChangelogHighlightsFixtures.BundleYaml)); [Test] - public void ShowsDescriptionInHighlightsSection() => Html.Should().Contain("This is the highlight description."); + public void RendersHtml() => Html.Should().MatchHtmlSnapshot(DocsHtml.Body()); } /// @@ -292,18 +257,7 @@ public void ParsesKeepHighlightDescriptions() => Block!.DescriptionVisibility.Should().Be(ChangelogDescriptionVisibility.KeepHighlightDescriptions); [Test] - public void ShowsDescriptionInHighlightsSection() => Html.Should().Contain("This is the highlight description."); - - [Test] - public void HidesDescriptionsInTypeSections() => Html.Should().NotContain("This is the regular feature description."); - - [Test] - public void StillRendersTitlesInTypeSections() - { - Html.Should().Contain("Features and enhancements"); - Html.Should().Contain("Highlighted feature"); - Html.Should().Contain("Regular feature"); - } + public void RendersHtml() => Html.Should().MatchHtmlSnapshot(DocsHtml.Body()); } /// keep-highlight-descriptions without :highlights: hides descriptions everywhere. @@ -349,19 +303,28 @@ public ChangelogKeepHighlightDescriptionsWithoutHighlightsTests() : base( ); [Test] - public void OmitsHighlightsSection() => Html.Should().NotContain("id=\"elasticsearch-9.3.0-highlights\""); - - [Test] - public void HidesAllRecordDescriptions() - { - Html.Should().NotContain("This is the highlight description."); - Html.Should().NotContain("This is the regular feature description."); - } - - [Test] - public void StillRendersTitles() - { - Html.Should().Contain("Highlighted feature"); - Html.Should().Contain("Regular feature"); - } + public void RendersHtml() => + Html.Should().MatchInlineHtmlSnapshot( + html: DocsHtml.Body(), + expected: """ +
    +

    + 9.3.0 +

    +
    + + + """ + ); } diff --git a/tests/Elastic.Markdown.Tests/Directives/ChangelogMergeTests.cs b/tests/Elastic.Markdown.Tests/Directives/ChangelogMergeTests.cs index a4e64b082d..19adb78cab 100644 --- a/tests/Elastic.Markdown.Tests/Directives/ChangelogMergeTests.cs +++ b/tests/Elastic.Markdown.Tests/Directives/ChangelogMergeTests.cs @@ -4,7 +4,9 @@ using System.IO.Abstractions.TestingHelpers; using AwesomeAssertions; +using Elastic.Documentation.Testing; using Elastic.Markdown.Myst.Directives.Changelog; +using Nullean.Snapshots.Html; namespace Elastic.Markdown.Tests.Directives; @@ -159,13 +161,7 @@ public void RendersOnlyOneVersionHeaderPerMergedTarget() } [Test] - public void RendersAllEntriesFromMergedBundles() - { - Html.Should().Contain("Kibana feature for August 5th"); - Html.Should().Contain("Elasticsearch feature for August 5th"); - Html.Should().Contain("Elasticsearch bugfix for August 5th"); - Html.Should().Contain("Serverless feature for August 5th"); - } + public void RendersHtml() => Html.Should().MatchHtmlSnapshot(DocsHtml.Body()); [Test] public void MaintainsCorrectDateOrder() @@ -274,12 +270,7 @@ public void KeepsDifferentTargetsSeparate() } [Test] - public void RendersAllVersionsSeparately() - { - Html.Should().Contain("9.3.0"); - Html.Should().Contain("9.2.0"); - Html.Should().Contain("9.1.0"); - } + public void RendersHtml() => Html.Should().MatchHtmlSnapshot(DocsHtml.Body()); [Test] public void MaintainsSemverOrder() @@ -343,11 +334,7 @@ public ChangelogMergeSingleBundleTests() : base( public void SingleBundleHasAllEntries() => Block!.LoadedBundles[0].Entries.Should().HaveCount(2); [Test] - public void SingleBundleRendersCorrectly() - { - Html.Should().Contain("Feature in 9.3.0"); - Html.Should().Contain("Bug fix in 9.3.0"); - } + public void RendersHtml() => Html.Should().MatchHtmlSnapshot(DocsHtml.Body()); } /// @@ -415,9 +402,5 @@ public void MixedVersionTypesRemainSeparate() } [Test] - public void RendersAllVersions() - { - Html.Should().Contain("9.3.0"); - Html.Should().Contain("August 5, 2025"); - } + public void RendersHtml() => Html.Should().MatchHtmlSnapshot(DocsHtml.Body()); } diff --git a/tests/Elastic.Markdown.Tests/Directives/ChangelogMissingFileTests.cs b/tests/Elastic.Markdown.Tests/Directives/ChangelogMissingFileTests.cs index a5f2619d96..7af2a3d831 100644 --- a/tests/Elastic.Markdown.Tests/Directives/ChangelogMissingFileTests.cs +++ b/tests/Elastic.Markdown.Tests/Directives/ChangelogMissingFileTests.cs @@ -5,7 +5,9 @@ using System.IO.Abstractions.TestingHelpers; using AwesomeAssertions; using Elastic.Documentation.Diagnostics; +using Elastic.Documentation.Testing; using Elastic.Markdown.Myst.Directives.Changelog; +using Nullean.Snapshots; namespace Elastic.Markdown.Tests.Directives; @@ -65,17 +67,12 @@ public ChangelogEntryWithoutInlineContentTests() : base( public void EmitsErrorNamingBundleAndEntry() => Collector .Diagnostics + .ToSnapshotText() .Should() - .ContainSingle( - d => d.Severity == Severity.Error && d.Message.Contains("9.3.0.yaml") && d.Message.Contains( - "1234-referenced-entry.yaml" - ) && d.Message.Contains("no inline content") + .MatchInlineSnapshot( + "error {repo}/docs/index.md:3 Bundle '9.3.0.yaml' entry '1234-referenced-entry.yaml' has no inline content (title and type are required); bundles must inline their entries. Skipping." ); - [Test] - public void ErrorIsNotAWarning() => - Collector.Diagnostics.Should().NotContain(d => d.Severity == Severity.Warning && d.Message.Contains("1234-referenced-entry.yaml")); - [Test] public void NeverLoadsTheReferencedFile() => Block!.LoadedBundles.Should().ContainSingle(b => b.Entries.Count == 0); } @@ -116,7 +113,7 @@ public ChangelogInlineEntriesNoErrorTests() : base( ); [Test] - public void HasNoDiagnostics() => Collector.Diagnostics.Should().BeEmpty(); + public void HasNoDiagnostics() => Collector.Diagnostics.ToSnapshotText().Should().MatchInlineSnapshot(""); [Test] public void LoadsEntries() => Block!.LoadedBundles.Should().ContainSingle(b => b.Entries.Count == 1); diff --git a/tests/Elastic.Markdown.Tests/Directives/ChangelogPathResolutionTests.cs b/tests/Elastic.Markdown.Tests/Directives/ChangelogPathResolutionTests.cs index 26f79206b0..869da4ff72 100644 --- a/tests/Elastic.Markdown.Tests/Directives/ChangelogPathResolutionTests.cs +++ b/tests/Elastic.Markdown.Tests/Directives/ChangelogPathResolutionTests.cs @@ -4,7 +4,9 @@ using System.IO.Abstractions.TestingHelpers; using AwesomeAssertions; +using Elastic.Documentation.Testing; using Elastic.Markdown.Myst.Directives.Changelog; +using Nullean.Snapshots.Html; namespace Elastic.Markdown.Tests.Directives; @@ -51,7 +53,27 @@ public void PathCombinedWithDocsetRoot() => Block!.BundlesFolderPath.Should().EndWith("custom/path/bundles".Replace('/', Path.DirectorySeparatorChar)); [Test] - public void RendersContent() => Html.Should().Contain("Test feature"); + public void RendersHtml() => + Html.Should().MatchInlineHtmlSnapshot( + html: DocsHtml.Body(), + expected: """ +
    +

    + 1.0.0 +

    +
    + +
      +
    • Test feature. + #12345 +
    • +
    + """ + ); } [InheritsTests] @@ -95,7 +117,27 @@ public void SlashPrefixIsTrimmed() => public void PathDoesNotContainDoubleSlashes() => Block!.BundlesFolderPath.Should().NotContain("//"); [Test] - public void RendersContent() => Html.Should().Contain("Another feature"); + public void RendersHtml() => + Html.Should().MatchInlineHtmlSnapshot( + html: DocsHtml.Body(), + expected: """ +
    +

    + 2.0.0 +

    +
    + +
      +
    • Another feature. + #67890 +
    • +
    + """ + ); } [InheritsTests] @@ -159,12 +201,7 @@ public ChangelogConfigRelativePathTests() : base( public void PublishBlockerIsNull() => Block!.PublishBlocker.Should().BeNull(); [Test] - public void RendersAllEntries_NoFiltering() - { - // Directive does not apply rules.publish; all entries are shown - Html.Should().Contain("Feature entry"); - Html.Should().Contain("Blocked entry"); - } + public void RendersHtml() => Html.Should().MatchHtmlSnapshot(DocsHtml.Body()); } [InheritsTests] @@ -226,12 +263,30 @@ public ChangelogConfigDocsetRootRelativePathTests() : base( public void PublishBlockerIsNull() => Block!.PublishBlocker.Should().BeNull(); [Test] - public void RendersAllEntries_NoFiltering() - { - // Directive does not apply rules.publish; all entries are shown - Html.Should().Contain("Regular feature"); - Html.Should().Contain("Internal feature"); - } + public void RendersHtml() => + Html.Should().MatchInlineHtmlSnapshot( + html: DocsHtml.Body(), + expected: """ +
    +

    + 1.0.0 +

    +
    + +
      +
    • Regular feature. + #33333 +
    • +
    • Internal feature. + #44444 +
    • +
    + """ + ); } [InheritsTests] @@ -268,7 +323,27 @@ public ChangelogBundlesFolderNestedRelativePathTests() : base( public void ResolvesDeepNestedPath() => Block!.Found.Should().BeTrue(); [Test] - public void RendersContent() => Html.Should().Contain("Nested feature"); + public void RendersHtml() => + Html.Should().MatchInlineHtmlSnapshot( + html: DocsHtml.Body(), + expected: """ +
    +

    + 3.0.0 +

    +
    + +
      +
    • Nested feature. + #99999 +
    • +
    + """ + ); } /// @@ -318,7 +393,27 @@ public ChangelogPathEdgeCaseTests() : base( public void ResolvesSlashPrefixedPath() => Block!.Found.Should().BeTrue(); [Test] - public void RendersContent() => Html.Should().Contain("Edge case feature"); + public void RendersHtml() => + Html.Should().MatchInlineHtmlSnapshot( + html: DocsHtml.Body(), + expected: """ +
    +

    + 1.0.0 +

    +
    + +
      +
    • Edge case feature. + #55555 +
    • +
    + """ + ); } [InheritsTests] @@ -382,10 +477,5 @@ public void BothPathsResolveCorrectly() } [Test] - public void RendersAllEntries_NoFiltering() - { - // Directive does not apply rules.publish; all entries are shown - Html.Should().Contain("Combined feature"); - Html.Should().Contain("Blocked by config"); - } + public void RendersHtml() => Html.Should().MatchHtmlSnapshot(DocsHtml.Body()); } diff --git a/tests/Elastic.Markdown.Tests/Directives/ChangelogReleaseDatesOptionTests.cs b/tests/Elastic.Markdown.Tests/Directives/ChangelogReleaseDatesOptionTests.cs index 2441e7d574..57346b084d 100644 --- a/tests/Elastic.Markdown.Tests/Directives/ChangelogReleaseDatesOptionTests.cs +++ b/tests/Elastic.Markdown.Tests/Directives/ChangelogReleaseDatesOptionTests.cs @@ -4,7 +4,9 @@ using System.IO.Abstractions.TestingHelpers; using AwesomeAssertions; +using Elastic.Documentation.Testing; using Elastic.Markdown.Myst.Directives.Changelog; +using Nullean.Snapshots.Html; namespace Elastic.Markdown.Tests.Directives; @@ -44,10 +46,27 @@ public ChangelogReleaseDatesOptionDefaultOffTests() : base( public void ReleaseDatesDisabledByDefault() => Block!.ReleaseDatesEnabled.Should().BeFalse(); [Test] - public void OmitsReleasedLineWhenFlagOmitted() => Html.Should().NotContain("Released:"); - - [Test] - public void StillRendersEntries() => Html.Should().Contain("Add tracing improvements"); + public void RendersHtml() => + Html.Should().MatchInlineHtmlSnapshot( + html: DocsHtml.Body(), + expected: """ +
    +

    + 1.34.0 +

    +
    + +
      +
    • Add tracing improvements. + #500 +
    • +
    + """ + ); } [InheritsTests] @@ -86,7 +105,30 @@ public ChangelogReleaseDatesOptionEnabledTests() : base( public void ReleaseDatesEnabledWhenFlagPresent() => Block!.ReleaseDatesEnabled.Should().BeTrue(); [Test] - public void RendersReleasedLineWhenBundleHasReleaseDate() => Html.Should().Contain("Released: April 9, 2026"); + public void RendersHtml() => + Html.Should().MatchInlineHtmlSnapshot( + html: DocsHtml.Body(), + expected: """ +
    +

    + 1.34.0 +

    +
    +

    + Released: April 9, 2026 +

    + +
      +
    • Add tracing improvements. + #500 +
    • +
    + """ + ); } [InheritsTests] @@ -121,7 +163,27 @@ public ChangelogReleaseDatesOptionEnabledWithoutBundleDateTests() : base( ); [Test] - public void OmitsReleasedLineWhenBundleHasNoReleaseDate() => Html.Should().NotContain("Released:"); + public void RendersHtml() => + Html.Should().MatchInlineHtmlSnapshot( + html: DocsHtml.Body(), + expected: """ +
    +

    + 9.3.0 +

    +
    + +
      +
    • New feature. + #100 +
    • +
    + """ + ); } [InheritsTests] @@ -158,8 +220,26 @@ This release includes tracing improvements and bug fixes. ); [Test] - public void OmitsReleasedLineWhenFlagOmitted() => Html.Should().NotContain("Released:"); - - [Test] - public void RendersBundleDescription() => Html.Should().Contain("This release includes tracing improvements and bug fixes."); + public void RendersHtml() => + Html.Should().MatchInlineHtmlSnapshot( + html: DocsHtml.Body(), + expected: """ +
    +

    + 1.34.0 +

    +
    +

    This release includes tracing improvements and bug fixes.

    + +
      +
    • Add tracing improvements. + #500 +
    • +
    + """ + ); } diff --git a/tests/Elastic.Markdown.Tests/Directives/ChangelogSubsectionsTests.cs b/tests/Elastic.Markdown.Tests/Directives/ChangelogSubsectionsTests.cs index a3b92d57e3..a88fb7e1fd 100644 --- a/tests/Elastic.Markdown.Tests/Directives/ChangelogSubsectionsTests.cs +++ b/tests/Elastic.Markdown.Tests/Directives/ChangelogSubsectionsTests.cs @@ -4,7 +4,9 @@ using System.IO.Abstractions.TestingHelpers; using AwesomeAssertions; +using Elastic.Documentation.Testing; using Elastic.Markdown.Myst.Directives.Changelog; +using Nullean.Snapshots.Html; namespace Elastic.Markdown.Tests.Directives; @@ -53,20 +55,30 @@ public ChangelogSubsectionsDisabledByDefaultTests() : base( public void SubsectionsPropertyDefaultsToFalse() => Block!.Subsections.Should().BeFalse(); [Test] - public void DoesNotRenderAreaHeaders() - { - // When subsections is false, area headers should not be rendered - Html.Should().NotContain("Search"); - Html.Should().NotContain("Indexing"); - } - - [Test] - public void RendersEntriesWithoutGrouping() - { - // Both entries should be rendered without area grouping - Html.Should().Contain("Feature in Search"); - Html.Should().Contain("Feature in Indexing"); - } + public void RendersHtml() => + Html.Should().MatchInlineHtmlSnapshot( + html: DocsHtml.Body(), + expected: """ +
    +

    + 9.3.0 +

    +
    + +
      +
    • Feature in Search. + #111111 +
    • +
    • Feature in Indexing. + #222222 +
    • +
    + """ + ); } [InheritsTests] @@ -115,20 +127,7 @@ public ChangelogSubsectionsEnabledTests() : base( public void SubsectionsPropertyIsTrue() => Block!.Subsections.Should().BeTrue(); [Test] - public void RendersAreaHeaders() - { - // When subsections is true, area headers should be rendered - Html.Should().Contain("Search"); - Html.Should().Contain("Indexing"); - } - - [Test] - public void RendersEntriesUnderCorrectAreas() - { - // Both entries should be rendered - Html.Should().Contain("Feature in Search"); - Html.Should().Contain("Feature in Indexing"); - } + public void RendersHtml() => Html.Should().MatchHtmlSnapshot(DocsHtml.Body()); } [InheritsTests] @@ -168,7 +167,27 @@ public ChangelogSubsectionsExplicitFalseTests() : base( public void SubsectionsPropertyIsFalse() => Block!.Subsections.Should().BeFalse(); [Test] - public void DoesNotRenderAreaHeaders() => Html.Should().NotContain("Search"); + public void RendersHtml() => + Html.Should().MatchInlineHtmlSnapshot( + html: DocsHtml.Body(), + expected: """ +
    +

    + 9.3.0 +

    +
    + +
      +
    • Feature in Search. + #111111 +
    • +
    + """ + ); } /// @@ -214,10 +233,28 @@ public ChangelogSubsectionsNoAreaRulesTests() : base( ); [Test] - public void GroupsUnderFirstArea() - { - // No publish rules with areas → use first area - Html.Should().Contain("Search"); - Html.Should().Contain("Multi-area feature"); - } + public void RendersHtml() => + Html.Should().MatchInlineHtmlSnapshot( + html: DocsHtml.Body(), + expected: """ +
    +

    + 9.3.0 +

    +
    + +

    + Search +

    +
      +
    • Multi-area feature. + #111111 +
    • +
    + """ + ); } diff --git a/tests/Elastic.Markdown.Tests/Directives/ChangelogTocFilteringTests.cs b/tests/Elastic.Markdown.Tests/Directives/ChangelogTocFilteringTests.cs index ec439f77bf..329d80da77 100644 --- a/tests/Elastic.Markdown.Tests/Directives/ChangelogTocFilteringTests.cs +++ b/tests/Elastic.Markdown.Tests/Directives/ChangelogTocFilteringTests.cs @@ -4,7 +4,10 @@ using System.IO.Abstractions.TestingHelpers; using AwesomeAssertions; +using Elastic.Documentation.Testing; using Elastic.Markdown.Myst.Directives.Changelog; +using Nullean.Snapshots; +using Nullean.Snapshots.Html; namespace Elastic.Markdown.Tests.Directives; @@ -119,12 +122,7 @@ public void AnchorsIncludeOtherSection() } [Test] - public void HtmlContainsAllSections() - { - Html.Should().Contain("Documentation"); - Html.Should().Contain("Other changes"); - Html.Should().Contain("Features and enhancements"); - } + public void RendersHtml() => Html.Should().MatchHtmlSnapshot(DocsHtml.Body()); } /// @@ -211,13 +209,27 @@ public void AnchorsRetainVisibleFeaturesSection() } [Test] - public void HtmlMatchesTocFiltering() - { - Html.Should().NotContain("Other changes"); - Html.Should().NotContain("Hidden other change"); - Html.Should().Contain("Features and enhancements"); - Html.Should().Contain("Visible feature"); - } + public void RendersHtml() => + Html.Should().MatchInlineHtmlSnapshot( + html: DocsHtml.Body(), + expected: """ +
    +

    + 9.3.0 +

    +
    + + + """ + ); } /// @@ -278,11 +290,27 @@ public void AnchorsRetainSectionWhenSomeEntriesRemain() } [Test] - public void HtmlShowsVisibleEntryOnly() - { - Html.Should().Contain("Visible other change"); - Html.Should().NotContain("Hidden other change"); - } + public void RendersHtml() => + Html.Should().MatchInlineHtmlSnapshot( + html: DocsHtml.Body(), + expected: """ +
    +

    + 9.3.0 +

    +
    +
    +

    + Other changes +

    +
    +
      +
    • Visible other change. + #111111 +
    • +
    + """ + ); } /// @@ -383,15 +411,7 @@ public void AnchorsExcludeOnlyHideFeatureFilteredSection() } [Test] - public void HtmlMatchesTocAndAnchors() - { - Html.Should().Contain("Features and enhancements"); - Html.Should().Contain("Visible feature"); - Html.Should().Contain("Documentation"); - Html.Should().Contain("Docs entry blocked by type"); - Html.Should().NotContain(">Fixes<"); - Html.Should().NotContain("Bug fix hidden by feature"); - } + public void RendersHtml() => Html.Should().MatchHtmlSnapshot(DocsHtml.Body()); } /// @@ -549,7 +569,11 @@ public void OmitsVersionFromTocWhenNoRenderableEntries() } [Test] - public void OmitsVersionFromRenderedOutput() => Html.Should().NotContain("9.3.0"); + public void OmitsVersionFromRenderedOutput() + { + Html.Should().MatchInlineHtmlSnapshot(html: DocsHtml.Body(), expected: ""); + Collector.Diagnostics.ToSnapshotText().Should().MatchInlineSnapshot(""); + } [Test] public void NoAnchorsGenerated() diff --git a/tests/Elastic.Markdown.Tests/Directives/ChangelogTypeFilterTests.cs b/tests/Elastic.Markdown.Tests/Directives/ChangelogTypeFilterTests.cs index 9b59b69299..2fac1f38bb 100644 --- a/tests/Elastic.Markdown.Tests/Directives/ChangelogTypeFilterTests.cs +++ b/tests/Elastic.Markdown.Tests/Directives/ChangelogTypeFilterTests.cs @@ -4,7 +4,10 @@ using System.IO.Abstractions.TestingHelpers; using AwesomeAssertions; +using Elastic.Documentation.Testing; using Elastic.Markdown.Myst.Directives.Changelog; +using Nullean.Snapshots; +using Nullean.Snapshots.Html; namespace Elastic.Markdown.Tests.Directives; @@ -87,39 +90,7 @@ public ChangelogTypeFilterDefaultTests() : base( public void DefaultBehaviorExcludesSeparatedTypes() => Block!.TypeFilter.Should().Be(ChangelogTypeFilter.Default); [Test] - public void DefaultBehaviorShowsFeatures() - { - Html.Should().Contain("Features and enhancements"); - Html.Should().Contain("New feature"); - } - - [Test] - public void DefaultBehaviorShowsBugFixes() - { - Html.Should().Contain(">Fixes<"); - Html.Should().Contain("Bug fix"); - } - - [Test] - public void DefaultBehaviorExcludesBreakingChanges() - { - Html.Should().NotContain("Breaking changes"); - Html.Should().NotContain("Breaking API change"); - } - - [Test] - public void DefaultBehaviorExcludesKnownIssues() - { - Html.Should().NotContain("Known issues"); - Html.Should().NotContain("Known issue"); - } - - [Test] - public void DefaultBehaviorExcludesDeprecations() - { - Html.Should().NotContain("Deprecations"); - Html.Should().NotContain("Deprecated feature"); - } + public void RendersHtml() => Html.Should().MatchHtmlSnapshot(DocsHtml.Body()); } /// @@ -197,19 +168,7 @@ public ChangelogTypeFilterAllTests() : base( public void TypeFilterIsAll() => Block!.TypeFilter.Should().Be(ChangelogTypeFilter.All); [Test] - public void ShowsAllEntryTypes() - { - Html.Should().Contain("Features and enhancements"); - Html.Should().Contain("New feature"); - Html.Should().Contain(">Fixes<"); - Html.Should().Contain("Bug fix"); - Html.Should().Contain("Breaking changes"); - Html.Should().Contain("Breaking API change"); - Html.Should().Contain("Known issues"); - Html.Should().Contain("Known issue"); - Html.Should().Contain("Deprecations"); - Html.Should().Contain("Deprecated feature"); - } + public void RendersHtml() => Html.Should().MatchHtmlSnapshot(DocsHtml.Body()); [Test] public void TableOfContentsIncludesSeparatedTypeSections() @@ -293,21 +252,30 @@ public ChangelogTypeFilterBreakingChangeTests() : base( public void TypeFilterIsBreakingChange() => Block!.TypeFilter.Should().Be(ChangelogTypeFilter.BreakingChange); [Test] - public void ShowsBreakingChanges() - { - Html.Should().NotContain("### Breaking changes"); - Html.Should().NotContain(">Breaking changes<"); - Html.Should().Contain("Breaking API change"); - } - - [Test] - public void ExcludesOtherTypes() - { - Html.Should().NotContain("Features and enhancements"); - Html.Should().NotContain("New feature"); - Html.Should().NotContain("Known issues"); - Html.Should().NotContain("Known issue"); - } + public void RendersHtml() => + Html.Should().MatchInlineHtmlSnapshot( + html: DocsHtml.Body(), + expected: """ +
    +

    + 9.3.0 +

    +
    +
      +
    • +

      Breaking API change. + #333333 +

      +

      + Impact: + Users must update.

      +

      + Action: + Follow guide.

      +
    • +
    + """ + ); } /// @@ -368,20 +336,7 @@ public ChangelogTypeFilterDeprecationTests() : base( public void TypeFilterIsDeprecation() => Block!.TypeFilter.Should().Be(ChangelogTypeFilter.Deprecation); [Test] - public void ShowsDeprecations() - { - Html.Should().NotContain("### Deprecations"); - Html.Should().NotContain(">Deprecations<"); - Html.Should().Contain("Deprecated feature"); - Html.Should().Contain("Another deprecation"); - } - - [Test] - public void ExcludesOtherTypes() - { - Html.Should().NotContain("Features and enhancements"); - Html.Should().NotContain("New feature"); - } + public void RendersHtml() => Html.Should().MatchHtmlSnapshot(DocsHtml.Body()); } /// @@ -442,20 +397,7 @@ public ChangelogTypeFilterKnownIssueTests() : base( public void TypeFilterIsKnownIssue() => Block!.TypeFilter.Should().Be(ChangelogTypeFilter.KnownIssue); [Test] - public void ShowsKnownIssues() - { - Html.Should().NotContain("### Known issues"); - Html.Should().NotContain(">Known issues<"); - Html.Should().Contain("Known issue 1"); - Html.Should().Contain("Known issue 2"); - } - - [Test] - public void ExcludesOtherTypes() - { - Html.Should().NotContain("Features and enhancements"); - Html.Should().NotContain("New feature"); - } + public void RendersHtml() => Html.Should().MatchHtmlSnapshot(DocsHtml.Body()); } /// @@ -506,15 +448,37 @@ public ChangelogTypeFilterInvalidTests() : base( public void FallsBackToDefaultBehavior() => Block!.TypeFilter.Should().Be(ChangelogTypeFilter.Default); [Test] - public void EmitsWarningForInvalidValue() => Collector.Diagnostics.Should().Contain(d => d.Message.Contains("Invalid :type: value")); + public void EmitsWarningForInvalidValue() => + Collector + .Diagnostics + .ToSnapshotText() + .Should() + .MatchInlineSnapshot( + "warning {repo}/docs/index.md:3 Invalid :type: value 'invalid-value'. Valid values are: all, breaking-change, deprecation, known-issue. Using default behavior." + ); [Test] - public void DefaultBehaviorIsApplied() - { - Html.Should().Contain("Features and enhancements"); - Html.Should().Contain("New feature"); - Html.Should().NotContain("Breaking changes"); - } + public void RendersHtml() => + Html.Should().MatchInlineHtmlSnapshot( + html: DocsHtml.Body(), + expected: """ +
    +

    + 9.3.0 +

    +
    + + + """ + ); } /// @@ -565,11 +529,7 @@ public ChangelogTypeFilterCaseInsensitiveTests() : base( public void AcceptsUppercaseAll() => Block!.TypeFilter.Should().Be(ChangelogTypeFilter.All); [Test] - public void ShowsAllTypes() - { - Html.Should().Contain("Features and enhancements"); - Html.Should().Contain("Breaking changes"); - } + public void RendersHtml() => Html.Should().MatchHtmlSnapshot(DocsHtml.Body()); } /// @@ -636,13 +596,7 @@ public void TypeFilterAndSubsectionsBothWork() } [Test] - public void ShowsAllTypesWithSubsections() - { - Html.Should().Contain("Features and enhancements"); - Html.Should().Contain("Search feature"); - Html.Should().Contain("Indexing feature"); - Html.Should().Contain("Breaking changes"); - } + public void RendersHtml() => Html.Should().MatchHtmlSnapshot(DocsHtml.Body()); } /// @@ -791,8 +745,8 @@ public ChangelogTypeFilterEmptyKnownIssueTests() : base( [Test] public void OmitsEmptyVersionBlock() { - Html.Should().NotContain("There are no known issues associated with this release"); - Html.Should().NotContain("9.3.0"); + Html.Should().MatchInlineHtmlSnapshot(html: DocsHtml.Body(), expected: ""); + Collector.Diagnostics.ToSnapshotText().Should().MatchInlineSnapshot(""); } } @@ -833,8 +787,8 @@ public ChangelogTypeFilterEmptyBreakingChangeTests() : base( [Test] public void OmitsEmptyVersionBlock() { - Html.Should().NotContain("There are no breaking changes associated with this release"); - Html.Should().NotContain("9.3.0"); + Html.Should().MatchInlineHtmlSnapshot(html: DocsHtml.Body(), expected: ""); + Collector.Diagnostics.ToSnapshotText().Should().MatchInlineSnapshot(""); } } @@ -875,8 +829,8 @@ public ChangelogTypeFilterEmptyDeprecationTests() : base( [Test] public void OmitsEmptyVersionBlock() { - Html.Should().NotContain("There are no deprecations associated with this release"); - Html.Should().NotContain("9.3.0"); + Html.Should().MatchInlineHtmlSnapshot(html: DocsHtml.Body(), expected: ""); + Collector.Diagnostics.ToSnapshotText().Should().MatchInlineSnapshot(""); } } @@ -919,8 +873,8 @@ public ChangelogTypeFilterEmptyDefaultTests() : base( [Test] public void OmitsEmptyVersionBlock() { - Html.Should().NotContain("No new features, enhancements, or fixes"); - Html.Should().NotContain("9.3.0"); + Html.Should().MatchInlineHtmlSnapshot(html: DocsHtml.Body(), expected: ""); + Collector.Diagnostics.ToSnapshotText().Should().MatchInlineSnapshot(""); } } @@ -954,8 +908,8 @@ public ChangelogTypeFilterEmptyAllTests() : base( [Test] public void OmitsEmptyVersionBlock() { - Html.Should().NotContain("No new features, enhancements, or fixes"); - Html.Should().NotContain("9.3.0"); + Html.Should().MatchInlineHtmlSnapshot(html: DocsHtml.Body(), expected: ""); + Collector.Diagnostics.ToSnapshotText().Should().MatchInlineSnapshot(""); } } @@ -1018,12 +972,30 @@ public ChangelogTypeFilterMixedBundlesEmptyOmissionTests() : base( } [Test] - public void RendersOnlyPopulatedVersions() - { - Html.Should().Contain("Known issue in 9.3"); - Html.Should().Contain("9.3.0"); - Html.Should().NotContain("9.2.0"); - } + public void RendersHtml() => + Html.Should().MatchInlineHtmlSnapshot( + html: DocsHtml.Body(), + expected: """ +
    +

    + 9.3.0 +

    +
    +
      +
    • +

      Known issue in 9.3. + #444444 +

      +

      + Impact: + Some impact.

      +

      + Action: + Workaround available.

      +
    • +
    + """ + ); } /// @@ -1056,12 +1028,18 @@ This release was pulled due to critical issues. ); [Test] - public void ShowsVersionAndDescriptionWithoutPlaceholder() - { - Html.Should().Contain("9.3.0"); - Html.Should().Contain("This release was pulled due to critical issues"); - Html.Should().NotContain("No new features, enhancements, or fixes"); - } + public void RendersHtml() => + Html.Should().MatchInlineHtmlSnapshot( + html: DocsHtml.Body(), + expected: """ +
    +

    + 9.3.0 +

    +
    +

    This release was pulled due to critical issues.

    + """ + ); } /// @@ -1095,8 +1073,8 @@ public ChangelogEmptyBundleWithReleaseDateOnlyTests() : base( [Test] public void OmitsVersionBlockWhenOnlyReleaseDate() { - Html.Should().NotContain("9.3.0"); - Html.Should().NotContain("Released:"); + Html.Should().MatchInlineHtmlSnapshot(html: DocsHtml.Body(), expected: ""); + Collector.Diagnostics.ToSnapshotText().Should().MatchInlineSnapshot(""); } } @@ -1139,8 +1117,8 @@ public ChangelogDedicatedPageIgnoresDescriptionTests() : base( [Test] public void OmitsVersionBlockWhenNoMatchingEntries() { - Html.Should().NotContain("9.3.0"); - Html.Should().NotContain("General release notes for this version"); + Html.Should().MatchInlineHtmlSnapshot(html: DocsHtml.Body(), expected: ""); + Collector.Diagnostics.ToSnapshotText().Should().MatchInlineSnapshot(""); } } @@ -1197,14 +1175,5 @@ public ChangelogDedicatedPageWithSubsectionsTests() : base( ); [Test] - public void GroupsEntriesByAreaWithoutSectionHeading() - { - Html.Should().NotContain("### Deprecations"); - Html.Should().NotContain(">Deprecations<"); - Html.Should().NotContain("{dropdown}"); - Html.Should().Contain("Search"); - Html.Should().Contain("Search deprecation"); - Html.Should().Contain("Indexing"); - Html.Should().Contain("Indexing deprecation"); - } + public void RendersHtml() => Html.Should().MatchHtmlSnapshot(DocsHtml.Body()); } diff --git a/tests/Elastic.Markdown.Tests/Directives/ChangelogVersionSortingTests.cs b/tests/Elastic.Markdown.Tests/Directives/ChangelogVersionSortingTests.cs index 34a1512857..7a0ffbff80 100644 --- a/tests/Elastic.Markdown.Tests/Directives/ChangelogVersionSortingTests.cs +++ b/tests/Elastic.Markdown.Tests/Directives/ChangelogVersionSortingTests.cs @@ -4,7 +4,9 @@ using System.IO.Abstractions.TestingHelpers; using AwesomeAssertions; +using Elastic.Documentation.Testing; using Elastic.Markdown.Myst.Directives.Changelog; +using Nullean.Snapshots.Html; namespace Elastic.Markdown.Tests.Directives; @@ -97,20 +99,7 @@ public void RendersInDateOrderDescending() } [Test] - public void RendersAllDateVersions() - { - Html.Should().Contain("August 15, 2025"); - Html.Should().Contain("August 5, 2025"); - Html.Should().Contain("August 1, 2025"); - } - - [Test] - public void RendersEntriesForDateVersions() - { - Html.Should().Contain("August 15th feature"); - Html.Should().Contain("August 5th feature"); - Html.Should().Contain("August 1st feature"); - } + public void RendersHtml() => Html.Should().MatchHtmlSnapshot(DocsHtml.Body()); } [InheritsTests] @@ -230,22 +219,7 @@ public void SemverVersionsAppearBeforeDates() } [Test] - public void RendersAllVersions() - { - Html.Should().Contain("9.3.0"); - Html.Should().Contain("9.2.0"); - Html.Should().Contain("August 5, 2025"); - Html.Should().Contain("July 1, 2025"); - } - - [Test] - public void RendersAllEntries() - { - Html.Should().Contain("Semver 9.3.0 feature"); - Html.Should().Contain("Semver 9.2.0 feature"); - Html.Should().Contain("Date-based feature"); - Html.Should().Contain("Earlier date feature"); - } + public void RendersHtml() => Html.Should().MatchHtmlSnapshot(DocsHtml.Body()); } /// @@ -336,21 +310,7 @@ public ChangelogYearMonthVersionTests() : base( public void LoadsBundles() => Block!.LoadedBundles.Should().HaveCount(3); [Test] - public void RendersHeadingsAsMonthYear() - { - Html.Should().Contain("December 2025"); - Html.Should().Contain("October 2025"); - Html.Should().Contain("August 2025"); - } - - [Test] - public void DoesNotRenderRawYearMonthInHeadings() - { - // The raw yyyy-MM format should only appear in slugs/anchors, not in visible headings - Html.Should().NotContain(">2025-12<"); - Html.Should().NotContain(">2025-10<"); - Html.Should().NotContain(">2025-08<"); - } + public void RendersHtml() => Html.Should().MatchHtmlSnapshot(DocsHtml.Body()); [Test] public void RendersInDescendingMonthOrder() @@ -363,24 +323,6 @@ public void RendersInDescendingMonthOrder() idxOct.Should().BeLessThan(idxAug, "October 2025 should appear before August 2025"); } - [Test] - public void PreservesOriginalSlugsForAnchors() - { - // Anchors should use the original yyyy-MM format, not the display format - Html.Should().Contain("2025-12"); - Html.Should().Contain("2025-10"); - Html.Should().Contain("2025-08"); - } - - [Test] - public void RendersAllEntries() - { - Html.Should().Contain("December feature"); - Html.Should().Contain("October feature"); - Html.Should().Contain("August feature"); - Html.Should().Contain("August bugfix"); - } - [Test] public void TocUsesMonthYearHeadings() { @@ -463,14 +405,7 @@ public ChangelogRawVersionFallbackTests() : base( public void LoadsBundles() => Block!.LoadedBundles.Should().HaveCount(2); [Test] - public void RendersNonStandardVersions() - { - // Both non-standard versions should be rendered (sorted lexicographically) - Html.Should().Contain("release-alpha"); - Html.Should().Contain("release-beta"); - Html.Should().Contain("Alpha release feature"); - Html.Should().Contain("Beta release feature"); - } + public void RendersHtml() => Html.Should().MatchHtmlSnapshot(DocsHtml.Body()); [Test] public void SortsLexicographically() diff --git a/tests/Elastic.Markdown.Tests/Directives/ChangelogVersionVisibilityTests.cs b/tests/Elastic.Markdown.Tests/Directives/ChangelogVersionVisibilityTests.cs index 3932e94f97..a3185b08c4 100644 --- a/tests/Elastic.Markdown.Tests/Directives/ChangelogVersionVisibilityTests.cs +++ b/tests/Elastic.Markdown.Tests/Directives/ChangelogVersionVisibilityTests.cs @@ -6,7 +6,10 @@ using Elastic.Documentation.Configuration.Assembler; using Elastic.Documentation.Configuration.ReleaseNotes; using Elastic.Documentation.Diagnostics; +using Elastic.Documentation.Testing; using Elastic.Markdown.Myst.Directives.Changelog; +using Nullean.Snapshots; +using Nullean.Snapshots.Html; namespace Elastic.Markdown.Tests.Directives; @@ -76,15 +79,37 @@ public class ChangelogVisibilityOnProductionTests() : ChangelogVersionVisibility protected override ContentSource? GetContentSource() => ContentSource.Current; [Test] - public void HidesBundlesTargetingUnreleasedVersions() - { - Html.Should().Contain(ReleasedTitle); - Html.Should().NotContain(UnreleasedTitle, "8.1.0 is newer than the current release (8.0.0) and production publishes 'current'"); - } + public void HidesBundlesTargetingUnreleasedVersions() => + Html.Should().MatchInlineHtmlSnapshot( + html: DocsHtml.Body(), + expected: """ +
    +

    + 7.9.0 +

    +
    + +
      +
    • Released change. + #100 +
    • +
    + """ + ); [Test] public void EmitsHintForHiddenBundle() => - Collector.Diagnostics.Should().Contain(d => d.Severity == Severity.Hint && d.Message.Contains("elasticsearch 8.1.0")); + Collector + .Diagnostics + .ToSnapshotText() + .Should() + .MatchInlineSnapshot( + "hint {repo}/docs/index.md:3 Hiding changelog bundle 'elasticsearch 8.1.0': it targets a version newer than the current release (8.0.0) and this build publishes the 'current' content source." + ); } [InheritsTests] @@ -93,11 +118,42 @@ public class ChangelogVisibilityOnStagingTests() : ChangelogVersionVisibilityTes protected override ContentSource? GetContentSource() => ContentSource.Next; [Test] - public void ShowsUnreleasedBundlesForPreReleaseReview() - { - Html.Should().Contain(ReleasedTitle); - Html.Should().Contain(UnreleasedTitle, "staging publishes 'next' so staged bundles are reviewable before release day"); - } + public void ShowsUnreleasedBundlesForPreReleaseReview() => + Html.Should().MatchInlineHtmlSnapshot( + html: DocsHtml.Body(), + expected: """ +
    +

    + 8.1.0 +

    +
    + +
      +
    • Unreleased staged change. + #200 +
    • +
    +
    +

    + 7.9.0 +

    +
    + +
      +
    • Released change. + #100 +
    • +
    + """ + ); } [InheritsTests] @@ -106,11 +162,42 @@ public class ChangelogVisibilityOnIsolatedBuildTests() : ChangelogVersionVisibil // No override: isolated/local builds have no content source and render everything. [Test] - public void ShowsAllBundles() - { - Html.Should().Contain(ReleasedTitle); - Html.Should().Contain(UnreleasedTitle); - } + public void ShowsAllBundles() => + Html.Should().MatchInlineHtmlSnapshot( + html: DocsHtml.Body(), + expected: """ +
    +

    + 8.1.0 +

    +
    + +
      +
    • Unreleased staged change. + #200 +
    • +
    +
    +

    + 7.9.0 +

    +
    + +
      +
    • Released change. + #100 +
    • +
    + """ + ); } /// @@ -152,5 +239,25 @@ protected override IReleaseNotesResolver GetReleaseNotesResolver() => ); [Test] - public void DoesNotFilterProductsWithoutVersioningSystem() => Html.Should().Contain("Future-looking change"); + public void RendersHtml() => + Html.Should().MatchInlineHtmlSnapshot( + html: DocsHtml.Body(), + expected: """ +
    +

    + 9.9.0 +

    +
    + +
      +
    • Future-looking change. + #300 +
    • +
    + """ + ); } diff --git a/tests/Elastic.Markdown.Tests/Directives/CsvIncludeTests.cs b/tests/Elastic.Markdown.Tests/Directives/CsvIncludeTests.cs index e8462b9cee..fa53b87102 100644 --- a/tests/Elastic.Markdown.Tests/Directives/CsvIncludeTests.cs +++ b/tests/Elastic.Markdown.Tests/Directives/CsvIncludeTests.cs @@ -6,7 +6,10 @@ using AwesomeAssertions; using Elastic.Documentation.Configuration; using Elastic.Documentation.FileSystems; +using Elastic.Documentation.Testing; using Elastic.Markdown.Myst.Directives.CsvInclude; +using Nullean.Snapshots; +using Nullean.Snapshots.Html; namespace Elastic.Markdown.Tests.Directives; @@ -161,7 +164,30 @@ protected override void AddToFileSystem(MockFileSystem fileSystem) => Search,[Text](https://www.google.com)")); [Test] - public void RendersMarkdownLinkAsLink() => Html.Should().Contain(">Text"); + public void RendersHtml() => + Html.Should().MatchInlineHtmlSnapshot( + html: DocsHtml.Body(), + expected: """ +
    + + + + + + + + + + + + + +
    NameLink
    Search + Text +
    +
    + """ + ); } public class CsvIncludeWithHtmlBreaksTests() : DirectiveTest(""" @@ -181,14 +207,7 @@ protected override void AddToFileSystem(MockFileSystem fileSystem) => ); [Test] - public void RendersHtmlBreaksInCsvCells() => Html.Should().Contain("Terms A"); - Html.Should().Contain(">Terms B"); - } + public void RendersHtml() => Html.Should().MatchHtmlSnapshot(DocsHtml.Body()); } [InheritsTests] @@ -201,11 +220,12 @@ public class CsvIncludeNotFoundTests() : DirectiveTest(""" public void ReportsFileNotFound() => Block!.Found.Should().BeFalse(); [Test] - public void EmitsErrorForMissingFile() - { - Collector.Diagnostics.Should().NotBeNullOrEmpty(); - Collector.Diagnostics.Should().OnlyContain(d => d.Message.Contains("does not exist")); - } + public void EmitsErrorForMissingFile() => + Collector + .Diagnostics + .ToSnapshotText() + .Should() + .MatchInlineSnapshot("error {repo}/docs/index.md:3 CSV file `{repo}/docs/missing-file.csv` does not exist."); } [InheritsTests] @@ -215,9 +235,10 @@ public class CsvIncludeNoArgumentTests() : DirectiveTest(""" """) { [Test] - public void EmitsErrorForMissingArgument() - { - Collector.Diagnostics.Should().NotBeNullOrEmpty(); - Collector.Diagnostics.Should().OnlyContain(d => d.Message.Contains("requires an argument")); - } + public void EmitsErrorForMissingArgument() => + Collector + .Diagnostics + .ToSnapshotText() + .Should() + .MatchInlineSnapshot("error {repo}/docs/index.md:3 csv-include requires an argument specifying the path to the CSV file."); } diff --git a/tests/Elastic.Markdown.Tests/Directives/ImageCarouselTests.cs b/tests/Elastic.Markdown.Tests/Directives/ImageCarouselTests.cs index 7ac6cf9d78..92a519763d 100644 --- a/tests/Elastic.Markdown.Tests/Directives/ImageCarouselTests.cs +++ b/tests/Elastic.Markdown.Tests/Directives/ImageCarouselTests.cs @@ -5,7 +5,9 @@ using System.IO.Abstractions.TestingHelpers; using AwesomeAssertions; using Elastic.Documentation.Diagnostics; +using Elastic.Documentation.Testing; using Elastic.Markdown.Myst.Directives.Image; +using Nullean.Snapshots; namespace Elastic.Markdown.Tests.Directives; @@ -52,7 +54,7 @@ public void ProcessesNestedImages() public void AllImagesFoundSoNoErrorIsEmitted() { Block!.Images.Should().AllSatisfy(img => img.Found.Should().BeTrue()); - Collector.Diagnostics.Count.Should().Be(0); + Collector.Diagnostics.ToSnapshotText().Should().MatchInlineSnapshot(""); } } @@ -75,7 +77,7 @@ public class ImageCarouselWithSmallHeightTests() : DirectiveTest d.Severity == Severity.Error); + Collector + .Diagnostics + .ToSnapshotText() + .Should() + .MatchInlineSnapshot( + "error {repo}/docs/index.md:5 `img/missing.png` does not exist. resolved to `Nullean.ScopedFileSystem.ScopedFileInfo" + ); } } diff --git a/tests/Elastic.Markdown.Tests/Directives/ImageTests.cs b/tests/Elastic.Markdown.Tests/Directives/ImageTests.cs index 24576e6402..ca0389a0de 100644 --- a/tests/Elastic.Markdown.Tests/Directives/ImageTests.cs +++ b/tests/Elastic.Markdown.Tests/Directives/ImageTests.cs @@ -5,7 +5,9 @@ using System.IO.Abstractions.TestingHelpers; using AwesomeAssertions; using Elastic.Documentation.Diagnostics; +using Elastic.Documentation.Testing; using Elastic.Markdown.Myst.Directives.Image; +using Nullean.Snapshots; namespace Elastic.Markdown.Tests.Directives; @@ -38,7 +40,7 @@ public void ParsesBreakPoint() public void ImageIsFoundSoNoErrorIsEmitted() { Block!.Found.Should().BeTrue(); - Collector.Diagnostics.Count.Should().Be(0); + Collector.Diagnostics.ToSnapshotText().Should().MatchInlineSnapshot(""); } } @@ -88,7 +90,7 @@ public class AllowedExternalHostTests() : DirectiveTest( public void AllowedHostDoesNotWarn() { Block!.Found.Should().BeTrue(); - Collector.Diagnostics.Count.Should().Be(0); + Collector.Diagnostics.ToSnapshotText().Should().MatchInlineSnapshot(""); } } @@ -113,6 +115,12 @@ public void WarnsOnExternalUri() { Block!.Found.Should().BeTrue(); - Collector.Diagnostics.Should().HaveCount(1).And.OnlyContain(d => d.Severity == Severity.Warning); + Collector + .Diagnostics + .ToSnapshotText() + .Should() + .MatchInlineSnapshot( + "warning {repo}/docs/index.md:3 image is using an external URI: https://github.com/rowanc1/pics/blob/main/sunset.png?raw=true " + ); } } diff --git a/tests/Elastic.Markdown.Tests/Directives/ListSubPagesTests.cs b/tests/Elastic.Markdown.Tests/Directives/ListSubPagesTests.cs index 0547fe619c..ada114ce50 100644 --- a/tests/Elastic.Markdown.Tests/Directives/ListSubPagesTests.cs +++ b/tests/Elastic.Markdown.Tests/Directives/ListSubPagesTests.cs @@ -4,7 +4,9 @@ using System.IO.Abstractions.TestingHelpers; using AwesomeAssertions; +using Elastic.Documentation.Testing; using Elastic.Markdown.Myst.Directives.SubPages; +using Nullean.Snapshots.Html; namespace Elastic.Markdown.Tests.Directives; @@ -38,12 +40,20 @@ public void SubPagesContainTitlesAndUrls() => Block!.SubPages.Should().OnlyContain(p => !string.IsNullOrEmpty(p.Title) && !string.IsNullOrEmpty(p.Url)); [Test] - public void RendersListWithLinks() - { - Html.Should().Contain("list-sub-pages"); - Html.Should().Contain(""); - } + public void RendersHtml() => + Html.Should().MatchInlineHtmlSnapshot( + html: DocsHtml.Body(), + expected: """ + + """ + ); } [InheritsTests] @@ -74,7 +84,21 @@ public void IncludesDescriptionWhenPresent() } [Test] - public void RendersDescriptionInOutput() => Html.Should().Contain("First page description"); + public void RendersHtml() => + Html.Should().MatchInlineHtmlSnapshot( + html: DocsHtml.Body(), + expected: """ + + """ + ); } [InheritsTests] diff --git a/tests/Elastic.Markdown.Tests/Directives/MathBlockTests.cs b/tests/Elastic.Markdown.Tests/Directives/MathBlockTests.cs index 356e2b4e0e..4c3f87cf66 100644 --- a/tests/Elastic.Markdown.Tests/Directives/MathBlockTests.cs +++ b/tests/Elastic.Markdown.Tests/Directives/MathBlockTests.cs @@ -4,7 +4,10 @@ using AwesomeAssertions; using Elastic.Documentation.Diagnostics; +using Elastic.Documentation.Testing; using Elastic.Markdown.Myst.Directives.Math; +using Nullean.Snapshots; +using Nullean.Snapshots.Html; namespace Elastic.Markdown.Tests.Directives; @@ -28,7 +31,8 @@ public class MathBlockTests() : DirectiveTest(""" public void DeterminesInlineMath() => Block!.IsDisplayMath.Should().BeFalse(); [Test] - public void RendersMathSpan() => Html.Should().Contain("E = mc^2"); + public void RendersHtml() => + Html.Should().MatchInlineHtmlSnapshot(html: DocsHtml.Body(), expected: "E = mc^2"); } [InheritsTests] @@ -52,7 +56,11 @@ public class MathBlockDisplayMathTests() : DirectiveTest( public void DeterminesDisplayMath() => Block!.IsDisplayMath.Should().BeTrue(); [Test] - public void RendersDisplayMathDiv() => Html.Should().Contain("
    "); + public void RendersHtml() => + Html.Should().MatchInlineHtmlSnapshot( + html: DocsHtml.Body(), + expected: "
    \\[ \\int_{-\\infty}^{\\infty} e^{-x^2} dx = \\sqrt{\\pi} \\]
    " + ); } [InheritsTests] @@ -70,7 +78,11 @@ public class MathBlockWithLabelTests() : DirectiveTest(""" public void ExtractsLabel() => Block!.Label.Should().Be("einstein-mass-energy"); [Test] - public void RendersWithId() => Html.Should().Contain("id=\"einstein-mass-energy\""); + public void RendersHtml() => + Html.Should().MatchInlineHtmlSnapshot( + html: DocsHtml.Body(), + expected: "E = mc^2" + ); } [InheritsTests] @@ -80,15 +92,8 @@ public class MathBlockEmptyTests() : DirectiveTest(""" """) { [Test] - public void EmptyContentGeneratesError() => Collector.Errors.Should().Be(1); - - [Test] - public void EmitsErrorForEmptyContent() - { - Collector.Diagnostics.Should().NotBeNullOrEmpty().And.HaveCount(1); - Collector.Diagnostics.Should().OnlyContain(d => d.Severity == Severity.Error); - Collector.Diagnostics.Should().OnlyContain(d => d.Message.StartsWith("Math directive requires content.")); - } + public void EmptyContentGeneratesError() => + Collector.Diagnostics.ToSnapshotText().Should().MatchInlineSnapshot("error {repo}/docs/index.md:3 Math directive requires content."); } [InheritsTests] @@ -113,5 +118,9 @@ public class MathBlockComplexExpressionTests() : DirectiveTest( public void DeterminesDisplayMathFromBegin() => Block!.IsDisplayMath.Should().BeTrue(); [Test] - public void RendersComplexMathDiv() => Html.Should().Contain("
    "); + public void RendersHtml() => + Html.Should().MatchInlineHtmlSnapshot( + html: DocsHtml.Body(), + expected: "
    \\begin{align} \\frac{\\partial f}{\\partial x} &= \\lim_{h \\to 0} \\frac{f(x+h) - f(x)}{h} \\\\ \\nabla \\cdot \\vec{E} &= \\frac{\\rho}{\\epsilon_0} \\end{align}
    " + ); } diff --git a/tests/Elastic.Markdown.Tests/Directives/MermaidTests.cs b/tests/Elastic.Markdown.Tests/Directives/MermaidTests.cs index 44f898a355..e66df61a3a 100644 --- a/tests/Elastic.Markdown.Tests/Directives/MermaidTests.cs +++ b/tests/Elastic.Markdown.Tests/Directives/MermaidTests.cs @@ -2,12 +2,22 @@ // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information +using System.Text.RegularExpressions; using AwesomeAssertions; +using Elastic.Documentation.Testing; using Elastic.Markdown.Myst.CodeBlocks; using Markdig.Syntax; +using Nullean.Snapshots; +using Nullean.Snapshots.Html; namespace Elastic.Markdown.Tests.Directives; +internal static class MermaidSnapshots +{ + /// The diagram file name carries a hash of the rendered SVG, which changes with the renderer, not with the markup. + public static SnapshotOptions Options => new SnapshotOptions().Scrub(new Regex(@"index-[0-9a-f]{8}\.svg"), "index-{hash}.svg"); +} + public class MermaidFlowchartTests() : DirectiveTest(""" ```mermaid flowchart LR @@ -25,10 +35,20 @@ flowchart LR public void HasMermaidLanguage() => Block!.Language.Should().Be("mermaid"); [Test] - public void RendersMermaidContainer() => Html.Should().Contain("
    "); - - [Test] - public void RendersImgElement() => Html.Should().Contain(" + Html.Should().MatchInlineHtmlSnapshot( + html: DocsHtml.Body(), + options: MermaidSnapshots.Options, + expected: """ +
    +
    +
    + Mermaid diagram +
    +
    +
    + """ + ); [Test] public void EmitsExternalSvgFile() => ReadMermaidSvgs().Should().NotBeEmpty(); @@ -61,10 +81,20 @@ participant B as Bob public void ParsesSequenceDiagram() => Block.Should().NotBeNull(); [Test] - public void RendersMermaidContainer() => Html.Should().Contain("
    "); - - [Test] - public void RendersImgElement() => Html.Should().Contain(" + Html.Should().MatchInlineHtmlSnapshot( + html: DocsHtml.Body(), + options: MermaidSnapshots.Options, + expected: """ +
    +
    +
    + Mermaid diagram +
    +
    +
    + """ + ); [Test] public void SvgContainsParticipantLabels() @@ -93,10 +123,20 @@ public class MermaidStateDiagramTests() : DirectiveTest( public void ParsesStateDiagram() => Block.Should().NotBeNull(); [Test] - public void RendersMermaidContainer() => Html.Should().Contain("
    "); - - [Test] - public void RendersImgElement() => Html.Should().Contain(" + Html.Should().MatchInlineHtmlSnapshot( + html: DocsHtml.Body(), + options: MermaidSnapshots.Options, + expected: """ +
    +
    +
    + Mermaid diagram +
    +
    +
    + """ + ); [Test] public void SvgContainsStateLabels() @@ -125,10 +165,20 @@ public class MermaidClassDiagramTests() : DirectiveTest( public void ParsesClassDiagram() => Block.Should().NotBeNull(); [Test] - public void RendersMermaidContainer() => Html.Should().Contain("
    "); - - [Test] - public void RendersImgElement() => Html.Should().Contain(" + Html.Should().MatchInlineHtmlSnapshot( + html: DocsHtml.Body(), + options: MermaidSnapshots.Options, + expected: """ +
    +
    +
    + Mermaid diagram +
    +
    +
    + """ + ); [Test] public void SvgContainsClassLabels() @@ -156,10 +206,20 @@ public class MermaidErDiagramTests() : DirectiveTest( public void ParsesErDiagram() => Block.Should().NotBeNull(); [Test] - public void RendersMermaidContainer() => Html.Should().Contain("
    "); - - [Test] - public void RendersImgElement() => Html.Should().Contain(" + Html.Should().MatchInlineHtmlSnapshot( + html: DocsHtml.Body(), + options: MermaidSnapshots.Options, + expected: """ +
    +
    +
    + Mermaid diagram +
    +
    +
    + """ + ); [Test] public void SvgContainsEntityLabels() @@ -186,13 +246,33 @@ class A elasticBlue ) { [Test] - public void EmitsHints() => Collector.Diagnostics.Should().NotBeEmpty(); + public void EmitsHints() => + Collector + .Diagnostics + .ToSnapshotText() + .Should() + .MatchInlineSnapshot( + "hint {repo}/docs/index.md:3 Mermaid strict mode stripped 3 item(s): ClassDefDirective (line 3), UnknownClassReference (line 4), StyleDirective (line 5)" + ); [Test] public void EmitsSvgFile() => ReadMermaidSvgs().Should().NotBeEmpty(); [Test] - public void DoesNotFallBackToRawSource() => Html.Should().NotContain("
    ");
    +	public void RendersHtml() =>
    +		Html.Should().MatchInlineHtmlSnapshot(
    +			html: DocsHtml.Body(),
    +			options: MermaidSnapshots.Options,
    +			expected: """
    +			
    +
    +
    + Mermaid diagram +
    +
    +
    + """ + ); } // Allowlisted semantic classes render correctly with site palette colors baked into SVG. @@ -204,13 +284,23 @@ flowchart LR """) { [Test] - public void RendersMermaidContainer() => Html.Should().Contain("
    "); + public void RendersHtml() => + Html.Should().MatchInlineHtmlSnapshot( + html: DocsHtml.Body(), + options: MermaidSnapshots.Options, + expected: """ +
    +
    +
    + Mermaid diagram +
    +
    +
    + """ + ); [Test] - public void RendersImgElement() => Html.Should().Contain(" Collector.Diagnostics.Should().BeEmpty(); + public void EmitsNoDiagnostics() => Collector.Diagnostics.ToSnapshotText().Should().MatchInlineSnapshot(""); [Test] public void SvgContainsWarningFillColor() => ReadMermaidSvgs()[0].Should().Contain("#fdf3d8"); @@ -227,10 +317,23 @@ public class MermaidPieDataPaletteTests() : DirectiveTest(""" """) { [Test] - public void RendersImgElement() => Html.Should().Contain(" Collector.Diagnostics.Should().BeEmpty(); + public void RendersHtml() => + Html.Should().MatchInlineHtmlSnapshot( + html: DocsHtml.Body(), + options: MermaidSnapshots.Options, + expected: """ +
    +
    +
    + Mermaid diagram +
    +
    +
    + """ + ); + + [Test] + public void EmitsNoDiagnostics() => Collector.Diagnostics.ToSnapshotText().Should().MatchInlineSnapshot(""); [Test] public void UsesThemePalette() => ReadMermaidSvgs()[0].Should().Contain("#3788ff"); // blue-elastic-70 diff --git a/tests/Elastic.Markdown.Tests/Directives/PageCardBlockTests.cs b/tests/Elastic.Markdown.Tests/Directives/PageCardBlockTests.cs index d9eaf63e1e..9cca34c73c 100644 --- a/tests/Elastic.Markdown.Tests/Directives/PageCardBlockTests.cs +++ b/tests/Elastic.Markdown.Tests/Directives/PageCardBlockTests.cs @@ -6,8 +6,10 @@ using AwesomeAssertions; using Elastic.Documentation.Diagnostics; using Elastic.Documentation.Navigation; +using Elastic.Documentation.Testing; using Elastic.Markdown.IO; using Elastic.Markdown.Myst.Directives.PageCard; +using Nullean.Snapshots; namespace Elastic.Markdown.Tests.Directives; @@ -30,7 +32,7 @@ protected override void AddToFileSystem(MockFileSystem fileSystem) => public void ResolvesUrlViaNavigationLookup() => Block!.ResolvedUrl.Should().Be("/other-page"); [Test] - public void EmitsNoErrors() => Collector.Diagnostics.Should().NotContain(d => d.Severity == Severity.Error); + public void EmitsNoErrors() => Collector.Diagnostics.ToSnapshotText().Should().MatchInlineSnapshot(""); } /// @@ -56,7 +58,7 @@ protected override void ConfigureDocumentationSet(DocumentationSet set) => public void ResolvesUrlWithRehomedPrefix() => Block!.ResolvedUrl.Should().Be("/reference/rehomed/other-page"); [Test] - public void EmitsNoErrors() => Collector.Diagnostics.Should().NotContain(d => d.Severity == Severity.Error); + public void EmitsNoErrors() => Collector.Diagnostics.ToSnapshotText().Should().MatchInlineSnapshot(""); } /// @@ -81,7 +83,7 @@ protected override void ConfigureDocumentationSet(DocumentationSet set) => public void ResolvesUrlWithRehomedPrefixAndAnchor() => Block!.ResolvedUrl.Should().Be("/reference/rehomed/other-page#install"); [Test] - public void EmitsNoErrors() => Collector.Diagnostics.Should().NotContain(d => d.Severity == Severity.Error); + public void EmitsNoErrors() => Collector.Diagnostics.ToSnapshotText().Should().MatchInlineSnapshot(""); } /// Namespace-style link (no .md extension) probes for /index.md variant. @@ -98,7 +100,7 @@ protected override void AddToFileSystem(MockFileSystem fileSystem) => public void ResolvesIndexPageUrl() => Block!.ResolvedUrl.Should().Be("/subdir"); [Test] - public void EmitsNoErrors() => Collector.Diagnostics.Should().NotContain(d => d.Severity == Severity.Error); + public void EmitsNoErrors() => Collector.Diagnostics.ToSnapshotText().Should().MatchInlineSnapshot(""); } /// Absolute HTTP URLs are rejected with an error. @@ -112,5 +114,11 @@ public class PageCardAbsoluteUrlErrorTests() : DirectiveTest( { [Test] public void EmitsErrorForAbsoluteUrl() => - Collector.Diagnostics.Should().Contain(d => d.Severity == Severity.Error && d.Message.Contains("absolute URL")); + Collector + .Diagnostics + .ToSnapshotText() + .Should() + .MatchInlineSnapshot( + "error {repo}/docs/index.md:3 page-card url must be a local .md path or crosslink, not an absolute URL: https://example.com/page" + ); } diff --git a/tests/Elastic.Markdown.Tests/Directives/RelatedLearningTests.cs b/tests/Elastic.Markdown.Tests/Directives/RelatedLearningTests.cs index 08d997ac22..ef9405c8dd 100644 --- a/tests/Elastic.Markdown.Tests/Directives/RelatedLearningTests.cs +++ b/tests/Elastic.Markdown.Tests/Directives/RelatedLearningTests.cs @@ -4,7 +4,9 @@ using AwesomeAssertions; using Elastic.Documentation.Diagnostics; +using Elastic.Documentation.Testing; using Elastic.Markdown.Myst.Directives.RelatedLearning; +using Nullean.Snapshots; namespace Elastic.Markdown.Tests.Directives; @@ -58,7 +60,7 @@ public void PageTocIncludesDefaultSlug() } [Test] - public void EmitsNoDiagnostics() => Collector.Diagnostics.Should().BeEmpty(); + public void EmitsNoDiagnostics() => Collector.Diagnostics.ToSnapshotText().Should().MatchInlineSnapshot(""); private static int CountOccurrences(string haystack, string needle) { @@ -137,8 +139,9 @@ public void EmitsErrorAndRendersNothing() { Collector .Diagnostics + .ToSnapshotText() .Should() - .Contain(d => d.Severity == Severity.Error && d.Message.Contains("unknown catalog ID 'not-a-module'")); + .MatchInlineSnapshot("error {repo}/docs/index.md:3 {related-learning} unknown catalog ID 'not-a-module'."); Block!.Items.Should().BeEmpty(); Html.Should().NotContain("related-learning"); File.PageTableOfContent.Should().NotContainKey(RelatedLearningBlock.DefaultSlug); @@ -159,8 +162,9 @@ public void WarnsAndKeepsFirstOccurrence() Block!.Items.Should().ContainSingle().Which.Id.Should().Be("apm-with-elastic"); Collector .Diagnostics + .ToSnapshotText() .Should() - .Contain(d => d.Severity == Severity.Warning && d.Message.Contains("duplicate catalog ID 'apm-with-elastic'")); + .MatchInlineSnapshot("warning {repo}/docs/index.md:3 {related-learning} duplicate catalog ID 'apm-with-elastic' was skipped."); } } @@ -175,8 +179,9 @@ public void EmitsErrorWhenArgumentMissing() { Collector .Diagnostics + .ToSnapshotText() .Should() - .Contain(d => d.Severity == Severity.Error && d.Message.Contains("requires at least one catalog ID as an argument")); + .MatchInlineSnapshot("error {repo}/docs/index.md:3 {related-learning} requires at least one catalog ID as an argument."); Block!.Items.Should().BeEmpty(); } } diff --git a/tests/Elastic.Markdown.Tests/Directives/StepperTocOptionTests.cs b/tests/Elastic.Markdown.Tests/Directives/StepperTocOptionTests.cs index 00ff3d9fa5..1d41add0f9 100644 --- a/tests/Elastic.Markdown.Tests/Directives/StepperTocOptionTests.cs +++ b/tests/Elastic.Markdown.Tests/Directives/StepperTocOptionTests.cs @@ -4,7 +4,9 @@ using AwesomeAssertions; using Elastic.Documentation.Diagnostics; +using Elastic.Documentation.Testing; using Elastic.Markdown.Myst.Directives.Stepper; +using Nullean.Snapshots.Html; namespace Elastic.Markdown.Tests.Directives; @@ -31,13 +33,22 @@ public void Toc_WhenDefault_IncludesStepTitle() } [Test] - public void Render_WhenDefault_UsesHeadingElement() - { - Html.Should().Contain(" + Html.Should().MatchInlineHtmlSnapshot( + html: DocsHtml.Body(), + expected: """ +
    +
      +
    1. +

      + Install +

      +

      First install the dependencies.

      +
    2. +
    +
    + """ + ); } [InheritsTests] @@ -62,15 +73,22 @@ public void Toc_WhenTocFalse_OmitsStepTitle() } [Test] - public void Render_WhenTocFalse_UsesDiv() - { - Html.Should().NotContain(" + Html.Should().MatchInlineHtmlSnapshot( + html: DocsHtml.Body(), + expected: """ +
    +
      +
    1. +
      + Install +
      +

      First install the dependencies.

      +
    2. +
    +
    + """ + ); } [InheritsTests] @@ -99,12 +117,7 @@ public void Toc_WhenTocFalse_KeepsInternalHeading() } [Test] - public void Render_WhenTocFalse_KeepsInternalHeadingLevel() - { - Html.Should().Contain(" Html.Should().MatchHtmlSnapshot(DocsHtml.Body()); } [InheritsTests] @@ -140,10 +153,25 @@ public void Hint_WhenNoPrecedingHeading_NamesOutlineLevel() } [Test] - public void Render_WhenNoPrecedingHeading_AdjustsInternalHeading() - { - Html.Should().Contain(" + Html.Should().MatchInlineHtmlSnapshot( + html: DocsHtml.Body(), + expected: """ +
    +
      +
    1. +
      + First +
      +
      +

      + Too high +

      +
      +

      Body.

      +
    2. +
    +
    + """ + ); } diff --git a/tests/Elastic.Markdown.Tests/Directives/StorybookTests.cs b/tests/Elastic.Markdown.Tests/Directives/StorybookTests.cs index 13731bb2d2..7c9b987c01 100644 --- a/tests/Elastic.Markdown.Tests/Directives/StorybookTests.cs +++ b/tests/Elastic.Markdown.Tests/Directives/StorybookTests.cs @@ -6,7 +6,10 @@ using AwesomeAssertions; using Elastic.Documentation; using Elastic.Documentation.Diagnostics; +using Elastic.Documentation.Testing; using Elastic.Markdown.Myst.Directives.Storybook; +using Nullean.Snapshots; +using Nullean.Snapshots.Html; namespace Elastic.Markdown.Tests.Directives; @@ -104,15 +107,7 @@ public void ResolvesStory() } [Test] - public void RendersInlineStory() - { - Html.Should().Contain(" Html.Should().MatchHtmlSnapshot(DocsHtml.Body()); } /// Deterministic so storybook interpolation tests don't depend on the host shell. @@ -169,8 +164,14 @@ public class StorybookDisallowedRegistryVariableTests() : StorybookRegistryTest( public void WarnsAndLeavesExpressionLiteral() => Collector .Diagnostics + .ToSnapshotText(firstLineOnly: true) .Should() - .Contain(d => d.Severity == Severity.Warning && d.Message.Contains("not allow-listed for interpolation")); + .MatchInlineSnapshot( + """ + warning {repo}/docs/docset.yml 'storybook.registry' references environment variable 'AWS_SECRET_ACCESS_KEY' which is not allow-listed for interpolation and is left literal. Allowed: KIBANA_STORYBOOK_REGISTRY. + error {repo}/docs/index.md:3 storybook registry could not be read: ${AWS_SECRET_ACCESS_KEY:-docs_registry.json} + """ + ); } [InheritsTests] @@ -204,8 +205,11 @@ public class StorybookStructuredReferenceWrongStorybookTests() : StorybookRegist public void DoesNotFallbackToAnotherStorybook() => Collector .Diagnostics + .ToSnapshotText() .Should() - .Contain(d => d.Message.Contains("does not contain id 'kibana:content_management:ai-components-aibutton--default'")); + .MatchInlineSnapshot( + "error {repo}/docs/index.md:3 storybook registry does not contain id 'kibana:content_management:ai-components-aibutton--default'." + ); } [InheritsTests] @@ -230,9 +234,13 @@ public class StorybookIframeTests() : StorybookRegistryTest(""" public void RendersIframeFallback() { Block!.HasInlineStory.Should().BeFalse(); - Html.Should().Contain(" + +
    + """ ); } } @@ -248,7 +256,7 @@ public class StorybookBodyTests() : StorybookRegistryTest( ) { [Test] - public void RendersBodyContent() => Html.Should().Contain("Supporting details for this story."); + public void RendersHtml() => Html.Should().MatchHtmlSnapshot(DocsHtml.Body()); } [InheritsTests] @@ -267,9 +275,19 @@ public void WarnsAndFallsBackToDefaultHeight() Block!.Height.Should().Be(400); Collector .Diagnostics + .ToSnapshotText() .Should() - .ContainSingle(d => d.Severity == Severity.Warning && d.Message.Contains(":height: must be a positive integer")); - Html.Should().Contain("height:400px"); + .MatchInlineSnapshot( + "warning {repo}/docs/index.md:3 storybook directive :height: must be a positive integer. Got 'tall', using default 400px." + ); + Html.Should().MatchInlineHtmlSnapshot( + html: DocsHtml.Body(), + expected: """ +
    + +
    + """ + ); } } @@ -283,7 +301,12 @@ public class StorybookMissingRegistryTests() : DirectiveTest( ) { [Test] - public void EmitsError() => Collector.Diagnostics.Should().Contain(d => d.Message.Contains("requires docset.yml storybook.registry")); + public void EmitsError() => + Collector + .Diagnostics + .ToSnapshotText() + .Should() + .MatchInlineSnapshot("error {repo}/docs/index.md:3 storybook directive requires docset.yml storybook.registry."); } [InheritsTests] @@ -293,7 +316,12 @@ public class StorybookMissingIdTests() : StorybookRegistryTest(""" """) { [Test] - public void EmitsError() => Collector.Diagnostics.Should().Contain(d => d.Message.Contains("requires :id: or :project:")); + public void EmitsError() => + Collector + .Diagnostics + .ToSnapshotText() + .Should() + .MatchInlineSnapshot("error {repo}/docs/index.md:3 storybook directive requires :id: or :project:."); } [InheritsTests] @@ -309,6 +337,7 @@ public class StorybookPositionalArgumentWarningTests() : StorybookRegistryTest( public void EmitsWarning() => Collector .Diagnostics + .ToSnapshotText() .Should() - .ContainSingle(d => d.Severity == Severity.Warning && d.Message.Contains("ignores positional arguments")); + .MatchInlineSnapshot("warning {repo}/docs/index.md:3 storybook directive ignores positional arguments. Use properties instead."); } diff --git a/tests/Elastic.Markdown.Tests/Directives/TableDirectiveTests.cs b/tests/Elastic.Markdown.Tests/Directives/TableDirectiveTests.cs index 9db847b13d..9f075867c9 100644 --- a/tests/Elastic.Markdown.Tests/Directives/TableDirectiveTests.cs +++ b/tests/Elastic.Markdown.Tests/Directives/TableDirectiveTests.cs @@ -4,7 +4,10 @@ using AwesomeAssertions; using Elastic.Documentation.Diagnostics; +using Elastic.Documentation.Testing; using Elastic.Markdown.Myst.Directives.Table; +using Nullean.Snapshots; +using Nullean.Snapshots.Html; namespace Elastic.Markdown.Tests.Directives; @@ -26,13 +29,28 @@ public class TableDirectiveBasicTests() : DirectiveTest( public void SetsCorrectDirectiveType() => Block!.Directive.Should().Be("table"); [Test] - public void RendersTableInOutput() - { - Html.Should().Contain("table-wrapper"); - Html.Should().Contain(" + Html.Should().MatchInlineHtmlSnapshot( + html: DocsHtml.Body(), + expected: """ +
    + + + + + + + + + + + + + +
    head ahead b
    ab
    +
    + """ + ); } [InheritsTests] @@ -57,13 +75,7 @@ public void ParsesWidthsOption() } [Test] - public void RendersColgroupWithWidths() - { - Html.Should().Contain("colgroup"); - Html.Should().Contain("table-layout:fixed"); - Html.Should().Contain("width:33.33%"); - Html.Should().Contain("width:66.67%"); - } + public void RendersHtml() => Html.Should().MatchHtmlSnapshot(DocsHtml.Body()); } [InheritsTests] @@ -88,7 +100,7 @@ public void MapsDescriptionTo4_8() } [Test] - public void RendersColgroup() => Html.Should().Contain("colgroup"); + public void RendersHtml() => Html.Should().MatchHtmlSnapshot(DocsHtml.Body()); } [InheritsTests] @@ -108,7 +120,30 @@ public class TableDirectiveAutoPresetTests() : DirectiveTest Block!.ColumnWidths.Should().BeEmpty(); [Test] - public void DoesNotInjectColgroup() => Html.Should().NotContain("colgroup"); + public void RendersHtml() => + Html.Should().MatchInlineHtmlSnapshot( + html: DocsHtml.Body(), + expected: """ +
    + + + + + + + + + + + + + + + +
    abc
    123
    +
    + """ + ); } [InheritsTests] @@ -128,7 +163,28 @@ public class TableDirectiveMatrixTests() : DirectiveTest( public void ParsesMatrixOption() => Block!.Matrix.Should().BeTrue(); [Test] - public void RendersMatrixClass() => Html.Should().Contain("table-wrapper table-matrix"); + public void RendersHtml() => + Html.Should().MatchInlineHtmlSnapshot( + html: DocsHtml.Body(), + expected: """ +
    + + + + + + + + + + + + + +
    head ahead b
    ab
    +
    + """ + ); } [InheritsTests] @@ -143,7 +199,28 @@ public class TableDirectiveWithoutMatrixTests() : DirectiveTest Html.Should().NotContain("table-matrix"); + public void RendersHtml() => + Html.Should().MatchInlineHtmlSnapshot( + html: DocsHtml.Body(), + expected: """ +
    + + + + + + + + + + + + + +
    head ahead b
    ab
    +
    + """ + ); } [InheritsTests] @@ -163,14 +240,30 @@ public class TableDirectiveFilterableTests() : DirectiveTest Block!.Filterable.Should().BeTrue(); [Test] - public void WrapsTableInHostElement() - { - Html.Should().Contain(""); - Html.Should().Contain(""); - } - - [Test] - public void KeepsServerRenderedTableInsideHost() => Html.Should().Contain("
    + Html.Should().MatchInlineHtmlSnapshot( + html: DocsHtml.Body(), + expected: """ + +
    + + + + + + + + + + + + + +
    head ahead b
    ab
    +
    +
    + """ + ); } [InheritsTests] @@ -188,7 +281,28 @@ public class TableDirectiveWithoutFilterableTests() : DirectiveTest Block!.Filterable.Should().BeFalse(); [Test] - public void DoesNotWrapTable() => Html.Should().NotContain("filterable-table"); + public void RendersHtml() => + Html.Should().MatchInlineHtmlSnapshot( + html: DocsHtml.Body(), + expected: """ +
    + + + + + + + + + + + + + +
    head ahead b
    ab
    +
    + """ + ); } [InheritsTests] @@ -207,12 +321,7 @@ public class TableDirectiveFilterableWithMatrixAndWidthsTests() : DirectiveTest< ) { [Test] - public void ComposesWithMatrixAndWidths() - { - Html.Should().Contain("
    Html.Should().MatchHtmlSnapshot(DocsHtml.Body()); } [InheritsTests] @@ -230,7 +339,11 @@ public class TableDirectiveWidthCountMismatchTests() : DirectiveTest - Collector.Diagnostics.Should().Contain(d => d.Severity == Severity.Error && d.Message.Contains("does not match")); + Collector + .Diagnostics + .ToSnapshotText() + .Should() + .MatchInlineSnapshot("error {repo}/docs/index.md:3 Column width count (3) does not match table column count (2)."); } [InheritsTests] @@ -248,7 +361,11 @@ public class TableDirectiveWidthsSumErrorTests() : DirectiveTest - Collector.Diagnostics.Should().Contain(d => d.Severity == Severity.Error && d.Message.Contains("sum to 12")); + Collector + .Diagnostics + .ToSnapshotText() + .Should() + .MatchInlineSnapshot("error {repo}/docs/index.md:3 Column widths must sum to 12 (Bootstrap grid). Got sum of 8."); } [InheritsTests] @@ -262,7 +379,13 @@ public class TableDirectiveNoTableTests() : DirectiveTest(" { [Test] public void EmitsError() => - Collector.Diagnostics.Should().Contain(d => d.Severity == Severity.Error && d.Message.Contains("pipe table")); + Collector + .Diagnostics + .ToSnapshotText() + .Should() + .MatchInlineSnapshot( + "error {repo}/docs/index.md:3 Table directive must contain a pipe table. Add a table using Markdown pipe syntax." + ); } [InheritsTests] @@ -280,7 +403,13 @@ public class TableDirectiveInvalidWidthsTests() : DirectiveTest - Collector.Diagnostics.Should().Contain(d => d.Severity == Severity.Error && d.Message.Contains("Invalid widths value")); + Collector + .Diagnostics + .ToSnapshotText() + .Should() + .MatchInlineSnapshot( + "error {repo}/docs/index.md:3 Invalid widths value 'foo'. Use preset (auto, description) or dash-separated integers 1-12 that sum to 12 (e.g., 4-8, 4-4-4)." + ); } [InheritsTests] @@ -298,7 +427,13 @@ public class TableDirectiveOutOfRangeWidthsTests() : DirectiveTest - Collector.Diagnostics.Should().Contain(d => d.Severity == Severity.Error && d.Message.Contains("Invalid widths value")); + Collector + .Diagnostics + .ToSnapshotText() + .Should() + .MatchInlineSnapshot( + "error {repo}/docs/index.md:3 Invalid widths value '0-12'. Use preset (auto, description) or dash-separated integers 1-12 that sum to 12 (e.g., 4-8, 4-4-4)." + ); } [InheritsTests] @@ -320,5 +455,9 @@ public class TableDirectiveMultipleTablesTests() : DirectiveTest - Collector.Diagnostics.Should().Contain(d => d.Severity == Severity.Error && d.Message.Contains("exactly one pipe table")); + Collector + .Diagnostics + .ToSnapshotText() + .Should() + .MatchInlineSnapshot("error {repo}/docs/index.md:3 Table directive must contain exactly one pipe table."); } diff --git a/tests/Elastic.Markdown.Tests/Directives/UnsupportedTests.cs b/tests/Elastic.Markdown.Tests/Directives/UnsupportedTests.cs index 4f1189197a..b5f6861937 100644 --- a/tests/Elastic.Markdown.Tests/Directives/UnsupportedTests.cs +++ b/tests/Elastic.Markdown.Tests/Directives/UnsupportedTests.cs @@ -4,7 +4,9 @@ using AwesomeAssertions; using Elastic.Documentation.Diagnostics; +using Elastic.Documentation.Testing; using Elastic.Markdown.Myst.Directives; +using Nullean.Snapshots; namespace Elastic.Markdown.Tests.Directives; @@ -27,15 +29,7 @@ A regular paragraph. public void SetsCorrectDirectiveType() => Block!.Directive.Should().Be(directive); [Test] - public void TracksASingleWarning() => Collector.Warnings.Should().Be(1); - - [Test] - public void EmitsUnsupportedWarnings() - { - Collector.Diagnostics.Should().NotBeNullOrEmpty().And.HaveCount(1); - Collector.Diagnostics.Should().OnlyContain(d => d.Severity == Severity.Warning); - Collector.Diagnostics.Should().OnlyContain(d => d.Message.StartsWith($"Directive block '{directive}' is unsupported.")); - } + public void EmitsUnsupportedWarnings() => Collector.Diagnostics.ToSnapshotText().Should().MatchSnapshot(); } [InheritsTests] diff --git a/tests/Elastic.Markdown.Tests/Directives/VectorSizingBlockTests.cs b/tests/Elastic.Markdown.Tests/Directives/VectorSizingBlockTests.cs index ad8bd22acc..f66599ebb7 100644 --- a/tests/Elastic.Markdown.Tests/Directives/VectorSizingBlockTests.cs +++ b/tests/Elastic.Markdown.Tests/Directives/VectorSizingBlockTests.cs @@ -3,7 +3,9 @@ // See the LICENSE file in the project root for more information using AwesomeAssertions; +using Elastic.Documentation.Testing; using Elastic.Markdown.Myst.Directives.VectorSizing; +using Nullean.Snapshots.Html; namespace Elastic.Markdown.Tests.Directives; @@ -20,5 +22,6 @@ public class VectorSizingBlockTests() : DirectiveTest(""" public void SetsCorrectDirectiveType() => Block!.Directive.Should().Be("vector-sizing-calculator"); [Test] - public void RendersCustomElement() => Html.Should().Contain(""); + public void RendersHtml() => + Html.Should().MatchInlineHtmlSnapshot(html: DocsHtml.Body(), expected: ""); } diff --git a/tests/Elastic.Markdown.Tests/Directives/VersionTests.cs b/tests/Elastic.Markdown.Tests/Directives/VersionTests.cs index 57a7990842..fc5c9db91e 100644 --- a/tests/Elastic.Markdown.Tests/Directives/VersionTests.cs +++ b/tests/Elastic.Markdown.Tests/Directives/VersionTests.cs @@ -4,8 +4,10 @@ using AwesomeAssertions; using Elastic.Documentation; +using Elastic.Documentation.Testing; using Elastic.Documentation.Versions; using Elastic.Markdown.Myst.Directives.Version; +using Nullean.Snapshots; namespace Elastic.Markdown.Tests.Directives; @@ -74,7 +76,7 @@ public class SimpleVersion() : VersionValidationTests("7.17") public void SetsVersion() => Block!.Version.Should().Be(new SemVersion(7, 17, 0)); [Test] - public void HasNoError() => Collector.Diagnostics.Should().BeEmpty(); + public void HasNoError() => Collector.Diagnostics.ToSnapshotText().Should().MatchInlineSnapshot(""); } [InheritsTests] @@ -82,7 +84,7 @@ public class MajorVersionOnly() : VersionValidationTests("8") { [Test] public void HasError() => - Collector.Diagnostics.Should().HaveCount(1).And.Contain(d => d.Message.Contains("'8' is not a valid version")); + Collector.Diagnostics.ToSnapshotText().Should().MatchInlineSnapshot("error {repo}/docs/index.md:3 '8' is not a valid version"); } [InheritsTests] @@ -90,5 +92,5 @@ public class BranchVersion() : VersionValidationTests("8.x") { [Test] public void HasError() => - Collector.Diagnostics.Should().HaveCount(1).And.Contain(d => d.Message.Contains("'8.x' is not a valid version")); + Collector.Diagnostics.ToSnapshotText().Should().MatchInlineSnapshot("error {repo}/docs/index.md:3 '8.x' is not a valid version"); }