summaryrefslogtreecommitdiff
path: root/plugins/code-modernization/tests/mount.test.ts
diff options
context:
space:
mode:
authorMorgan Lunt <morganl@anthropic.com>2026-09-24 20:52:27 -0700
committerMorgan Lunt <morganl@anthropic.com>2026-09-24 20:52:27 -0700
commit51b1ae9e20486d62b839ed9f37e1cfc7d55bf85c (patch)
treeeb31cc4964d84b4a82b8032452739fe1e9b37d3f /plugins/code-modernization/tests/mount.test.ts
parent5b8ec4b30f45b5e8b4c8a6efd63719730cf1a5ad (diff)
code-modernization: make the live pane work below 144 columns and show the proof
Found by exercising the pane against the real outputs of finished runs: - Below 144 columns the engine holds an unasked pane back; the pane ignored that, so it drew no pane, no show bar, and the panel command "hid" a pane that was never there. - A symlinked legacy/<name> lists as another kind of entry, so the source link that preflight now creates was never recognized as a system. - Uplift and reimagine next steps were placeholders with no button. - The refresh debounce was starved while agents ran, so the map froze. - Hostile lines in the brief, rules and baseline could take seconds to match; lines are now capped. The rule-review ledger is validated on read and merged on save, and keeps a reviewer's note. - A baseline with no row read as "the baseline had 0"; one-module baseline totals now count as that module's row. New: a verdict chip with words on every built module, a verify-first next step, and a readable palette that follows the terminal theme. 140 engine tests pass and the type check is clean.
Diffstat (limited to 'plugins/code-modernization/tests/mount.test.ts')
-rw-r--r--plugins/code-modernization/tests/mount.test.ts93
1 files changed, 93 insertions, 0 deletions
diff --git a/plugins/code-modernization/tests/mount.test.ts b/plugins/code-modernization/tests/mount.test.ts
new file mode 100644
index 00000000..de4da75b
--- /dev/null
+++ b/plugins/code-modernization/tests/mount.test.ts
@@ -0,0 +1,93 @@
+import { describe, expect, mock, test } from 'claude-code/testing'
+
+import { BAND, command, PANE, SESSION, SIGN_PANE } from './fixtures/inputs'
+import { MAVEN_UPLIFT, REIMAGINE, LEGACY_ONLY } from './fixtures/stacks'
+import { worldOf } from './fixtures/world'
+import { FULL, UNSIGNED } from './fixtures/workspace'
+
+const PLUGIN = 'code-modernization'
+
+type Mounted = { surface: string; unmount: () => Promise<void> }
+
+/**
+ * `$.ui.mount` is newer than the declarations `tsc` reads (`.claude/types`), so it is reached through a cast. A mount is held
+ * to the terminal's element table and then let go, so the next one is a fresh instance of the same pane.
+ */
+const accepted =
+ ($: unknown) =>
+ async (input: Record<string, unknown>): Promise<string> => {
+ const mounted = await ($ as { ui: { mount: (target: unknown) => Promise<Mounted> } }).ui.mount(input)
+
+ await mounted.unmount()
+
+ return mounted.surface
+ }
+
+/**
+ * `$.ui.render` hands back what the plugin drew; `$.ui.mount` also holds it to the terminal's element table, as the screen
+ * does: a prop or an element the surface refuses means the engine draws its own and the pane never shows.
+ */
+describe('what the plugin draws is accepted by the terminal', () => {
+ const pack = JSON.stringify({
+ modules: [{ name: 'INTCALC', track: 'rewrite', verdict: 'NOT PROVEN', reasons: ['Tests ran: 2 tests failed.'], verifiedAt: '2026-09-24 20:31 UTC' }],
+ })
+
+ const cases: [string, Record<string, string>][] = [
+ ['a finished rewrite', FULL],
+ ['a rewrite with a failed proof', { ...FULL, 'analysis/billing/VERIFICATION.json': pack }],
+ ['an unsigned brief', UNSIGNED],
+ ['a Maven uplift', MAVEN_UPLIFT],
+ ['a reimagine', REIMAGINE],
+ ['a legacy tree', LEGACY_ONLY],
+ ['a workspace with nothing', { 'README.md': 'x' }],
+ ]
+
+ for (const [name, files] of cases) {
+ test(`the pane for ${name}, docked at three widths and inline`, async ($, on) => {
+ worldOf(on, files)
+ mock.clock(on)
+ on('ui.render', () => ({ type: 'Text', children: [''] }))
+ await $.session.start(SESSION)
+ await $.command.run(command('modernize-panel'))
+
+ for (const bodyColumns of [26, 48, 72]) {
+ expect(await accepted($)({ ...PANE, plugin: PLUGIN, props: { ...PANE.props, bodyColumns, scroll: { offset: 0, bodyRows: 40 } } })).toBe('terminal')
+ }
+
+ expect(await accepted($)({ ...PANE, plugin: PLUGIN, props: { ...PANE.props, placement: 'inline', bodyColumns: 100, scroll: { offset: 0, bodyRows: 8 } } })).toBe('terminal')
+ })
+ }
+
+ test('the show bar, the review deck with and without source, and the sign-off dialog', async ($, on) => {
+ const world = worldOf(on, {
+ ...UNSIGNED,
+ 'analysis/billing/RULE_REVIEWS.json': JSON.stringify({ reviews: { 'P0-002': { verdict: 'discuss', at: '2026-09-16', note: 'a question for the owner' } } }),
+ })
+
+ const clock = mock.clock(on)
+
+ void world
+ on('ui.render', () => ({ type: 'Text', children: [''] }))
+ await $.session.start(SESSION)
+
+ expect(await accepted($)({ ...BAND, plugin: PLUGIN })).toBe('terminal')
+
+ await $.command.run(command('modernize-review', 'all'))
+ await $.ui.render(BAND)
+ await $.ui.press({ plugin: PLUGIN, key: 'prev' })
+
+ for (const maxRows of [8, 12, 16, 30]) {
+ expect(await accepted($)({ ...BAND, plugin: PLUGIN, props: { ...BAND.props, maxRows, scroll: { offset: 0, bodyRows: maxRows - 1 } } })).toBe('terminal')
+ }
+
+ await $.ui.render(BAND)
+ await $.ui.press({ plugin: PLUGIN, key: 'source' })
+ await clock.settle()
+ expect(await accepted($)({ ...BAND, plugin: PLUGIN })).toBe('terminal')
+ await $.ui.render(BAND)
+ await $.ui.press({ plugin: PLUGIN, key: 'close' })
+
+ await $.command.run(command('modernize-sign'))
+ expect(await accepted($)({ ...SIGN_PANE, plugin: PLUGIN })).toBe('terminal')
+ })
+})