Oregami
Repositories/oxedyne/daimond

oxedyne/daimond/dev/probe_skillsau3.mjs

2.5 KiB, 1 run

created by r2519314175:81, which is this file's identity for as long as the history lasts, whatever it is later renamed to

download · who wrote it · its history

1import { open } from './harness.mjs';
2const s = await open({ name: 'skillsau3', defaults: false });
3const { page } = s;
4const msgs = [];
5page.on('console', m => msgs.push(m.type() + ': ' + m.text().slice(0, 200)));
6page.on('pageerror', e => msgs.push('PAGEERROR: ' + String(e).slice(0, 200)));
7await page.waitForTimeout(2500);
8await page.evaluate(() => DaimondPanels.show('work'));
9await page.waitForTimeout(1200);
10const out = {};
11// Blank the file so the chip is in its empty state.
12out.blanked = await page.evaluate(async () => {
13 const m = await import('/pkg/oxedyne_daimond.js');
14 await m.store_write('DAIMOND.md', '');
15 return String(await m.store_read('DAIMOND.md') || '').length;
16});
17await page.reload(); await page.waitForTimeout(3000);
18await page.evaluate(() => DaimondPanels.show('work'));
19await page.waitForTimeout(1200);
20out.chip = await page.evaluate(() => {
21 const e = document.getElementById('instructions-chip');
22 return e ? { d: e.style.display, empty: e.getAttribute('data-empty') } : null;
23});
24out.seedExported = await page.evaluate(async () => {
25 const m = await import('/pkg/oxedyne_daimond.js');
26 return typeof m.instructions_seed === 'function' ? String(m.instructions_seed()).length : 'absent';
27});
28msgs.length = 0;
29out.box = await page.evaluate(() => {
30 const e = document.getElementById('instructions-chip');
31 if (!e) return null;
32 const r = e.getBoundingClientRect();
33 return { w: r.width, h: r.height, x: r.x, y: r.y, onclick: typeof e.onclick,
34 panel: (e.closest('[id^=panel-]') || {}).id || null,
35 panelShown: (() => { const p = e.closest('[id^=panel-]'); return p ? getComputedStyle(p).display : null; })() };
36});
37// Dispatched on the element rather than at its coordinates: the reload above drops
38// the session, so the unlock modal is over the page and intercepts a real pointer.
39// What is under test is the chip's own handler.
40await page.evaluate(() => document.getElementById('instructions-chip').click());
41await page.waitForTimeout(3000);
42out.after = await page.evaluate(async () => {
43 const m = await import('/pkg/oxedyne_daimond.js');
44 let bytes = 0; try { bytes = String(await m.store_read('DAIMOND.md') || '').length; } catch (e) {}
45 let ws = 0; try { ws = String(await m.read_file('DAIMOND.md') || '').length; } catch (e) { ws = 'read err'; }
46 const e = document.getElementById('instructions-chip');
47 return { storeBytes: bytes, workspaceBytes: ws, empty: e && e.getAttribute('data-empty'),
48 editorOpen: /How to answer me/.test(document.body.innerText) };
49});
50out.console = msgs.slice(0, 12);
51console.log(JSON.stringify(out, null, 1));
52await s.browser.close();