|
1 | 1 | /** |
2 | 2 | * @vitest-environment node |
3 | 3 | */ |
4 | | -import { dbChainMock, queueTableRows, resetDbChainMock, schemaMock } from '@sim/testing' |
| 4 | +import { |
| 5 | + dbChainMock, |
| 6 | + dbChainMockFns, |
| 7 | + queueTableRows, |
| 8 | + resetDbChainMock, |
| 9 | + schemaMock, |
| 10 | +} from '@sim/testing' |
5 | 11 | import { beforeEach, describe, expect, it, vi } from 'vitest' |
6 | 12 |
|
7 | 13 | const { |
@@ -47,7 +53,7 @@ vi.mock('@/lib/workspaces/permissions/utils', () => ({ |
47 | 53 | checkWorkspaceAccess: mockCheckWorkspaceAccess, |
48 | 54 | })) |
49 | 55 |
|
50 | | -import { runWakeTurn, validateWake } from './wake' |
| 56 | +import { resolveTaskPill, runWakeTurn, validateWake } from './wake' |
51 | 57 |
|
52 | 58 | const WAKE = { |
53 | 59 | taskId: '22222222-2222-4222-8222-222222222222', |
@@ -120,6 +126,44 @@ describe('copilot task wake', () => { |
120 | 126 | ) |
121 | 127 | }) |
122 | 128 |
|
| 129 | + it('resolves the pill in the arming message before the wake turn lands', async () => { |
| 130 | + queueTableRows(schemaMock.copilotMessages, [ |
| 131 | + { |
| 132 | + id: 'row-1', |
| 133 | + content: { |
| 134 | + id: 'assistant-1', |
| 135 | + role: 'assistant', |
| 136 | + contentBlocks: [ |
| 137 | + { type: 'text', content: 'armed' }, |
| 138 | + { |
| 139 | + type: 'task', |
| 140 | + task: { |
| 141 | + taskId: WAKE.taskId, |
| 142 | + kind: 'timer', |
| 143 | + target: {}, |
| 144 | + note: 'n', |
| 145 | + status: 'pending', |
| 146 | + }, |
| 147 | + }, |
| 148 | + ], |
| 149 | + }, |
| 150 | + }, |
| 151 | + ]) |
| 152 | + await resolveTaskPill('chat-1', WAKE.taskId, 'completed', 'Timer elapsed') |
| 153 | + expect(dbChainMockFns.update).toHaveBeenCalledWith(schemaMock.copilotMessages) |
| 154 | + const [setArg] = dbChainMockFns.set.mock.calls[0] as [ |
| 155 | + { |
| 156 | + content: { |
| 157 | + contentBlocks: Array<{ type: string; task?: { status?: string; summary?: string } }> |
| 158 | + } |
| 159 | + }, |
| 160 | + ] |
| 161 | + expect(setArg.content.contentBlocks[1]?.task).toMatchObject({ |
| 162 | + status: 'completed', |
| 163 | + summary: 'Timer elapsed', |
| 164 | + }) |
| 165 | + }) |
| 166 | + |
123 | 167 | it('skips the turn when another stream holds the chat', async () => { |
124 | 168 | mockAcquirePendingChatStream.mockResolvedValue(false) |
125 | 169 | await runWakeTurn(WAKE) |
|
0 commit comments