Commit 2a0550f
test(tauri): improve command test coverage and fix quality issues (#215)
* test(tauri): improve command test coverage and fix quality issues
Add tests for triggerDeeplink main function (embedded/CrabNebula/standard
modes), mock browser context resolution, reset/restoreAllMocks error
paths, and clearAllMocks regex edge cases. Fix type safety and strengthen
weak assertions in existing tests.
Co-Authored-By: Claude Opus 4.6 <[email protected]>
* test(tauri): enhance core module tests with error paths and edge cases
Cover driver management (crabnebula/official providers, auto-install, cargo
detection), Edge driver lifecycle (version detection, download, mismatch),
embedded provider (port resolution, start/stop, timeouts), plugin validator
(warn flows), crabnebula backend (readline, health checks), and driver pool
(error propagation, mixed states).
Co-Authored-By: Claude Opus 4.6 <[email protected]>
* test(tauri): add service lifecycle and window management tests
Cover before/beforeTest/beforeCommand/afterSession hooks in service.spec.ts
including API attachment, mock clearing, window focus, multiremote skip,
and session cleanup. Add window.spec.ts tests for findActiveWindow priority
logic, switchToWindowByTitle, getCurrentDevtoolsPort, and clearWindowState.
Co-Authored-By: Claude Opus 4.6 <[email protected]>
* test(tauri-plugin): add first unit tests for guest-js plugin module
Add 42 tests covering CleanupRegistry, getConsoleForwardingCode, execute,
setupConsoleForwarding, setupInvokeInterception, init, and waitForInit.
Includes vitest config with jsdom environment and test script in package.json.
Co-Authored-By: Claude Opus 4.6 <[email protected]>
* test(tauri): remove platform-skipped tests in driverManager
Replace skipIf(process.platform !== 'linux') tests with properly mocked
equivalents that run on all platforms, eliminating the 2 skipped tests.
Co-Authored-By: Claude Opus 4.6 <[email protected]>
* test(tauri-plugin): fix idempotency test to actually call init() twice
The test claimed to verify double-init protection but only called init()
once and manually set the guard flag. Now calls init() a second time to
properly exercise the _wdioInvokeInterceptor guard path.
Co-Authored-By: Claude Opus 4.6 <[email protected]>
* test(tauri): remove misleading mockReset props from restoreAllMocks test
The inner-callback for restoreAllMocks blanks or deletes keys from
__wdio_mocks__ — it never calls mockReset on them. Replace the dead
vi.fn() properties with plain objects to avoid misleading readers.
Co-Authored-By: Claude Opus 4.6 <[email protected]>
* test(tauri): fix retry test to actually exercise retry logic
The test awaited the server start before calling waitTestRunnerBackendReady,
so it always connected on the first attempt. Now reserves a port, starts
waiting immediately, then brings the server up after 200ms to force at
least one retry cycle.
Co-Authored-By: Claude Opus 4.6 <[email protected]>
* test(tauri): fix promisify mock to use correct callback-to-promise wrapper
The identity mock (fn => fn) caused promisified exec calls to silently
return undefined instead of a Promise, hiding real behavior. Aligned with
the pattern in edgeDriverManager.spec.ts. Also added exec error mock for
the WebKitWebDriver-not-found test to prevent detectPackageManager from
hanging.
Co-Authored-By: Claude Opus 4.6 <[email protected]>
* test(tauri-plugin): fix waitForInit test and add explicit init() variant
Renamed existing test to clarify it verifies auto-init on module import.
Added a second test that calls init() explicitly before waitForInit() to
verify the stated behavior of waiting for initialization to complete.
Co-Authored-By: Claude Opus 4.6 <[email protected]>
* test(tauri): fix TOCTOU port race and fragile call-count mock
crabnebulaBackend: Remove 200ms sleep between port release and re-bind
to minimize the window where another process could steal the port.
Re-bind immediately after starting waitTestRunnerBackendReady.
driverPool: Replace callCount % 2 trick with explicit mockReturnValueOnce
chain so the test doesn't break if the implementation changes how many
times it calls isRunning() per driver.
Co-Authored-By: Claude Opus 4.6 <[email protected]>
* test(tauri): add missing browser assignment in beforeTest false-options test
Without the browser, beforeTest early-returns before checking the mock
options, so the not.toHaveBeenCalled assertions passed trivially regardless
of the option values.
Co-Authored-By: Claude Opus 4.6 <[email protected]>
* test(tauri): mock node:net to eliminate real network I/O and port races
Replace real TCP connections and net.createServer() with a mocked
node:net module using programmable socket events. This makes the
waitTestRunnerBackendReady and isTestRunnerBackendHealthy tests
near-instantaneous, fully deterministic, and immune to TOCTOU port
races on busy CI runners.
Co-Authored-By: Claude Opus 4.6 <[email protected]>
* test(tauri): fix timeout test deadlock with fake timers
The previous version awaited the rejection assertion before advancing
timers, causing a deadlock on CI. Now attaches the rejection handler
synchronously, advances timers to trigger the timeout, then awaits
the assertion.
Co-Authored-By: Claude Opus 4.6 <[email protected]>
* test(tauri): fix timeout test to avoid fake timer deadlock
Use .catch() to capture the rejection before advancing timers, then
assert on the captured error. This avoids the deadlock where awaiting
expect().rejects blocks before timers fire, and prevents the ESLint
valid-expect rule from re-adding the problematic await.
Co-Authored-By: Claude Opus 4.6 <[email protected]>
* test(tauri): verify restoreAllMocks/mockStore.clear execution order
The test claimed to verify ordering but only checked both were called.
Now tracks call sequence with an array and asserts the exact order.
Co-Authored-By: Claude Opus 4.6 <[email protected]>
---------
Co-authored-by: Claude Opus 4.6 <[email protected]>1 parent b0dc503 commit 2a0550f
16 files changed
Lines changed: 2744 additions & 76 deletions
File tree
- packages
- tauri-plugin
- guest-js/__tests__
- tauri-service/test
- commands
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | | - | |
| 20 | + | |
| 21 | + | |
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
Lines changed: 19 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
63 | 63 | | |
64 | 64 | | |
65 | 65 | | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
66 | 85 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | | - | |
| 16 | + | |
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| 24 | + | |
24 | 25 | | |
25 | 26 | | |
26 | 27 | | |
| |||
68 | 69 | | |
69 | 70 | | |
70 | 71 | | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
71 | 139 | | |
72 | 140 | | |
Lines changed: 50 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
| 41 | + | |
41 | 42 | | |
42 | 43 | | |
43 | 44 | | |
44 | 45 | | |
45 | 46 | | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
46 | 63 | | |
47 | 64 | | |
48 | 65 | | |
| |||
62 | 79 | | |
63 | 80 | | |
64 | 81 | | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
65 | 100 | | |
66 | 101 | | |
67 | 102 | | |
| |||
70 | 105 | | |
71 | 106 | | |
72 | 107 | | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
73 | 123 | | |
Lines changed: 47 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
| 41 | + | |
41 | 42 | | |
42 | 43 | | |
43 | 44 | | |
44 | 45 | | |
45 | 46 | | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
46 | 62 | | |
47 | 63 | | |
48 | 64 | | |
| |||
62 | 78 | | |
63 | 79 | | |
64 | 80 | | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
65 | 97 | | |
66 | 98 | | |
67 | 99 | | |
| |||
70 | 102 | | |
71 | 103 | | |
72 | 104 | | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
73 | 120 | | |
0 commit comments