From 01c9de1f7c33a5b5110d2b3da9bb2906314600c9 Mon Sep 17 00:00:00 2001 From: Martijn Laarman Date: Tue, 30 Sep 2025 16:44:12 +0200 Subject: [PATCH 1/2] update more fsharp nullable warnings which are noisy on CI --- .../Framework/MarkdownDocumentAssertions.fs | 4 +-- .../FrontMatter/ProductsFrontMatter.fs | 26 ++++++++++++++----- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/tests/authoring/Framework/MarkdownDocumentAssertions.fs b/tests/authoring/Framework/MarkdownDocumentAssertions.fs index 1380f4d7e..81617d3c4 100644 --- a/tests/authoring/Framework/MarkdownDocumentAssertions.fs +++ b/tests/authoring/Framework/MarkdownDocumentAssertions.fs @@ -33,8 +33,8 @@ module MarkdownDocumentAssertions = let matter = result.File.YamlFrontMatter match matter with | NonNull m -> - match expectedAvailability with - | NonNull a -> m.AppliesTo.Diagnostics <- a.Diagnostics + match (expectedAvailability, m.AppliesTo) with + | NonNull a, NonNull applies -> applies.Diagnostics <- a.Diagnostics | _ -> () let apply = m.AppliesTo diff --git a/tests/authoring/FrontMatter/ProductsFrontMatter.fs b/tests/authoring/FrontMatter/ProductsFrontMatter.fs index f349c39bd..e22e73355 100644 --- a/tests/authoring/FrontMatter/ProductsFrontMatter.fs +++ b/tests/authoring/FrontMatter/ProductsFrontMatter.fs @@ -69,13 +69,19 @@ This is a test page without products frontmatter. // Test that the file has the correct products test <@ defaultFile.File.YamlFrontMatter <> null @> - test <@ defaultFile.File.YamlFrontMatter.Products <> null @> - test <@ defaultFile.File.YamlFrontMatter.Products.Count = 2 @> + match defaultFile.File.YamlFrontMatter with + | NonNull yamlFrontMatter -> + test <@ yamlFrontMatter.Products <> null @> + match yamlFrontMatter.Products with + | NonNull products -> + test <@ products.Count = 2 @> + // Test that the products are correctly identified + let productIds = products |> Seq.map _.Id |> Set.ofSeq + test <@ productIds.Contains("elasticsearch") @> + test <@ productIds.Contains("ecctl") @> + | _ -> () + | _ -> () - // Test that the products are correctly identified - let productIds = defaultFile.File.YamlFrontMatter.Products |> Seq.map (fun p -> p.Id) |> Set.ofSeq - test <@ productIds.Contains("elasticsearch") @> - test <@ productIds.Contains("ecctl") @> [] let ``does not include products in frontmatter when no products are specified`` () = @@ -84,4 +90,10 @@ This is a test page without products frontmatter. let defaultFile = results.MarkdownResults |> Seq.find (fun r -> r.File.RelativePath = "index.md") // Test that the file has no products - test <@ defaultFile.File.YamlFrontMatter = null || defaultFile.File.YamlFrontMatter.Products = null || defaultFile.File.YamlFrontMatter.Products.Count = 0 @> + match defaultFile.File.YamlFrontMatter with + | NonNull frontMatter -> + match frontMatter.Products with + | NonNull products -> + test <@ products.Count = 0 @> + | _ -> () + | _ -> () From 4389b631486ba2ea2cb1e5af12561851373f6758 Mon Sep 17 00:00:00 2001 From: Martijn Laarman Date: Tue, 30 Sep 2025 16:45:19 +0200 Subject: [PATCH 2/2] fix related warning --- tests/Elastic.Markdown.Tests/Directives/AdmonitionTests.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/Elastic.Markdown.Tests/Directives/AdmonitionTests.cs b/tests/Elastic.Markdown.Tests/Directives/AdmonitionTests.cs index 7f976b892..49d427b2b 100644 --- a/tests/Elastic.Markdown.Tests/Directives/AdmonitionTests.cs +++ b/tests/Elastic.Markdown.Tests/Directives/AdmonitionTests.cs @@ -170,6 +170,8 @@ A regular paragraph. """ ) { + private readonly ITestOutputHelper _output = output; + [Fact] public void SetsCorrectAdmonitionType() => Block!.Admonition.Should().Be("dropdown"); @@ -194,8 +196,8 @@ public void ContainsNestedDirective() { var html = Html; // Output the full HTML for inspection - output.WriteLine("Generated HTML:"); - output.WriteLine(html); + _output.WriteLine("Generated HTML:"); + _output.WriteLine(html); html.Should().Contain("Nested Note"); html.Should().Contain("This is a nested note with colons: 10:30 AM");