import { test, expect } from '@playwright/test'; test.describe('Theme toggle', () => { test('switches theme and persists across navigation', async ({ page }) => { await page.goto('/'); const html = page.locator('html'); const surface = page.getByTestId('page-surface'); const darkButton = page.getByRole('button', { name: 'Dark theme' }); const lightButton = page.getByRole('button', { name: 'Light theme' }); await darkButton.click(); await expect(html).toHaveClass(/dark/); await expect .poll(async () => page.evaluate(() => localStorage.getItem('theme'))) .toBe('dark'); const darkBackground = await surface.evaluate((element) => getComputedStyle(element).backgroundColor); await page.goto('/privacy'); await expect(html).toHaveClass(/dark/); await lightButton.click(); await expect(html).not.toHaveClass(/dark/); await expect .poll(async () => page.evaluate(() => localStorage.getItem('theme'))) .toBe('light'); await page.goto('/'); const lightBackground = await surface.evaluate((element) => getComputedStyle(element).backgroundColor); expect(lightBackground).not.toBe(darkBackground); await page.goto('/tos'); await expect(html).not.toHaveClass(/dark/); }); }); test.describe('Light theme contrast', () => { test.beforeEach(async ({ page }) => { // Set light theme before each test await page.goto('/'); await page.getByRole('button', { name: 'Light theme' }).click(); await expect(page.locator('html')).not.toHaveClass(/dark/); }); test('homepage has readable text in light mode', async ({ page }) => { await page.goto('/'); // Check that main heading is visible const heading = page.getByRole('heading', { name: /every word/i }); await expect(heading).toBeVisible(); // Check that heading text has good contrast (not white on white) const headingColor = await heading.evaluate((el) => { const style = getComputedStyle(el); return style.color; }); // Should not be white (rgb(255, 255, 255)) expect(headingColor).not.toBe('rgb(255, 255, 255)'); // Check free app section heading is visible const freeAppHeading = page.getByRole('heading', { name: /completely free\. open source/i }); await expect(freeAppHeading).toBeVisible(); }); test('download page has readable text in light mode', async ({ page }) => { await page.goto('/download'); // Check main heading const heading = page.getByRole('heading', { name: /how to install jotley for mac/i }); await expect(heading).toBeVisible(); // Verify step cards are visible await expect(page.getByRole('heading', { name: 'Open DMG, Drag to Applications & Launch' })).toBeVisible(); }); test('support page has readable text in light mode', async ({ page }) => { await page.goto('/support'); await expect(page.getByRole('heading', { name: 'Support', exact: true })).toBeVisible(); await expect(page.getByRole('heading', { name: 'Send feedback or report a bug', exact: true })).toBeVisible(); }); });