Skip to content

Commit 6f1c016

Browse files
authored
Test that the board rail counts the list the board draws (#2087)
Fixes #2086 Written-by: Dev-1 Owner: Dev-1 Reviewer: Birfy Claim-Id: d666ef54f2b14bc7bff2e774871e5fc9 Branch: dev/1-kanban-scope-counts Base: fca35af Tip SHA: d799eb7 ## What happens today `#2069` fixed the rail so a room board counts the room's list and a Bot board counts its own, at `core/src/client/kanban.js:422`: ```js for (const task of [...(scope?.kind === 'group' ? groupTasks : own), ...(archive ?? []).slice(0, ARCHIVE_SHOWN)]) { ``` Nothing in `core/test/kanban.test.js` pins that branch. The existing room fixture `boardWith(...)` fills `own` with the same cards it puts into `groupTasks`, so both arms of the ternary produce the same numbers and a single-arm change stays green. Measured on live main `fca35af6` with only the source changed: ```js // kanban.js:422, made constant: for (const task of [...(own), ...(archive ?? []).slice(0, ARCHIVE_SHOWN)]) { ``` → `core/test/kanban.test.js` **21 tests / 21 pass / 0 fail, exit 0**, three runs identical. The `#2069` fix can be undone with a fully green file. ## The change One case and its fixture, in two mirrored files (`core/test/kanban.test.js` and `patches/ds-bot/files/test/kanban.test.js`, the generated mirror), `+96 / −0`. No source file is touched. - `boardWithLists(scope, own, groupActive, archive = [])` seeds the two lists **apart**, which the existing `boardWith` cannot do in a room scope. - `P-364: the rail counts the list the board draws, never the one the other scope left behind` has one arm per direction. A room board whose `own` still holds the Bot board's read (one card for Writer) while the room's list holds Writer's three and Chief's one must read `0/3` for Writer and `0/1` for Chief, who appears only in the room's list. A Bot board whose room list still holds four cards while `own` holds two must read `0/2`, not `0/4`. ## Red first (on base `fca35af6`) Only the new case added, source untouched: - as-is → **22 tests / 22 pass / 0 fail**, exit 0, three runs identical. - `kanban.js:422` made constant `own` → **22 / 21 / 1**, three runs identical, exit 1. The red is `not ok 15 - P-364: the rail counts the list the board draws, never the one the other scope left behind`: `'0/1' !== '0/3'` — "the room board counts the room's three, not the stale single card". - `kanban.js:422` made constant `groupTasks` → **22 / 18 / 4**, three runs identical, exit 1. The red is test 15's Bot arm plus the three existing Bot-board cases: `#2045: a page that is not full still reads as the whole history, unchanged` (11), `#2045: the rail hedge follows the Bot's drawn done rows, not its total` (13) and `#2069: a room board reached from a Bot board counts each active card once in the rail` (17). Both directions are therefore bitten, and neither mutation can hide behind the other's arm. ## Verified `TZ=UTC ARCH_DOCS_BASE=fca35af6f29a10214f239b78a2087b82845ba4ce npm run verify`, on the committed tree → exit 0: core **2558/2558**, social 541, tree 127, timeline 135, workflow 336, `.github/scripts` **575**, interop 37, live-e2e 24. Lint: core **73 warnings / 0 errors**, the other four packages 36 / 9 / 2 / 16 warnings and 0 errors, interop 1 warning / 0 errors, live-e2e 0 / 0. `arch-docs: OK (2 changed file(s))` — the two files this branch changes and no others. Also green on the same tree: `node scripts/ds-bot-patches.mjs check` (10 patches apply cleanly in order; `core/ equals ds-bot/ + patches/ds-bot/`) and `node core/scripts/build-client.mjs --check`. ## Which tree the checks ran on Local commit `a22f6542a6c8fc7b695e7d562af59237ae183b04`, tree `8fc6072d0045f370a1c2d80b9f707591cf8d9145`, single parent `fca35af6f29a10214f239b78a2087b82845ba4ce`. Verify and `arch-docs` ran on that checkout. The pushed head `d799eb757785aa31cadb6eebd41bc672ec70f5a4` was rebuilt from the same tree by the push path, so its sha differs while its tree does not; `checks.at` names the pushed tip, which is what CI reads. ## Not in scope - `core/src/client/kanban.js` is unchanged. The ternary has been correct since `#2069`; this PR only adds the case that reds when it is changed, as the issue scoped it. - No changelog fragment and no subsystem doc: nothing user-visible changes. ## Not run The smoke test (nothing under `core/index.js` or `core/src/host/` changed) and the packaged Desktop install path. ## Checkpoint <!-- flybot:checkpoint --> ```json { "pr": 2087, "claim": "Dev-1", "issue": 2086, "summary": "The rail counts a room board from groupTasks and a Bot board from own (#2069), but no test could tell the two lists apart: the existing room fixture seeds both with the same cards, so a constant own stayed 21 of 21 green. A new case seeds them apart and asserts 0/3 for a Writer with three room cards, not the stale 0/1, and 0/2 on the Bot board, not the leftover 0/4. Each mutation reds it (always own 22/21/1, always groupTasks 22/18/4) and the unmutated file is 22/22, with no source file touched.", "files": [ "core/test/kanban.test.js", "patches/ds-bot/files/test/kanban.test.js" ], "checks": { "ran": "npm run verify (ARCH_DOCS_BASE=fca35af6, core 2558, .github/scripts 575) exit 0; core/test/kanban.test.js 22/22 x3; mutants always own 22/21/1 x3, always groupTasks 22/18/4 x3", "result": "green", "at": "d799eb757785aa31cadb6eebd41bc672ec70f5a4" }, "next": "none — ready for review" } ``` <!-- /flybot:checkpoint -->
1 parent 7166f5a commit 6f1c016

2 files changed

Lines changed: 96 additions & 0 deletions

File tree

‎core/test/kanban.test.js‎

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,54 @@ test('P-364: a room board rail counts the room\'s active cards, not only its arc
435435
assert.equal(room.railMeta('a'), '0/1', 'a Bot with an active card and none finished is 0 of 1, not a blank rail')
436436
})
437437

