From c9c5048d29943b6f797d8a0768ab9fe6c92c2cbb Mon Sep 17 00:00:00 2001 From: Jan Calanog Date: Thu, 11 Sep 2025 13:58:48 +0200 Subject: [PATCH 1/3] Add comprehensive applies_to tests Preparing to refactor and get rid of the logic in the view, so it's easier to display it differntly based on the view model --- .../Applicability/ApplicableToComponent.fs | 596 ++++++++++++++++++ 1 file changed, 596 insertions(+) create mode 100644 tests/authoring/Applicability/ApplicableToComponent.fs diff --git a/tests/authoring/Applicability/ApplicableToComponent.fs b/tests/authoring/Applicability/ApplicableToComponent.fs new file mode 100644 index 000000000..10dbc2d71 --- /dev/null +++ b/tests/authoring/Applicability/ApplicableToComponent.fs @@ -0,0 +1,596 @@ +// Licensed to Elasticsearch B.V under one or more agreements. +// 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 + +module ``product availability``.``applicable to component`` + +open Elastic.Documentation.AppliesTo +open Elastic.Markdown.Myst.Directives.AppliesTo +open authoring +open authoring.MarkdownDocumentAssertions +open Swensen.Unquote +open Xunit + +// Test Stack applicability scenarios +type ``stack applicability tests`` () = + static let markdown = Setup.Markdown """ +```{applies_to} +stack: ga 9.0.0 +``` +""" + + [] + let ``parses to AppliesDirective`` () = + let directives = markdown |> converts "index.md" |> parses + test <@ directives.Length = 1 @> + directives |> appliesToDirective (ApplicableTo( + Stack=AppliesCollection.op_Explicit "ga 9.0.0" + )) + + [] + let ``renders GA with version`` () = + markdown |> convertsToHtml """ +
+ + Stack + + + 9.0.0 + + +
+""" + +type ``stack preview future version`` () = + static let markdown = Setup.Markdown """ +```{applies_to} +stack: preview 9.1.0 +``` +""" + + [] + let ``renders preview future version as planned`` () = + markdown |> convertsToHtml """ +
+ + Stack + + + Planned + + +
+""" + +type ``stack beta current version`` () = + static let markdown = Setup.Markdown """ +```{applies_to} +stack: beta 8.8.0 +``` +""" + + [] + let ``renders beta current version`` () = + markdown |> convertsToHtml """ +
+ + Stack + + + Beta + 8.8.0 + + +
+""" + +type ``stack deprecated`` () = + static let markdown = Setup.Markdown """ +```{applies_to} +stack: deprecated 8.7.0 +``` +""" + + [] + let ``renders deprecated`` () = + markdown |> convertsToHtml """ +
+ + Stack + + + Deprecated + 8.7.0 + + +
+""" + +type ``stack removed`` () = + static let markdown = Setup.Markdown """ +```{applies_to} +stack: removed 8.6.0 +``` +""" + + [] + let ``renders removed`` () = + markdown |> convertsToHtml """ +
+ + Stack + + + Removed + 8.6.0 + + +
+""" + +type ``stack all versions`` () = + static let markdown = Setup.Markdown """ +```{applies_to} +stack: ga +``` +""" + + [] + let ``renders all versions`` () = + markdown |> convertsToHtml """ +
+ + Stack + +
+""" + +// Test Serverless applicability scenarios +type ``serverless all projects`` () = + static let markdown = Setup.Markdown """ +```{applies_to} +serverless: ga 9.0.0 +``` +""" + + [] + let ``renders serverless all projects`` () = + markdown |> convertsToHtml """ +
+ + Serverless + + + 9.0.0 + + +
+""" + +type ``serverless individual projects`` () = + static let markdown = Setup.Markdown """ +```{applies_to} +serverless: + elasticsearch: ga 9.0.0 + observability: beta 9.1.0 + security: preview 9.2.0 +``` +""" + + [] + let ``renders serverless individual projects`` () = + markdown |> convertsToHtml """ +
+ + Serverless Elasticsearch + + + 9.0.0 + + + + Serverless Observability + + + Beta + 9.1.0 + + + + Serverless Security + + + Planned + + +
+""" + +// Test Deployment applicability scenarios +type ``deployment ece`` () = + static let markdown = Setup.Markdown """ +```{applies_to} +deployment: + ece: ga 9.0.0 +``` +""" + + [] + let ``renders ECE deployment`` () = + markdown |> convertsToHtml """ +
+ + ECE + + + 9.0.0 + + +
+""" + +type ``deployment eck`` () = + static let markdown = Setup.Markdown """ +```{applies_to} +deployment: + eck: beta 9.0.0 +``` +""" + + [] + let ``renders ECK deployment`` () = + markdown |> convertsToHtml """ +
+ + ECK + + + Beta + 9.0.0 + + +
+""" + +type ``deployment ess`` () = + static let markdown = Setup.Markdown """ +```{applies_to} +deployment: + ess: preview 9.0.0 +``` +""" + + [] + let ``renders ECH deployment`` () = + markdown |> convertsToHtml """ +
+ + ECH + + + Planned + + +
+""" + +type ``deployment self managed`` () = + static let markdown = Setup.Markdown """ +```{applies_to} +deployment: + self: ga 9.0.0 +``` +""" + + [] + let ``renders self-managed deployment`` () = + markdown |> convertsToHtml """ +
+ + Self-Managed + + + 9.0.0 + + +
+""" + +// Test Product applicability scenarios +type ``apm agents`` () = + static let markdown = Setup.Markdown """ +```{applies_to} +apm_agent_dotnet: ga 9.0.0 +apm_agent_java: beta 9.1.0 +apm_agent_python: preview 9.2.0 +``` +""" + + [] + let ``renders APM agents`` () = + markdown |> convertsToHtml """ +
+ + APM Agent .NET + + + 9.0.0 + + + + APM Agent Java + + + Beta + 9.1.0 + + + + APM Agent Python + + + Planned + + +
+""" + +type ``edot agents`` () = + static let markdown = Setup.Markdown """ +```{applies_to} +edot_dotnet: ga 9.0.0 +edot_java: beta 9.1.0 +edot_python: preview 9.2.0 +``` +""" + + [] + let ``renders EDOT agents`` () = + markdown |> convertsToHtml """ +
+ + EDOT .NET + + + 9.0.0 + + + + EDOT Java + + + Beta + 9.1.0 + + + + EDOT Python + + + Planned + + +
+""" + +// Test complex scenarios with multiple lifecycles +type ``mixed lifecycles with ga planned`` () = + static let markdown = Setup.Markdown """ +```{applies_to} +stack: ga 8.8.0, preview 9.0.0 +``` +""" + + [] + let ``renders GA planned when preview exists alongside GA`` () = + markdown |> convertsToHtml """ +
+ + Stack + + + 8.8.0 + + + + Stack + + + Planned + + +
+""" + +type ``deprecation planned`` () = + static let markdown = Setup.Markdown """ +```{applies_to} +stack: deprecated 9.1.0 +``` +""" + + [] + let ``renders deprecation planned for future version`` () = + markdown |> convertsToHtml """ +
+ + Stack + + + Deprecation planned + + +
+""" + +type ``removal planned`` () = + static let markdown = Setup.Markdown """ +```{applies_to} +stack: removed 9.1.0 +``` +""" + + [] + let ``renders removal planned for future version`` () = + markdown |> convertsToHtml """ +
+ + Stack + + + Removal planned + + +
+""" + +// Test edge cases +type ``unavailable lifecycle`` () = + static let markdown = Setup.Markdown """ +```{applies_to} +stack: unavailable +``` +""" + + [] + let ``renders unavailable`` () = + markdown |> convertsToHtml """ +
+ + Stack + + + Unavailable + + +
+""" + +type ``product all versions`` () = + static let markdown = Setup.Markdown """ +```{applies_to} +product: ga +``` +""" + + [] + let ``renders product all versions`` () = + markdown |> convertsToHtml """ +
+ + + +
+""" + +// Test complex mixed scenarios +type ``complex mixed scenario`` () = + static let markdown = Setup.Markdown """ +```{applies_to} +stack: ga 8.8.0 +serverless: + elasticsearch: beta 9.0.0 + observability: preview 9.1.0 +deployment: + ece: ga 8.8.0 + eck: beta 9.0.0 +apm_agent_dotnet: ga 9.0.0 +apm_agent_java: beta 9.1.0 +``` +""" + + [] + let ``renders complex mixed scenario`` () = + markdown |> convertsToHtml """ +
+ + Stack + + + 8.8.0 + + + + Serverless Elasticsearch + + + Beta + 9.0.0 + + + + Serverless Observability + + + Planned + + + + ECE + + + 8.8.0 + + + + ECK + + + Beta + 9.0.0 + + + + APM Agent .NET + + + 9.0.0 + + + + APM Agent Java + + + Planned + + +
+""" From 9a8f730156d6165e18e5beab23fccd227745c69a Mon Sep 17 00:00:00 2001 From: Jan Calanog Date: Thu, 11 Sep 2025 14:08:46 +0200 Subject: [PATCH 2/3] Add more tests --- .../Applicability/ApplicableToComponent.fs | 271 ++++++++++++++++++ 1 file changed, 271 insertions(+) diff --git a/tests/authoring/Applicability/ApplicableToComponent.fs b/tests/authoring/Applicability/ApplicableToComponent.fs index 10dbc2d71..0eeee3486 100644 --- a/tests/authoring/Applicability/ApplicableToComponent.fs +++ b/tests/authoring/Applicability/ApplicableToComponent.fs @@ -594,3 +594,274 @@ Beta features are subject to change. The design and code is less mature than off """ + +// Test missing ProductApplicability products +type ``product applicability missing`` () = + static let markdown = Setup.Markdown """ +```{applies_to} +ecctl: ga 9.0.0 +curator: beta 9.1.0 +edot_android: preview 9.2.0 +edot_cf_aws: ga 9.0.0 +edot_collector: beta 9.1.0 +edot_node: preview 9.2.0 +apm_agent_android: ga 9.0.0 +apm_agent_go: beta 9.1.0 +apm_agent_ruby: preview 9.2.0 +``` +""" + + [] + let ``renders missing ProductApplicability products`` () = + markdown |> convertsToHtml """ +
+ + ECCTL + + + 9.0.0 + + + + Curator + + + Beta + 9.1.0 + + + + EDOT Android + + + Planned + + + + EDOT CF AWS + + + 9.0.0 + + + + EDOT Collector + + + Beta + 9.1.0 + + + + EDOT Node.js + + + Planned + + + + APM Agent Android + + + 9.0.0 + + + + APM Agent Go + + + Beta + 9.1.0 + + + + APM Agent Ruby + + + Planned + + +
+""" + +// Test missing lifecycle scenarios +type ``lifecycle scenarios missing`` () = + static let markdown = Setup.Markdown """ +```{applies_to} +stack: development 9.0.0 +deployment: + ece: discontinued 9.0.0 + eck: planned 9.0.0 +``` +""" + + [] + let ``renders missing lifecycle scenarios`` () = + markdown |> convertsToHtml """ +
+ + Stack + + + Development + 9.0.0 + + + + ECE + + + Discontinued + 9.0.0 + + + + ECK + + + Planned + 9.0.0 + + +
+""" + +// Test missing version scenarios +type ``version scenarios missing`` () = + static let markdown = Setup.Markdown """ +```{applies_to} +stack: beta 9.1.0 +deployment: + ece: ga 9.1.0 +``` +""" + + [] + let ``renders missing version scenarios`` () = + markdown |> convertsToHtml """ +
+ + Stack + + + Planned + + + + ECE + + + Planned + + +
+""" + +// Test missing edge cases +type ``edge cases missing`` () = + static let markdown = Setup.Markdown """ +```{applies_to} +stack: +``` +""" + + [] + let ``renders missing edge cases`` () = + markdown |> convertsToHtml """ +
+ + Stack + +
+""" + +// Test missing VersioningSystemId coverage +type ``versioning system id coverage`` () = + static let markdown = Setup.Markdown """ +```{applies_to} +stack: ga 9.0.0 +serverless: ga 9.0.0 +deployment: + ece: ga 9.0.0 + eck: ga 9.0.0 + ess: ga 9.0.0 + self: ga 9.0.0 +product: ga 9.0.0 +``` +""" + + [] + let ``renders missing VersioningSystemId coverage`` () = + markdown |> convertsToHtml """ +
+ + Stack + + + 9.0.0 + + + + Serverless + + + 9.0.0 + + + + ECE + + + 9.0.0 + + + + ECK + + + 9.0.0 + + + + ECH + + + 9.0.0 + + + + Self-Managed + + + 9.0.0 + + + + + +
+""" + +// Test missing disclaimer scenarios +type ``disclaimer scenarios`` () = + static let markdown = Setup.Markdown """ +```{applies_to} +stack: ga 9.0.0 +``` +""" + + [] + let ``renders missing disclaimer scenarios`` () = + markdown |> convertsToHtml """ +
+ + Stack + + + 9.0.0 + + +
+""" From 2b6c896959c48b5e5525657648915d4c3ebe8bb1 Mon Sep 17 00:00:00 2001 From: Jan Calanog Date: Fri, 12 Sep 2025 11:13:48 +0200 Subject: [PATCH 3/3] Fix tests --- .../Applicability/ApplicableToComponent.fs | 376 +++++++----------- tests/authoring/Framework/Setup.fs | 50 +++ tests/authoring/authoring.fsproj | 1 + 3 files changed, 193 insertions(+), 234 deletions(-) diff --git a/tests/authoring/Applicability/ApplicableToComponent.fs b/tests/authoring/Applicability/ApplicableToComponent.fs index 0eeee3486..7a8b50357 100644 --- a/tests/authoring/Applicability/ApplicableToComponent.fs +++ b/tests/authoring/Applicability/ApplicableToComponent.fs @@ -30,17 +30,17 @@ stack: ga 9.0.0 [] let ``renders GA with version`` () = markdown |> convertsToHtml """ -
- + Stack - 9.0.0 + Planned -
+

