import { expect, test } from '@playwright/test' test.describe('default theme code blocks', () => { test('highlights the code with shiki', async ({ page }) => { await page.goto('guide/code.html') const block = page.locator('.vp-doc div.language-ts') const firstLine = block.locator('pre.shiki code > span.line').first() const token = firstLine.locator('span').first() await expect(block).toBeVisible() await expect(block).toHaveAttribute('data-highlighter', 'shiki') await expect(block.locator('pre.shiki')).toHaveClass(/\bshiki-themes\b/u) await expect(token).toHaveText('import') const textColor = await page .locator('.vp-doc p') .first() .evaluate((element) => getComputedStyle(element).color) const lightColor = await token.evaluate( (element) => getComputedStyle(element).color, ) // the token is colored by the light theme of the highlighter expect(lightColor).not.toBe(textColor) await page .locator('.vp-navbar-appearance button.vp-switch-appearance') .click() await expect(page.locator('html')).toHaveAttribute('data-theme', 'dark') // the same token is colored by the dark theme of the highlighter await expect(token).not.toHaveCSS('color', lightColor) }) test('highlights inline code', async ({ page }) => { await page.goto('guide/code.html') const inlineCode = page .locator('.vp-doc p code') .filter({ hasText: 'const count = ref(0)' }) await expect(inlineCode).toBeVisible() expect( await inlineCode.evaluate( (element) => getComputedStyle(element).backgroundColor, ), ).not.toBe('rgba(0, 0, 0, 0)') }) })