438+
// P-364 follow-up: `boardWith` seeds both board lists with the same cards when the scope is a room,
439+
// so no case could tell which list the rail's counts read. These arms seed them apart: a room board
440+
// whose `own` still holds the Bot board's read, and a Bot board reached after a room left its list
441+
// behind. Either mutation of `counts` (always `own`, always `groupTasks`) has to show here.
442+
const boardWithLists = (scope, own, groupActive, archive = []) => {
443+
states.length = 0
444+
states.push(scope, null, '', '', own, groupActive, archive)
445+
const view = expand(KanbanDialog({ roster, actions: { closeBoard: () => {}, boardClose: () => {} } }))
446+
const railMeta = id => {
447+
const row = all(view).find(node => node.props?.['data-id'] === id)
448+
const meta = byClass(row, 'bt-board-rail-meta')[0]
449+
return meta ? textOf(meta) : ''
450+
}
451+
return { view, railMeta }
452+
}
453+
454+
test('P-364: the rail counts the list the board draws, never the one the other scope left behind', () => {
455+
// A room board: `own` still holds the Bot board's read (one open card for Writer), the room's
456+
// list holds Writer's three active cards and Chief's one. The rail counts the room's list.
457+
const staleOwn = [task('task-open-stale', 'open', { title: 'Stale for s', ownerBotId: 's', createdAt: 1, updatedAt: 2 })]
458+
const roomList = [
459+
task('task-open-s', 'open', { title: 'Open for s', ownerBotId: 's', createdAt: 3, updatedAt: 4 }),
460+
task('task-working-s', 'working', { title: 'Working for s', ownerBotId: 's', createdAt: 5, updatedAt: 6 }),
461+
task('task-open-s-2', 'open', { title: 'Another for s', ownerBotId: 's', createdAt: 7, updatedAt: 8 }),
462+
task('task-open-a', 'open', { title: 'Open for a', ownerBotId: 'a', createdAt: 9, updatedAt: 10 }),
463+
]
464+
const room = boardWithLists({ kind: 'group', roomId: 'war' }, staleOwn, roomList)
465+
assert.equal(room.railMeta('s'), '0/3', 'the room board counts the room\'s three, not the stale single card')
466+
assert.equal(room.railMeta('a'), '0/1', 'a Bot that only appears in the room\'s list is counted from it')
467+
assert.notEqual(room.railMeta('s'), '0/1', 'the stale Bot board read is not what the rail counts')
468+
469+
// A Bot board: `own` holds Writer's two active cards, the room's list still holds four. The rail
470+
// counts the Bot's two, so one direction's mutation cannot hide behind the other's.
471+
const ownList = [
472+
task('task-open-s', 'open', { title: 'Open for s', ownerBotId: 's', createdAt: 1, updatedAt: 2 }),
473+
task('task-working-s', 'working', { title: 'Working for s', ownerBotId: 's', createdAt: 3, updatedAt: 4 }),
474+
]
475+
const leftRoom = [
476+
task('task-open-s', 'open', { title: 'Open for s', ownerBotId: 's', createdAt: 5, updatedAt: 6 }),
477+
task('task-working-s', 'working', { title: 'Working for s', ownerBotId: 's', createdAt: 7, updatedAt: 8 }),
478+
task('task-open-s-2', 'open', { title: 'Another for s', ownerBotId: 's', createdAt: 9, updatedAt: 10 }),
479+
task('task-open-s-3', 'open', { title: 'Yet another for s', ownerBotId: 's', createdAt: 11, updatedAt: 12 }),
480+
]
481+
const bot = boardWithLists({ kind: 'bot', botId: 's' }, ownList, leftRoom)
482+
assert.equal(bot.railMeta('s'), '0/2', 'the Bot board counts its own two, not the room list still in state')
483+
assert.notEqual(bot.railMeta('s'), '0/4', 'the room list is not what a Bot board counts')
484+
})
485+
438486
// P-360: the rail switch from one Bot to another. The fake React at the top of this file hands an
439487
// effect back to the test and never re-runs one, so a switch case written against it passes whatever
440488
// the hook does (#1810). This is a second, stateful context: hook slots per component, an effect

