mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-05 12:24:30 +01:00
test(frontend): read theme source files with ?raw imports instead of node builtins
This commit is contained in:
1 parent
9b405325c0
commit
33be4afeb7
3 files changed
+6
-19
No files matched your search
@@ -1,6 +1,4 @@
|
||||
import { readFileSync } from 'node:fs'
|
||||
import path from 'node:path'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
import indexHtml from '../../../index.html?raw'
|
||||
import { beforeEach, describe, expect, it } from 'vitest'
|
||||
import {
|
||||
APPEARANCE_STORAGE_KEY,
|
||||
@@ -9,11 +7,6 @@ import {
|
||||
resolveColorThemeTokens,
|
||||
} from './colorTheme'
|
||||
|
||||
const indexHtml = readFileSync(
|
||||
path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../../../index.html'),
|
||||
'utf8',
|
||||
)
|
||||
|
||||
function themeColorMeta(): string | null {
|
||||
return document.querySelector('meta[name="theme-color"]')?.getAttribute('content') ?? null
|
||||
}
|
||||
|
||||
@@ -1,17 +1,8 @@
|
||||
import { readFileSync } from 'node:fs'
|
||||
import path from 'node:path'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
import indexCss from '../../index.css?raw'
|
||||
import textPart from '../../components/message/TextPart.tsx?raw'
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { resolveColorThemeTokens } from './colorTheme'
|
||||
|
||||
const themeDir = path.dirname(fileURLToPath(import.meta.url))
|
||||
|
||||
const indexCss = readFileSync(path.resolve(themeDir, '../../index.css'), 'utf8')
|
||||
const textPart = readFileSync(
|
||||
path.resolve(themeDir, '../../components/message/TextPart.tsx'),
|
||||
'utf8',
|
||||
)
|
||||
|
||||
function countOccurrences(source: string, needle: string): number {
|
||||
return source.split(needle).length - 1
|
||||
}
|
||||
|
||||
@@ -16,6 +16,9 @@ export default defineConfig({
|
||||
NODE_ENV: "test",
|
||||
},
|
||||
setupFiles: ["./src/test/setup.ts"],
|
||||
css: {
|
||||
include: [/[?&]raw(?:&|$)/],
|
||||
},
|
||||
include: ["src/**/*.test.{ts,tsx}"],
|
||||
},
|
||||
resolve: {
|
||||
|
||||
Reference in new issue
Block a user