oxedyne/daimond/dev/verify_folddelta.mjs
2.8 KiB, 1 run
created by r2519314175:419, 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 | // A fold retains its raw delta; the History must let you read it back. |
| 2 | // |
| 3 | // This used to type a delta straight into the crystal's own `#fold-delta` box |
| 4 | // and press Propose. Both are gone: a Diamond has ONE composer, in the chat |
| 5 | // face, and the crystal carries no input of its own. The property is unchanged |
| 6 | // -- a fold keeps the words that caused it, and History shows them -- so the |
| 7 | // fold is now made the way one is actually made, by selecting turns of a chat |
| 8 | // and folding them into the Diamond. |
| 9 | // |
| 10 | // node dev/verify_folddelta.mjs |
| 11 | // |
| 12 | // Needs dev/serve.mjs and dev/mockllm.mjs (dev/world.sh N --up gives both). |
| 13 | import { open, errors, chat } from './harness.mjs'; |
| 14 | |
| 15 | const MARKER = 'DELTA-MARKER-42: ship the thing'; |
| 16 | const DIAMOND = 'Delta Test'; |
| 17 | const sleep = ms => new Promise(r => setTimeout(r, ms)); |
| 18 | |
| 19 | const s = await open({ name: 'folddelta' }); |
| 20 | const p = s.page; |
| 21 | |
| 22 | // A Diamond for the fold to land in. |
| 23 | await p.click('#new-diamond-btn', { force: true }); |
| 24 | await p.waitForSelector('.dlg-input', { timeout: 8000 }); |
| 25 | await p.fill('.dlg-input', DIAMOND); |
| 26 | await p.click('.dlg-ok', { force: true }); |
| 27 | await sleep(1200); |
| 28 | |
| 29 | // A chat carrying the marker, so the delta the fold records contains it. |
| 30 | // Through the harness helper, which knows that a new chat needs its Start |
| 31 | // pressed and that a visible composer may belong to a Diamond rather than a chat. |
| 32 | await chat(s, MARKER); |
| 33 | |
| 34 | // Select every turn and fold them into the Diamond -- the surviving path, and |
| 35 | // the one a person uses. |
| 36 | await p.evaluate(() => { |
| 37 | const c = document.getElementById('collapse-btn'); |
| 38 | if (c && !c.classList.contains('on')) c.click(); |
| 39 | }); |
| 40 | await sleep(400); |
| 41 | await p.click('#sel-all', { force: true }); |
| 42 | await sleep(200); |
| 43 | await p.click('#sel-fold', { force: true }); |
| 44 | await p.waitForSelector('.fold-menu', { timeout: 8000 }); |
| 45 | await p.evaluate((name) => { |
| 46 | const item = [...document.querySelectorAll('.fold-menu-item')] |
| 47 | .find(b => b.textContent.trim() === name); |
| 48 | if (item) item.click(); |
| 49 | }, DIAMOND); |
| 50 | await sleep(4000); |
| 51 | |
| 52 | const accept = await p.$('.diff-accept'); |
| 53 | if (accept && !(await accept.isDisabled())) { await accept.click(); await sleep(2000); } |
| 54 | |
| 55 | // History, then the fold record's Delta button. |
| 56 | const hist = await p.$('button.crystal-act:has-text("History")'); |
| 57 | if (hist) { await hist.click(); await sleep(700); } |
| 58 | const deltaBtn = await p.$('button.crystal-act:has-text("Delta")'); |
| 59 | let shown = ''; |
| 60 | if (deltaBtn) { |
| 61 | await deltaBtn.click(); |
| 62 | await sleep(700); |
| 63 | shown = await p.evaluate(() => (document.querySelector('.dlg-pre') || {}).textContent || ''); |
| 64 | } |
| 65 | |
| 66 | const ok = !!deltaBtn && shown.indexOf('DELTA-MARKER-42') >= 0; |
| 67 | console.log('delta button present:', !!deltaBtn); |
| 68 | console.log('shows the raw delta:', shown.indexOf('DELTA-MARKER-42') >= 0); |
| 69 | console.log(''); |
| 70 | console.log('FOLD DELTA VIEWABLE:', ok); |
| 71 | console.log('errors:', errors(s)); |
| 72 | await s.close(); |
| 73 | process.exit(ok ? 0 : 1); |