Files
gnome-jarvis/test/brand.test.js
T
snxraven 18802cb55d
Rolling release / release (push) Successful in 6m57s
Branding
2026-09-12 14:06:02 -04:00

84 lines
4.1 KiB
JavaScript

import test from 'node:test';
import assert from 'node:assert/strict';
import { readFileSync, existsSync } from 'node:fs';
const root = new URL('../apps/gnome-extension/[email protected]/', import.meta.url);
const tokens = JSON.parse(readFileSync(new URL('brand/tokens.json', root), 'utf8'));
const brandSource = readFileSync(new URL('brand.js', root), 'utf8');
const stylesheet = readFileSync(new URL('stylesheet.css', root), 'utf8');
const gtkCss = readFileSync(new URL('brand/gtk.css', root), 'utf8');
const metadata = JSON.parse(readFileSync(new URL('metadata.json', root), 'utf8'));
const settingsWindow = readFileSync(new URL('settings-window.js', root), 'utf8');
const extensionSource = readFileSync(new URL('extension.js', root), 'utf8');
const install = readFileSync(new URL('../packaging/install.sh', import.meta.url), 'utf8');
const uninstall = readFileSync(new URL('../packaging/uninstall.sh', import.meta.url), 'utf8');
const icons = [
'brand/icons/jarvis-mark.svg',
'brand/icons/jarvis-mark-symbolic.svg',
'brand/icons/jarvis-wordmark.svg',
'brand/icons/io.qvac.Jarvis.Control.svg',
'brand/icons/scalable/apps/io.qvac.Jarvis.Control.svg',
];
test('brand tokens match the coded gold and signal palette', () => {
assert.equal(tokens.name, 'Jarvis');
assert.equal(tokens.product, 'Jarvis QVAC');
assert.equal(tokens.tagline, 'Local voice for your desktop');
assert.equal(tokens.colors.gold, '#F4B942');
assert.equal(tokens.colors.signal, '#4FD2FF');
assert.equal(tokens.colors.ink, '#0B0E14');
assert.equal(tokens.accents[0].id, 'gold');
assert.match(brandSource, /gold: '#F4B942'/);
assert.match(brandSource, /signal: '#4FD2FF'/);
assert.match(brandSource, /tagline: 'Local voice for your desktop'/);
});
test('brand icons ship as SVG marks with gold visor and cyan core', () => {
for (const icon of icons) {
const path = new URL(icon, root);
assert.equal(existsSync(path), true, icon);
const svg = readFileSync(path, 'utf8');
assert.match(svg, /<svg /);
assert.match(svg, /viewBox=/);
}
const mark = readFileSync(new URL('brand/icons/jarvis-mark.svg', root), 'utf8');
assert.match(mark, /#F4B942/);
assert.match(mark, /#4FD2FF/);
const wordmark = readFileSync(new URL('brand/icons/jarvis-wordmark.svg', root), 'utf8');
assert.match(wordmark, /viewBox="0 0 300 64"/);
assert.doesNotMatch(wordmark, /translate\(0\s+-?\d+\)/);
const app = readFileSync(new URL('brand/icons/io.qvac.Jarvis.Control.svg', root), 'utf8');
assert.match(app, /#0B0E14/);
const symbolic = readFileSync(new URL('brand/icons/jarvis-mark-symbolic.svg', root), 'utf8');
assert.match(symbolic, /currentColor/);
});
test('HUD, settings, and launcher consume the brand package', () => {
assert.match(stylesheet, /--jarvis-accent/);
assert.match(stylesheet, /--jarvis-signal: #4FD2FF/);
assert.match(stylesheet, /\.jarvis-panel-mark/);
assert.match(stylesheet, /\.jarvis-talk \{ background-color: var\(--jarvis-accent/);
assert.match(gtkCss, /@define-color jarvis_gold #F4B942/);
assert.match(gtkCss, /button\.jarvis-swatch-gold/);
assert.equal(metadata.name, 'Jarvis');
assert.match(metadata.description, /Local voice for your desktop/);
assert.match(settingsWindow, /from '\.\/brand\.js'/);
assert.match(settingsWindow, /brandBanner/);
assert.match(settingsWindow, /accentRow/);
assert.match(extensionSource, /brand\/icons\/jarvis-mark\.svg/);
assert.match(extensionSource, /text: 'Jarvis'/);
assert.match(install, /io\.qvac\.Jarvis\.Control\.desktop/);
assert.match(install, /Local voice for your desktop/);
assert.match(uninstall, /io\.qvac\.Jarvis\.Control\.desktop/);
});
test('accent helper rejects invalid hex and keeps Gold', async () => {
const { normalizeAccent, DEFAULT_ACCENT, BRAND } = await import(new URL('../apps/gnome-extension/[email protected]/brand.js', import.meta.url));
assert.equal(DEFAULT_ACCENT, '#F4B942');
assert.equal(normalizeAccent('#4FD2FF'), '#4FD2FF');
assert.equal(normalizeAccent('not-a-color'), '#F4B942');
assert.equal(normalizeAccent(''), '#F4B942');
assert.equal(BRAND.accents.length, 5);
});