Skip to content

Commit

Permalink
fix: do not do partial retries in test runs (#811)
Browse files Browse the repository at this point in the history
## Problem
 
Postman actions cannot be re-tested when a partial success happened in
the last test step.


## Solution

Prevent partial retries in test runs.
  • Loading branch information
pregnantboy authored Dec 5, 2024
1 parent 69de54c commit db01e24
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,7 @@ describe('send transactional email', () => {
recipient: recipients,
},
})
$.execution.testRun = false
await expect(sendTransactionalEmail.run($)).resolves.not.toThrow()
expect($.http.post).toBeCalledTimes(4)
expect($.setActionItem).toHaveBeenCalledWith({
Expand All @@ -476,4 +477,42 @@ describe('send transactional email', () => {
},
})
})

it('should send to all recipients in test runs', async () => {
const recipients = [
'[email protected]',
'[email protected]',
'[email protected]',
'[email protected]',
'[email protected]',
]
$.step.parameters.destinationEmail = recipients.join(',')
$.getLastExecutionStep = vi.fn().mockResolvedValueOnce({
status: 'success',
errorDetails: 'error error',
dataOut: {
status: [
'BLACKLISTED',
'ACCEPTED',
'INTERMITTENT-ERROR',
'ERROR',
'RATE-LIMITED',
],
recipient: recipients,
},
})
$.execution.testRun = true
await expect(sendTransactionalEmail.run($)).resolves.not.toThrow()
expect($.http.post).toBeCalledTimes(5)
expect($.setActionItem).toHaveBeenCalledWith({
raw: {
status: ['ACCEPTED', 'ACCEPTED', 'ACCEPTED', 'ACCEPTED', 'ACCEPTED'],
recipient: recipients,
subject: 'test subject',
body: 'test body',
from: 'jack',
reply_to: '[email protected]',
},
})
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,10 @@ const action: IRawAction = {
lastExecutionStep?.dataOut,
)
const isPartialRetry =
prevDataOutParseResult.success && lastExecutionStep.errorDetails
prevDataOutParseResult.success &&
lastExecutionStep.errorDetails &&
// Don't do partial retry in test runs! always send to all recipients
!$.execution.testRun

if (isPartialRetry) {
const { status, recipient } = prevDataOutParseResult.data
Expand Down

0 comments on commit db01e24

Please sign in to comment.