Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion app/api/debug/reset/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
2 changes: 1 addition & 1 deletion next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 [
Expand Down
2 changes: 1 addition & 1 deletion playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
5 changes: 4 additions & 1 deletion tests/playwright/lib/visual.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
targetWidth?: number
): Promise<void> {
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(
Expand All @@ -69,6 +69,9 @@
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) {
Expand All @@ -90,7 +93,7 @@
delete finalOptions.fullPage
}

await expect(target).toHaveScreenshot(snapshotName, finalOptions)

Check failure on line 96 in tests/playwright/lib/visual.ts

View workflow job for this annotation

GitHub Actions / 🛡️ Quality Gates / 🧪 Visual Tests

[chromium] › tests/playwright/vrt-hr-components.spec.ts:100:5 › Visual Regression Tests › HR-Related Components › dashboard with 2 HR devices

2) [chromium] › tests/playwright/vrt-hr-components.spec.ts:100:5 › Visual Regression Tests › HR-Related Components › dashboard with 2 HR devices Error: expect(locator).toHaveScreenshot(expected) failed Locator: getByTestId('dashboard') Expected an image 1920px by 1080px, received 1920px by 1151px. 545042 pixels (ratio 0.25 of all image pixels) are different. Snapshot: dashboard-with-2-hr-devices.png Call log: - Expect "toHaveScreenshot(dashboard-with-2-hr-devices.png)" with timeout 5000ms - verifying given screenshot expectation - waiting for getByTestId('dashboard') - locator resolved to <div data-testid="dashboard" class="MuiContainer-root MuiContainer-maxWidthXl mui-165smz0">…</div> - taking element screenshot - disabled all CSS animations - waiting for fonts to load... - fonts loaded - attempting scroll into view action - waiting for element to be stable - Expected an image 1920px by 1080px, received 1920px by 1151px. 545042 pixels (ratio 0.25 of all image pixels) are different. - waiting 100ms before taking screenshot - waiting for getByTestId('dashboard') - locator resolved to <div data-testid="dashboard" class="MuiContainer-root MuiContainer-maxWidthXl mui-165smz0">…</div> - taking element screenshot - disabled all CSS animations - waiting for fonts to load... - fonts loaded - attempting scroll into view action - waiting for element to be stable - captured a stable screenshot - Expected an image 1920px by 1080px, received 1920px by 1151px. 545042 pixels (ratio 0.25 of all image pixels) are different. at lib/visual.ts:96 94 | } 95 | > 96 | await expect(target).toHaveScreenshot(snapshotName, finalOptions) | ^ 97 | } 98 | 99 | /** at takeScreenshot (/home/runner/work/hrm/hrm/tests/playwright/lib/visual.ts:96:24) at /home/runner/work/hrm/hrm/tests/playwright/vrt-hr-components.spec.ts:135:7

Check failure on line 96 in tests/playwright/lib/visual.ts

View workflow job for this annotation

GitHub Actions / 🛡️ Quality Gates / 🧪 Visual Tests

[chromium] › tests/playwright/vrt-dashboard.spec.ts:156:5 › Visual Regression Tests › Dashboard Component › mobile viewport

1) [chromium] › tests/playwright/vrt-dashboard.spec.ts:156:5 › Visual Regression Tests › Dashboard Component › mobile viewport Error: expect(locator).toHaveScreenshot(expected) failed Locator: getByTestId('dashboard') Expected an image 375px by 1038px, received 375px by 1000px. Snapshot: dashboard-mobile.png Call log: - Expect "toHaveScreenshot(dashboard-mobile.png)" with timeout 5000ms - verifying given screenshot expectation - waiting for getByTestId('dashboard') - locator resolved to <div data-testid="dashboard" class="MuiContainer-root MuiContainer-maxWidthXl mui-165smz0">…</div> - taking element screenshot - disabled all CSS animations - waiting for fonts to load... - fonts loaded - attempting scroll into view action - waiting for element to be stable - Expected an image 375px by 1038px, received 375px by 1000px. - waiting 100ms before taking screenshot - waiting for getByTestId('dashboard') - locator resolved to <div data-testid="dashboard" class="MuiContainer-root MuiContainer-maxWidthXl mui-165smz0">…</div> - taking element screenshot - disabled all CSS animations - waiting for fonts to load... - fonts loaded - attempting scroll into view action - waiting for element to be stable - captured a stable screenshot - Expected an image 375px by 1038px, received 375px by 1000px. at lib/visual.ts:96 94 | } 95 | > 96 | await expect(target).toHaveScreenshot(snapshotName, finalOptions) | ^ 97 | } 98 | 99 | /** at takeScreenshot (/home/runner/work/hrm/hrm/tests/playwright/lib/visual.ts:96:24) at /home/runner/work/hrm/hrm/tests/playwright/vrt-dashboard.spec.ts:174:7
}

/**
Expand Down
28 changes: 28 additions & 0 deletions tests/playwright/vrt-dashboard.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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', {
Expand All @@ -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', {
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 0 additions & 3 deletions tests/playwright/vrt-timer-controls.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down
Loading