Skip to content

Commit 78383e3

Browse files
committed
fix(zoho-desk): enrich prevState with contentText symmetrically with payload
formatInput derived plain-text contentText only on payload, so an update event for a comment/thread left prevState as raw HTML while payload carried contentText - inconsistent shapes for before/after comparisons. Apply withDerivedContentText to prevState too. Test asserts both are enriched.
1 parent b8863a2 commit 78383e3

2 files changed

Lines changed: 16 additions & 9 deletions

File tree

apps/sim/lib/webhooks/providers/zoho-desk.test.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -163,16 +163,22 @@ describe('zohoDeskHandler', () => {
163163
content: '<div style="direction: ltr;"><div>testing</div></div>',
164164
contentType: 'html',
165165
},
166-
prevState: null,
166+
prevState: { id: 'comment-1', content: '<div>before</div>', contentType: 'html' },
167167
},
168168
],
169169
headers: {},
170170
requestId: 'test',
171171
})
172-
const payload = (result?.input as { payload: Record<string, unknown> }).payload
173-
expect(payload.content).toBe('<div style="direction: ltr;"><div>testing</div></div>')
174-
expect(payload.contentType).toBe('html')
175-
expect(payload.contentText).toBe('testing')
172+
const input = result?.input as {
173+
payload: Record<string, unknown>
174+
prevState: Record<string, unknown>
175+
}
176+
expect(input.payload.content).toBe('<div style="direction: ltr;"><div>testing</div></div>')
177+
expect(input.payload.contentType).toBe('html')
178+
expect(input.payload.contentText).toBe('testing')
179+
// prevState is enriched symmetrically so before/after comparisons match shapes.
180+
expect(input.prevState.content).toBe('<div>before</div>')
181+
expect(input.prevState.contentText).toBe('before')
176182
})
177183

178184
it('mirrors plainText content into contentText', async () => {

apps/sim/lib/webhooks/providers/zoho-desk.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -383,16 +383,17 @@ export const zohoDeskHandler: WebhookProviderHandler = {
383383
}
384384
const record = event as Record<string, unknown>
385385
// Comment / thread event payloads carry a raw `content` + `contentType`
386-
// ('html' | 'plainText') pair; augment the payload with a derived plain-text
387-
// `contentText` (HTML stripped) alongside the untouched raw content. Payloads
388-
// without a content pair (e.g. ticket / contact events) pass through unchanged.
386+
// ('html' | 'plainText') pair; augment both `payload` and `prevState` with a
387+
// derived plain-text `contentText` (HTML stripped) alongside the untouched raw
388+
// content, so before/after comparisons see a consistent shape. Values without
389+
// a content pair (ticket / contact events) pass through unchanged.
389390
return {
390391
input: {
391392
eventType: record.eventType ?? null,
392393
eventTime: record.eventTime ?? null,
393394
orgId: record.orgId ?? null,
394395
payload: record.payload != null ? withDerivedContentText(record.payload) : null,
395-
prevState: record.prevState ?? null,
396+
prevState: record.prevState != null ? withDerivedContentText(record.prevState) : null,
396397
},
397398
}
398399
},

0 commit comments

Comments
 (0)