Skip to content

Commit 0f84dd1

Browse files
thymikeeclaude
andcommitted
test(daemon): tighten provider-not-registered assertions and document exemptions
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
1 parent 9923eec commit 0f84dd1

3 files changed

Lines changed: 22 additions & 5 deletions

File tree

‎packages/daemon/src/sessions/handlers/__tests__/lease.test.ts‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -662,7 +662,13 @@ test('lease_allocate treats a daemon that reports no provider runtimes as having
662662
sessionStore: makeSessionStore('agent-device-no-runtimes-'),
663663
leaseRegistry: new LeaseRegistry(),
664664
}),
665-
(error: unknown) =>
666-
error instanceof AppError && error.details?.registeredProviders !== undefined,
665+
(error: unknown) => {
666+
assert.ok(error instanceof AppError);
667+
assert.equal(error.code, 'UNSUPPORTED_OPERATION');
668+
assert.equal(error.details?.reason, 'provider-not-registered');
669+
assert.equal(error.details?.provider, 'browserstack');
670+
assert.deepEqual(error.details?.registeredProviders, []);
671+
return true;
672+
},
667673
);
668674
});

‎src/daemon-composition-credentials.test.ts‎

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,16 @@ vi.mock('./platform-runtime.ts', () => ({
3131
vi.mock('./provider-device-runtimes.ts', () => ({
3232
DEFAULT_PROVIDER_RUNTIME_REQUIRED_IDS: [],
3333
createDaemonProviderRuntimeComposition: async () => ({
34-
runtimes: [{ provider: 'browserstack', ownsDevice: () => false }],
34+
runtimes: [
35+
{
36+
provider: 'browserstack',
37+
leaseLifecycle: {},
38+
deviceInventoryProvider: { discover: async () => [] },
39+
ownsDevice: () => false,
40+
getInteractor: () => undefined,
41+
shutdown: async () => {},
42+
},
43+
],
3544
platformModules: [],
3645
}),
3746
}));
@@ -80,7 +89,9 @@ test('daemon startup compares lease credentials with its own startup environment
8089
expect(await allocate({ ...daemonEnv, BROWSERSTACK_ACCESS_KEY: 'key-2' })).toContain(
8190
'provider-credentials-changed',
8291
);
83-
expect(await allocate(daemonEnv)).not.toContain('provider-credentials-changed');
92+
const accepted = await allocate(daemonEnv);
93+
expect(accepted).not.toContain('provider-credentials-changed');
94+
expect(accepted).toContain('leaseId');
8495
} finally {
8596
await runtime?.shutdown();
8697
}

‎website/docs/docs/client-api.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ Domain client methods:
252252
- `client.sessions.list()`, `stateDir()`, `close()`, `saveScript()`, `artifacts()`
253253
- `client.apps.install()`, `reinstall()`, `uninstall()`, `installFromSource()`, `list()`, `open()`, `close()`, `push()`, `triggerEvent()`
254254
- `client.materializations.release()`
255-
- `client.leases.allocate()`, `heartbeat()`, `release()`. Pass `retainOnClose: true` to `allocate()` when you release the lease yourself; session `close` then leaves it active until `release()`, expiry, or daemon shutdown. The returned lease has `retainOnClose: true` only when the daemon honored it. Keep heartbeating a retained lease between sessions: it expires after its `ttlMs` like any other lease. Pass `leaseId` (16 to 128 hex characters) to `allocate()` to name a new lease with an id the daemon has never issued, or to get back your live lease with that id when you retry with the same tenant, run, client, lease backend, and provider (and no device, or the leased one), then use the returned `leaseId`: a run that already holds a lease gets that one back, and an older daemon mints its own. `allocate()` with a `leaseProvider` the daemon has no runtime for fails with `UNSUPPORTED_OPERATION`, reason `provider-not-registered`, and `details.registeredProviders`; no lease is recorded.
255+
- `client.leases.allocate()`, `heartbeat()`, `release()`. Pass `retainOnClose: true` to `allocate()` when you release the lease yourself; session `close` then leaves it active until `release()`, expiry, or daemon shutdown. The returned lease has `retainOnClose: true` only when the daemon honored it. Keep heartbeating a retained lease between sessions: it expires after its `ttlMs` like any other lease. Pass `leaseId` (16 to 128 hex characters) to `allocate()` to name a new lease with an id the daemon has never issued, or to get back your live lease with that id when you retry with the same tenant, run, client, lease backend, and provider (and no device, or the leased one), then use the returned `leaseId`: a run that already holds a lease gets that one back, and an older daemon mints its own. `allocate()` with a `leaseProvider` the daemon has no runtime for fails with `UNSUPPORTED_OPERATION`, reason `provider-not-registered`, and `details.registeredProviders`; no lease is recorded. Leases with no provider, `proxy`, or `cloud` need no runtime.
256256
- `client.metro.prepare()`, `reload()`
257257
- `client.capture.snapshot()`, `screenshot()`, `diff()`
258258
- `client.interactions.click()`, `press()`, `longPress()`, `swipe()`, `pan()`, `drag()`, `fling()`, `swipeGesture()`, `focus()`, `type()`, `fill()`, `scroll()`, `pinch()`, `rotateGesture()`, `transformGesture()`, `get()`, `is()`, `find()`

0 commit comments

Comments
 (0)