mirror of
https://github.com/HKUDS/DeepTutor.git
synced 2026-12-03 21:10:50 +08:00
test(desktop): verify Windows installer lifecycle and preserve user files
This commit is contained in:
6
.github/workflows/desktop-release.yml
vendored
6
.github/workflows/desktop-release.yml
vendored
@@ -144,6 +144,11 @@ jobs:
|
||||
APPLE_SIGNING_IDENTITY: ${{ env.PUBLISH == 'true' && secrets.APPLE_SIGNING_IDENTITY || '' }}
|
||||
run: npm run package -- --target ${{ matrix.target }}
|
||||
|
||||
- name: Verify Windows installation and app lifecycle
|
||||
if: runner.os == 'Windows'
|
||||
shell: pwsh
|
||||
run: ./platforms/windows-x64/smoke-installer.ps1
|
||||
|
||||
- name: Notarize the DMG
|
||||
if: runner.os == 'macOS' && env.HAS_NOTARY == 'true' && env.PUBLISH == 'true'
|
||||
env:
|
||||
@@ -180,3 +185,4 @@ jobs:
|
||||
apps/desktop/out/*-Portable.zip
|
||||
apps/desktop/.local/${{ matrix.target }}/smoke.log
|
||||
apps/desktop/.local/${{ matrix.target }}/smoke-result.json
|
||||
apps/desktop/.local/${{ matrix.target }}/installed-app.log
|
||||
|
||||
@@ -132,5 +132,9 @@ signature and platform rejection, process shutdown, cancellation and local
|
||||
service behaviour; CI runs it on Linux and Windows. `npm run smoke` boots the
|
||||
real bundled core in a fresh temporary workspace, checks backend, frontend and
|
||||
API proxy, then verifies both ports close. It does not call a paid model or
|
||||
test optional external renderers. `OPEN_DEEPTUTOR_TEST_HOME` selects a
|
||||
disposable desktop home for UI checks.
|
||||
test optional external renderers. Windows CI also runs
|
||||
`platforms/windows-x64/smoke-installer.ps1`: it silently installs the app,
|
||||
opens the actual Electron window with a fresh data path containing spaces and
|
||||
Chinese characters, checks UI/API readiness and service shutdown on window
|
||||
close, then verifies uninstall preserves learning data and unrelated files.
|
||||
`OPEN_DEEPTUTOR_TEST_HOME` selects a disposable desktop home for UI checks.
|
||||
|
||||
@@ -44,12 +44,21 @@ VIAddVersionKey "FileVersion" "${FILEVERSION}"
|
||||
RMDir /r "$INSTDIR\resources"
|
||||
RMDir /r "$INSTDIR\locales"
|
||||
Delete "$INSTDIR\${EXE}"
|
||||
Delete "$INSTDIR\*.dll"
|
||||
Delete "$INSTDIR\*.pak"
|
||||
Delete "$INSTDIR\*.bin"
|
||||
Delete "$INSTDIR\*.dat"
|
||||
Delete "$INSTDIR\*.json"
|
||||
Delete "$INSTDIR\LICENSE*"
|
||||
Delete "$INSTDIR\d3dcompiler_47.dll"
|
||||
Delete "$INSTDIR\dxcompiler.dll"
|
||||
Delete "$INSTDIR\electron_wer.dll"
|
||||
Delete "$INSTDIR\ffmpeg.dll"
|
||||
Delete "$INSTDIR\vk_swiftshader.dll"
|
||||
Delete "$INSTDIR\vulkan-1.dll"
|
||||
Delete "$INSTDIR\chrome_100_percent.pak"
|
||||
Delete "$INSTDIR\chrome_200_percent.pak"
|
||||
Delete "$INSTDIR\resources.pak"
|
||||
Delete "$INSTDIR\snapshot_blob.bin"
|
||||
Delete "$INSTDIR\v8_context_snapshot.bin"
|
||||
Delete "$INSTDIR\icudtl.dat"
|
||||
Delete "$INSTDIR\vk_swiftshader_icd.json"
|
||||
Delete "$INSTDIR\LICENSE"
|
||||
Delete "$INSTDIR\LICENSES.chromium.html"
|
||||
Delete "$INSTDIR\version"
|
||||
!macroend
|
||||
|
||||
|
||||
71
apps/desktop/platforms/windows-x64/smoke-installer.ps1
Normal file
71
apps/desktop/platforms/windows-x64/smoke-installer.ps1
Normal file
@@ -0,0 +1,71 @@
|
||||
# Run the actual installed Electron app with a fresh, non-ASCII user path.
|
||||
$ErrorActionPreference = 'Stop'
|
||||
$desktop = (Resolve-Path "$PSScriptRoot/../..").Path
|
||||
$installer = @(Get-ChildItem "$desktop/out/*-Setup.exe")
|
||||
if ($installer.Count -ne 1) { throw 'Expected exactly one Windows installer' }
|
||||
$root = Join-Path $env:TEMP "DeepTutor 安装 smoke $([guid]::NewGuid())"
|
||||
$install = Join-Path $root 'installed app'
|
||||
$userRoot = Join-Path $root 'user data'
|
||||
New-Item -ItemType Directory -Path $install, $userRoot -Force | Out-Null
|
||||
# A custom destination may already contain unrelated files of the same types.
|
||||
$sentinel = Join-Path $install 'keep-user-file.dll'
|
||||
Set-Content $sentinel 'unrelated user file'
|
||||
$oldPath = $env:PATH
|
||||
$oldHome = $env:OPEN_DEEPTUTOR_TEST_HOME
|
||||
$appProcess = $null
|
||||
$log = Join-Path $userRoot 'logs/runtime.log'
|
||||
try {
|
||||
$setup = Start-Process $installer[0].FullName -ArgumentList @('/S', "/D=$install") -Wait -PassThru
|
||||
if ($setup.ExitCode -ne 0) { throw "Installer exited with $($setup.ExitCode)" }
|
||||
$exe = Join-Path $install 'Open DeepTutor.exe'
|
||||
if (!(Test-Path $exe) -or !(Test-Path $sentinel)) { throw 'Install did not preserve the destination' }
|
||||
$env:OPEN_DEEPTUTOR_TEST_HOME = $userRoot
|
||||
$env:PATH = "$env:SystemRoot\System32;$env:SystemRoot;$env:SystemRoot\System32\Wbem"
|
||||
$appProcess = Start-Process $exe -PassThru
|
||||
$deadline = (Get-Date).AddMinutes(10)
|
||||
$backend = $null
|
||||
$frontend = $null
|
||||
do {
|
||||
if ($appProcess.HasExited) { throw "App exited early: $($appProcess.ExitCode)" }
|
||||
if (Test-Path $log) {
|
||||
$text = Get-Content $log -Raw
|
||||
if ($text -match 'Uvicorn running on (http://127\.0\.0\.1:\d+)') { $backend = $Matches[1] }
|
||||
if ($text -match 'Local:\s+(http://127\.0\.0\.1:\d+)') { $frontend = $Matches[1] }
|
||||
}
|
||||
if ($backend -and $frontend) {
|
||||
try {
|
||||
$health = Invoke-WebRequest "$backend/health/ready" -TimeoutSec 5
|
||||
$page = Invoke-WebRequest $frontend -TimeoutSec 5
|
||||
$proxy = Invoke-WebRequest "$frontend/api/settings/ui" -TimeoutSec 5
|
||||
if ($health.StatusCode -eq 200 -and $page.Content -match 'DeepTutor' -and $proxy.StatusCode -eq 200) { break }
|
||||
} catch { }
|
||||
}
|
||||
if ((Get-Date) -gt $deadline) { throw 'Installed app did not become ready' }
|
||||
Start-Sleep -Seconds 2
|
||||
} while ($true)
|
||||
|
||||
# Closing the real window must stop both services, not just Electron.
|
||||
$appProcess.Refresh()
|
||||
if (!$appProcess.CloseMainWindow()) { throw 'App did not expose a main window' }
|
||||
if (!$appProcess.WaitForExit(30000)) { throw 'App did not quit after closing its window' }
|
||||
foreach ($url in @($frontend, "$backend/health/ready")) {
|
||||
$responded = $false
|
||||
try { Invoke-WebRequest $url -TimeoutSec 3 | Out-Null; $responded = $true } catch { }
|
||||
if ($responded) { throw "Service survived app exit: $url" }
|
||||
}
|
||||
$data = Join-Path $userRoot 'workspace/data/user/settings/interface.json'
|
||||
if (!(Test-Path $data)) { throw 'App did not initialize its user data' }
|
||||
Start-Process (Join-Path $install 'Uninstall Open DeepTutor.exe') -ArgumentList '/S' -Wait | Out-Null
|
||||
$deadline = (Get-Date).AddSeconds(30)
|
||||
while ((Test-Path $exe) -and (Get-Date) -lt $deadline) { Start-Sleep -Seconds 1 }
|
||||
if (Test-Path $exe) { throw 'Uninstall left the app executable behind' }
|
||||
if (!(Test-Path $sentinel) -or !(Test-Path $data)) { throw 'Uninstall removed user files or learning data' }
|
||||
Write-Host 'PASS: Windows install, first launch, UI/API, window close, and uninstall preserve user data.'
|
||||
} finally {
|
||||
if ($appProcess -and !$appProcess.HasExited) {
|
||||
& "$env:SystemRoot/System32/taskkill.exe" /PID $appProcess.Id /T /F | Out-Null
|
||||
}
|
||||
$env:PATH = $oldPath
|
||||
$env:OPEN_DEEPTUTOR_TEST_HOME = $oldHome
|
||||
if (Test-Path $log) { Copy-Item $log "$desktop/.local/windows-x64/installed-app.log" -Force }
|
||||
}
|
||||
Reference in New Issue
Block a user