@@ -19,12 +19,18 @@ const validator = new ContextMetadataValidator();
1919export default async ( ) => {
2020 const fdc3 = await getAgent ( ) ;
2121 const cc = new ChannelControlImpl ( fdc3 ) ;
22+ let mockAppOpened = false ;
2223
2324 return describe ( 'fdc3.contextMetadata' , ( ) => {
24- beforeEach ( cc . leaveChannel ) ;
25+ beforeEach ( async function beforeEach ( ) {
26+ mockAppOpened = false ;
27+ await cc . leaveChannel ( ) ;
28+ } ) ;
2529
2630 afterEach ( async function afterEach ( ) {
27- await cc . closeMockApp ( this . currentTest ?. title ?? 'Some-Test-Title' ) ;
31+ if ( mockAppOpened ) {
32+ await cc . closeMockApp ( this . currentTest ?. title ?? 'Some-Test-Title' ) ;
33+ }
2834 } ) ;
2935
3036 // --- User Channel Tests ---
@@ -51,6 +57,7 @@ export default async () => {
5157
5258 const channel = await cc . getNonGlobalUserChannel ( ) ;
5359 await cc . joinChannel ( channel ) ;
60+ mockAppOpened = true ;
5461 await cc . openChannelApp ( ucMetadataBroadcast , channel . id , JOIN_AND_BROADCAST ) ;
5562 await resolveExecutionCompleteListener ;
5663
@@ -88,6 +95,7 @@ export default async () => {
8895
8996 const channel = await cc . getNonGlobalUserChannel ( ) ;
9097 await cc . joinChannel ( channel ) ;
98+ mockAppOpened = true ;
9199 await cc . openChannelApp ( ucMetadataTraceId , channel . id , JOIN_AND_BROADCAST_WITH_TRACE_ID ) ;
92100 await resolveExecutionCompleteListener ;
93101
@@ -126,6 +134,7 @@ export default async () => {
126134
127135 const channel = await cc . getNonGlobalUserChannel ( ) ;
128136 await cc . joinChannel ( channel ) ;
137+ mockAppOpened = true ;
129138 await cc . openChannelApp ( ucMetadataSignatureCustom , channel . id , JOIN_AND_BROADCAST_WITH_SIGNATURE_CUSTOM ) ;
130139 await resolveExecutionCompleteListener ;
131140
@@ -164,6 +173,7 @@ export default async () => {
164173 }
165174 ) ;
166175
176+ mockAppOpened = true ;
167177 await cc . openChannelApp ( acMetadataBroadcast , 'test-channel' , APP_CHANNEL_AND_BROADCAST ) ;
168178 await resolveExecutionCompleteListener ;
169179
@@ -189,6 +199,7 @@ export default async () => {
189199 const resolveExecutionCompleteListener = cc . initCompleteListener ( acGetCurrentContextWithMetadata ) ;
190200 const testChannel = await fdc3 . getOrCreateChannel ( 'test-channel' ) ;
191201
202+ mockAppOpened = true ;
192203 await cc . openChannelApp ( acGetCurrentContextWithMetadata , 'test-channel' , APP_CHANNEL_AND_BROADCAST ) ;
193204 await resolveExecutionCompleteListener ;
194205
0 commit comments