Files
ruflo/plugins/ruflo-console/tests/watch.test.ts
T
rUvandr 45bf52cd86 feat(mods): adopt Claude Code 2.1.290-2.1.318 mod API changes (mods 0.16.0, console 0.49.11, swarm 0.3.8) (#4702)
- ruflo-mods guard (tool.check): read-only fast path on e.isReadOnly (2.1.304)
  that skips the policy-projection stat while a full check found none in the
  last 2 s (web tools excluded so the research ask still fires); a chain deny
  returns without file reads; decider "person" on every ask ruflo raises;
  agentId names the subagent on ruflo's reason; the chain's ceiling survives a
  tightening; .catch documented for 2.1.301 semantics, still fails closed.
- ruflo-console: console_state and console_run registered with
  isDeferred: false (2.1.293); console_open/console_set stay deferred.
- console + swarm: Text bold -> weight (2.1.299 deprecation), codemodded;
  bold: true -> weight: "semibold" (what the host already maps bold to).
  Engines before 2.1.299 refuse a tree with an unknown Text prop, so the kit
  maps weight back to bold there (text-weight.ts, via $.session.version()).
- tests for 2.1.318's kit: $.tool.call now raises tool.check first
  (guidance test); stub answers are validated (swarm prompt.fill stub);
  stale expectations fixed (probe session.compact, learning-loop handshake).
- console kit tests: timeoutMs 30_000 (the 5 s default timed out 19-58
  end-to-end tests under load, on 2.1.289 and 2.1.318 alike), and the mock
  clock advanced past runner.ts's VERIFY_RETRY_MS in actions/settings tests.

Co-authored-by: r <r@x>
2026-11-04 15:49:08 -06:00

66 lines
2.9 KiB
TypeScript

/**
* The Timeline and Events pages in the pane (ADR-474): the Timeline's window chips redraw the title, and the Events page's kind and level
* chips, search field, pause button and empty-state wording are there and answer.
*/
import type { TestBody } from 'claude-code/testing'
import { describe, expect, mock, test } from 'claude-code/testing'
import { RUFLO_FILES } from './fixtures/ruflo-run'
import { inputKeys, command, elementsOf, keyOf, paneAt, PLUGIN, SESSION, textOf, worldOf } from './fixtures/world'
type Body = Parameters<TestBody>
const keys = (tree: Parameters<typeof elementsOf>[0]) => elementsOf(tree, 'Button').map(keyOf)
async function opened($: Body[0], on: Body[1], view: string) {
worldOf(on, RUFLO_FILES)
mock.clock(on)
await $.session.start(SESSION)
await $.command.run(command(view))
const pane = await $.ui.mount({ ...paneAt(150), surface: 'terminal' as const, plugin: PLUGIN })
await pane.drawn()
return pane
}
describe('timeline and events pages', () => {
test('timeline: the window chips change the window named in the title', { timeoutMs: 30_000, options: { boot: false } }, async ($, on) => {
const pane = await opened($, on, 'timeline')
const first = await pane.drawn()
expect(keys(first)).toEqual(expect.arrayContaining(['tl-win-5m', 'tl-win-15m', 'tl-win-1h', 'tl-win-6h', 'tl-win-24h', 'tl-win-session', 'tl-zin', 'tl-zout', 'tl-now', 'tl-sort']))
expect(textOf(first)).toContain('15 min')
await pane.press({ key: 'tl-win-1h' })
expect(textOf(await pane.drawn())).toContain('1 h')
await pane.press({ key: 'tl-win-5m' })
expect(textOf(await pane.drawn())).toContain('5 min')
await pane.press({ key: 'tl-zout' })
expect(textOf(await pane.drawn())).toContain('15 min')
await pane.unmount()
})
test('events: kind chips, a search field and a pause button; searching for nothing says no event matches; pause then resume flips the button', { timeoutMs: 30_000, options: { boot: false } }, async ($, on) => {
const pane = await opened($, on, 'events')
const first = await pane.drawn()
expect(keys(first)).toEqual(expect.arrayContaining(['ev-kind-all', 'ev-level-all', 'ev-win-all', 'ev-pause', 'ev-clear', 'ev-export-md', 'ev-forget']))
expect(inputKeys(first)).toContain('ev-query')
expect(textOf(first)).toContain('live')
await pane.press({ key: 'ev-pause' })
expect(textOf(await pane.drawn())).toContain('paused')
expect(keys(await pane.drawn())).toContain('ev-pause')
await pane.press({ key: 'ev-pause' })
expect(textOf(await pane.drawn())).toContain('live')
await pane.input({ key: 'ev-query', text: 'zzz-not-an-event', kind: 'submit' })
const none = await pane.drawn()
expect(textOf(none)).toMatch(/no event matches|Nothing has changed/)
await pane.press({ key: 'ev-clear' })
expect(textOf(await pane.drawn())).toContain('filters cleared')
await pane.unmount()
})
})