Skip to content

Commit e1b61f5

Browse files
committed
test(logs-block): lock the shared joinIds output for existing filters
joinIds is shared with the workflow and status filters, so the per-entry trimming added for hand-typed triggers must not move their output. Covers every value a stored multi-select or advanced field can hold, plus the block-saved-before-the-filter case where triggers must not reach the query.
1 parent fd50a97 commit e1b61f5

1 file changed

Lines changed: 39 additions & 0 deletions

File tree

apps/sim/blocks/blocks/logs.test.ts

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,45 @@ describe('LogsV2Block trigger filter', () => {
6262
})
6363
})
6464

65+
describe('LogsV2Block backwards compatibility', () => {
66+
// `joinIds` is shared with the pre-existing workflow and status filters, so the
67+
// per-entry trimming added for hand-typed triggers must not move their output.
68+
// Every value a stored multi-select or advanced field can hold is listed here:
69+
// option ids and workflow ids contain neither spaces nor commas.
70+
const UUID = '3f2504e0-4f89-11d3-9a0c-0305e82c3301'
71+
72+
it.each([
73+
['unset', undefined, undefined],
74+
['empty selection', [], undefined],
75+
['one workflow', [UUID], UUID],
76+
[
77+
'two workflows',
78+
[UUID, 'b7a1c2d3-0000-4000-8000-000000000001'],
79+
`${UUID},b7a1c2d3-0000-4000-8000-000000000001`,
80+
],
81+
['advanced string', 'id-one,id-two', 'id-one,id-two'],
82+
['empty string', '', undefined],
83+
])('leaves workflowIds untouched for %s', (_name, value, expected) => {
84+
expect(buildQueryParams({ workflowIds: value }).workflowIds).toBe(expected)
85+
})
86+
87+
it.each([
88+
['unset', undefined, undefined],
89+
['empty selection', [], undefined],
90+
['one status', ['info'], 'info'],
91+
['several statuses', ['info', 'error', 'cancelled'], 'info,error,cancelled'],
92+
])('leaves level untouched for %s', (_name, value, expected) => {
93+
expect(buildQueryParams({ level: value }).level).toBe(expected)
94+
})
95+
96+
it('omits triggers entirely for a block saved before the filter existed', () => {
97+
const params = buildQueryParams({ workflowIds: [UUID], level: ['info'] })
98+
expect(params.triggers).toBeUndefined()
99+
// Undefined values are dropped on serialization, so nothing reaches the query.
100+
expect(JSON.stringify(params)).not.toContain('triggers')
101+
})
102+
})
103+
65104
describe('LogsV2Block trigger subblocks', () => {
66105
const subBlockIds = LogsV2Block.subBlocks.map((subBlock) => subBlock.id)
67106

0 commit comments

Comments
 (0)