@@ -2371,14 +2371,18 @@ describe('hasWorkflowChanged', () => {
23712371 } )
23722372
23732373 it . concurrent (
2374- 'should detect change when triggerConfig differs but runtime metadata also differs' ,
2374+ 'should detect change when actual config differs but runtime metadata also differs' ,
23752375 ( ) => {
2376+ // Test that when a real config field changes along with runtime metadata,
2377+ // the change is still detected. Using 'model' as the config field since
2378+ // triggerConfig is now excluded from comparison (individual trigger fields
2379+ // are compared separately).
23762380 const deployedState = createWorkflowState ( {
23772381 blocks : {
23782382 block1 : createBlock ( 'block1' , {
23792383 type : 'starter' ,
23802384 subBlocks : {
2381- triggerConfig : { value : { event : 'push' } } ,
2385+ model : { value : 'gpt-4' } ,
23822386 webhookId : { value : null } ,
23832387 } ,
23842388 } ) ,
@@ -2390,7 +2394,7 @@ describe('hasWorkflowChanged', () => {
23902394 block1 : createBlock ( 'block1' , {
23912395 type : 'starter' ,
23922396 subBlocks : {
2393- triggerConfig : { value : { event : 'pull_request' } } ,
2397+ model : { value : 'gpt-4o' } ,
23942398 webhookId : { value : 'wh_123456' } ,
23952399 } ,
23962400 } ) ,
@@ -2402,8 +2406,12 @@ describe('hasWorkflowChanged', () => {
24022406 )
24032407
24042408 it . concurrent (
2405- 'should not detect change when runtime metadata is added to current state ' ,
2409+ 'should not detect change when triggerConfig differs (individual fields compared separately) ' ,
24062410 ( ) => {
2411+ // triggerConfig is excluded from comparison because:
2412+ // 1. Individual trigger fields are stored as separate subblocks and compared individually
2413+ // 2. The client populates triggerConfig with default values from trigger definitions,
2414+ // which aren't present in the deployed state, causing false positive change detection
24072415 const deployedState = createWorkflowState ( {
24082416 blocks : {
24092417 block1 : createBlock ( 'block1' , {
@@ -2420,7 +2428,36 @@ describe('hasWorkflowChanged', () => {
24202428 block1 : createBlock ( 'block1' , {
24212429 type : 'starter' ,
24222430 subBlocks : {
2423- triggerConfig : { value : { event : 'push' } } ,
2431+ triggerConfig : { value : { event : 'pull_request' , extraField : true } } ,
2432+ } ,
2433+ } ) ,
2434+ } ,
2435+ } )
2436+
2437+ expect ( hasWorkflowChanged ( currentState , deployedState ) ) . toBe ( false )
2438+ }
2439+ )
2440+
2441+ it . concurrent (
2442+ 'should not detect change when runtime metadata is added to current state' ,
2443+ ( ) => {
2444+ const deployedState = createWorkflowState ( {
2445+ blocks : {
2446+ block1 : createBlock ( 'block1' , {
2447+ type : 'starter' ,
2448+ subBlocks : {
2449+ model : { value : 'gpt-4' } ,
2450+ } ,
2451+ } ) ,
2452+ } ,
2453+ } )
2454+
2455+ const currentState = createWorkflowState ( {
2456+ blocks : {
2457+ block1 : createBlock ( 'block1' , {
2458+ type : 'starter' ,
2459+ subBlocks : {
2460+ model : { value : 'gpt-4' } ,
24242461 webhookId : { value : 'wh_123456' } ,
24252462 triggerPath : { value : '/api/webhooks/abc123' } ,
24262463 } ,
0 commit comments