@@ -7,6 +7,8 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
77
88const mockState = vi . hoisted ( ( ) => ( {
99 hydrationPhase : 'ready' as 'idle' | 'state-loading' | 'ready' ,
10+ hydrationWorkflowId : 'workflow-1' as string | null ,
11+ registryActiveWorkflowId : 'workflow-1' as string | null ,
1012 hasBlocks : true ,
1113 isDeployed : false ,
1214 changeDetected : false ,
@@ -80,7 +82,13 @@ vi.mock('@/hooks/queries/deployments', () => ({
8082
8183vi . mock ( '@/stores/workflows/registry/store' , ( ) => ( {
8284 useWorkflowRegistry : ( selector : ( state : unknown ) => unknown ) =>
83- selector ( { hydration : { phase : mockState . hydrationPhase } } ) ,
85+ selector ( {
86+ activeWorkflowId : mockState . registryActiveWorkflowId ,
87+ hydration : {
88+ phase : mockState . hydrationPhase ,
89+ workflowId : mockState . hydrationWorkflowId ,
90+ } ,
91+ } ) ,
8492} ) )
8593
8694import { Deploy } from '@/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/deploy/deploy'
@@ -114,6 +122,8 @@ beforeEach(() => {
114122 document . body . appendChild ( container )
115123 root = createRoot ( container )
116124 mockState . hydrationPhase = 'ready'
125+ mockState . hydrationWorkflowId = 'workflow-1'
126+ mockState . registryActiveWorkflowId = 'workflow-1'
117127 mockState . hasBlocks = true
118128 mockState . isDeployed = false
119129 mockState . changeDetected = false
@@ -154,6 +164,12 @@ describe('Deploy compact mode', () => {
154164 expect ( container . querySelector ( 'button' ) ?. getAttribute ( 'aria-label' ) ) . toBe ( 'Update' )
155165 } )
156166
167+ it ( 'disables deployment while the active tab is still hydrating another workflow' , ( ) => {
168+ renderDeploy ( { hydrationWorkflowId : 'workflow-2' , registryActiveWorkflowId : 'workflow-2' } )
169+
170+ expect ( container . querySelector ( 'button' ) ?. disabled ) . toBe ( true )
171+ } )
172+
157173 it . each ( [
158174 [ 'non-admin users' , { canAdmin : false } ] ,
159175 [ 'empty workflows' , { hasBlocks : false } ] ,
0 commit comments