@@ -4,8 +4,8 @@ import { sendIntegrationResults } from './integration-results';
44
55export const runIntegrationTests = task ( {
66 id : 'run-integration-tests' ,
7- run : async ( payload : { organizationId : string ; forceFailure ?: boolean } ) => {
8- const { organizationId, forceFailure = false } = payload ;
7+ run : async ( payload : { organizationId : string } ) => {
8+ const { organizationId } = payload ;
99
1010 logger . info ( `Running integration tests for organization: ${ organizationId } ` ) ;
1111
@@ -44,32 +44,6 @@ export const runIntegrationTests = task({
4444 `Found ${ integrations . length } integrations to test for organization: ${ organizationId } ` ,
4545 ) ;
4646
47- if ( forceFailure ) {
48- await new Promise ( ( resolve ) => setTimeout ( resolve , 5000 ) ) ;
49-
50- const forcedFailureMessage =
51- 'Test failure: intentionally failing integration job for UI verification' ;
52-
53- const forcedFailedIntegrations = integrations . map ( ( integration ) => ( {
54- id : integration . id ,
55- integrationId : integration . integrationId ,
56- name : integration . name ,
57- error : forcedFailureMessage ,
58- } ) ) ;
59-
60- logger . warn (
61- `Force-failing integration tests for organization ${ organizationId } : ${ forcedFailureMessage } ` ,
62- ) ;
63-
64- return {
65- success : false ,
66- organizationId,
67- integrationsCount : integrations . length ,
68- errors : [ forcedFailureMessage ] ,
69- failedIntegrations : forcedFailedIntegrations ,
70- } ;
71- }
72-
7347 const batchItems = integrations . map ( ( integration ) => ( {
7448 payload : {
7549 integration : {
@@ -94,21 +68,32 @@ export const runIntegrationTests = task({
9468 } > = [ ] ;
9569
9670 batchHandle . runs . forEach ( ( run , index ) => {
97- if ( run . ok ) {
98- return ;
99- }
100-
10171 const integration = integrations [ index ] ;
102- const errorValue = run . error ;
103- const errorMessage =
104- errorValue instanceof Error ? errorValue . message : String ( errorValue ?? 'Unknown error' ) ;
10572
106- failedIntegrations . push ( {
107- id : integration . id ,
108- integrationId : integration . integrationId ,
109- name : integration . name ,
110- error : errorMessage ,
111- } ) ;
73+ if ( run . ok ) {
74+ // Check if the task completed but returned success: false
75+ const runOutput = run . output as { success ?: boolean ; error ?: string } | undefined ;
76+
77+ if ( runOutput && runOutput . success === false ) {
78+ failedIntegrations . push ( {
79+ id : integration . id ,
80+ integrationId : integration . integrationId ,
81+ name : integration . name ,
82+ error : runOutput . error || 'Integration failed' ,
83+ } ) ;
84+ }
85+ } else {
86+ // Task crashed or threw an error
87+ const errorMessage =
88+ run . error instanceof Error ? run . error . message : String ( run . error ?? 'Unknown error' ) ;
89+
90+ failedIntegrations . push ( {
91+ id : integration . id ,
92+ integrationId : integration . integrationId ,
93+ name : integration . name ,
94+ error : errorMessage ,
95+ } ) ;
96+ }
11297 } ) ;
11398
11499 if ( failedIntegrations . length > 0 ) {
0 commit comments