Repository navigation
refactor(daemon): relocate the handler tests by what they assert #3666
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
thymikee
merged 18 commits into
refactor/daemon-server-tests
from
refactor/daemon-handlers-tests
Oct 15, 2026
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
6aafd23
test(daemon): split lease provider-credentials suite into daemon refu…
thymikee 5acfaff
test(daemon): split doctor warmup suite into daemon routing (a) and h…
thymikee 7b18195
test(daemon): split relaunch guard suite into daemon routing (a) and …
thymikee aeae3c3
test(daemon): move claim-cancellation case to the daemon claims suite…
thymikee cdb9189
test(daemon): split runner-retention close suite into daemon wiring (…
thymikee fbdfcb3
test(daemon): split relaunch/close suite into daemon wiring (a) and A…
thymikee 15cbfe2
test(daemon): split snapshot handler and freshness suites into daemon…
thymikee 3233394
test(daemon): split wait handler suite into daemon capture/decoration…
thymikee 43c0a36
test(daemon): move scoped-refs suite beside the snapshot handler (a)
thymikee 4c582dc
test(daemon): split sessionless cleanup suite into daemon policy (a) …
thymikee b1b46e2
test: relocate Android alert occlusion suite beside the Android inter…
thymikee 4a1b15d
test(daemon): move wait landmark-recording suite beside the wait runt…
thymikee 58869a8
style: format the redesigned handler tests
thymikee 5119789
test: drop assertions owned by the daemon open timing and fix output …
thymikee 69ed0e3
test(platform-apple): drop an unread app-resolution mock from the rel…
thymikee ee9560e
test: point the macOS close coverage claim at the test that now carri…
thymikee f198599
chore(daemon): drop the seven testing subpaths the handler batch left…
thymikee 4b07e86
test(daemon): run every snapshot-handler diff on the forwarding surfa…
thymikee File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| import { afterEach, expect, test } from 'vitest'; | ||
| import { IOS_SIMULATOR } from '@agent-device/test-kit/device-fixtures'; | ||
| import { withSessionlessRunnerCleanup } from './snapshot-session.ts'; | ||
| import { installProviderDeviceAdmission } from './provider-device-admission.ts'; | ||
| import { platformResourceCleanupFixture } from '../__tests__/support/platform-resource-cleanup-fixture.ts'; | ||
| import { makeSession } from '../__tests__/support/session-factories.ts'; | ||
|
|
||
| const returnOk = async () => 'ok'; | ||
|
|
||
| afterEach(() => { | ||
| installProviderDeviceAdmission({ isActive: () => false }); | ||
| }); | ||
|
|
||
| test('sessionless cleanup releases the local execution host after the task', async () => { | ||
| const events: string[] = []; | ||
| const platformCleanup = platformResourceCleanupFixture({ | ||
| cleanupSessionlessExecutionHost: async () => { | ||
| events.push('cleanup'); | ||
| }, | ||
| }); | ||
|
|
||
| const result = await withSessionlessRunnerCleanup( | ||
| undefined, | ||
| IOS_SIMULATOR, | ||
| async () => { | ||
| events.push('task'); | ||
| return 'ok'; | ||
| }, | ||
| platformCleanup, | ||
| ); | ||
|
|
||
| expect(result).toBe('ok'); | ||
| expect(events).toEqual(['task', 'cleanup']); | ||
| expect(platformCleanup.cleanupSessionlessExecutionHost).toHaveBeenCalledWith(IOS_SIMULATOR); | ||
| }); | ||
|
|
||
| test('sessionless cleanup runs when the task fails and keeps the failure', async () => { | ||
| const platformCleanup = platformResourceCleanupFixture(); | ||
| const failure = new Error('capture failed'); | ||
|
|
||
| await expect( | ||
| withSessionlessRunnerCleanup( | ||
| undefined, | ||
| IOS_SIMULATOR, | ||
| async () => { | ||
| throw failure; | ||
| }, | ||
| platformCleanup, | ||
| ), | ||
| ).rejects.toBe(failure); | ||
| expect(platformCleanup.cleanupSessionlessExecutionHost).toHaveBeenCalledWith(IOS_SIMULATOR); | ||
| }); | ||
|
|
||
| test('sessionless cleanup leaves a provider-owned device to its provider', async () => { | ||
| const device = { ...IOS_SIMULATOR, id: 'limrun:ios:lease-a' }; | ||
| installProviderDeviceAdmission({ isActive: (candidate) => candidate.id === device.id }); | ||
| const platformCleanup = platformResourceCleanupFixture(); | ||
|
|
||
| const result = await withSessionlessRunnerCleanup(undefined, device, returnOk, platformCleanup); | ||
|
|
||
| expect(result).toBe('ok'); | ||
| expect(platformCleanup.cleanupSessionlessExecutionHost).not.toHaveBeenCalled(); | ||
| }); | ||
|
|
||
| test('a session keeps its execution host past the task', async () => { | ||
| const platformCleanup = platformResourceCleanupFixture(); | ||
|
|
||
| const result = await withSessionlessRunnerCleanup( | ||
| makeSession('open-session', { device: IOS_SIMULATOR }), | ||
| IOS_SIMULATOR, | ||
| returnOk, | ||
| platformCleanup, | ||
| ); | ||
|
|
||
| expect(result).toBe('ok'); | ||
| expect(platformCleanup.cleanupSessionlessExecutionHost).not.toHaveBeenCalled(); | ||
| }); | ||
|
|
||
| test('sessionless cleanup refuses to run without an injected platform cleanup', async () => { | ||
| await expect(withSessionlessRunnerCleanup(undefined, IOS_SIMULATOR, returnOk)).rejects.toThrow( | ||
| 'Platform resource cleanup was not injected', | ||
| ); | ||
| }); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.