fix: ensure dark mode E2E test creates a note before asserting colors

The "note cards use dark colors" test was conditional on notes existing,
making the assertion potentially vacuous. Now creates a note first.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Frederic Cabassut
2026-03-21 08:47:20 +01:00
committed by Fred Cabassut
co-authored by Claude Opus 4.6
parent 09c8e290a9
commit 552c2b6265
+12 -8
View File
@@ -1,4 +1,4 @@
import { test, expect } from './helpers/fixtures.js'; import { test, expect, createNote } from './helpers/fixtures.js';
test.describe.serial('Dark mode', () => { test.describe.serial('Dark mode', () => {
test('Scenario: Theme toggle persists selection across page reload', async ({ test('Scenario: Theme toggle persists selection across page reload', async ({
@@ -62,7 +62,12 @@ test.describe.serial('Dark mode', () => {
test('Scenario: Note cards use dark colors in dark mode', async ({ test('Scenario: Note cards use dark colors in dark mode', async ({
authenticatedPage: page authenticatedPage: page
}) => { }) => {
// Given dark theme is active // Given a note exists
await page.goto('/');
await page.waitForLoadState('networkidle');
await createNote(page, 'Dark Mode Test Note');
// And dark theme is active
await page.goto('/settings/preferences'); await page.goto('/settings/preferences');
await page.waitForLoadState('networkidle'); await page.waitForLoadState('networkidle');
await page.getByTestId('pref-theme-dark').click(); await page.getByTestId('pref-theme-dark').click();
@@ -72,12 +77,11 @@ test.describe.serial('Dark mode', () => {
await page.goto('/'); await page.goto('/');
await page.waitForLoadState('networkidle'); await page.waitForLoadState('networkidle');
// Then note cards should have dark background colors (if any exist) // Then note cards should have dark background colors
const noteCard = page.getByTestId('note-card').first(); const noteCard = page.getByTestId('note-card').first();
if (await noteCard.isVisible()) { await expect(noteCard).toBeVisible();
const bg = await noteCard.evaluate((el) => getComputedStyle(el).backgroundColor); const bg = await noteCard.evaluate((el) => getComputedStyle(el).backgroundColor);
// Dark default color is #2a2520 = rgb(42, 37, 32) // Dark default color is #2a2520 = rgb(42, 37, 32); NOT light default rgb(250, 245, 235)
expect(bg).not.toBe('rgb(250, 245, 235)'); // Not the light default expect(bg).not.toBe('rgb(250, 245, 235)');
}
}); });
}); });