Skip to content

Commit 5e1862e

Browse files
fix(tables): preserve group auto-run semantics (#6579)
1 parent a72457b commit 5e1862e

2 files changed

Lines changed: 41 additions & 3 deletions

File tree

apps/sim/lib/table/application/groups.test.ts

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ const mocks = vi.hoisted(() => ({
1616
resolveContext: vi.fn(),
1717
resolvePermission: vi.fn(),
1818
resolveWorkflowContext: vi.fn(),
19+
runDetached: vi.fn(),
20+
runWorkflowColumn: vi.fn(),
1921
signal: vi.fn(),
2022
updateGroup: vi.fn(),
2123
}))
@@ -36,7 +38,12 @@ vi.mock('@sim/platform-authz/workspace', () => ({
3638
}))
3739
vi.mock('@sim/utils/id', () => ({ generateId: () => 'generated-id' }))
3840
vi.mock('@/enrichments/registry', () => ({ getEnrichment: mocks.getEnrichment }))
39-
vi.mock('@/lib/core/utils/background', () => ({ runDetached: vi.fn() }))
41+
vi.mock('@/lib/core/utils/background', () => ({
42+
runDetached: (label: string, work: () => Promise<unknown>) => {
43+
mocks.runDetached(label)
44+
void work()
45+
},
46+
}))
4047
vi.mock('@/lib/core/utils/request', () => ({ generateRequestId: () => 'request-1' }))
4148
vi.mock('@/lib/table/application/context', () => ({
4249
resolveActiveTableContext: mocks.resolveContext,
@@ -51,7 +58,9 @@ vi.mock('@/lib/table/column-naming', () => ({
5158
},
5259
}))
5360
vi.mock('@/lib/table/events', () => ({ signalTableSchemaChanged: mocks.signal }))
54-
vi.mock('@/lib/table/workflow-columns', () => ({ runWorkflowColumn: vi.fn() }))
61+
vi.mock('@/lib/table/workflow-columns', () => ({
62+
runWorkflowColumn: mocks.runWorkflowColumn,
63+
}))
5564
vi.mock('@/lib/table/workflow-groups/service', () => ({
5665
addWorkflowGroup: mocks.addGroup,
5766
addWorkflowGroupOutput: mocks.addOutput,
@@ -145,6 +154,10 @@ describe('workflow and enrichment Table application commands', () => {
145154
beforeEach(() => {
146155
vi.clearAllMocks()
147156
mocks.resolvePermission.mockResolvedValue('write')
157+
mocks.runWorkflowColumn.mockResolvedValue({
158+
dispatchId: 'dispatch-1',
159+
shouldSignalRowsChanged: false,
160+
})
148161
mocks.resolveContext.mockResolvedValue({
149162
tableId: table.id,
150163
table,
@@ -244,6 +257,30 @@ describe('workflow and enrichment Table application commands', () => {
244257
)
245258
})
246259

260+
it('starts group auto-run without manual rerun semantics', async () => {
261+
await createWorkflowTableGroup.execute({
262+
principal,
263+
input: {
264+
tableId: table.id,
265+
workspaceId: table.workspaceId,
266+
workflowId: 'workflow-1',
267+
outputs: [{ blockId: 'block-2', path: 'score' }],
268+
autoRun: true,
269+
},
270+
})
271+
272+
expect(mocks.runDetached).toHaveBeenCalledWith('table-workflow-group-create-auto-run')
273+
expect(mocks.runWorkflowColumn).toHaveBeenCalledWith({
274+
tableId: table.id,
275+
workspaceId: table.workspaceId,
276+
groupIds: ['generated-id'],
277+
mode: 'new',
278+
isManualRun: false,
279+
requestId: 'request-1',
280+
triggeredByUserId: 'user-1',
281+
})
282+
})
283+
247284
it('conceals a cross-workspace workflow before group mutation or effects', async () => {
248285
mocks.resolveWorkflowContext.mockRejectedValueOnce(
249286
new OrchestrationError('not_found', 'Workflow not found')

apps/sim/lib/table/application/groups.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,8 @@ function dispatchGroupAutoRun(params: {
156156
tableId: params.tableId,
157157
workspaceId: params.workspaceId,
158158
groupIds: [params.groupId],
159-
mode: 'all',
159+
mode: 'new',
160+
isManualRun: false,
160161
requestId: generateRequestId(),
161162
triggeredByUserId: params.actorUserId,
162163
})

0 commit comments

Comments
 (0)