base-styles.client.spec.ts 1002 B

1234567891011121314151617181920212223242526
  1. /** Shell base styles stay independent from the dynamically loaded theme bundle. */
  2. import { readFileSync } from 'node:fs'
  3. import { fileURLToPath } from 'node:url'
  4. import { describe, expect, it } from 'vitest'
  5. const THEME_PACKAGE = '@deepseek-ai/dsh-client-ui-theme'
  6. const baseCss = readFileSync(fileURLToPath(new URL('../src/base.css', import.meta.url)), 'utf8')
  7. /**
  8. * Import specifiers of the sheet, in source order. Quote style and surrounding
  9. * whitespace are intentionally irrelevant; duplicate imports remain visible.
  10. * @param css - stylesheet text.
  11. * @returns import specifiers in declaration order.
  12. */
  13. function importOrder(css: string): string[] {
  14. return [...css.matchAll(/@import\s+['"]([^'"]+)['"]/g)].map(([, specifier = '']) => specifier)
  15. }
  16. const imports = importOrder(baseCss)
  17. describe('web shell base.css', () => {
  18. it('leaves theme styles to the dynamic ui-theme client entry', () => {
  19. expect(imports).toEqual([])
  20. expect(baseCss).not.toContain(THEME_PACKAGE)
  21. })
  22. })