From f7419ebd43a15649c718d73ec0c900e316455f0d Mon Sep 17 00:00:00 2001 From: Roy Klooster <76492458+royklo@users.noreply.github.com> Date: Thu, 22 Oct 2026 21:13:03 +0200 Subject: [PATCH] test: cover the not assessed numbers in the assessment HTML reports Adds a behavioural test that runs Invoke-InforcerAssessment single-tenant with -OutputPath and checks the rendered filter counts, score, and the category percentage and badge. Adds presence checks for the single-report 'na' filter branch and the matrix "?" cell and passed/assessed header. Mutations now caught that previously survived: - single-tenant HTML given Failed = TotalChecks - Passed - category percentage computed over all checks - single-report 'na' filter line removed - matrix st-u "?" cell branch removed - matrix header reverted to t.total Co-Authored-By: Claude Opus 5.5 --- Tests/Consistency.Tests.ps1 | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Tests/Consistency.Tests.ps1 b/Tests/Consistency.Tests.ps1 index c7632d3..683191b 100644 --- a/Tests/Consistency.Tests.ps1 +++ b/Tests/Consistency.Tests.ps1 @@ -1272,6 +1272,18 @@ Describe 'Private helpers (via module scope)' { $json[0].ComplianceScore | Should -Be 50 } + It 'writes the assessed counts, score and category percentage to the single-tenant HTML report' { + $path = Join-Path $TestDrive 'report.html' + Invoke-InforcerAssessment -TenantId 1 -AssessmentId 'a1' -OutputPath $path 6>$null | Out-Null + $html = Get-Content -Raw $path + $html | Should -Match "setFilter\('pass',this\)"">Passed \(2\)<" + $html | Should -Match "setFilter\('fail',this\)"">Failed \(2\)<" + $html | Should -Match "setFilter\('na',this\)"">Not Assessed \(2\)<" + $html | Should -Match '50%' + $html | Should -Match '50%' + $html | Should -Match 'subcat-badge badge-warn">2/4<' + } + It 'renders not assessed checks with a neutral badge and filter in the single-tenant HTML' { & (Get-Module InforcerCommunity) { $checks = @( @@ -1284,6 +1296,7 @@ Describe 'Private helpers (via module scope)' { $html | Should -Match '>Not Assessed<' $html | Should -Match "setFilter\('na',this\)" $html | Should -Match 'subcat-badge badge-na">0/0<' + $html | Should -Match ([regex]::Escape("if(currentFilter==='na'&&(status==='Pass'||status==='Fail'))show=false;")) } } @@ -1301,6 +1314,8 @@ Describe 'Private helpers (via module scope)' { $html | Should -Match '"na":1' $html | Should -Match "setFilter\('na',this\)" $html | Should -Match "filt==='na'" + $html | Should -Match ([regex]::Escape('?')) + $html | Should -Match ([regex]::Escape("(t.passed+t.failed)+' passed")) $tr[0].NotAssessed = 0 $tr[0].Checks = @($tr[0].Checks[0])