diff --git a/app/api/debug/reset/route.ts b/app/api/debug/reset/route.ts index 4b3082fd9a..48ce28d164 100644 --- a/app/api/debug/reset/route.ts +++ b/app/api/debug/reset/route.ts @@ -3,9 +3,10 @@ import fs from 'fs' import path from 'path' import logger from '@/utils/logger' import { resetSocketManager } from '@/utils/socketManager' +import { env } from '@/lib/env' export async function POST() { - if (process.env.NODE_ENV !== 'development') { + if (env.NODE_ENV === 'production' && !env.ALLOW_DEBUG_RESET) { return NextResponse.json( { message: 'This feature is only available in development mode.' }, { status: 403 } diff --git a/next.config.js b/next.config.js index 86f2ecf157..21fbede4f6 100644 --- a/next.config.js +++ b/next.config.js @@ -18,7 +18,7 @@ const nextConfig = { ], }, env: { - NEXT_PUBLIC_TESTING: process.env.TESTING, + NEXT_PUBLIC_TESTING: process.env.TESTING ?? process.env.NEXT_PUBLIC_TESTING, }, async redirects() { return [ diff --git a/playwright.config.ts b/playwright.config.ts index e06dfc8e60..6d5d6f3a1b 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -77,7 +77,7 @@ export default defineConfig({ // Fail build on CI if you accidentally left test.only forbidOnly: !!process.env.CI, - retries: 0, + retries: process.env.CI_RETRIES ? parseInt(process.env.CI_RETRIES) : 0, // Test execution optimizations - Fail Fast Strategy expect: { diff --git a/tests/playwright/lib/visual.ts b/tests/playwright/lib/visual.ts index 9895b78655..5a01b7b341 100644 --- a/tests/playwright/lib/visual.ts +++ b/tests/playwright/lib/visual.ts @@ -44,7 +44,7 @@ export async function waitForVRTReady( targetWidth?: number ): Promise { await page.evaluateHandle(() => document.fonts.ready) - await page.waitForLoadState('networkidle') + await page.waitForLoadState('domcontentloaded') await page.evaluate(() => document.body.offsetHeight) if (targetWidth !== undefined) { await page.waitForFunction( @@ -69,6 +69,9 @@ export async function takeScreenshot( const { skipA11y = false, ...screenshotOptions } = options const isLocator = 'scrollIntoViewIfNeeded' in target + if (isLocator) { + await (target as Locator).evaluate((node) => node.getBoundingClientRect()) + } // Only scroll to top for full-page targets: MUI portals detach if scrolled. if (!isLocator) { diff --git a/tests/playwright/vrt-dashboard.spec.ts b/tests/playwright/vrt-dashboard.spec.ts index 7fe4fc4d99..75acc63975 100644 --- a/tests/playwright/vrt-dashboard.spec.ts +++ b/tests/playwright/vrt-dashboard.spec.ts @@ -155,6 +155,20 @@ test.describe('Visual Regression Tests', () => { test('mobile viewport', async () => { await dashboardPage.setViewportSize(MOBILE_VIEWPORT) + await dashboardPage + .getByTestId('main-content-layout') + .waitFor({ state: 'visible' }) + await dashboardPage + .getByTestId('timer-display-container') + .waitFor({ state: 'visible' }) + await Promise.race([ + dashboardPage + .getByTestId('spotify-auth-container') + .waitFor({ state: 'visible' }), + dashboardPage + .getByTestId('spotify-display-container') + .waitFor({ state: 'visible' }), + ]) await waitForVRTReady(dashboardPage, MOBILE_VIEWPORT.width) const dashboard = dashboardPage.getByTestId('dashboard') await takeScreenshot(dashboard, 'dashboard-mobile.png', { @@ -165,6 +179,20 @@ test.describe('Visual Regression Tests', () => { test('tablet viewport', async () => { await dashboardPage.setViewportSize(TABLET_VIEWPORT) + await dashboardPage + .getByTestId('main-content-layout') + .waitFor({ state: 'visible' }) + await dashboardPage + .getByTestId('timer-display-container') + .waitFor({ state: 'visible' }) + await Promise.race([ + dashboardPage + .getByTestId('spotify-auth-container') + .waitFor({ state: 'visible' }), + dashboardPage + .getByTestId('spotify-display-container') + .waitFor({ state: 'visible' }), + ]) await waitForVRTReady(dashboardPage, TABLET_VIEWPORT.width) const dashboard = dashboardPage.getByTestId('dashboard') await takeScreenshot(dashboard, 'dashboard-tablet.png', { diff --git a/tests/playwright/vrt-dashboard.spec.ts-snapshots/dashboard-mobile-chromium-linux.png b/tests/playwright/vrt-dashboard.spec.ts-snapshots/dashboard-mobile-chromium-linux.png index 4e65530b21..0223c576a6 100644 Binary files a/tests/playwright/vrt-dashboard.spec.ts-snapshots/dashboard-mobile-chromium-linux.png and b/tests/playwright/vrt-dashboard.spec.ts-snapshots/dashboard-mobile-chromium-linux.png differ diff --git a/tests/playwright/vrt-timer-controls.spec.ts b/tests/playwright/vrt-timer-controls.spec.ts index 56f6a4cb61..d338f8053c 100644 --- a/tests/playwright/vrt-timer-controls.spec.ts +++ b/tests/playwright/vrt-timer-controls.spec.ts @@ -77,9 +77,6 @@ test.describe('Visual Regression Tests', () => { await takeScreenshot(timerControls, 'timer-controls-active.png', { mask: [controlPage.getByTestId('timer-countdown')], }) - - // Stop the timer to reset for the next test - await controlPage.getByTestId('stop-timer-button').click() }) test('start button hover state', async () => {