@@ -2,7 +2,6 @@ import { test } from 'vitest';
22import assert from 'node:assert/strict' ;
33import { applyRequestLockPolicy } from '../request-lock-policy.ts' ;
44import type { SessionState } from '../types.ts' ;
5- import { AppError } from '../../utils/errors.ts' ;
65
76const IOS_SESSION : SessionState = {
87 name : 'qa-ios' ,
@@ -33,21 +32,6 @@ const ANDROID_SESSION: SessionState = {
3332 } ,
3433} ;
3534
36- const RECORDING_SESSION : SessionState = {
37- ...ANDROID_SESSION ,
38- name : 'default' ,
39- recordOnlySession : true ,
40- recording : {
41- platform : 'android' ,
42- outPath : '/tmp/recording.mp4' ,
43- remotePath : '/sdcard/recording.mp4' ,
44- remotePid : '1234' ,
45- startedAt : Date . now ( ) ,
46- showTouches : false ,
47- gestureEvents : [ ] ,
48- } ,
49- } ;
50-
5135test ( 'rejects fresh-session selector conflicts under request lock policy' , ( ) => {
5236 assert . throws (
5337 ( ) =>
@@ -68,37 +52,6 @@ test('rejects fresh-session selector conflicts under request lock policy', () =>
6852 ) ;
6953} ) ;
7054
71- test ( 'reject lock policy explains fresh-session recovery commands' , ( ) => {
72- assert . throws (
73- ( ) =>
74- applyRequestLockPolicy ( {
75- token : 'token' ,
76- session : 'qa-ios' ,
77- command : 'snapshot' ,
78- positionals : [ ] ,
79- flags : {
80- device : 'Pixel 9' ,
81- } ,
82- meta : {
83- lockPolicy : 'reject' ,
84- lockPlatform : 'ios' ,
85- } ,
86- } ) ,
87- ( error ) => {
88- assert . ok ( error instanceof AppError ) ;
89- assert . match ( error . message , / s n a p s h o t i s u s i n g a b o u n d - s e s s i o n l o c k f o r i o s / i) ;
90- assert . match ( error . message , / - - d e v i c e = P i x e l 9 / i) ;
91- assert . match ( error . details ?. hint ?? '' , / R e m o v e c o n f l i c t i n g d e v i c e s e l e c t o r s / i) ;
92- assert . match (
93- error . details ?. hint ?? '' ,
94- / a g e n t - d e v i c e o p e n < a p p > - - s e s s i o n q a - i o s - - p l a t f o r m i o s / i,
95- ) ;
96- assert . match ( error . details ?. hint ?? '' , / a g e n t - d e v i c e s e s s i o n l i s t / i) ;
97- return true ;
98- } ,
99- ) ;
100- } ) ;
101-
10255test ( 'allows open to choose a fresh-session target under request lock policy' , ( ) => {
10356 const req = applyRequestLockPolicy ( {
10457 token : 'token' ,
@@ -165,66 +118,6 @@ test('rejects existing-session selector conflicts under request lock policy', ()
165118 ) ;
166119} ) ;
167120
168- test ( 'reject lock policy explains existing-session recovery commands' , ( ) => {
169- assert . throws (
170- ( ) =>
171- applyRequestLockPolicy (
172- {
173- token : 'token' ,
174- session : 'qa-ios' ,
175- command : 'snapshot' ,
176- positionals : [ ] ,
177- flags : {
178- serial : 'emulator-5554' ,
179- } ,
180- meta : {
181- lockPolicy : 'reject' ,
182- } ,
183- } ,
184- IOS_SESSION ,
185- ) ,
186- ( error ) => {
187- assert . ok ( error instanceof AppError ) ;
188- assert . match ( error . message , / a l r e a d y b o u n d t o s e s s i o n " q a - i o s " / i) ;
189- assert . match ( error . message , / i o s d e v i c e " i P h o n e 1 6 " \( S I M - 0 0 1 \) / i) ;
190- assert . match ( error . message , / - - s e r i a l = e m u l a t o r - 5 5 5 4 / i) ;
191- assert . match ( error . details ?. hint ?? '' , / a g e n t - d e v i c e s e s s i o n l i s t / i) ;
192- assert . match ( error . details ?. hint ?? '' , / - - s e s s i o n q a - i o s / i) ;
193- assert . match ( error . details ?. hint ?? '' , / a g e n t - d e v i c e c l o s e - - s e s s i o n q a - i o s / i) ;
194- return true ;
195- } ,
196- ) ;
197- } ) ;
198-
199- test ( 'reject lock policy explains recording-session recovery commands' , ( ) => {
200- assert . throws (
201- ( ) =>
202- applyRequestLockPolicy (
203- {
204- token : 'token' ,
205- session : 'default' ,
206- command : 'snapshot' ,
207- positionals : [ ] ,
208- flags : {
209- device : 'Pixel 8' ,
210- } ,
211- meta : {
212- lockPolicy : 'reject' ,
213- } ,
214- } ,
215- RECORDING_SESSION ,
216- ) ,
217- ( error ) => {
218- assert . ok ( error instanceof AppError ) ;
219- assert . match ( error . message , / a l r e a d y b o u n d t o s e s s i o n " d e f a u l t " / i) ;
220- assert . match ( error . details ?. hint ?? '' , / r e c o r d i n g s e s s i o n " d e f a u l t " / i) ;
221- assert . match ( error . details ?. hint ?? '' , / a g e n t - d e v i c e r e c o r d s t o p - - s e s s i o n d e f a u l t / i) ;
222- assert . match ( error . details ?. hint ?? '' , / a g e n t - d e v i c e c l o s e - - s e s s i o n d e f a u l t / i) ;
223- return true ;
224- } ,
225- ) ;
226- } ) ;
227-
228121test ( 'allows inventory commands to use explicit Apple selectors under another lock platform' , ( ) => {
229122 const req = applyRequestLockPolicy ( {
230123 token : 'token' ,
0 commit comments