main
John Lauer Add Codex Desktop installation and native chat starter prompts to the dashboard 1b98adc 1mo ago
const assert = require('node:assert/strict');
const fs = require('node:fs');
const path = require('node:path');
const test = require('node:test');
const vm = require('node:vm');

const html = fs.readFileSync(path.join(__dirname, '../dashboard/index.html'), 'utf8');

function boot() {
  let config;
  const requests = [];
  const nodes = new Map();
  const document = {
    querySelector(selector) {
      if (!nodes.has(selector)) nodes.set(selector, {
        addEventListener() {}, style: {}, pause() {}, replaceChildren() {},
      });
      return nodes.get(selector);
    },
    querySelectorAll() { return []; },
  };
  const context = vm.createContext({
    document, window: {}, setTimeout,
    AdomNewbiePanel: { mount(value) { config = value; return {}; } },
    fetch(url) { requests.push(url); return new Promise(() => {}); },
    EventSource: class {},
  });
  for (const script of html.matchAll(/<script\b([^>]*)>([\s\S]*?)<\/script>/g)) {
    if (!/\bsrc=/.test(script[1])) new vm.Script(script[2]).runInContext(context);
  }
  return { config, requests };
}

test('EDA prompts lead and all desktop prompts fit the shared six-row limit', () => {
  const { config } = boot();
  assert.equal(config.ai, 'codex');
  assert.equal(config.apiBase, '/codex');
  assert.equal(config.phrases.length, 6);
  assert.equal(config.phrases[0], 'Codex Astra, reproduce this Fusion demo');
  assert.match(config.phrases[2], /PCB thermal/);
  config.phrases.slice(3).forEach(phrase => assert.match(phrase, /Codex Desktop.*arav-rog/));
});

test('desktop examples preserve setup approvals and target the actual app', () => {
  const { config } = boot();
  assert.match(config.phrases[3], /ask before accepting agreements/);
  assert.match(config.phrases[3], /AB toast before UAC/);
  assert.match(config.phrases[4], /actual Codex Desktop app/);
  assert.match(config.phrases[4], /Read its reply back/);
  assert.match(config.phrases[5], /let me choose one to continue/);
});

test('opening the dashboard does not send any sample prompt', () => {
  const { requests } = boot();
  assert.deepEqual(requests, ['/api/status']);
  assert.doesNotMatch(html, /Planned: verified desktop installation|Integration roadmap/);
  assert.match(html, /adom\/codex\/files\/bridge\/README\.md/);
});