| 1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- /** Shell base styles stay independent from the dynamically loaded theme bundle. */
- import { readFileSync } from 'node:fs'
- import { fileURLToPath } from 'node:url'
- import { describe, expect, it } from 'vitest'
- const THEME_PACKAGE = '@deepseek-ai/dsh-client-ui-theme'
- const baseCss = readFileSync(fileURLToPath(new URL('../src/base.css', import.meta.url)), 'utf8')
- /**
- * Import specifiers of the sheet, in source order. Quote style and surrounding
- * whitespace are intentionally irrelevant; duplicate imports remain visible.
- * @param css - stylesheet text.
- * @returns import specifiers in declaration order.
- */
- function importOrder(css: string): string[] {
- return [...css.matchAll(/@import\s+['"]([^'"]+)['"]/g)].map(([, specifier = '']) => specifier)
- }
- const imports = importOrder(baseCss)
- const normalizedCss = baseCss
- .replaceAll(/\/\*[\s\S]*?\*\//g, '')
- .replaceAll(/\s+/g, ' ')
- const literalContentSelectors = [
- 'code',
- 'pre',
- '[data-diff]',
- '[data-read]',
- '[data-search]',
- '[data-terminal]',
- ]
- describe('web shell base.css', () => {
- it('leaves theme styles to the dynamic ui-theme client entry', () => {
- expect(imports).toEqual([])
- expect(baseCss).not.toContain(THEME_PACKAGE)
- })
- it('auto-spaces prose while preserving literal content', () => {
- expect(baseCss).toMatch(/body\s*\{[^}]*text-autospace:\s*normal;/)
- expect(normalizedCss).toContain(
- `${literalContentSelectors.join(', ')} { text-autospace: no-autospace; }`,
- )
- })
- })
|