diff --git a/.github/workflows/pr-validation.yml b/.github/workflows/pr-validation.yml index f695a36..2d53bd8 100644 --- a/.github/workflows/pr-validation.yml +++ b/.github/workflows/pr-validation.yml @@ -296,12 +296,12 @@ jobs: // Page status table const pages = ['home', 'screenshots', 'documentation', 'downloads', 'support']; + const getIcon = (name) => { + const img = report.images.find(i => i.name === name); + return !img ? '➖' : img.status === 'changed' ? '🔄' : '✅'; + }; const pageRows = pages.map(p => { - const desktopImg = report.images.find(i => i.name === `${p}-desktop.png`); - const mobileImg = report.images.find(i => i.name === `${p}-mobile.png`); - const desktopIcon = !desktopImg ? '➖' : desktopImg.status === 'changed' ? '🔄' : '✅'; - const mobileIcon = !mobileImg ? '➖' : mobileImg.status === 'changed' ? '🔄' : '✅'; - return `| ${p} | ${desktopIcon} | ${mobileIcon} |`; + return `| ${p} | ${getIcon(`${p}-dark-desktop.png`)} | ${getIcon(`${p}-dark-mobile.png`)} | ${getIcon(`${p}-light-desktop.png`)} | ${getIcon(`${p}-light-mobile.png`)} |`; }).join('\n'); const mergeStatus = jobStatus === 'success' && e2eStatus === 'success' @@ -318,8 +318,8 @@ jobs: ``, visualSection, `### 📸 Page Status`, - `| Page | 🖥️ Desktop | 📱 Mobile |`, - `|------|-----------|----------|`, + `| Page | 🌙 Dark Desktop | 🌙 Dark Mobile | ☀️ Light Desktop | ☀️ Light Mobile |`, + `|------|----------------|----------------|-----------------|-----------------|`, pageRows, ``, mergeStatus, diff --git a/e2e/screenshots.spec.ts b/e2e/screenshots.spec.ts index f070b68..045701c 100644 --- a/e2e/screenshots.spec.ts +++ b/e2e/screenshots.spec.ts @@ -1,5 +1,5 @@ import { test, expect } from '@playwright/test'; -import { expectScreenshot, printWarningSummary } from './visual'; +import { expectScreenshot, setTheme, printWarningSummary } from './visual'; const pages = [ { path: '/', name: 'home' }, @@ -10,26 +10,33 @@ const pages = [ ]; const MOBILE_VIEWPORT = { width: 375, height: 812 }; +const themes = ['dark', 'light'] as const; test.describe('desktop screenshots', () => { - for (const { path, name } of pages) { - test(`${name} page renders correctly`, async ({ page }) => { - await page.goto(path, { waitUntil: 'networkidle' }); - await expect(page).toHaveTitle(/DiffractWD/); - await expectScreenshot(page, `${name}-desktop.png`); - }); + for (const theme of themes) { + for (const { path, name } of pages) { + test(`${name} page renders correctly (${theme}, desktop)`, async ({ page }) => { + await page.goto(path, { waitUntil: 'networkidle' }); + await setTheme(page, theme); + await expect(page).toHaveTitle(/DiffractWD/); + await expectScreenshot(page, `${name}-${theme}-desktop.png`); + }); + } } }); test.describe('mobile screenshots', () => { test.use({ viewport: MOBILE_VIEWPORT }); - for (const { path, name } of pages) { - test(`${name} page renders correctly on mobile`, async ({ page }) => { - await page.goto(path, { waitUntil: 'networkidle' }); - await expect(page).toHaveTitle(/DiffractWD/); - await expectScreenshot(page, `${name}-mobile.png`); - }); + for (const theme of themes) { + for (const { path, name } of pages) { + test(`${name} page renders correctly (${theme}, mobile)`, async ({ page }) => { + await page.goto(path, { waitUntil: 'networkidle' }); + await setTheme(page, theme); + await expect(page).toHaveTitle(/DiffractWD/); + await expectScreenshot(page, `${name}-${theme}-mobile.png`); + }); + } } }); diff --git a/e2e/screenshots/documentation-dark-desktop.png b/e2e/screenshots/documentation-dark-desktop.png new file mode 100644 index 0000000..74765ce Binary files /dev/null and b/e2e/screenshots/documentation-dark-desktop.png differ diff --git a/e2e/screenshots/documentation-dark-mobile.png b/e2e/screenshots/documentation-dark-mobile.png new file mode 100644 index 0000000..23ebbff Binary files /dev/null and b/e2e/screenshots/documentation-dark-mobile.png differ diff --git a/e2e/screenshots/documentation-desktop.png b/e2e/screenshots/documentation-desktop.png deleted file mode 100644 index 3c4dc60..0000000 Binary files a/e2e/screenshots/documentation-desktop.png and /dev/null differ diff --git a/e2e/screenshots/documentation-light-desktop.png b/e2e/screenshots/documentation-light-desktop.png new file mode 100644 index 0000000..2331782 Binary files /dev/null and b/e2e/screenshots/documentation-light-desktop.png differ diff --git a/e2e/screenshots/documentation-light-mobile.png b/e2e/screenshots/documentation-light-mobile.png new file mode 100644 index 0000000..cf5ea3c Binary files /dev/null and b/e2e/screenshots/documentation-light-mobile.png differ diff --git a/e2e/screenshots/documentation-mobile.png b/e2e/screenshots/documentation-mobile.png deleted file mode 100644 index 0ecfc40..0000000 Binary files a/e2e/screenshots/documentation-mobile.png and /dev/null differ diff --git a/e2e/screenshots/downloads-dark-desktop.png b/e2e/screenshots/downloads-dark-desktop.png new file mode 100644 index 0000000..abf269f Binary files /dev/null and b/e2e/screenshots/downloads-dark-desktop.png differ diff --git a/e2e/screenshots/downloads-dark-mobile.png b/e2e/screenshots/downloads-dark-mobile.png new file mode 100644 index 0000000..9ee2dbc Binary files /dev/null and b/e2e/screenshots/downloads-dark-mobile.png differ diff --git a/e2e/screenshots/downloads-desktop.png b/e2e/screenshots/downloads-desktop.png deleted file mode 100644 index 7c1e600..0000000 Binary files a/e2e/screenshots/downloads-desktop.png and /dev/null differ diff --git a/e2e/screenshots/downloads-light-desktop.png b/e2e/screenshots/downloads-light-desktop.png new file mode 100644 index 0000000..46bb946 Binary files /dev/null and b/e2e/screenshots/downloads-light-desktop.png differ diff --git a/e2e/screenshots/downloads-light-mobile.png b/e2e/screenshots/downloads-light-mobile.png new file mode 100644 index 0000000..dd7c0e6 Binary files /dev/null and b/e2e/screenshots/downloads-light-mobile.png differ diff --git a/e2e/screenshots/downloads-mobile.png b/e2e/screenshots/downloads-mobile.png deleted file mode 100644 index 82d175a..0000000 Binary files a/e2e/screenshots/downloads-mobile.png and /dev/null differ diff --git a/e2e/screenshots/home-dark-desktop.png b/e2e/screenshots/home-dark-desktop.png new file mode 100644 index 0000000..8ef365b Binary files /dev/null and b/e2e/screenshots/home-dark-desktop.png differ diff --git a/e2e/screenshots/home-dark-mobile.png b/e2e/screenshots/home-dark-mobile.png new file mode 100644 index 0000000..aaac5cf Binary files /dev/null and b/e2e/screenshots/home-dark-mobile.png differ diff --git a/e2e/screenshots/home-desktop.png b/e2e/screenshots/home-desktop.png deleted file mode 100644 index 56bcbb2..0000000 Binary files a/e2e/screenshots/home-desktop.png and /dev/null differ diff --git a/e2e/screenshots/home-light-desktop.png b/e2e/screenshots/home-light-desktop.png new file mode 100644 index 0000000..d3edf2d Binary files /dev/null and b/e2e/screenshots/home-light-desktop.png differ diff --git a/e2e/screenshots/home-light-mobile.png b/e2e/screenshots/home-light-mobile.png new file mode 100644 index 0000000..5cd706c Binary files /dev/null and b/e2e/screenshots/home-light-mobile.png differ diff --git a/e2e/screenshots/home-mobile.png b/e2e/screenshots/home-mobile.png deleted file mode 100644 index 5a6c767..0000000 Binary files a/e2e/screenshots/home-mobile.png and /dev/null differ diff --git a/e2e/screenshots/screenshots-dark-desktop.png b/e2e/screenshots/screenshots-dark-desktop.png new file mode 100644 index 0000000..09e54b4 Binary files /dev/null and b/e2e/screenshots/screenshots-dark-desktop.png differ diff --git a/e2e/screenshots/screenshots-dark-mobile.png b/e2e/screenshots/screenshots-dark-mobile.png new file mode 100644 index 0000000..0c6fad7 Binary files /dev/null and b/e2e/screenshots/screenshots-dark-mobile.png differ diff --git a/e2e/screenshots/screenshots-desktop.png b/e2e/screenshots/screenshots-desktop.png deleted file mode 100644 index e564df0..0000000 Binary files a/e2e/screenshots/screenshots-desktop.png and /dev/null differ diff --git a/e2e/screenshots/screenshots-light-desktop.png b/e2e/screenshots/screenshots-light-desktop.png new file mode 100644 index 0000000..89453ee Binary files /dev/null and b/e2e/screenshots/screenshots-light-desktop.png differ diff --git a/e2e/screenshots/screenshots-light-mobile.png b/e2e/screenshots/screenshots-light-mobile.png new file mode 100644 index 0000000..52e5eb9 Binary files /dev/null and b/e2e/screenshots/screenshots-light-mobile.png differ diff --git a/e2e/screenshots/screenshots-mobile.png b/e2e/screenshots/screenshots-mobile.png deleted file mode 100644 index 59445c9..0000000 Binary files a/e2e/screenshots/screenshots-mobile.png and /dev/null differ diff --git a/e2e/screenshots/support-dark-desktop.png b/e2e/screenshots/support-dark-desktop.png new file mode 100644 index 0000000..872872b Binary files /dev/null and b/e2e/screenshots/support-dark-desktop.png differ diff --git a/e2e/screenshots/support-dark-mobile.png b/e2e/screenshots/support-dark-mobile.png new file mode 100644 index 0000000..e8336d7 Binary files /dev/null and b/e2e/screenshots/support-dark-mobile.png differ diff --git a/e2e/screenshots/support-desktop.png b/e2e/screenshots/support-desktop.png deleted file mode 100644 index fc07156..0000000 Binary files a/e2e/screenshots/support-desktop.png and /dev/null differ diff --git a/e2e/screenshots/support-light-desktop.png b/e2e/screenshots/support-light-desktop.png new file mode 100644 index 0000000..d9c4775 Binary files /dev/null and b/e2e/screenshots/support-light-desktop.png differ diff --git a/e2e/screenshots/support-light-mobile.png b/e2e/screenshots/support-light-mobile.png new file mode 100644 index 0000000..03bcde6 Binary files /dev/null and b/e2e/screenshots/support-light-mobile.png differ diff --git a/e2e/screenshots/support-mobile.png b/e2e/screenshots/support-mobile.png deleted file mode 100644 index 4adb3c6..0000000 Binary files a/e2e/screenshots/support-mobile.png and /dev/null differ diff --git a/e2e/visual.ts b/e2e/visual.ts index 9f2e419..89089c9 100644 --- a/e2e/visual.ts +++ b/e2e/visual.ts @@ -26,6 +26,19 @@ export function getVisualMode(): VisualMode { return 'warning'; } +export async function setTheme(page: Page, theme: 'dark' | 'light'): Promise { + await page.evaluate((t) => { + localStorage.setItem('theme', t); + if (t === 'dark') { + document.documentElement.classList.add('dark'); + } else { + document.documentElement.classList.remove('dark'); + } + }, theme); + // Allow styles to settle after theme change + await page.waitForTimeout(300); +} + export async function waitForVisualStability(page: Page, timeout = 500): Promise { await page.waitForLoadState('networkidle'); await page.evaluate(() => document.fonts.ready);