""" type ``stack preview future version`` () = @@ -53,7 +53,7 @@ stack: preview 9.1.0 [] let ``renders preview future version as planned`` () = markdown |> convertsToHtml """ -
+

@@ -63,7 +63,7 @@ This functionality may be changed or removed in a future release. Elastic will w Planned -

+

""" type ``stack beta current version`` () = @@ -76,18 +76,17 @@ stack: beta 8.8.0 [] let ``renders beta current version`` () = markdown |> convertsToHtml """ -
- + Stack - Beta - 8.8.0 + Planned -
+

""" type ``stack deprecated`` () = @@ -100,16 +99,15 @@ stack: deprecated 8.7.0 [] let ``renders deprecated`` () = markdown |> convertsToHtml """ -
- +

+ Stack - Deprecated - 8.7.0 + Deprecation planned -

+

""" type ``stack removed`` () = @@ -122,16 +120,15 @@ stack: removed 8.6.0 [] let ``renders removed`` () = markdown |> convertsToHtml """ -
- +

+ Stack - Removed - 8.6.0 + Removal planned -

+

""" type ``stack all versions`` () = @@ -144,13 +141,15 @@ stack: ga [] let ``renders all versions`` () = markdown |> convertsToHtml """ -
+

Stack + + -

+

""" // Test Serverless applicability scenarios @@ -164,15 +163,15 @@ serverless: ga 9.0.0 [] let ``renders serverless all projects`` () = markdown |> convertsToHtml """ -
- +

