Skip to content

Commit 39a4fda

Browse files
committed
fix(resend): keep the catalog's audience requirement static and type the new tests
1 parent 0510aed commit 39a4fda

3 files changed

Lines changed: 24 additions & 5 deletions

File tree

‎apps/sim/blocks/blocks/resend.test.ts‎

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ describe('Resend Create Broadcast recipient', () => {
5454
...values,
5555
}
5656
const subBlocks = Object.fromEntries(
57-
Object.entries(params).map(([id, value]) => [id, { id, type: 'short-input', value }])
57+
Object.entries(params).map(([id, value]) => [id, { id, type: 'short-input' as const, value }])
5858
)
5959
const block = {
6060
id: 'b1',
@@ -81,4 +81,17 @@ describe('Resend Create Broadcast recipient', () => {
8181
)
8282
}
8383
)
84+
85+
it.each([ResendBlock, ResendV2Block])(
86+
'publishes Audience ID as required only for the audience operations when no values are known',
87+
(config) => {
88+
const audienceId = config.subBlocks.find((subBlock) => subBlock.id === 'audienceId')
89+
const required = audienceId?.required
90+
if (typeof required !== 'function') throw new Error('Audience ID requirement is not dynamic')
91+
expect(required()).toEqual({
92+
field: 'operation',
93+
value: ['get_audience', 'delete_audience'],
94+
})
95+
}
96+
)
8497
})

‎apps/sim/blocks/blocks/resend.ts‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -317,11 +317,17 @@ Return ONLY the email body - no explanations, no extra text.`,
317317
field: 'operation',
318318
value: ['get_audience', 'delete_audience', 'create_broadcast'],
319319
},
320+
/**
321+
* Create Broadcast needs an audience only when no segment is set. Without block values (the
322+
* public catalog, Copilot validation) a segment may still be given, so only the audience
323+
* operations require it.
324+
*/
320325
required: (values) => ({
321326
field: 'operation',
322-
value: String(values?.segmentId ?? '').trim()
323-
? ['get_audience', 'delete_audience']
324-
: ['get_audience', 'delete_audience', 'create_broadcast'],
327+
value:
328+
values && !String(values.segmentId ?? '').trim()
329+
? ['get_audience', 'delete_audience', 'create_broadcast']
330+
: ['get_audience', 'delete_audience'],
325331
}),
326332
},
327333

‎apps/sim/blocks/blocks/sailpoint.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ describe('SailPoint search list fields', () => {
8080
accessToken: 'token',
8181
query: { query: '*' },
8282
})
83-
expect(request.searchAfter).toEqual(['12345'])
83+
expect(request).toMatchObject({ searchAfter: ['12345'] })
8484
})
8585
})
8686

0 commit comments

Comments
 (0)