d66b17b855
Co-authored-by: 段舒康 <kdletters@qq.com> Reviewed-on: https://git.genarrative.world/git/GenarrativeAI/Genarrative/pulls/79 Reviewed-by: 段舒康 <kdletters@qq.com> Co-authored-by: kvtodev <kvtodev@outlook.com> Co-committed-by: kvtodev <kvtodev@outlook.com>
54 lines
1.8 KiB
TypeScript
54 lines
1.8 KiB
TypeScript
import fs from 'node:fs';
|
|
import path from 'node:path';
|
|
|
|
import {describe, expect, it} from 'vitest';
|
|
|
|
const themePath = path.resolve(
|
|
process.cwd(),
|
|
'packages/shared/src/theme.css',
|
|
);
|
|
|
|
function getCssBlock(source: string, selector: string) {
|
|
const selectorIndex = source.indexOf(selector);
|
|
expect(selectorIndex, `${selector} should exist`).toBeGreaterThanOrEqual(0);
|
|
|
|
const openBraceIndex = source.indexOf('{', selectorIndex);
|
|
let depth = 0;
|
|
for (let index = openBraceIndex; index < source.length; index += 1) {
|
|
const char = source[index];
|
|
if (char === '{') {
|
|
depth += 1;
|
|
} else if (char === '}') {
|
|
depth -= 1;
|
|
if (depth === 0) {
|
|
return source.slice(openBraceIndex + 1, index);
|
|
}
|
|
}
|
|
}
|
|
|
|
throw new Error(`${selector} block is not closed`);
|
|
}
|
|
|
|
describe('shared platform theme', () => {
|
|
it('exposes the shared platform font stack without fixing its cascade position', () => {
|
|
const css = fs.readFileSync(themePath, 'utf8');
|
|
const platformTheme = getCssBlock(css, '.platform-theme');
|
|
|
|
expect(platformTheme).toContain("--platform-font-family: 'Inter'");
|
|
expect(css).not.toContain('.platform-theme,\n.platform-theme *');
|
|
});
|
|
|
|
it('keeps the light and dark semantic color contracts', () => {
|
|
const css = fs.readFileSync(themePath, 'utf8');
|
|
const light = getCssBlock(css, '.platform-theme--light');
|
|
const dark = getCssBlock(css, '.platform-theme--dark');
|
|
|
|
expect(light).toContain('--platform-accent: #c7653d;');
|
|
expect(light).toContain('linear-gradient(135deg, #df7f40, #b95d3a)');
|
|
expect(light).toContain('--platform-text-strong: #3d1f10;');
|
|
expect(dark).toContain('--platform-accent: #5b6cff;');
|
|
expect(dark).toContain('linear-gradient(135deg, #5b6cff, #3dd9ff)');
|
|
expect(dark).toContain('--platform-text-strong: #ffffff;');
|
|
});
|
|
});
|