@@ -628,7 +628,7 @@ describe('完整用户流程E2E测试', () => {
628628 } )
629629
630630 describe ( '4. 变量管理的跨组件协作' , ( ) => {
631- it ( '应该支持ConversationManager到VariableManager的变量创建流程 ' , async ( ) => {
631+ it ( '应该为变量管理器提供缺失变量信息以便触发创建流程 ' , async ( ) => {
632632 // 步骤1:初始化ConversationManager,包含缺失变量
633633 conversationWrapper = mount ( ConversationManager , {
634634 props : {
@@ -659,12 +659,11 @@ describe('完整用户流程E2E测试', () => {
659659 expect ( detectedVars ) . toEqual ( [ 'existingVar' , 'missingVar' ] )
660660 expect ( missingVars ) . toEqual ( [ 'missingVar' ] )
661661
662- // 步骤2:点击快速创建变量按钮
663- await conversationWrapper . vm . handleCreateVariable ( 'missingVar' )
664-
665- // 验证变量管理器打开事件
666- expect ( conversationWrapper . emitted ( 'openVariableManager' ) ) . toBeTruthy ( )
667- expect ( conversationWrapper . emitted ( 'openVariableManager' ) [ 0 ] ) . toEqual ( [ 'missingVar' ] )
662+ // 步骤2:获取缺失变量并模拟父层触发变量管理器
663+ const missingVariablesFromComponent = conversationWrapper . vm . allMissingVariables
664+ expect ( missingVariablesFromComponent ) . toEqual ( [ 'missingVar' ] )
665+ const variableToCreate = missingVariablesFromComponent [ 0 ]
666+ expect ( variableToCreate ) . toBe ( 'missingVar' )
668667
669668 // 步骤3:初始化VariableManagerModal
670669 variableManagerWrapper = mount ( VariableManagerModal , {
@@ -875,7 +874,17 @@ describe('完整用户流程E2E测试', () => {
875874
876875 // 步骤3:编辑消息内容
877876 const messageWithVariables = '用户请求 {{userInput}} 处理 {{actionType}}'
877+ vi . useFakeTimers ( )
878878 await conversationWrapper . vm . handleMessageUpdate ( 0 , { role : 'user' , content : messageWithVariables } )
879+ vi . runAllTimers ( )
880+ await nextTick ( )
881+ vi . useRealTimers ( )
882+ const updateEvents = conversationWrapper . emitted ( 'update:messages' ) || [ ]
883+ const latestPayload = updateEvents [ updateEvents . length - 1 ] ?. [ 0 ]
884+ if ( latestPayload ) {
885+ await conversationWrapper . setProps ( { messages : latestPayload } )
886+ await nextTick ( )
887+ }
879888
880889 // 验证变量检测
881890 const detectedVars = scanVariables ( messageWithVariables )
@@ -884,9 +893,11 @@ describe('完整用户流程E2E测试', () => {
884893 expect ( detectedVars ) . toEqual ( [ 'userInput' , 'actionType' ] )
885894 expect ( missingVars ) . toEqual ( [ 'userInput' , 'actionType' ] )
886895
887- // 步骤4:创建变量
888- await conversationWrapper . vm . handleCreateVariable ( 'userInput' )
889- expect ( conversationWrapper . emitted ( 'openVariableManager' ) ) . toBeTruthy ( )
896+ // 步骤4:识别缺失变量并模拟父层响应
897+ const missingVariables = conversationWrapper . vm . allMissingVariables
898+ expect ( missingVariables ) . toEqual ( [ 'userInput' , 'actionType' ] )
899+ const targetVariable = missingVariables [ 0 ]
900+ expect ( targetVariable ) . toBe ( 'userInput' )
890901
891902 // 步骤5:进入深度编辑模式 - 简化验证
892903 const handleOpenContextEditor = conversationWrapper . vm . handleOpenContextEditor
@@ -987,4 +998,4 @@ describe('完整用户流程E2E测试', () => {
987998 expect ( conversationWrapper . exists ( ) ) . toBe ( true )
988999 } )
9891000 } )
990- } )
1001+ } )
0 commit comments