Skip to content

Commit 48dcaaf

Browse files
use static tests for user default color scheme
since we do not support dynamic change of prefers-color-scheme yet
1 parent 56fb617 commit 48dcaaf

File tree

3 files changed

+58
-20
lines changed

3 files changed

+58
-20
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import { test, expect } from '@playwright/test';
2+
3+
async function check_red_blue(page) {
4+
const locatr = await page.locator('body').first();
5+
await expect(locatr).toHaveClass('fullcontent quarto-dark');
6+
await expect(locatr).toHaveCSS('background-color', 'rgb(66, 7, 11)');
7+
await page.locator("a.quarto-color-scheme-toggle").click();
8+
const locatr2 = await page.locator('body').first();
9+
await expect(locatr2).toHaveCSS('background-color', 'rgb(204, 221, 255)');
10+
}
11+
12+
test.use({
13+
colorScheme: 'dark'
14+
});
15+
16+
// brands used in these documents have background colors
17+
18+
test('Dark and light brand after user themes', async ({ page }) => {
19+
// brand overrides theme background color
20+
await page.goto('./html/dark-brand/brand-after-theme.html');
21+
await check_red_blue(page);
22+
});
23+
24+
// project tests
25+
26+
test('Project specifies dark and light brands', async ({ page }) => {
27+
await page.goto('./html/dark-brand/project-light-dark/simple.html');
28+
await check_red_blue(page);
29+
});
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import { test, expect } from '@playwright/test';
2+
3+
async function check_blue_red(page) {
4+
const locatr = await page.locator('body').first();
5+
await expect(locatr).toHaveClass('fullcontent quarto-light');
6+
await expect(locatr).toHaveCSS('background-color', 'rgb(204, 221, 255)');
7+
await page.locator("a.quarto-color-scheme-toggle").click();
8+
const locatr2 = await page.locator('body').first();
9+
await expect(locatr2).toHaveCSS('background-color', 'rgb(66, 7, 11)');
10+
}
11+
12+
test.use({
13+
colorScheme: 'light'
14+
});
15+
16+
// brands used in these documents have background colors
17+
18+
test('Dark and light brand after user themes', async ({ page }) => {
19+
// brand overrides theme background color
20+
await page.goto('./html/dark-brand/brand-after-theme.html');
21+
await check_blue_red(page);
22+
});
23+
24+
// project tests
25+
26+
test('Project specifies dark and light brands', async ({ page }) => {
27+
await page.goto('./html/dark-brand/project-light-dark/simple.html');
28+
await check_blue_red(page);
29+
});

tests/integration/playwright/tests/html-dark-mode.spec.ts

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,5 @@
11
import { test, expect } from '@playwright/test';
22

3-
async function check_red_blue(page) {
4-
const locatr = await page.locator('body').first();
5-
await expect(locatr).toHaveClass('fullcontent quarto-dark');
6-
await expect(locatr).toHaveCSS('background-color', 'rgb(66, 7, 11)');
7-
await page.locator("a.quarto-color-scheme-toggle").click();
8-
const locatr2 = await page.locator('body').first();
9-
await expect(locatr2).toHaveCSS('background-color', 'rgb(204, 221, 255)');
10-
}
11-
123
async function check_theme_overrides(page) {
134
const locatr = await page.locator('body').first();
145
await expect(locatr).toHaveClass('fullcontent quarto-light');
@@ -19,12 +10,6 @@ async function check_theme_overrides(page) {
1910
}
2011
// themes used in these documents have background colors
2112

22-
test('Dark and light brand after user themes', async ({ page }) => {
23-
// brand overrides theme background color
24-
await page.goto('./html/dark-brand/brand-after-theme.html');
25-
await check_red_blue(page);
26-
});
27-
2813
test('Dark and light brand before user themes', async ({ page }) => {
2914
// theme will override brand
3015
await page.goto('./html/dark-brand/brand-before-theme.html');
@@ -33,11 +18,6 @@ test('Dark and light brand before user themes', async ({ page }) => {
3318

3419
// project tests
3520

36-
test('Project specifies dark and light brands', async ({ page }) => {
37-
await page.goto('./html/dark-brand/project-light-dark/simple.html');
38-
await check_red_blue(page);
39-
});
40-
4121
test('Project brand before user themes', async ({ page }) => {
4222
// theme will override brand
4323
await page.goto('./html/dark-brand/project-light-dark/brand-under-theme.html');

0 commit comments

Comments
 (0)