|
4 | 4 | <meta charset="UTF-8"> |
5 | 5 | <title>Starting tests...</title> |
6 | 6 | <script type="text/javascript"> |
| 7 | + function navigateToTests(testSuiteToExec) { |
| 8 | + if (testSuiteToExec) { |
| 9 | + location.href = `test/SpecRunner.html?spec=All&category=${testSuiteToExec}`; |
| 10 | + } else { |
| 11 | + location.href = `test/SpecRunner.html`; |
| 12 | + } |
| 13 | + } |
| 14 | + |
| 15 | + function parseCliArg(args, argName) { |
| 16 | + // Parse --argName=value or --argName value from array |
| 17 | + for (let i = 0; i < args.length; i++) { |
| 18 | + const arg = args[i]; |
| 19 | + if (arg.startsWith(`--${argName}=`)) { |
| 20 | + return arg.split('=')[1]; |
| 21 | + } |
| 22 | + if (arg === `--${argName}` && args[i + 1] && !args[i + 1].startsWith('--')) { |
| 23 | + return args[i + 1]; |
| 24 | + } |
| 25 | + } |
| 26 | + return null; |
| 27 | + } |
| 28 | + |
7 | 29 | function redirectToTestPage() { |
8 | | - if(window.__TAURI__) { |
9 | | - __TAURI__.window.appWindow.setFocus().catch(console.error).finally(()=>{ |
10 | | - __TAURI__.cli.getMatches().then(matches=>{ |
| 30 | + if (window.__TAURI__) { |
| 31 | + // Tauri path |
| 32 | + __TAURI__.window.appWindow.setFocus().catch(console.error).finally(() => { |
| 33 | + __TAURI__.cli.getMatches().then(matches => { |
11 | 34 | const testSuiteToExec = matches.args["run-tests"].value; |
12 | | - if(testSuiteToExec){ |
13 | | - location.href = `test/SpecRunner.html?spec=All&category=${testSuiteToExec}`; |
14 | | - } else { |
15 | | - location.href = `test/SpecRunner.html`; |
16 | | - } |
| 35 | + navigateToTests(testSuiteToExec); |
| 36 | + }).catch(console.error); |
| 37 | + }); |
| 38 | + } else if (window.electronAppAPI?.isElectron) { |
| 39 | + // Electron path |
| 40 | + window.electronAPI.focusWindow().catch(console.error).finally(() => { |
| 41 | + window.electronAppAPI.getCliArgs().then(args => { |
| 42 | + const testSuiteToExec = parseCliArg(args, 'run-tests'); |
| 43 | + navigateToTests(testSuiteToExec); |
17 | 44 | }).catch(console.error); |
18 | 45 | }); |
19 | 46 | } else { |
20 | | - location.href = "test/SpecRunner.html"; |
| 47 | + // Browser fallback |
| 48 | + navigateToTests(null); |
21 | 49 | } |
22 | 50 | } |
23 | 51 | </script> |
|
0 commit comments