Files
deepseek-harness/packages/client/web/tests/base-styles.client.spec.ts
T
fz 1c808341ec Add global CJK/Latin auto-spacing via text-autospace
Progressive enhancement on body in the shell base sheet so mixed
Chinese/English copy gets consistent spacing without content edits;
engines without support ignore the property.
2026-08-27 17:21:40 +08:00

45 lines
1.5 KiB
TypeScript

/** 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; }`,
)
})
})