test: add repeatable presentation screenshot rehearsal
This commit is contained in:
@@ -27,6 +27,7 @@ coverage/
|
|||||||
|
|
||||||
# Local presentation screenshots
|
# Local presentation screenshots
|
||||||
web/apps/console/.visual-smoke/
|
web/apps/console/.visual-smoke/
|
||||||
|
web/apps/console/.visual-smoke/rehearsal/
|
||||||
|
|
||||||
# IDE/Editor Specific
|
# IDE/Editor Specific
|
||||||
.vscode/
|
.vscode/
|
||||||
|
|||||||
@@ -22,6 +22,20 @@ Capture the receipt state and open-inspector state at each viewport. Confirm
|
|||||||
no page scroll, unchanged primary geometry, bounded raw evidence, focus
|
no page scroll, unchanged primary geometry, bounded raw evidence, focus
|
||||||
restoration, compact chat exclusion, and a clean browser console.
|
restoration, compact chat exclusion, and a clean browser console.
|
||||||
|
|
||||||
|
## Repeatable Rehearsal Capture
|
||||||
|
|
||||||
|
With the presentation dev server running, capture every canonical route at both
|
||||||
|
supported rehearsal viewports:
|
||||||
|
|
||||||
|
```powershell
|
||||||
|
pwsh -File scripts/presentation-rehearsal.ps1
|
||||||
|
```
|
||||||
|
|
||||||
|
Review the generated screenshots in story order, then inspect any route that
|
||||||
|
shows clipping, stale chrome, unreadable copy, or a changed primary visual.
|
||||||
|
The runner waits for the settled route before each capture and writes ignored
|
||||||
|
output under `web/apps/console/.visual-smoke/rehearsal/`.
|
||||||
|
|
||||||
## Automated Smoke
|
## Automated Smoke
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
|||||||
@@ -0,0 +1,50 @@
|
|||||||
|
[CmdletBinding()]
|
||||||
|
param(
|
||||||
|
[string]$BaseUrl = "http://127.0.0.1:5173",
|
||||||
|
[string]$OutputRoot = "web/apps/console/.visual-smoke/rehearsal",
|
||||||
|
[string[]]$Viewports = @("1280,720", "1024,768")
|
||||||
|
)
|
||||||
|
|
||||||
|
$ErrorActionPreference = "Stop"
|
||||||
|
$ManifestPath = Join-Path $PSScriptRoot "presentation-rehearsal-routes.json"
|
||||||
|
|
||||||
|
try {
|
||||||
|
Invoke-WebRequest -Uri $BaseUrl -UseBasicParsing -TimeoutSec 5 | Out-Null
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
throw "Presentation dev server unavailable at $BaseUrl. Start it with: pnpm --dir web dev"
|
||||||
|
}
|
||||||
|
|
||||||
|
if (-not (Test-Path -LiteralPath $ManifestPath -PathType Leaf)) {
|
||||||
|
throw "Presentation rehearsal route manifest not found: $ManifestPath"
|
||||||
|
}
|
||||||
|
|
||||||
|
$Routes = Get-Content -LiteralPath $ManifestPath -Raw | ConvertFrom-Json
|
||||||
|
if ($null -eq $Routes -or @($Routes).Count -eq 0) {
|
||||||
|
throw "Presentation rehearsal route manifest is empty: $ManifestPath"
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($Viewport in $Viewports) {
|
||||||
|
$ViewportRoot = Join-Path $OutputRoot $Viewport
|
||||||
|
New-Item -ItemType Directory -Path $ViewportRoot -Force | Out-Null
|
||||||
|
|
||||||
|
foreach ($Route in $Routes) {
|
||||||
|
if ([string]::IsNullOrWhiteSpace($Route.route) -or [string]::IsNullOrWhiteSpace($Route.fileStem)) {
|
||||||
|
throw "Each rehearsal route must define both route and fileStem: $($Route | ConvertTo-Json -Compress)"
|
||||||
|
}
|
||||||
|
|
||||||
|
$FileName = (($Route.fileStem -replace '[^A-Za-z0-9._-]', '-') + ".png")
|
||||||
|
$Url = "$($BaseUrl.TrimEnd('/'))/present#scene/$($Route.route)"
|
||||||
|
$OutputPath = Join-Path $ViewportRoot $FileName
|
||||||
|
|
||||||
|
Write-Host "$Viewport $Url -> $OutputPath"
|
||||||
|
& pnpx --yes playwright screenshot `
|
||||||
|
--viewport-size $Viewport `
|
||||||
|
--wait-for-timeout 800 `
|
||||||
|
$Url `
|
||||||
|
$OutputPath
|
||||||
|
if ($LASTEXITCODE -ne 0) {
|
||||||
|
throw "Screenshot capture failed for $Url at $Viewport (exit code $LASTEXITCODE)"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user