@@ -139,8 +139,11 @@ function tabs(
139139 ) ;
140140}
141141
142- async function renderTabs ( ... args : Parameters < typeof tabs > ) {
142+ function setup ( ) {
143143 setAudioMuted . mockClear ( ) ;
144+ }
145+
146+ function renderTabs ( ...args : Parameters < typeof tabs > ) {
144147 return render ( tabs ( ...args ) ) ;
145148}
146149
@@ -151,6 +154,7 @@ const button = (container: HTMLElement, name: string) =>
151154
152155describe ( "preview tab favicon" , ( ) => {
153156 it ( "prefers a live capture and never asks a public provider about a private hostname" , async ( ) => {
157+ setup ( ) ;
154158 await using screen = await renderTabs ( favicon ( PIXEL_A , "http://24x.xf.local/" ) ) ;
155159 expect ( imageSources ( screen . container ) ) . toEqual ( [ PIXEL_A ] ) ;
156160
@@ -159,6 +163,7 @@ describe("preview tab favicon", () => {
159163 } ) ;
160164
161165 it ( "keeps route-specific captures isolated between live tabs on one origin" , async ( ) => {
166+ setup ( ) ;
162167 await using screen = await renderTabs (
163168 favicon ( PIXEL_A , "http://24x.xf.local/" ) ,
164169 favicon ( PIXEL_B , "http://24x.xf.local/admin" ) ,
@@ -167,6 +172,7 @@ describe("preview tab favicon", () => {
167172 } ) ;
168173
169174 it ( "hides a capture while the server session still describes another origin" , async ( ) => {
175+ setup ( ) ;
170176 await using screen = await renderTabs ( favicon ( PIXEL_A , "https://example.com/" ) ) ;
171177 expect ( imageSources ( screen . container ) ) . not . toContain ( PIXEL_A ) ;
172178 } ) ;
@@ -177,6 +183,7 @@ describe("preview tab audio toggle", () => {
177183 { audible : false , audioMuted : false } ,
178184 { audible : false , audioMuted : true } ,
179185 ] ) ( "is absent for a silent tab (muted=$audioMuted)" , async ( audio ) => {
186+ setup ( ) ;
180187 await using screen = await renderTabs ( null , undefined , audio ) ;
181188 expect ( button ( screen . container , "Mute Local site" ) ) . toBeUndefined ( ) ;
182189 expect ( button ( screen . container , "Unmute Local site" ) ) . toBeUndefined ( ) ;
@@ -186,12 +193,14 @@ describe("preview tab audio toggle", () => {
186193 { audioMuted : false , label : "Mute Local site" , nextMuted : true } ,
187194 { audioMuted : true , label : "Unmute Local site" , nextMuted : false } ,
188195 ] ) ( "$label addresses the desktop by runtime tab id" , async ( { audioMuted, label, nextMuted } ) => {
196+ setup ( ) ;
189197 await using screen = await renderTabs ( null , undefined , { audible : true , audioMuted } ) ;
190198 await act ( ( ) => button ( screen . container , label ) ! . click ( ) ) ;
191199 expect ( setAudioMuted ) . toHaveBeenCalledExactlyOnceWith ( "runtime:tab-1" , nextMuted ) ;
192200 } ) ;
193201
194202 it ( "hides the toggle when no runtime tab id can be resolved" , async ( ) => {
203+ setup ( ) ;
195204 await using screen = await renderTabs ( null , undefined , { audible : true } , null ) ;
196205 expect ( button ( screen . container , "Mute Local site" ) ) . toBeUndefined ( ) ;
197206 } ) ;
0 commit comments