@@ -3,8 +3,12 @@ import { expect, test } from 'vitest';
33import { createAgentDeviceClient } from '@agent-device/client' ;
44import { runCommand } from '@agent-device/command-surface' ;
55import type { DevicePin } from '@agent-device/contracts/device' ;
6- import { PROVIDER_SCENARIO_ANDROID , PROVIDER_SCENARIO_IOS_SIMULATOR } from './fixtures.ts' ;
7- import { assertRpcError } from './assertions.ts' ;
6+ import {
7+ PROVIDER_SCENARIO_ANDROID ,
8+ PROVIDER_SCENARIO_IOS_SIMULATOR ,
9+ PROVIDER_SCENARIO_MACOS ,
10+ } from './fixtures.ts' ;
11+ import { assertRpcError , assertRpcOk } from './assertions.ts' ;
812import { createProviderScenarioHarness , withProviderScenarioResource } from './harness.ts' ;
913
1014for ( const platform of [ 'ios' , 'android' ] as const ) {
@@ -90,3 +94,48 @@ for (const platform of ['ios', 'android'] as const) {
9094 ) ;
9195 } ) ;
9296}
97+
98+ for ( const [ pinnedPlatform , requestedPlatform , expectedId ] of [
99+ [ 'ios' , 'apple' , PROVIDER_SCENARIO_IOS_SIMULATOR . id ] ,
100+ [ 'macos' , 'apple' , PROVIDER_SCENARIO_MACOS . id ] ,
101+ [ 'apple' , 'ios' , PROVIDER_SCENARIO_IOS_SIMULATOR . id ] ,
102+ [ 'apple' , 'macos' , PROVIDER_SCENARIO_MACOS . id ] ,
103+ ] as const ) {
104+ test ( `Provider-backed integration ${ pinnedPlatform } pin intersects ${ requestedPlatform } before selection` , async ( ) => {
105+ const pin : DevicePin = {
106+ selector : { platform : pinnedPlatform } ,
107+ source : { kind : 'project' , path : '/project/agent-device.json' } ,
108+ } ;
109+ await withProviderScenarioResource (
110+ ( ) =>
111+ createProviderScenarioHarness ( {
112+ deviceInventoryProvider : async ( ) => [
113+ PROVIDER_SCENARIO_MACOS ,
114+ PROVIDER_SCENARIO_IOS_SIMULATOR ,
115+ ] ,
116+ } ) ,
117+ async ( daemon ) => {
118+ const flags = { platform : requestedPlatform } ;
119+ const direct = await daemon . callCommand ( 'capabilities' , [ ] , flags , {
120+ meta : { devicePin : pin } ,
121+ } ) ;
122+ expect ( assertRpcOk ( direct ) ) . toMatchObject ( { device : { id : expectedId } } ) ;
123+ const client = createAgentDeviceClient (
124+ { daemonBaseUrl : daemon . baseUrl , daemonAuthToken : daemon . token } ,
125+ { devicePin : pin } ,
126+ ) ;
127+ const result = await runCommand ( client , 'capabilities' , flags ) ;
128+ assert . equal ( result . device ?. id , expectedId ) ;
129+ const batch = await daemon . callCommand (
130+ 'batch' ,
131+ [ ] ,
132+ { batchSteps : [ { command : 'capabilities' , flags } ] } ,
133+ { meta : { devicePin : pin } } ,
134+ ) ;
135+ expect ( assertRpcOk ( batch ) ) . toMatchObject ( {
136+ results : [ { data : { device : { id : expectedId } } } ] ,
137+ } ) ;
138+ } ,
139+ ) ;
140+ } ) ;
141+ }
0 commit comments