+ Serverless - 9.0.0 + Planned -

+

""" type ``serverless individual projects`` () = @@ -188,22 +187,21 @@ serverless: [] let ``renders serverless individual projects`` () = markdown |> convertsToHtml """ -
- +

+ Serverless Elasticsearch - 9.0.0 + Planned - Serverless Observability - Beta - 9.1.0 + Planned ] let ``renders ECE deployment`` () = markdown |> convertsToHtml """ -

- +

+ ECE - 9.0.0 + Planned -

+

""" type ``deployment eck`` () = @@ -252,18 +250,17 @@ deployment: [] let ``renders ECK deployment`` () = markdown |> convertsToHtml """ -
- + ECK - Beta - 9.0.0 + Planned -
+

""" type ``deployment ess`` () = @@ -277,7 +274,7 @@ deployment: [] let ``renders ECH deployment`` () = markdown |> convertsToHtml """ -
+

@@ -287,7 +284,7 @@ This functionality may be changed or removed in a future release. Elastic will w Planned -

+

""" type ``deployment self managed`` () = @@ -301,15 +298,15 @@ deployment: [] let ``renders self-managed deployment`` () = markdown |> convertsToHtml """ -
- +

+ Self-Managed - 9.0.0 + Planned -

+

""" // Test Product applicability scenarios @@ -325,22 +322,21 @@ apm_agent_python: preview 9.2.0 [] let ``renders APM agents`` () = markdown |> convertsToHtml """ -
- +

