Skip to content

Commit 026bca7

Browse files
committed
test(task): document partial provider double and assert delegation metadata in say-rejection test
1 parent 018f165 commit 026bca7

1 file changed

Lines changed: 15 additions & 2 deletions

File tree

‎src/__tests__/provider-delegation.spec.ts‎

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -537,6 +537,9 @@ describe("ClineProvider.delegateParentAndOpenChild()", () => {
537537
const taskHistoryStore = makeStoreStub()
538538
const providerLog = vi.fn()
539539

540+
// Partial provider double: the real ClineProvider.prototype.delegateParentAndOpenChild
541+
// is invoked below via .call() with only the members that method reads, so the full
542+
// interface is not implemented and the double assertion is the last-resort hand-off.
540543
const provider = {
541544
taskScheduler: new TaskScheduler(),
542545
emit: vi.fn(),
@@ -563,9 +566,19 @@ describe("ClineProvider.delegateParentAndOpenChild()", () => {
563566
// The say rejection is surfaced through the provider log, not thrown.
564567
expect(providerLog).toHaveBeenCalledWith(expect.stringContaining("non-fatal"))
565568
expect(providerLog).toHaveBeenCalledWith(expect.stringContaining("task disposed"))
566-
// Delegation metadata is still persisted for the (already disposed) parent.
569+
// Delegation metadata is still persisted for the (already disposed) parent:
570+
// capture the updater's resulting item and assert the delegated status and both
571+
// child links, not just that the metadata transaction was entered.
567572
expect(taskHistoryStore.atomicReadAndUpdate).toHaveBeenCalledTimes(1)
568-
expect(taskHistoryStore.atomicReadAndUpdate.mock.calls[0][0]).toBe("parent-1")
573+
const [calledTaskId, updater] = taskHistoryStore.atomicReadAndUpdate.mock.calls[0]
574+
expect(calledTaskId).toBe("parent-1")
575+
expect(updater(parentHistoryItem)).toMatchObject({
576+
id: "parent-1",
577+
status: "delegated",
578+
delegatedToId: "child-1",
579+
awaitingChildId: "child-1",
580+
childIds: expect.arrayContaining(["child-1"]),
581+
})
569582
// And the child is still scheduled despite the failed notification.
570583
expect(childRun).toHaveBeenCalledTimes(1)
571584
})

0 commit comments

Comments
 (0)