47 lines
2.2 KiB
PowerShell
47 lines
2.2 KiB
PowerShell
$ErrorActionPreference = 'Stop'
|
|
|
|
$root = Split-Path -Parent $PSScriptRoot
|
|
$captureScriptPath = Join-Path $root 'scripts/capture-chrome-page.js'
|
|
|
|
if (-not (Test-Path -LiteralPath $captureScriptPath)) {
|
|
throw 'Missing Chrome capture script'
|
|
}
|
|
|
|
$captureScript = Get-Content -LiteralPath $captureScriptPath -Raw -Encoding utf8
|
|
|
|
if ($captureScript -notmatch "const renderSettleMilliseconds = 900") {
|
|
throw 'Chrome capture must define a 900ms render-settle delay after the target selector appears'
|
|
}
|
|
if ($captureScript -notmatch 'await sleep\(renderSettleMilliseconds\)') {
|
|
throw 'Chrome capture must wait for the render-settle delay before taking a screenshot'
|
|
}
|
|
if ($captureScript -match 'await sleep\(300\)') {
|
|
throw 'Chrome capture must not retain the unstable 300ms post-selector delay'
|
|
}
|
|
if ($captureScript -notmatch 'const waitForLoadedImages = async \(send\) =>') {
|
|
throw 'Chrome capture must define an image-load wait before a visual screenshot'
|
|
}
|
|
if ($captureScript -notmatch 'Array\.from\(document\.images\)\.every') {
|
|
throw 'Chrome capture must wait until every document image has loaded'
|
|
}
|
|
if ($captureScript -notmatch 'await waitForLoadedImages\(send\)') {
|
|
throw 'Chrome capture must wait for document images after the target selector renders'
|
|
}
|
|
if ($captureScript -notmatch "await send\('Page.reload'\)") {
|
|
throw 'Chrome capture must reload after navigation so route screenshots do not inherit a prior Vue state'
|
|
}
|
|
if ($captureScript.IndexOf("await send('Page.navigate'") -ge $captureScript.IndexOf("await send('Page.reload')")) {
|
|
throw 'Chrome capture must reload only after it has navigated to the requested URL'
|
|
}
|
|
if ($captureScript -notmatch 'const waitForFreshDocument = async \(send, documentTimeOrigin\) =>') {
|
|
throw 'Chrome capture must define a fresh-document wait after reloading'
|
|
}
|
|
if ($captureScript -notmatch 'performance\.timeOrigin') {
|
|
throw 'Chrome capture must distinguish a fresh document from a reused Vue route state'
|
|
}
|
|
if ($captureScript -notmatch 'await waitForFreshDocument\(send, documentTimeOrigin\)') {
|
|
throw 'Chrome capture must wait for a fresh document before checking the target selector'
|
|
}
|
|
|
|
Write-Output 'CAPTURE-CHROME-PAGE-CONTRACT PASS'
|