Files
ruflo/plugins/ruflo-console/tests/steps.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

56 lines
2.4 KiB
TypeScript

/**
* The "Start here" card on a page with an order: in an empty project it leads the Swarm page with the first step marked next, the
* step's button asks before it runs anything (the confirm opens right under the step), and a project that already has everything
* the disk can check is not asked for again: its steps show done and the next one is marked.
*/
import { describe, expect, mock, test } from 'claude-code/testing'
import { RUFLO_FILES } from './fixtures/ruflo-run'
import { command, elementsOf, keyOf, paneAt, PLUGIN, SESSION, textOf, worldOf } from './fixtures/world'
const keys = (tree: Parameters<typeof elementsOf>[0]) => elementsOf(tree, 'Button').map(keyOf)
describe('start here', () => {
test('an empty project: the Swarm page leads with its steps, the first is next, and its button asks before it runs', { timeoutMs: 30_000, options: { boot: false } }, async ($, on) => {
const world = worldOf(on, {})
mock.clock(on)
await $.session.start(SESSION)
await $.command.run(command('swarm'))
const pane = await $.ui.mount({ ...paneAt(120), plugin: PLUGIN })
const first = await pane.drawn()
const text = textOf(first)
expect(text).toMatch(/START HERE: GET A SWARM GOING/i)
expect(text).toContain('▶ 1. Initialise ruflo in this project')
expect(text).toContain('0 of 5 done')
expect(text).toContain('○ 2. Start a swarm')
expect(keys(first)).toEqual(expect.arrayContaining(['step-swarm-0', 'step-swarm-1', 'step-swarm-5']))
await pane.press({ key: 'step-swarm-0' })
expect(textOf(await pane.drawn())).toContain('Confirm: initialise ruflo in this project')
expect(world.runs.filter(argv => argv.includes('init'))).toEqual([])
await pane.press({ key: 'cancel' })
expect(world.runs.filter(argv => argv.includes('init'))).toEqual([])
await pane.unmount()
})
test('a project with ruflo and a swarm shows those steps done, and the next one marked', { timeoutMs: 30_000, options: { boot: false } }, async ($, on) => {
worldOf(on, RUFLO_FILES)
mock.clock(on)
await $.session.start(SESSION)
await $.command.run(command('swarm'))
const pane = await $.ui.mount({ ...paneAt(120), plugin: PLUGIN })
const text = textOf(await pane.drawn())
expect(text).toContain('✔ 1. Initialise ruflo in this project')
expect(text).toContain('✔ 2. Start a swarm')
expect(text).toMatch(/▶ [3-5]\. Spawn a/)
expect(text).toMatch(/[2-4] of 5 done/)
await pane.unmount()
})
})