|
| 1 | +import { test, expect } from '@playwright/test'; |
| 2 | + |
| 3 | +async function check_light_content_visibility(page) { |
| 4 | + // In light mode, light-content should be visible, dark-content should be hidden |
| 5 | + const light_spans = page.locator('span.light-content'); |
| 6 | + const dark_spans = page.locator('span.dark-content'); |
| 7 | + |
| 8 | + // Check that light content spans exist and are visible |
| 9 | + await expect(light_spans.first()).toBeVisible(); |
| 10 | + |
| 11 | + // Check that dark content spans are hidden |
| 12 | + await expect(dark_spans.first()).toBeHidden(); |
| 13 | + |
| 14 | + const light_divs = page.locator('div.light-content'); |
| 15 | + const dark_divs = page.locator('div.dark-content'); |
| 16 | + |
| 17 | + await expect(light_divs.first()).toBeVisible(); |
| 18 | + await expect(dark_divs.first()).toBeHidden(); |
| 19 | +} |
| 20 | + |
| 21 | +test.describe('Light and dark content in light mode', () => { |
| 22 | + test.use({ |
| 23 | + colorScheme: 'light' |
| 24 | + }); |
| 25 | + |
| 26 | + test('HTML: light and dark content visibility in light mode', async ({ page }) => { |
| 27 | + await page.goto('./html/unified-brand/light-dark-content.html'); |
| 28 | + await check_light_content_visibility(page); |
| 29 | + }); |
| 30 | +}); |
| 31 | + |
| 32 | + |
| 33 | +test.describe('Light and dark content in RevealJS', () => { |
| 34 | + test('RevealJS: light and dark content visibility', async ({ page }) => { |
| 35 | + await page.goto('./revealjs/light-dark-content.html'); |
| 36 | + |
| 37 | + // Check that light-content and dark-content elements exist |
| 38 | + const light_spans = page.locator('span.light-content'); |
| 39 | + const dark_spans = page.locator('span.dark-content'); |
| 40 | + const light_divs = page.locator('div.light-content'); |
| 41 | + const dark_divs = page.locator('div.dark-content'); |
| 42 | + |
| 43 | + await expect(light_spans).not.toHaveCount(0); |
| 44 | + await expect(dark_spans).not.toHaveCount(0); |
| 45 | + await expect(light_divs).not.toHaveCount(0); |
| 46 | + await expect(dark_divs).not.toHaveCount(0); |
| 47 | + |
| 48 | + // Check that body has the correct theme class |
| 49 | + const body = page.locator('body'); |
| 50 | + await expect(body).toHaveClass(/quarto-light/); |
| 51 | + |
| 52 | + // Verify visibility based on theme |
| 53 | + await expect(light_spans.first()).toBeVisible(); |
| 54 | + await expect(dark_spans.first()).toBeHidden(); |
| 55 | + |
| 56 | + await expect(light_divs.first()).toBeVisible(); |
| 57 | + await expect(dark_divs.first()).toBeHidden(); |
| 58 | + }); |
| 59 | +}); |
0 commit comments