@@ -127,6 +127,13 @@ export async function navigateAndWait(
127127 } )
128128 . catch ( ( ) => console . warn ( 'Test controls not found within timeout' ) )
129129
130+ // Trigger user interaction to unlock AudioContext (seen in logs preventing muted states)
131+ try {
132+ await page . mouse . click ( 0 , 0 )
133+ } catch ( e ) {
134+ console . warn ( `[navigateAndWait] Failed to unlock AudioContext: ${ e } ` )
135+ }
136+
130137 // Stabilize VRT by disabling animations, transitions, and backdrop filters
131138 await page . addStyleTag ( {
132139 content : `
@@ -136,6 +143,13 @@ export async function navigateAndWait(
136143 backdrop-filter: none !important;
137144 -webkit-backdrop-filter: none !important;
138145 }
146+ body, html, * {
147+ scrollbar-width: none !important;
148+ -ms-overflow-style: none !important;
149+ }
150+ ::-webkit-scrollbar {
151+ display: none !important;
152+ }
139153 [data-testid="main-content-layout"] {
140154 opacity: 1 !important;
141155 transform: none !important;
@@ -162,6 +176,35 @@ export async function resetServerState(
162176 }
163177}
164178
179+ /**
180+ * Comprehensive setup for visual regression tests.
181+ * Creates a clean browser context, initializes all required pages,
182+ * and prepares them for snapshot testing.
183+ *
184+ * @param browser - The Playwright Browser fixture
185+ * @returns An object containing the context and all created pages.
186+ */
187+ export async function mockSpotifyEnvironment (
188+ contextOrPage : BrowserContext | Page
189+ ) {
190+ // Mock internal Auth API for Spotify VRT to prevent 401s and websocket reset loops
191+ await contextOrPage . route ( '**/api/spotify/access-token' , async ( route ) => {
192+ await route . fulfill ( {
193+ status : 200 ,
194+ contentType : 'application/json' ,
195+ body : JSON . stringify ( {
196+ accessToken : 'mock_token' ,
197+ expiresAt : Date . now ( ) + 3600000 ,
198+ } ) ,
199+ } )
200+ } )
201+
202+ // Block the real Spotify SDK from loading and erroring out
203+ await contextOrPage . route ( 'https://sdk.scdn.co/spotify-player.js' , ( route ) =>
204+ route . abort ( )
205+ )
206+ }
207+
165208/**
166209 * Comprehensive setup for visual regression tests.
167210 * Creates a clean browser context, initializes all required pages,
@@ -195,6 +238,8 @@ export async function setupVisualRegressionTest(browser: Browser): Promise<{
195238 } )
196239 } )
197240
241+ await mockSpotifyEnvironment ( context )
242+
198243 // Create all pages in parallel for efficiency
199244 const [ dashboardPage , controlPage , mockPage ] = await Promise . all ( [
200245 context . newPage ( ) ,
@@ -250,6 +295,8 @@ export async function setupMinimalVisualRegressionTest(
250295 } )
251296 } )
252297
298+ await mockSpotifyEnvironment ( page )
299+
253300 // Mock the iframe for the root path before navigation
254301 if ( path === '' || path === '/' ) {
255302 await mockGoogleDocIframe ( page )
0 commit comments