Oregami
Repositories/oxedyne/daimond

oxedyne/daimond/dev/shot_adminrail.mjs

2.6 KiB, 1 run

created by r2519314175:135, 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

1// shot_adminrail.mjs — the rail's split into a pinned Status strip and an
2// on-demand Admin drawer. Drives: rest → cog opens Admin (menu) → close →
3// Models status row opens Admin (Models) → Esc closes.
4import { open, shot } from './harness.mjs';
5
6const s = await open({ name: 'adminrail-shot', signIn: true, connect: true });
7const { page } = s;
8const pause = (ms) => page.waitForTimeout(ms);
9const openState = () => page.$eval('#admin', el => el.classList.contains('admin-open'));
10
11await pause(400);
12const r0 = await openState();
13await shot(s, 'adminrail-rest'); // drawer closed, Status strip only
14
15// The cog opens the Admin drawer on its menu.
16await page.click('#settings-btn', { force: true });
17await pause(350);
18const r1 = await openState();
19const title1 = await page.$eval('#admin-drawer-title', el => el.textContent);
20await shot(s, 'adminrail-cog-open');
21
22// Close it with the drawer's ×.
23await page.click('#admin-close', { force: true });
24await pause(350);
25const r2 = await openState();
26
27// A Status row (Models) opens the drawer straight to that section.
28await page.click('#astat-model', { force: true });
29await pause(400);
30const r3 = await openState();
31const title3 = await page.$eval('#admin-drawer-title', el => el.textContent);
32const modelsShown = await page.$eval('#admin-models', el => el.style.display !== 'none');
33await shot(s, 'adminrail-models-open');
34
35// Esc closes it.
36await page.keyboard.press('Escape');
37await pause(350);
38const r4 = await openState();
39
40// A click outside the rail also closes it (open, then click the stage).
41await page.click('#settings-btn', { force: true });
42await pause(300);
43const r5open = await openState();
44await page.mouse.click(760, 400); // somewhere on the stage
45await pause(300);
46const r6 = await openState();
47
48console.log(JSON.stringify({
49 rest_closed: r0 === false,
50 cog_opens: r1 === true,
51 cog_title_admin: title1.trim() === 'Admin',
52 x_closes: r2 === false,
53 models_row_opens: r3 === true && modelsShown,
54 models_title: title3.trim() === 'Models',
55 esc_closes: r4 === false,
56 clickaway_opens: r5open === true,
57 clickaway_closes: r6 === false,
58}, null, 2));
59
60const realErrs = s.errs.filter(e => !/502|Bad Gateway|\/api\b/.test(e));
61const ok = r0 === false && r1 === true && title1.trim() === 'Admin' && r2 === false
62 && r3 === true && modelsShown && title3.trim() === 'Models' && r4 === false
63 && r5open === true && r6 === false && realErrs.length === 0;
64console.log(ok ? '\n✅ PASS' : '\n❌ FAIL');
65if (realErrs.length) console.log('ERRORS:', realErrs);
66await s.close();
67process.exit(ok ? 0 : 1);