1+ /*
2+ Copyright 2023-2025 API Testing Authors.
3+
4+ Licensed under the Apache License, Version 2.0 (the "License");
5+ you may not use this file except in compliance with the License.
6+ You may obtain a copy of the License at
7+
8+ http://www.apache.org/licenses/LICENSE-2.0
9+
10+ Unless required by applicable law or agreed to in writing, software
11+ distributed under the License is distributed on an "AS IS" BASIS,
12+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+ See the License for the specific language governing permissions and
14+ limitations under the License.
15+ */
16+
17+ import { config } from '@vue/test-utils'
18+ import ElementPlus from 'element-plus'
19+ import { createI18n } from 'vue-i18n'
20+
21+ // Create a mock i18n instance for testing
22+ const i18n = createI18n ( {
23+ legacy : false ,
24+ locale : 'en' ,
25+ fallbackLocale : 'en' ,
26+ messages : {
27+ en : {
28+ ai : {
29+ status : {
30+ healthy : 'Healthy' ,
31+ unhealthy : 'Unhealthy' ,
32+ unknown : 'Unknown'
33+ } ,
34+ trigger : {
35+ button : 'AI Assistant' ,
36+ dialog : {
37+ title : 'AI Assistant' ,
38+ placeholder : 'Ask me anything about your API tests...' ,
39+ send : 'Send' ,
40+ cancel : 'Cancel'
41+ }
42+ } ,
43+ triggerButton : 'AI Assistant'
44+ } ,
45+ 'AI Assistant' : 'AI Assistant' ,
46+ 'AI Plugin Status' : 'AI Plugin Status'
47+ } ,
48+ zh : {
49+ ai : {
50+ status : {
51+ healthy : '健康' ,
52+ unhealthy : '不健康' ,
53+ unknown : '未知'
54+ } ,
55+ trigger : {
56+ button : 'AI助手' ,
57+ dialog : {
58+ title : 'AI助手' ,
59+ placeholder : '询问关于API测试的任何问题...' ,
60+ send : '发送' ,
61+ cancel : '取消'
62+ }
63+ } ,
64+ triggerButton : 'AI助手'
65+ } ,
66+ 'AI Assistant' : 'AI助手' ,
67+ 'AI Plugin Status' : 'AI插件状态'
68+ }
69+ }
70+ } )
71+
72+ // Global plugins configuration for tests
73+ config . global . plugins = [ ElementPlus , i18n ]
74+
75+ // Global stubs for Element Plus components
76+ config . global . stubs = {
77+ 'el-icon' : {
78+ template : '<div class="el-icon"><slot /></div>'
79+ } ,
80+ 'el-tooltip' : {
81+ template : '<div class="el-tooltip"><slot /></div>'
82+ } ,
83+ 'el-badge' : {
84+ template : '<div class="el-badge"><slot /></div>'
85+ } ,
86+ 'el-button' : {
87+ template : '<button class="el-button" @click="$emit(\'click\')"><slot /></button>' ,
88+ emits : [ 'click' ]
89+ } ,
90+ 'el-dialog' : {
91+ template : '<div class="el-dialog" v-if="modelValue"><slot /></div>' ,
92+ props : [ 'modelValue' ] ,
93+ emits : [ 'update:modelValue' ]
94+ } ,
95+ 'el-input' : {
96+ template : '<input class="el-input" :value="modelValue" @input="$emit(\'update:modelValue\', $event.target.value)" />' ,
97+ props : [ 'modelValue' ] ,
98+ emits : [ 'update:modelValue' ]
99+ } ,
100+ 'el-alert' : {
101+ template : '<div class="el-alert"><slot /></div>'
102+ } ,
103+ 'Loading' : {
104+ template : '<div class="loading">Loading...</div>'
105+ } ,
106+ 'ChatLineSquare' : {
107+ template : '<div class="chat-line-square-icon"></div>'
108+ }
109+ }
110+
111+ // Mock global properties that might be used in components
112+ config . global . mocks = {
113+ $t : ( key : string ) => key
114+ }
0 commit comments