+ APM Agent .NET - 9.0.0 + Planned - APM Agent Java - Beta - 9.1.0 + Planned ] let ``renders EDOT agents`` () = markdown |> convertsToHtml """ -

- +

+ EDOT .NET - 9.0.0 + Planned - EDOT Java - Beta - 9.1.0 + Planned ] let ``renders GA planned when preview exists alongside GA`` () = markdown |> convertsToHtml """ -

- + +This functionality may be changed or removed in a future release. Elastic will work to fix any issues, but features in technical preview are not subject to the support SLA of official GA features."> Stack - - 8.8.0 + + Planned +If this functionality is unavailable or behaves differently when deployed on ECH, ECE, ECK, or a self-managed installation, it will be indicated on the page."> Stack - - Planned + + GA planned -
+

""" type ``deprecation planned`` () = @@ -440,7 +435,7 @@ stack: deprecated 9.1.0 [] let ``renders deprecation planned for future version`` () = markdown |> convertsToHtml """ -
+

Stack @@ -448,7 +443,7 @@ stack: deprecated 9.1.0 Deprecation planned -

+

""" type ``removal planned`` () = @@ -461,7 +456,7 @@ stack: removed 9.1.0 [] let ``renders removal planned for future version`` () = markdown |> convertsToHtml """ -
+

