Skip to content

Enhanced ChatGPT Clone: Features Agents, MCP, Skills, DeepSeek, Anthropic, AWS, OpenAI, Responses API, Azure, Groq, o1, GPT-5, Mistral, OpenRouter, Vertex AI, Gemini, Artifacts, AI model switching, message search, Code Interpreter, langchain, DALL-E-3, OpenAPI Actions, Functions, Secure Multi-User Auth, Presets, open-source for self-hosting. Active

test: Count Derived Scrim Tokens as Theme-Owned (#16512)

Marco Beretta60b8bb9a77fd
diff --git a/packages/client/src/theme/tokens.spec.ts b/packages/client/src/theme/tokens.spec.ts
index 3a6c4890b2..5741d8a39c 100644
--- a/packages/client/src/theme/tokens.spec.ts
+++ b/packages/client/src/theme/tokens.spec.ts
@@ -11,11 +11,15 @@ globalThis.structuredClone ??= <T>(value: T): T => deserialize(serialize(value))
const tokensPath = path.resolve(__dirname, 'tokens.css');
const tokens = fs.readFileSync(tokensPath, 'utf8');
-const declared = new Set(
- Array.from(tokens.matchAll(/--color-([\w-]+):/g), (match) => match[1]).filter(
- (name) => !name.endsWith('*'),
- ),
+/** Each declared color token, mapped to the custom properties its value reads. */
+const declarations = new Map(
+ Array.from(
+ tokens.matchAll(/--color-([\w-]+):([^;]+);/g),
+ ([, name, value]) =>
+ [name, Array.from(value.matchAll(/var\(--([\w-]+)/g), (match) => match[1])] as const,
+ ).filter(([name]) => !name.endsWith('*')),
);
+const declared = new Set(declarations.keys());
/**
* Theme properties consumed by stylesheets rather than by utilities: the shimmer animation and
@@ -70,7 +74,9 @@ describe('theme color tokens', () => {
it('lets a theme set every color token the stylesheet declares', () => {
const registered = new Set(Object.keys(defaultTheme).map((key) => key.replace(/^rgb-/, '')));
- const unowned = [...declared].filter((token) => !registered.has(token));
+ const unowned = [...declarations]
+ .filter(([, reads]) => !reads.some((property) => registered.has(property)))
+ .map(([token]) => token);
expect(unowned).toEqual([]);
});