‎patches/ds-bot/files/test/kanban.test.js‎

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,54 @@ test('P-364: a room board rail counts the room\'s active cards, not only its arc
435435
assert.equal(room.railMeta('a'), '0/1', 'a Bot with an active card and none finished is 0 of 1, not a blank rail')
436436
})
437437

438+
// P-364 follow-up: `boardWith` seeds both board lists with the same cards when the scope is a room,
439+
// so no case could tell which list the rail's counts read. These arms seed them apart: a room board
440+
// whose `own` still holds the Bot board's read, and a Bot board reached after a room left its list
441+
// behind. Either mutation of `counts` (always `own`, always `groupTasks`) has to show here.
442+
const boardWithLists = (scope, own, groupActive, archive = []) => {
443+
states.length = 0
444+
states.push(scope, null, '', '', own, groupActive, archive)
445+
const view = expand(KanbanDialog({ roster, actions: { closeBoard: () => {}, boardClose: () => {} } }))
446+
const railMeta = id => {
447+
const row = all(view).find(node => node.props?.['data-id'] === id)
448+
const meta = byClass(row, 'bt-board-rail-meta')[0]
449+
return meta ? textOf(meta) : ''
450+
}
451+
return { view, railMeta }
452+
}
453+
454+
test('P-364: the rail counts the list the board draws, never the one the other scope left behind', () => {
455+
// A room board: `own` still holds the Bot board's read (one open card for Writer), the room's
456+
// list holds Writer's three active cards and Chief's one. The rail counts the room's list.
457+
const staleOwn = [task('task-open-stale', 'open', { title: 'Stale for s', ownerBotId: 's', createdAt: 1, updatedAt: 2 })]
458+
const roomList = [
459+
task('task-open-s', 'open', { title: 'Open for s', ownerBotId: 's', createdAt: 3, updatedAt: 4 }),
460+
task('task-working-s', 'working', { title: 'Working for s', ownerBotId: 's', createdAt: 5, updatedAt: 6 }),
461+
task('task-open-s-2', 'open', { title: 'Another for s', ownerBotId: 's', createdAt: 7, updatedAt: 8 }),
462+
task('task-open-a', 'open', { title: 'Open for a', ownerBotId: 'a', createdAt: 9, updatedAt: 10 }),
463+
]
464+
const room = boardWithLists({ kind: 'group', roomId: 'war' }, staleOwn, roomList)
465+
assert.equal(room.railMeta('s'), '0/3', 'the room board counts the room\'s three, not the stale single card')
466+
assert.equal(room.railMeta('a'), '0/1', 'a Bot that only appears in the room\'s list is counted from it')
467+
assert.notEqual(room.railMeta('s'), '0/1', 'the stale Bot board read is not what the rail counts')
468+
469+
// A Bot board: `own` holds Writer's two active cards, the room's list still holds four. The rail
470+
// counts the Bot's two, so one direction's mutation cannot hide behind the other's.
471+
const ownList = [
472+
task('task-open-s', 'open', { title: 'Open for s', ownerBotId: 's', createdAt: 1, updatedAt: 2 }),
473+
task('task-working-s', 'working', { title: 'Working for s', ownerBotId: 's', createdAt: 3, updatedAt: 4 }),
474+
]
475+
const leftRoom = [
476+
task('task-open-s', 'open', { title: 'Open for s', ownerBotId: 's', createdAt: 5, updatedAt: 6 }),
477+
task('task-working-s', 'working', { title: 'Working for s', ownerBotId: 's', createdAt: 7, updatedAt: 8 }),
478+
task('task-open-s-2', 'open', { title: 'Another for s', ownerBotId: 's', createdAt: 9, updatedAt: 10 }),
479+
task('task-open-s-3', 'open', { title: 'Yet another for s', ownerBotId: 's', createdAt: 11, updatedAt: 12 }),
480+
]
481+
const bot = boardWithLists({ kind: 'bot', botId: 's' }, ownList, leftRoom)
482+
assert.equal(bot.railMeta('s'), '0/2', 'the Bot board counts its own two, not the room list still in state')
483+
assert.notEqual(bot.railMeta('s'), '0/4', 'the room list is not what a Bot board counts')
484+
})
485+
438486
// P-360: the rail switch from one Bot to another. The fake React at the top of this file hands an
439487
// effect back to the test and never re-runs one, so a switch case written against it passes whatever
440488
// the hook does (#1810). This is a second, stateful context: hook slots per component, an effect

0 commit comments

Comments
 (0)