Elffuss BraidHub

utopia-ia/elffuss-claw public

main · 1.8 KiBRawPermalink
1// Historial del prompt del chat en Claw: ↑/↓ recuperan lo enviado.
2import { chromium } from 'playwright';
3import { CHROME_ARGS } from './chrome-args.mjs';
4const BASE = process.env.BASE || 'http://localhost:8788';
5let fails = 0;
6const ok = (n, c, e = '') => { console.log((c ? '✅' : '❌') + ' ' + n + (e ? ' — ' + e : '')); if (!c) fails++; };
7
8const b = await chromium.launch({ args: ['--enable-unsafe-webgpu', ...CHROME_ARGS] });
9const ctx = await b.newContext();
10// Ya «bienvenido»: el splash de primera visita es un diálogo modal con el foco
11// en «Entrar», y el primer Enter era para él (no se enviaba «hola uno»).
12await ctx.addInitScript(() => { try { localStorage.setItem('elffuss.model', 'rules'); localStorage.setItem('elffuss.welcomed', '1'); } catch {} });
13const p = await ctx.newPage({ viewport: { width: 1200, height: 860 } });
14await p.goto(BASE + '/', { waitUntil: 'domcontentloaded' });
15await p.waitForTimeout(1800);
16
17const val = () => p.locator('#prompt').inputValue();
18const submit = async (t) => { await p.locator('#prompt').fill(t); await p.locator('#prompt').press('Enter'); await p.waitForTimeout(250); };
19
20await submit('hola uno');
21await submit('hola dos');
22await p.locator('#prompt').focus();
23await p.keyboard.press('ArrowUp');
24ok('↑ recupera el último', (await val()) === 'hola dos', await val());
25await p.keyboard.press('ArrowUp');
26ok('↑↑ recupera el anterior', (await val()) === 'hola uno', await val());
27await p.keyboard.press('ArrowDown');
28ok('↓ vuelve al siguiente', (await val()) === 'hola dos', await val());
29await p.keyboard.press('ArrowDown');
30ok('↓ al final restaura borrador', (await val()) === '', JSON.stringify(await val()));
31
32console.log(fails ? `\n❌ ${fails} FALLO(S)` : '\n✅ HISTORIAL CHAT (CLAW) OK');
33await b.close();
34process.exit(fails ? 1 : 0);