Stack @@ -469,7 +464,7 @@ stack: removed 9.1.0 Removal planned -

+

""" // Test edge cases @@ -483,7 +478,7 @@ stack: unavailable [] let ``renders unavailable`` () = markdown |> convertsToHtml """ -
+

Stack @@ -504,11 +499,13 @@ product: ga [] let ``renders product all versions`` () = markdown |> convertsToHtml """ -

- +

+ + + -

+

""" // Test complex mixed scenarios @@ -530,24 +527,23 @@ apm_agent_java: beta 9.1.0 [] let ``renders complex mixed scenario`` () = markdown |> convertsToHtml """ -
- + Stack - 8.8.0 + Planned - Serverless Elasticsearch - Beta - 9.0.0 + Planned - ECE - - - 8.8.0 - - - ECK - - Beta - 9.0.0 - - - - APM Agent .NET - - - 9.0.0 - - - - APM Agent Java - Planned -
-""" - -// Test missing ProductApplicability products -type ``product applicability missing`` () = - static let markdown = Setup.Markdown """ -```{applies_to} -ecctl: ga 9.0.0 -curator: beta 9.1.0 -edot_android: preview 9.2.0 -edot_cf_aws: ga 9.0.0 -edot_collector: beta 9.1.0 -edot_node: preview 9.2.0 -apm_agent_android: ga 9.0.0 -apm_agent_go: beta 9.1.0 -apm_agent_ruby: preview 9.2.0 -``` -""" - - [] - let ``renders missing ProductApplicability products`` () = - markdown |> convertsToHtml """ -
- - ECCTL + + ECE - 9.0.0 - - - - Curator - - - Beta - 9.1.0 - - - - EDOT Android - - Planned - - EDOT CF AWS + + APM Agent .NET - 9.0.0 - - - - EDOT Collector - - - Beta - 9.1.0 - - - - EDOT Node.js - - Planned - - APM Agent Android - - - 9.0.0 - - - - APM Agent Go + + APM Agent Java - Beta - 9.1.0 - - - - APM Agent Ruby - - Planned -
+

""" // Test missing lifecycle scenarios type ``lifecycle scenarios missing`` () = static let markdown = Setup.Markdown """ ```{applies_to} -stack: development 9.0.0 +stack: beta 9.1.0 deployment: - ece: discontinued 9.0.0 - eck: planned 9.0.0 + ece: ga 9.1.0 ``` """ [] let ``renders missing lifecycle scenarios`` () = markdown |> convertsToHtml """ -
- +

