CI / test (push) Failing after 16s
moon-plasma / moonplasma / MoonPlasma / Moon Plasma become chandra / Chandra everywhere: the WIT package (chandra:desktop, chandra:host, chandra:wm), the MoonBit module (chandra/desktop) and generated bindings, the Rust host, identifiers (ChandraCompositor), the session script (chandra-session) and desktop entry (chandra.desktop), config and data paths ($XDG_CONFIG_HOME/chandra, share/chandra/modules), env vars (CHANDRA_*), UI strings, docs and tests. The test fixture components are rebuilt against the renamed WIT. Saved panel.edn and state.edn are still read from the old $XDG_CONFIG_HOME/moon-plasma until the first save writes the new copy. The remote repository keeps its experiments/moon-plasma name for now. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DPL5hi3L9oVBoRd373Qr4n
55 lines
2.9 KiB
JavaScript
55 lines
2.9 KiB
JavaScript
#!/usr/bin/env node
|
|
// Drive the browser host with headless Chromium and save PNG screenshots.
|
|
// CHROME_PATH=/path/to/chrome node scripts/screenshot.mjs <outdir> [--tag name]
|
|
// Uses playwright-core (devDependency of host/) with an already-installed
|
|
// Chromium; nothing is downloaded here.
|
|
import { mkdir } from 'node:fs/promises';
|
|
import { join } from 'node:path';
|
|
import { createRequire } from 'node:module';
|
|
import { fileURLToPath } from 'node:url';
|
|
import { serve } from '../host/serve.mjs';
|
|
|
|
const require = createRequire(join(fileURLToPath(import.meta.url), '..', '..', 'host', 'package.json'));
|
|
const { chromium } = require('playwright-core');
|
|
const outdir = process.argv[2];
|
|
if (!outdir) { console.error('usage: screenshot.mjs <outdir> [--tag name]'); process.exit(2); }
|
|
const tagI = process.argv.indexOf('--tag');
|
|
const tag = tagI > 0 ? process.argv[tagI + 1] : 'desktop';
|
|
const exe = process.env.CHROME_PATH;
|
|
if (!exe) { console.error('error: set CHROME_PATH to a Chromium/Chrome executable'); process.exit(2); }
|
|
await mkdir(outdir, { recursive: true });
|
|
|
|
const srv = await serve(0);
|
|
const url = `http://127.0.0.1:${srv.address().port}/host/web/index.html`;
|
|
const browser = await chromium.launch({ executablePath: exe, args: ['--no-sandbox'] });
|
|
const page = await browser.newPage({ viewport: { width: 1280, height: 748 } });
|
|
const errors = [];
|
|
page.on('pageerror', (e) => errors.push(String(e)));
|
|
page.on('console', (m) => { if (m.type() === 'error') errors.push(m.text()); });
|
|
const T = 'time=2026-11-24T14:07:37';
|
|
const shot = async (name, query, steps) => {
|
|
await page.goto(`${url}?${T}&${query}`);
|
|
await page.waitForFunction(() => window.chandra?.ready || window.chandraError, null, { timeout: 30000 });
|
|
const err = await page.evaluate(() => window.chandraError);
|
|
if (err) throw new Error(`host failed in browser: ${err}`);
|
|
if (steps) await steps();
|
|
const f = join(outdir, `${tag}-${name}.png`);
|
|
await page.locator('#screen').screenshot({ path: f });
|
|
console.log(f);
|
|
};
|
|
const canvasPoint = async (x, y) => { const b = await page.locator('#screen').boundingBox(); return [b.x + x, b.y + y]; };
|
|
const click = async (x, y) => { const [px, py] = await canvasPoint(x, y); await page.mouse.move(px, py); await page.mouse.down(); await page.mouse.up(); };
|
|
|
|
await shot('1-desktop', 'config=desktop.json');
|
|
await shot('2-launcher-open', 'config=desktop.json', async () => {
|
|
await click(60, 700);
|
|
await page.keyboard.type('s');
|
|
const [px, py] = await canvasPoint(100, 450); await page.mouse.move(px, py);
|
|
});
|
|
await shot('3-binary-clock-swapped', 'config=desktop.json', async () => {
|
|
await page.evaluate(() => window.chandra.swap('clock', 'clock-binary'));
|
|
});
|
|
await shot('4-day-theme', 'config=desktop.json&theme=moon-day', async () => { await click(60, 700); });
|
|
await browser.close(); srv.close();
|
|
if (errors.length) { console.error('browser errors:\n' + errors.join('\n')); process.exit(1); }
|