2026-08-08 15:25:46 +08:00
|
|
|
[CmdletBinding()]
|
|
|
|
|
param(
|
|
|
|
|
[switch]$DryRun,
|
|
|
|
|
[switch]$SkipAdmin,
|
2026-09-08 17:24:48 +08:00
|
|
|
[switch]$SkipClient,
|
|
|
|
|
[switch]$SkipPda
|
2026-08-08 15:25:46 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
$ErrorActionPreference = 'Stop'
|
2026-10-19 17:56:36 +08:00
|
|
|
if (-not $DryRun -and -not $env:CHONGCHONG_LOCAL_CHECK_OWNER) {
|
|
|
|
|
$batch = @('pwsh', '-NoProfile', '-File', $PSCommandPath)
|
|
|
|
|
foreach ($flag in @('SkipAdmin', 'SkipClient', 'SkipPda')) {
|
|
|
|
|
if ($PSBoundParameters[$flag]) { $batch += "-$flag" }
|
|
|
|
|
}
|
|
|
|
|
& (Join-Path $PSScriptRoot 'local-check.ps1') -Label 'Frontend full regression' -Command $batch
|
|
|
|
|
exit $LASTEXITCODE
|
|
|
|
|
}
|
2026-08-08 15:25:46 +08:00
|
|
|
$repoRoot = (Resolve-Path (Join-Path $PSScriptRoot '../..')).Path
|
|
|
|
|
|
|
|
|
|
function Invoke-FrontendStep {
|
|
|
|
|
param([string]$Name, [string]$Directory, [string]$Task)
|
|
|
|
|
$display = "pnpm --dir `"$Directory`" $Task"
|
2026-10-19 17:56:36 +08:00
|
|
|
if ($Task -eq 'test' -and (Split-Path -Leaf $Directory) -eq 'client-web') {
|
|
|
|
|
$display = "pnpm --dir `"$Directory`" exec node --test --test-concurrency=2 src/**/*.test.mjs"
|
|
|
|
|
}
|
2026-08-08 15:25:46 +08:00
|
|
|
Write-Host " [$Name] $display"
|
|
|
|
|
if ($DryRun) { return }
|
2026-10-19 17:56:36 +08:00
|
|
|
if ($Task -eq 'test' -and (Split-Path -Leaf $Directory) -eq 'client-web') {
|
|
|
|
|
& pnpm --dir $Directory exec node --test --test-concurrency=2 'src/**/*.test.mjs'
|
|
|
|
|
} else {
|
|
|
|
|
& pnpm --dir $Directory $Task
|
|
|
|
|
}
|
2026-08-08 15:25:46 +08:00
|
|
|
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
|
|
|
|
|
}
|
|
|
|
|
|
2026-09-08 17:24:48 +08:00
|
|
|
function Invoke-PdaTests {
|
|
|
|
|
param([string]$Directory)
|
|
|
|
|
$pattern = Join-Path $Directory 'tests/*.test.mjs'
|
|
|
|
|
Write-Host " [test] node --test `"$pattern`""
|
|
|
|
|
if ($DryRun) { return }
|
2026-10-19 17:56:36 +08:00
|
|
|
& node --test --test-concurrency=2 $pattern
|
2026-09-08 17:24:48 +08:00
|
|
|
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($SkipAdmin -and $SkipClient -and $SkipPda) { Write-Error 'At least one of Admin, Client or PDA must be selected.'; exit 2 }
|
|
|
|
|
if ((-not $SkipAdmin -or -not $SkipClient) -and -not (Get-Command pnpm -ErrorAction SilentlyContinue)) {
|
|
|
|
|
Write-Error 'pnpm was not found on PATH.'; exit 2
|
|
|
|
|
}
|
|
|
|
|
if (-not $SkipPda -and -not (Get-Command node -ErrorAction SilentlyContinue)) {
|
|
|
|
|
Write-Error 'node was not found on PATH.'; exit 2
|
|
|
|
|
}
|
2026-08-08 15:25:46 +08:00
|
|
|
|
|
|
|
|
$targets = @()
|
|
|
|
|
if (-not $SkipAdmin) { $targets += @{ Name = 'Admin'; Directory = Join-Path $repoRoot 'apps/admin-web' } }
|
|
|
|
|
if (-not $SkipClient) { $targets += @{ Name = 'Client'; Directory = Join-Path $repoRoot 'apps/client-web' } }
|
|
|
|
|
|
|
|
|
|
Write-Host 'Frontend full regression (local only)'
|
|
|
|
|
Write-Host "Repository: $repoRoot"
|
|
|
|
|
Write-Host "Mode: $(if ($DryRun) { 'DryRun' } else { 'Execute' })"
|
|
|
|
|
Write-Host 'Gateway/database/deployment: not used'
|
|
|
|
|
|
|
|
|
|
foreach ($target in $targets) {
|
|
|
|
|
$packageJson = Join-Path $target.Directory 'package.json'
|
|
|
|
|
if (-not (Test-Path -LiteralPath $packageJson)) { Write-Error "$($target.Name) package.json not found: $packageJson"; exit 2 }
|
|
|
|
|
Write-Host "[$($target.Name)]"
|
|
|
|
|
Invoke-FrontendStep 'test' $target.Directory 'test'
|
|
|
|
|
Invoke-FrontendStep 'typecheck' $target.Directory 'typecheck'
|
|
|
|
|
}
|
|
|
|
|
|
2026-09-08 17:24:48 +08:00
|
|
|
if (-not $SkipPda) {
|
2026-09-09 17:16:34 +08:00
|
|
|
$pdaTargets = @(
|
|
|
|
|
@{ Name = 'Domestic PDA'; Directory = Join-Path $repoRoot 'apps/pda-uniapp' },
|
|
|
|
|
@{ Name = 'Overseas PDA'; Directory = Join-Path $repoRoot 'apps/pda-overseas-uniapp' }
|
|
|
|
|
)
|
|
|
|
|
foreach ($pdaTarget in $pdaTargets) {
|
|
|
|
|
if (-not (Test-Path -LiteralPath (Join-Path $pdaTarget.Directory 'tests'))) {
|
|
|
|
|
Write-Error "$($pdaTarget.Name) tests directory not found: $($pdaTarget.Directory)"; exit 2
|
|
|
|
|
}
|
|
|
|
|
Write-Host "[$($pdaTarget.Name)]"
|
|
|
|
|
Invoke-PdaTests $pdaTarget.Directory
|
2026-09-08 17:24:48 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-08-08 15:25:46 +08:00
|
|
|
Write-Host 'Frontend regression completed.'
|