Files
openless/openless-all/app/scripts/windows-startup-lifecycle-contract.test.mjs
TRIPandHKLHaoBin 6f9af89583 release: OpenLess 2.0.0-Beta.4+build.20260930 (#1126)
Integrate ASR/Omni fixes, API Route, Android IME and confirmation-based vocabulary learning. Complete settings transitions and macOS single-item credential storage. Synchronize all application versions to 2.0.0-Beta.4+build.20260930.

Integrated PRs: #1116, #1120, #1121, #1123, #1124, #1067 and #1128. Linux #1117 remains independent and is excluded from automatic release.

Validated: full cross-platform CI, 18 UI motion cases, 112 frontend test files, 1245 Core tests (1 ignored) and 572 macOS native tests.

Co-authored-by: HKLHaoBin <we3q@qq.com>
2026-09-30 20:32:53 +08:00

39 lines
1.3 KiB
JavaScript

import { readFile } from 'node:fs/promises';
function assertEqual(actual, expected, name) {
if (actual !== expected) {
throw new Error(`${name}: expected ${expected}, got ${actual}`);
}
}
function assertMatch(source, pattern, name) {
if (!pattern.test(source)) {
throw new Error(`${name}: pattern ${pattern} not found`);
}
}
const raw = await readFile(new URL('../src-tauri/tauri.conf.json', import.meta.url), 'utf-8');
const config = JSON.parse(raw);
const mainWindow = config.app.windows.find((window) => window.label === 'main');
const appTsx = await readFile(new URL('../src/App.tsx', import.meta.url), 'utf-8');
if (!mainWindow) {
throw new Error('main window config missing');
}
assertEqual(
mainWindow.visible,
false,
'main window should stay hidden until startup contract allows first show',
);
// Windows polls hotkey status in a while loop, waiting for state !== 'starting' before
// setGate('ready'). That path lives inside the if (os === 'win') branch and uses an inline loop
// rather than a separate function.
assertMatch(appTsx, /if \(os === 'win'\)/, 'windows startup gate should branch on os === win');
assertMatch(
appTsx,
/status\.state !== 'starting'[\s\S]*?setGate\('ready'\)/m,
'windows startup should wait for hotkey status to leave the starting phase before entering ready',
);