Skip to content

Free, Open Source, Self-Hosted WhatsApp API Gateway

test(dashboard): drop a duplicate focus scan, pin the row meta token

Yudhi Armyndharisec4e36ecdfa9
diff --git a/dashboard/src/pages/chats-focus.test.ts b/dashboard/src/pages/chats-focus.test.ts
deleted file mode 100644
index e54fe039d..000000000
--- a/dashboard/src/pages/chats-focus.test.ts
+++ /dev/null
@@ -1,22 +0,0 @@
-// Keyboard focus on the chat page stays visible: no `:focus-visible` rule in Chats.css may remove the outline
-// the app draws for focus (index.css), since a hover-like tint alone is too faint to tell which control has it.
-import { test } from 'node:test';
-import assert from 'node:assert/strict';
-import { readFileSync } from 'node:fs';
-import { fileURLToPath } from 'node:url';
-import { dirname, join } from 'node:path';
-
-const CSS = readFileSync(join(dirname(fileURLToPath(import.meta.url)), 'Chats.css'), 'utf8').replace(
- /\/\*[\s\S]*?\*\//g,
- '',
-);
-
-test('no :focus-visible rule in Chats.css removes the focus outline', () => {
- const offending: string[] = [];
- for (const [, selectors, body] of CSS.matchAll(/([^{}]+)\{([^{}]*)\}/g)) {
- if (selectors.includes(':focus-visible') && /outline\s*:\s*(none|0)\b/.test(body)) {
- offending.push(selectors.trim().replace(/\s+/g, ' '));
- }
- }
- assert.deepEqual(offending, []);
-});
diff --git a/dashboard/src/theme-contrast.test.ts b/dashboard/src/theme-contrast.test.ts
index abd078b78..cfedd27c2 100644
--- a/dashboard/src/theme-contrast.test.ts
+++ b/dashboard/src/theme-contrast.test.ts
@@ -525,8 +525,20 @@ test('text that uses --text-muted is not faded again with opacity', () => {
test('muted text on a tinted row uses --text-secondary, which clears AA on the tint in both themes', () => {
// The chat list rows are no tint: the active one is the opaque --chat-active, on which the chat text tests above
- // check the time and the preview (--chat-meta) in every theme.
+ // check the time and the preview (--chat-meta) in every theme. Those are the tokens the row draws them in, and no
+ // rule for the active row paints them in another.
assert.match(chatRule('.chats-page .chat-item-card.active'), /background:\s*var\(--chat-active\)/);
+ assert.match(chatRule('.chats-page .chat-item-time'), /(?:^|;)\s*color:\s*var\(--chat-meta\)/);
+ assert.match(chatRule('.chats-page .chat-item-snippet'), /(?:^|;)\s*color:\s*var\(--chat-meta\)/);
+ assert.match(chatRule('.chats-page .chat-item-card.unread .chat-item-time'), /color:\s*var\(--chat-accent-text\)/);
+ const repainted = [...CHATS_CSS.replace(/\/\*[\s\S]*?\*\//g, '').matchAll(/([^{}]+)\{([^{}]*)\}/g)]
+ .filter(m => /\.active\b[^,]*\.chat-item-(?:time|snippet)/.test(m[1]) && /(?:^|;)\s*color:/.test(m[2]))
+ .map(m => m[1].trim());
+ assert.deepEqual(
+ repainted,
+ [],
+ 'the active row paints its time or preview in a token the tests above do not measure',
+ );
// [stylesheet, selector, tint alpha in light, tint alpha in dark, surface under the tint]
const rules: [string, string, number, number, string][] = [
// The selected template row is --primary-soft: 12 percent in light, 18 percent in dark.