Skip to content

Commit 020bb45

Browse files
committed
refactor(daemon): pin the device-status wire order and cite the shared builder
Review follow-up (#3557): the contracts doc comments now cite the shared deviceStatusReportResponse the literals moved into, and the boot-shape test pins Object.keys so a wire key-order change is a test failure.
1 parent 64e4e78 commit 020bb45

2 files changed

Lines changed: 20 additions & 5 deletions

File tree

‎packages/contracts/src/device.ts‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ import type { TargetShutdownResult } from './target-shutdown-contract.ts';
88

99
/**
1010
* Closed result of the `boot` command. Mirrors the daemon handler's only
11-
* success return EXACTLY (src/daemon/handlers/session-boot.ts) — the fixed
11+
* success return EXACTLY (src/daemon/handlers/session-boot.ts via
12+
* session-device-status-response.ts) — the fixed
1213
* object literal `{ platform, target, device, id, kind, booted }` plus the
1314
* additive `appleOs` discriminant, emitted only for Apple devices.
1415
*/
@@ -32,7 +33,8 @@ export type BootCommandResult = {
3233

3334
/**
3435
* Closed result of the `shutdown` command. Mirrors the daemon handler's success
35-
* return EXACTLY (src/daemon/handlers/session-shutdown.ts) — the fixed object
36+
* return EXACTLY (src/daemon/handlers/session-shutdown.ts via
37+
* session-device-status-response.ts) — the fixed object
3638
* literal `{ platform, target, device, id, kind, shutdown }` plus the additive
3739
* `appleOs` discriminant (Apple devices only). The `shutdown` field is the raw
3840
* {@link TargetShutdownResult} returned by the bound `shutdownTarget` operation.

‎src/daemon/handlers/__tests__/session-device-status-response.test.ts‎

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,11 @@ const shutdownResult: TargetShutdownResult = {
1212

1313
describe('deviceStatusReportResponse', () => {
1414
test('emits the public identity fields with the boot status', () => {
15-
expect(
16-
deviceStatusReportResponse({ ...IOS_SIMULATOR, target: 'mobile' }, { booted: true }),
17-
).toEqual({
15+
const response = deviceStatusReportResponse(
16+
{ ...IOS_SIMULATOR, target: 'mobile' },
17+
{ booted: true },
18+
);
19+
expect(response).toEqual({
1820
ok: true,
1921
data: {
2022
platform: 'ios',
@@ -26,6 +28,17 @@ describe('deviceStatusReportResponse', () => {
2628
appleOs: 'ios',
2729
},
2830
});
31+
// The wire order the pre-refactor literals emitted: identity, status, appleOs.
32+
if (!response.ok || !response.data) return;
33+
expect(Object.keys(response.data)).toEqual([
34+
'platform',
35+
'target',
36+
'device',
37+
'id',
38+
'kind',
39+
'booted',
40+
'appleOs',
41+
]);
2942
});
3043

3144
test('emits the shutdown status and defaults the target to mobile', () => {

0 commit comments

Comments
 (0)