Skip to content

Commit 320ca13

Browse files
committed
fix(buffer): normalize cleared inputs and complete test scope
1 parent d486cae commit 320ca13

3 files changed

Lines changed: 14 additions & 6 deletions

File tree

‎apps/sim/blocks/blocks/buffer.ts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -666,7 +666,11 @@ export const BufferBlock: BlockConfig = {
666666
key === 'operation'
667667
)
668668
continue
669-
if (value === undefined || value === null || value === '') continue
669+
if (value === undefined || value === null) continue
670+
if (value === '') {
671+
result[key] = undefined
672+
continue
673+
}
670674
if ((key === 'mode' || key === 'schedulingType') && value === 'default') {
671675
result[key] =
672676
params.operation === 'create_post'

‎apps/sim/executor/handlers/generic/generic-handler.test.ts‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,13 @@ describe('GenericBlockHandler', () => {
8080
mockExecuteTool.mockResolvedValue({ success: true, output: { customResult: 'OK' } })
8181
})
8282

83-
it('preserves the current Buffer schedule and approval state when editing only text', async () => {
83+
it.each([
84+
{
85+
selection: 'keep-current scheduling',
86+
optional: { mode: 'default', schedulingType: 'default', approvalChange: 'default' },
87+
},
88+
{ selection: 'cleared structured editors', optional: { assets: '', metadata: '' } },
89+
])('preserves existing Buffer state for a caption edit with $selection', async ({ optional }) => {
8490
mockGetBlock.mockReturnValue(BufferBlock)
8591
mockGetTool.mockReturnValue(bufferEditPostTool)
8692
const providerInputs: Record<string, unknown>[] = []
@@ -115,9 +121,7 @@ describe('GenericBlockHandler', () => {
115121
apiKey: 'buffer-key',
116122
postId: 'post-1',
117123
text: 'Updated caption',
118-
mode: 'default',
119-
schedulingType: 'default',
120-
approvalChange: 'default',
124+
...optional,
121125
}
122126
)
123127

‎apps/sim/scripts/test-buffer-e2e.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ async function tool(id: string, params: Record<string, unknown> = {}) {
5353
{ apiKey, ...params },
5454
{
5555
signal: AbortSignal.timeout(60_000),
56-
operationContext: { userId: fixtureId, workflowId: fixtureId },
56+
operationContext: { userId: fixtureId, workflowId: fixtureId, workspaceId: fixtureId },
5757
}
5858
)
5959
assert(result.success, result.error ?? `${id} failed`)

0 commit comments

Comments
 (0)