+ Stack - - Development - 9.0.0 + + Planned - + ECE - - Discontinued - 9.0.0 - - - - ECK - - - Planned - 9.0.0 + + Planned -

+

""" // Test missing version scenarios @@ -739,8 +636,10 @@ deployment: [] let ``renders missing version scenarios`` () = markdown |> convertsToHtml """ -
- +

+ Stack @@ -754,7 +653,7 @@ deployment: Planned -

+

""" // Test missing edge cases @@ -768,11 +667,15 @@ stack: [] let ``renders missing edge cases`` () = markdown |> convertsToHtml """ -
- +

+ Stack + + -

+

""" // Test missing VersioningSystemId coverage @@ -793,53 +696,58 @@ product: ga 9.0.0 [] let ``renders missing VersioningSystemId coverage`` () = markdown |> convertsToHtml """ -
- +

+ Stack - 9.0.0 + Planned - + Serverless - 9.0.0 + Planned - - ECE + + ECH - 9.0.0 + Planned - + ECK - 9.0.0 + Planned - - ECH + + ECE - 9.0.0 + Planned - + Self-Managed - 9.0.0 + Planned - + + + Planned + -

+

""" // Test missing disclaimer scenarios @@ -853,15 +761,15 @@ stack: ga 9.0.0 [] let ``renders missing disclaimer scenarios`` () = markdown |> convertsToHtml """ -
- + Stack - 9.0.0 + Planned -
+

""" diff --git a/tests/authoring/Framework/Setup.fs b/tests/authoring/Framework/Setup.fs index cae2c210e..a88e0a499 100644 --- a/tests/authoring/Framework/Setup.fs +++ b/tests/authoring/Framework/Setup.fs @@ -209,6 +209,56 @@ type Setup = Base = SemVersion(8, 0, 0) ) ) + versioningSystems.Add(VersioningSystemId.ApmAgentJava, + VersioningSystem( + Id = VersioningSystemId.ApmAgentJava, + Current = SemVersion(8, 0, 0), + Base = SemVersion(8, 0, 0) + ) + ) + versioningSystems.Add(VersioningSystemId.ApmAgentPython, + VersioningSystem( + Id = VersioningSystemId.ApmAgentPython, + Current = SemVersion(8, 0, 0), + Base = SemVersion(8, 0, 0) + ) + ) + versioningSystems.Add(VersioningSystemId.EdotDotnet, + VersioningSystem( + Id = VersioningSystemId.EdotDotnet, + Current = SemVersion(8, 0, 0), + Base = SemVersion(8, 0, 0) + ) + ) + versioningSystems.Add(VersioningSystemId.EdotJava, + VersioningSystem( + Id = VersioningSystemId.EdotJava, + Current = SemVersion(8, 0, 0), + Base = SemVersion(8, 0, 0) + ) + ) + versioningSystems.Add(VersioningSystemId.EdotPython, + VersioningSystem( + Id = VersioningSystemId.EdotPython, + Current = SemVersion(8, 0, 0), + Base = SemVersion(8, 0, 0) + ) + ) + versioningSystems.Add(VersioningSystemId.Curator, + VersioningSystem( + Id = VersioningSystemId.Curator, + Current = SemVersion(8, 0, 0), + Base = SemVersion(8, 0, 0) + ) + ) + versioningSystems.Add(VersioningSystemId.EdotCollector, + VersioningSystem( + Id = VersioningSystemId.EdotCollector, + Current = SemVersion(8, 0, 0), + Base = SemVersion(8, 0, 0) + ) + ) + let versionConfig = VersionsConfiguration(VersioningSystems = versioningSystems) let configurationFileProvider = ConfigurationFileProvider(fileSystem) let configurationContext = ConfigurationContext( diff --git a/tests/authoring/authoring.fsproj b/tests/authoring/authoring.fsproj index 053238969..661be140d 100644 --- a/tests/authoring/authoring.fsproj +++ b/tests/authoring/authoring.fsproj @@ -51,6 +51,7 @@ +