Tests/UI.Tests.ps1
|
#Requires -Modules Pester # Static checks on the local web page. The page's behaviour is tested in a browser walkthrough # (see Docs/Lab-Test-Plan.md); these guard against regressions that break it outright. BeforeAll { $script:PagePath = Join-Path (Split-Path $PSScriptRoot -Parent) 'UI/index.html' $script:Page = [System.IO.File]::ReadAllText($script:PagePath) } Describe 'Web page' { It 'is plain ASCII so it serves the same on PowerShell 5.1 and 7' { $bytes = [System.IO.File]::ReadAllBytes($script:PagePath) @($bytes | Where-Object { $_ -gt 127 }).Count | Should -Be 0 } It 'has no inline event handlers, which the page security policy would block' { $script:Page | Should -Not -Match '\son(click|change|input|load|submit)\s*=' } It 'loads no script or style from another site' { $script:Page | Should -Not -Match '<script[^>]+src=["'']https?://' $script:Page | Should -Not -Match '<link[^>]+href=["'']https?://' } It 'offers in-place editing, bulk save, refresh and the RBAC health view' { foreach ($id in 'edSave', 'edStage', 'bulkSave', 'bulkGo', 'btnRefresh') { $script:Page | Should -Match ('id="' + $id + '"') } $script:Page | Should -Match 'function renderHealthView' $script:Page | Should -Match 'function healthFindings' } It 'asks for the typed phrase above the quick-confirm limit' { $script:Page | Should -Match 'QUICK_CONFIRM_MAX = 25' $script:Page | Should -Match "APPLY " } } |