Files
Genarrative/src/index.test.ts
高物 50a0d6f982 Refine creation tab UX, generation flow, and bindings
Large changes across frontend, backend and docs to align creation-tab and generation-page behavior with new product UI/UX and Spacetime bindings. Updated hermes decision-log and pitfalls with concrete rules (banner carousel, font sizing, unread-dot tokens, template-card layout, direct card->entry routing, separation of account balance vs prize pools, removal of global page card shell, generation progress milestones and unified circular progress, and background video handling). Added GenerationProgressHero component and media assets, plus generation-related UI/tests updates (CustomWorldGenerationView, BarkBattleGeneratingView, creation hub/cards, platform entry routing, index tests). Backend and contract updates include new category fields in admin API types and admin UI form/list, spacetime-client/module/migration changes and generated bindings script. Misc: many tests adjusted, new docs and plan files added, and several server-rs crate changes to support the updated creation/ generation workflows.
2026-05-25 00:41:30 +08:00

55 lines
1.8 KiB
TypeScript

import fs from 'node:fs';
import path from 'node:path';
import { describe, expect, it } from 'vitest';
function readIndexCss() {
return fs.readFileSync(path.resolve(process.cwd(), 'src/index.css'), 'utf8');
}
function getCssBlock(source: string, selector: string) {
const selectorIndex = source.indexOf(selector);
expect(selectorIndex, `${selector} should exist in src/index.css`).toBeGreaterThanOrEqual(0);
const openBraceIndex = source.indexOf('{', selectorIndex);
expect(openBraceIndex, `${selector} should open a CSS block`).toBeGreaterThanOrEqual(0);
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('index stylesheet unread dots', () => {
it('uses warm brown tokens for draft unread markers instead of red literals', () => {
const css = readIndexCss();
expect(css).toContain('--platform-unread-dot-fill: #8b5a3d;');
expect(css).toContain('--platform-unread-dot-glow: rgba(139, 90, 61, 0.34);');
expect(css).toContain('--platform-unread-dot-fill: #d6a27c;');
expect(css).toContain('--platform-unread-dot-glow: rgba(214, 162, 124, 0.24);');
for (const selector of [
'.creation-work-card__unread-dot',
'.platform-nav-unread-dot',
]) {
const block = getCssBlock(css, selector);
expect(block).toContain('background: var(--platform-unread-dot-fill);');
expect(block).toContain('var(--platform-unread-dot-glow)');
expect(block).not.toContain('#b64a35');
expect(block).not.toContain('rgba(239, 68, 68');
}
});
});