@@ -43,35 +43,13 @@ export async function assertLifecycleAndSystem(context: LiveContext): Promise<vo
4343 ) ;
4444 verifyCommand ( context , C . triggerAppEvent , 'deep event name and JSON payload render exactly' ) ;
4545
46- await runStep ( context , 'reset microphone permission before prompt recovery' , [
47- 'settings' ,
48- 'permission' ,
49- 'reset' ,
50- 'microphone' ,
51- ] ) ;
46+ await resetMicrophonePermissionAndRestart ( context , 'initial' ) ;
5247 await clickMicrophonePermission ( context , 'request microphone permission for denial' ) ;
5348 await runStep ( context , 'wait for microphone permission prompt' , [ 'alert' , 'wait' , '5000' ] ) ;
5449 await runStep ( context , 'deny microphone permission prompt' , [ 'alert' , 'dismiss' ] ) ;
5550 await assertElementText ( context , 'id="automation-microphone-permission"' , 'denied' ) ;
5651
57- await runStep ( context , 'reset denied microphone permission' , [
58- 'settings' ,
59- 'permission' ,
60- 'reset' ,
61- 'microphone' ,
62- ] ) ;
63- await runStep ( context , 'restart fixture after permission reset' , [
64- 'open' ,
65- context . appId ,
66- '--relaunch' ,
67- ] ) ;
68- await runStep ( context , 'restore automation route after permission reset' , [
69- 'trigger-app-event' ,
70- 'fixture.permission.recovery' ,
71- '{"source":"permission-reset"}' ,
72- ] ) ;
73- await assertWaitText ( context , 'Automation lab' ) ;
74- await assertElementText ( context , 'id="automation-microphone-permission"' , 'not-requested' ) ;
52+ await resetMicrophonePermissionAndRestart ( context , 'recovery' ) ;
7553 await clickMicrophonePermission ( context , 'request microphone permission after reset' ) ;
7654 await runStep ( context , 'wait for recovered microphone permission prompt' , [
7755 'alert' ,
@@ -168,6 +146,30 @@ export async function assertLifecycleAndSystem(context: LiveContext): Promise<vo
168146 await assertWaitText ( context , 'Automation lab' ) ;
169147}
170148
149+ async function resetMicrophonePermissionAndRestart (
150+ context : LiveContext ,
151+ phase : 'initial' | 'recovery' ,
152+ ) : Promise < void > {
153+ await runStep ( context , `reset microphone permission for ${ phase } prompt` , [
154+ 'settings' ,
155+ 'permission' ,
156+ 'reset' ,
157+ 'microphone' ,
158+ ] ) ;
159+ await runStep ( context , `restart fixture after ${ phase } permission reset` , [
160+ 'open' ,
161+ context . appId ,
162+ '--relaunch' ,
163+ ] ) ;
164+ await runStep ( context , `restore automation route after ${ phase } permission reset` , [
165+ 'trigger-app-event' ,
166+ `fixture.permission.${ phase } ` ,
167+ `{"source":"permission-${ phase } "}` ,
168+ ] ) ;
169+ await assertWaitText ( context , 'Automation lab' ) ;
170+ await assertElementText ( context , 'id="automation-microphone-permission"' , 'not-requested' ) ;
171+ }
172+
171173async function clickMicrophonePermission ( context : LiveContext , step : string ) : Promise < void > {
172174 for ( let attempt = 0 ; attempt < 4 ; attempt += 1 ) {
173175 const clicked = await runStep (
0 commit comments