Skip to content

Commit fec1a08

Browse files
chore: fix flaky app action call response test [] (#2806)
1 parent 0e44894 commit fec1a08

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

test/integration/app-action-call-structured-integration.test.ts

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
createAppInstallation,
1212
timeoutToCalmRateLimiting,
1313
} from '../helpers'
14+
import { pollAsyncActionStatus } from '../../lib/methods/action'
1415

1516
describe('AppActionCall structured endpoints', function () {
1617
let client: PlainClientAPI
@@ -104,16 +105,23 @@ describe('AppActionCall structured endpoints', function () {
104105
{ parameters: {} },
105106
)
106107

107-
const call = await client.appActionCall.get({
108-
spaceId: space.sys.id,
109-
environmentId: 'master',
110-
appDefinitionId: appDefinition.sys.id,
111-
appActionId,
112-
callId: created.sys.id,
113-
})
108+
// Poll until the call completes (status is no longer 'processing')
109+
const call = await pollAsyncActionStatus<AppActionCallProps>(
110+
async () =>
111+
client.appActionCall.get({
112+
spaceId: space.sys.id,
113+
environmentId: 'master',
114+
appDefinitionId: appDefinition.sys.id,
115+
appActionId,
116+
callId: created.sys.id,
117+
}),
118+
{ throwOnFailedExecution: false }, // Don't throw on 'failed' status, we just need it to complete
119+
)
114120

115121
expect(call.sys.type).toBe('AppActionCall')
122+
expect(['succeeded', 'failed']).toContain(call.sys.status)
116123

124+
// Now that the call has completed, the response should be available
117125
const raw = await client.appActionCall.getResponse({
118126
spaceId: space.sys.id,
119127
environmentId: 'master',

0 commit comments

Comments
 (0)