A literal #3ecf8e green read 1.03:1 on the Windows 98 silver card (theme QA r1). Status text now mixes the status hue toward --wb-text; store.css may hold no literal text colours outside its token defaults.
23 lines
1.3 KiB
TypeScript
23 lines
1.3 KiB
TypeScript
// Theme QA bug class "fixed status colour on a themed card": the Store and install screen are themed through
|
|
// --wb-* tokens, so no text colour there may be a literal (a raw #3ecf8e green was 1.03:1 on Windows 98
|
|
// silver). Literals are allowed only in the token default block; text uses --wb-*-ink or other tokens.
|
|
import { test } from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
import { readFileSync } from 'node:fs';
|
|
import { join } from 'node:path';
|
|
|
|
const css = readFileSync(join(import.meta.dirname, '../src/store.css'), 'utf8');
|
|
|
|
test('store.css: no literal text colours outside the token defaults', () => {
|
|
const body = css.replace(/:where\(\.wbs, \.wbi-backdrop, \.wbi-drop\) \{[\s\S]*?\n\}/, '').replace(/\/\*[\s\S]*?\*\//g, '');
|
|
const literal = [...body.matchAll(/(?<![-\w])color:\s*(#[0-9a-f]{3,8}|rgba?\([^)]*\))/gi)].map(m => m[0]);
|
|
const allowed = literal.filter(d => !/#fff\b|#ffffff|rgba?\(0,? 0,? 0/i.test(d));
|
|
assert.deepEqual(allowed, [], 'use var(--wb-ok-ink)/var(--wb-warn-ink) or another --wb-* token');
|
|
});
|
|
|
|
test('store.css: status words use the ink tokens', () => {
|
|
for (const sel of ['.wbs-state.is-ok', '.wbs-perms li.is-ok', '.wbs-perms li.is-warn', '.wbs-status.is-warn']) {
|
|
const rule = css.slice(css.indexOf(sel)).split('}')[0];
|
|
assert.match(rule, /color: var\(--wb-(ok|warn)-ink\)/, sel);
|
|
}
|
|
});
|