From 970f4fafcdd40f491d8665c89a3f4498f471057a Mon Sep 17 00:00:00 2001 From: WesleyJammer Date: Mon, 19 Jan 2026 13:35:35 +0100 Subject: [PATCH 1/2] Exclude UsageHintGroup from proof explanation rendering Updated DefaultProofExplanationTextPreRenderer to filter out UsageHintGroup children when rendering proof explanations. Added a test to verify that usage hints are not included in the output for proof explanations. --- .../DefaultProofExplanationTextPreRenderer.kt | 3 +- .../atrium/reporting/CreateReportTest.kt | 35 +++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/atrium-core/src/commonMain/kotlin/ch/tutteli/atrium/reporting/prerendering/text/impl/DefaultProofExplanationTextPreRenderer.kt b/atrium-core/src/commonMain/kotlin/ch/tutteli/atrium/reporting/prerendering/text/impl/DefaultProofExplanationTextPreRenderer.kt index 8df262bfa0..6c5d18a7e1 100644 --- a/atrium-core/src/commonMain/kotlin/ch/tutteli/atrium/reporting/prerendering/text/impl/DefaultProofExplanationTextPreRenderer.kt +++ b/atrium-core/src/commonMain/kotlin/ch/tutteli/atrium/reporting/prerendering/text/impl/DefaultProofExplanationTextPreRenderer.kt @@ -5,6 +5,7 @@ import ch.tutteli.atrium.reporting.prerendering.text.TextPreRenderControlObject import ch.tutteli.atrium.reporting.prerendering.text.TypedTextPreRenderer import ch.tutteli.atrium.reporting.reportables.Icon import ch.tutteli.atrium.reporting.reportables.ProofExplanation +import ch.tutteli.atrium.reporting.reportables.UsageHintGroup internal class DefaultProofExplanationTextPreRenderer : TypedTextPreRenderer(ProofExplanation::class) { @@ -17,7 +18,7 @@ internal class DefaultProofExplanationTextPreRenderer : prefix = Icon.PROOF_EXPLANATION_BULLET_POINT, explainsProof = true ) - return OutputNode.singleWithoutColumnsNotOwnLevel(children = reportable.children.flatMap { child -> + return OutputNode.singleWithoutColumnsNotOwnLevel(children = reportable.children.filterNot { it is UsageHintGroup }.flatMap { child -> controlObject.transformChildIncludingIndentationAndPrefix(child, newControlObject) }) } diff --git a/atrium-core/src/commonTest/kotlin/ch/tutteli/atrium/reporting/CreateReportTest.kt b/atrium-core/src/commonTest/kotlin/ch/tutteli/atrium/reporting/CreateReportTest.kt index 59bf335fb0..d6ae93a9fb 100644 --- a/atrium-core/src/commonTest/kotlin/ch/tutteli/atrium/reporting/CreateReportTest.kt +++ b/atrium-core/src/commonTest/kotlin/ch/tutteli/atrium/reporting/CreateReportTest.kt @@ -764,6 +764,41 @@ class CreateReportTest { ) } + @Test + fun proofExplanation_With_UsageHint() { + val builder = buildRootGroup { + proofGroup(Text("not to contain"), Text.EMPTY) { + invisibleFailingProofGroup { + proofExplanation { + simpleProof(Text("to be greater than"), 2) { false } + usageHintGroup { + add(ErrorMessages.FORGOT_DO_DEFINE_EXPECTATION) + addAll(defaultHintsAtLeastOneExpectationDefined) + } + } + } + } + } + + expectForReporterWithoutAnsi( + builder, + """ + |a verb : "representation" + |(f) not to contain :${' '} + | » to be greater than : 2 + """.trimMargin() + ) + + expectForReporterWithAnsi( + builder, + """ + |a verb : "representation" + |$x not to contain :${' '} + | » to be greater than : 2 + """.trimMargin() + ) + } + @Test fun row_withIconAndWithoutBorder() { val builder = buildRootGroup { From 52f54e4ffd5856244c54a48c29b2564a8156b6f0 Mon Sep 17 00:00:00 2001 From: WesleyJammer Date: Wed, 21 Jan 2026 11:18:36 +0100 Subject: [PATCH 2/2] Fix usage hint rendering in proof explanations Removes filtering of UsageHintGroup in DefaultProofExplanationTextPreRenderer and updates DefaultUsageHintGroupTextPreRenderer to skip rendering when explaining proof. Adds a test to verify usage hints are not rendered in proof explanations as direct and not-direct children. --- .../DefaultProofExplanationTextPreRenderer.kt | 3 +- .../DefaultUsageHintGroupTextPreRenderer.kt | 1 + .../atrium/reporting/CreateReportTest.kt | 32 +++++++++++++++++++ 3 files changed, 34 insertions(+), 2 deletions(-) diff --git a/atrium-core/src/commonMain/kotlin/ch/tutteli/atrium/reporting/prerendering/text/impl/DefaultProofExplanationTextPreRenderer.kt b/atrium-core/src/commonMain/kotlin/ch/tutteli/atrium/reporting/prerendering/text/impl/DefaultProofExplanationTextPreRenderer.kt index 6c5d18a7e1..8df262bfa0 100644 --- a/atrium-core/src/commonMain/kotlin/ch/tutteli/atrium/reporting/prerendering/text/impl/DefaultProofExplanationTextPreRenderer.kt +++ b/atrium-core/src/commonMain/kotlin/ch/tutteli/atrium/reporting/prerendering/text/impl/DefaultProofExplanationTextPreRenderer.kt @@ -5,7 +5,6 @@ import ch.tutteli.atrium.reporting.prerendering.text.TextPreRenderControlObject import ch.tutteli.atrium.reporting.prerendering.text.TypedTextPreRenderer import ch.tutteli.atrium.reporting.reportables.Icon import ch.tutteli.atrium.reporting.reportables.ProofExplanation -import ch.tutteli.atrium.reporting.reportables.UsageHintGroup internal class DefaultProofExplanationTextPreRenderer : TypedTextPreRenderer(ProofExplanation::class) { @@ -18,7 +17,7 @@ internal class DefaultProofExplanationTextPreRenderer : prefix = Icon.PROOF_EXPLANATION_BULLET_POINT, explainsProof = true ) - return OutputNode.singleWithoutColumnsNotOwnLevel(children = reportable.children.filterNot { it is UsageHintGroup }.flatMap { child -> + return OutputNode.singleWithoutColumnsNotOwnLevel(children = reportable.children.flatMap { child -> controlObject.transformChildIncludingIndentationAndPrefix(child, newControlObject) }) } diff --git a/atrium-core/src/commonMain/kotlin/ch/tutteli/atrium/reporting/prerendering/text/impl/DefaultUsageHintGroupTextPreRenderer.kt b/atrium-core/src/commonMain/kotlin/ch/tutteli/atrium/reporting/prerendering/text/impl/DefaultUsageHintGroupTextPreRenderer.kt index eba28f717d..4df926a5ee 100644 --- a/atrium-core/src/commonMain/kotlin/ch/tutteli/atrium/reporting/prerendering/text/impl/DefaultUsageHintGroupTextPreRenderer.kt +++ b/atrium-core/src/commonMain/kotlin/ch/tutteli/atrium/reporting/prerendering/text/impl/DefaultUsageHintGroupTextPreRenderer.kt @@ -12,6 +12,7 @@ internal class DefaultUsageHintGroupTextPreRenderer : TypedTextPreRenderer { + if (controlObject.explainsProof) return emptyList() val newControlObject = controlObject.copy(prefix = Icon.BULB, indentLevel = controlObject.indentLevel + 1) return OutputNode.singleWithoutColumnsNotOwnLevel(children = reportable.children.flatMap { child -> controlObject.transformChildIncludingIndentationAndPrefix(child, newControlObject) diff --git a/atrium-core/src/commonTest/kotlin/ch/tutteli/atrium/reporting/CreateReportTest.kt b/atrium-core/src/commonTest/kotlin/ch/tutteli/atrium/reporting/CreateReportTest.kt index d6ae93a9fb..205afabc27 100644 --- a/atrium-core/src/commonTest/kotlin/ch/tutteli/atrium/reporting/CreateReportTest.kt +++ b/atrium-core/src/commonTest/kotlin/ch/tutteli/atrium/reporting/CreateReportTest.kt @@ -798,6 +798,38 @@ class CreateReportTest { """.trimMargin() ) } + @Test + fun proofExplanation_With_UsageHint_Not_As_Direct_Child() { + + val builder = buildRootGroup { + + proofGroup(Text("Elements need all"), Text.EMPTY){ + invisibleFailingProofGroup { + proofExplanation { + feature(Text("password"), Text("should not be shown")) { + simpleProof(Text("not to equal"), "qwerty") { false } + usageHintGroup { + add(ErrorMessages.FORGOT_DO_DEFINE_EXPECTATION) + addAll(defaultHintsAtLeastOneExpectationDefined) + } + + + } + } + } + } + } + expectForReporterWithoutAnsi( + builder, + """ + |a verb : "representation" + |(f) Elements need all :${' '} + | » > password :${' '} + | • not to equal : "qwerty" + """.trimMargin() + + ) + } @Test fun row_withIconAndWithoutBorder() {