Skip to content

Local-first AI coding agent desktop: Electron + Rust host core + pi Agent Harness + user-installable plugins

1.9 KB
Raw Blame
import assert from "node:assert/strict";
import { readFile } from "node:fs/promises";
import test from "node:test";
import { loadStyles } from "./helpers/styles.mjs";

const stylesSource = await loadStyles();
const recentSource = await readFile(
  new URL("../src/lib/recent-projects.ts", import.meta.url),
  "utf8",
);

test("design accent tokens are neutral gray, not blue", () => {
  assert.doesNotMatch(stylesSource, /--blue-\d+/);
  assert.doesNotMatch(stylesSource, /#0285ff/i);
  assert.doesNotMatch(stylesSource, /#339cff/i);
  assert.doesNotMatch(stylesSource, /#99ceff/i);
  assert.doesNotMatch(stylesSource, /#e5f3ff/i);

  assert.match(
    stylesSource,
    /--ds-accent:\s*var\(--gray-0\)/,
  );
  assert.match(
    stylesSource,
    /--ds-accent-hover:\s*var\(--gray-100\)/,
  );
  assert.match(
    stylesSource,
    /--ds-accent-soft:\s*var\(--gray-300\)/,
  );
  assert.match(
    stylesSource,
    /:root\[data-theme="light"\][\s\S]*?--ds-accent:\s*#1a1c1f/,
  );
  assert.match(
    stylesSource,
    /:root\[data-theme="light"\][\s\S]*?--ds-accent-hover:\s*#303030/,
  );
  assert.match(
    stylesSource,
    /:root\[data-theme="light"\][\s\S]*?--ds-accent-soft:\s*#5d5d5d/,
  );
});

test("project color dots stay on the gray ladder", () => {
  assert.doesNotMatch(recentSource, /#0285ff/i);
  assert.doesNotMatch(recentSource, /#7c5cff/i);
  const match = recentSource.match(/const COLORS = \[([^\]]+)\]/);
  assert.ok(match, "COLORS array missing");
  const hexes = match[1].match(/#[0-9a-fA-F]{6}/g) ?? [];
  assert.equal(hexes.length, 6);
  for (const hex of hexes) {
    const r = parseInt(hex.slice(1, 3), 16);
    const g = parseInt(hex.slice(3, 5), 16);
    const b = parseInt(hex.slice(5, 7), 16);
    // Near-gray: channels stay close and out of the blue brand range.
    assert.ok(Math.abs(r - g) <= 8 && Math.abs(g - b) <= 8, hex);
    assert.ok(b <= r + 8, `blue-leaning ${hex}`);
  }
});