Skip to content

Commit 5a920a2

Browse files
committed
feat: go relate History panel
1 parent a019f15 commit 5a920a2

File tree

6 files changed

+86
-30
lines changed

6 files changed

+86
-30
lines changed

console/atest-ui/src/App.vue

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,12 @@ const handleChangeLan = (command: string) => {
8383
}
8484
};
8585
86+
const ID = ref(null);
87+
const toHistoryPanel = ({ ID: selectID, panelName: historyPanelName }) => {
88+
ID.value = selectID;
89+
panelName.value = historyPanelName;
90+
}
91+
8692
</script>
8793

8894
<template>
@@ -140,8 +146,8 @@ const handleChangeLan = (command: string) => {
140146
</el-dropdown>
141147
</el-col>
142148
</div>
143-
<TestingPanel v-if="panelName === 'testing'" />
144-
<TestingHistoryPanel v-else-if="panelName === 'history'" />
149+
<TestingPanel v-if="panelName === 'testing'" @toHistoryPanel="toHistoryPanel"/>
150+
<TestingHistoryPanel v-else-if="panelName === 'history'" :ID="ID"/>
145151
<MockManager v-else-if="panelName === 'mock'" />
146152
<StoreManager v-else-if="panelName === 'store'" />
147153
<SecretManager v-else-if="panelName === 'secret'" />

console/atest-ui/src/locales/en.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
"fullScreen": "Full Screen",
2525
"cancelFullScreen": "Cancel Full Screen",
2626
"viewHistory": "View History Test Case Result",
27-
"revert": "Revert"
27+
"revert": "Revert",
28+
"goToHistory": "Go to History"
2829
},
2930
"title": {
3031
"createTestSuite": "Create Test Suite",

console/atest-ui/src/locales/zh.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
"fullScreen": "全屏显示",
2525
"cancelFullScreen": "取消全屏",
2626
"viewHistory": "查看历史记录",
27-
"revert": "回退"
27+
"revert": "回退",
28+
"goToHistory": "跳转历史记录"
2829
},
2930
"title": {
3031
"createTestSuite": "创建测试用例集",

console/atest-ui/src/views/TestCase.vue

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ const props = defineProps({
3737
historySuiteName: String,
3838
historyCaseID: String
3939
})
40-
const emit = defineEmits(['updated'])
40+
const emit = defineEmits(['updated','toHistoryPanel'])
4141
4242
let querySuggestedAPIs = NewSuggestedAPIsQuery(Cache.GetCurrentStore().name!, props.suite!)
4343
const testResultActiveTab = ref(Cache.GetPreference().responseActiveTab)
@@ -534,6 +534,21 @@ const submitForm = async (formEl) => {
534534
})
535535
}
536536
537+
const goToHistory = async (formEl) => {
538+
if (!formEl) return
539+
await formEl.validate((valid: boolean, fields) => {
540+
if (valid) {
541+
caseRevertLoading.value = true
542+
emit('toHistoryPanel', { ID: selectedHistory.value.ID, panelName: 'history' });
543+
caseRevertLoading.value = false
544+
historyDialogOpened.value = false
545+
historyForm.value.selectedID = ''
546+
const target = document.getElementById('compareView');
547+
target.innerHTML = '';
548+
}
549+
})
550+
}
551+
537552
const options = GetHTTPMethods()
538553
const requestActiveTab = ref(Cache.GetPreference().requestActiveTab)
539554
watch(requestActiveTab, Cache.WatchRequestActiveTab)
@@ -744,14 +759,11 @@ Magic.Keys(() => {
744759
<el-container>
745760
<el-header style="padding-left: 5px;">
746761
<div style="margin-bottom: 5px">
747-
<el-button type="primary" @click="saveTestCase" :icon="Edit" :loading="saveLoading"
748-
disabled v-if="Cache.GetCurrentStore().readOnly || isHistoryTestCase"
749-
>{{ t('button.save') }}</el-button>
750762
<el-button type="primary" @click="saveTestCase" :icon="Edit" :loading="saveLoading"
751763
v-if="!Cache.GetCurrentStore().readOnly && !isHistoryTestCase"
752764
>{{ t('button.save') }}</el-button>
753765
<el-button type="danger" @click="deleteCase" :icon="Delete">{{ t('button.delete') }}</el-button>
754-
<el-button type="primary" @click="openDuplicateTestCaseDialog" :icon="CopyDocument">{{ t('button.duplicate') }}</el-button>
766+
<el-button type="primary" @click="openDuplicateTestCaseDialog" :icon="CopyDocument" v-if="!isHistoryTestCase">{{ t('button.duplicate') }}</el-button>
755767
<el-button type="primary" @click="openCodeDialog">{{ t('button.generateCode') }}</el-button>
756768
<el-button type="primary" v-if="!isHistoryTestCase" @click="openHistoryDialog">{{ t('button.viewHistory') }}</el-button>
757769
<span v-if="isHistoryTestCase" style="margin-left: 15px;">{{ t('tip.runningAt') }}{{ HistoryTestCaseCreateTime }}</span>
@@ -1052,12 +1064,20 @@ Magic.Keys(() => {
10521064
</el-select>
10531065
</el-col>
10541066
<el-col :span="4">
1067+
<div style="display: flex">
10551068
<el-button
10561069
type="primary"
10571070
@click="submitForm(viewHistoryRef)"
10581071
:loading="caseRevertLoading"
10591072
>{{ t('button.revert') }}
10601073
</el-button>
1074+
<el-button
1075+
type="primary"
1076+
@click="goToHistory(viewHistoryRef)"
1077+
:loading="caseRevertLoading"
1078+
>{{ t('button.goToHistory') }}
1079+
</el-button>
1080+
</div>
10611081
</el-col>
10621082
</el-row>
10631083
</el-form-item>

console/atest-ui/src/views/TestingHistoryPanel.vue

Lines changed: 43 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ interface Tree {
2424
children?: Tree[]
2525
}
2626
27+
const props = defineProps({
28+
ID: String,
29+
})
2730
const testCaseName = ref('')
2831
const testSuite = ref('')
2932
const testKind = ref('')
@@ -151,19 +154,36 @@ function loadStores(lastSuitName?: string, lastCaseName?: string) {
151154
152155
let targetSuite = {} as Tree
153156
let targetChild = {} as Tree
154-
if (key.suite !== '' && key.testcase !== '') {
155-
for (var i = 0; i < treeData.value.length; i++) {
156-
const item = treeData.value[i]
157-
if (item.id === key.suite && item.children) {
158-
for (var j = 0; j < item.children.length; j++) {
159-
const child = item.children[j]
160-
if (child.id === key.testcase) {
161-
targetSuite = item
162-
targetChild = child
163-
break
157+
158+
const targetID = props.ID
159+
if (targetID && targetID !== '') {
160+
for (const suite of treeData.value) {
161+
if (suite.children) {
162+
const foundChild = suite.children.find(child => child.id === targetID)
163+
if (foundChild) {
164+
targetSuite = suite
165+
targetChild = foundChild
166+
handleNodeClick(targetChild)
167+
updateTreeSelection(targetSuite, targetChild)
168+
return
169+
}
170+
}
171+
}
172+
} else {
173+
if (key.suite !== '' && key.testcase !== '') {
174+
for (var i = 0; i < treeData.value.length; i++) {
175+
const item = treeData.value[i]
176+
if (item.id === key.suite && item.children) {
177+
for (var j = 0; j < item.children.length; j++) {
178+
const child = item.children[j]
179+
if (child.id === key.testcase) {
180+
targetSuite = item
181+
targetChild = child
182+
break
183+
}
164184
}
185+
break
165186
}
166-
break
167187
}
168188
}
169189
}
@@ -175,14 +195,7 @@ function loadStores(lastSuitName?: string, lastCaseName?: string) {
175195
}
176196
177197
viewName.value = 'testsuite'
178-
currentNodekey.value = targetChild.id
179-
180-
treeRef.value!.setCurrentKey(targetChild.id)
181-
treeRef.value!.setCheckedKeys([targetChild.id], false)
182-
183-
testSuite.value = targetSuite.label
184-
Cache.SetCurrentStore(targetSuite.store)
185-
testKind.value = targetChild.kind
198+
updateTreeSelection(targetSuite, targetChild)
186199
} else {
187200
viewName.value = ""
188201
}
@@ -198,6 +211,17 @@ function loadStores(lastSuitName?: string, lastCaseName?: string) {
198211
}
199212
loadStores()
200213
214+
function updateTreeSelection(targetSuite: Tree, targetChild: Tree) {
215+
currentNodekey.value = targetChild.id
216+
217+
treeRef.value!.setCurrentKey(targetChild.id)
218+
treeRef.value!.setCheckedKeys([targetChild.id], false)
219+
220+
testSuite.value = targetSuite.label
221+
Cache.SetCurrentStore(targetSuite.store)
222+
testKind.value = targetChild.kind
223+
}
224+
201225
const filterText = ref('')
202226
watch(filterText, (val) => {
203227
treeRef.value!.filter(val)
@@ -239,10 +263,8 @@ const deviceAuthNext = () => {
239263
<el-main style="padding-top: 5px; padding-bottom: 5px;">
240264
<el-container style="height: 100%">
241265
<el-aside>
242-
<el-button type="primary" @click="Set" data-intro="History Set" test-id="history-set">设置</el-button>
243266
<el-button type="primary" @click="loadStores" :icon="Refresh">{{ t('button.refresh') }}</el-button>
244267
<el-input v-model="filterText" :placeholder="t('tip.filter')" test-id="search" style="padding: 5px;" />
245-
246268
<el-tree
247269
v-loading="storesLoading"
248270
:data=treeData

console/atest-ui/src/views/TestingPanel.vue

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,11 @@ const submitForm = async (formEl: FormInstance | undefined) => {
280280
})
281281
}
282282
283+
const emit = defineEmits(['toHistoryPanel']);
284+
const handleToHistoryPanel = (payload) => {
285+
emit('toHistoryPanel', payload);
286+
};
287+
283288
const importSuiteFormRules = reactive<FormRules<Suite>>({
284289
url: [
285290
{ required: true, message: 'URL is required', trigger: 'blur' },
@@ -391,6 +396,7 @@ const suiteKinds = [{
391396
:suite="testSuite"
392397
:kindName="testSuiteKind"
393398
:name="testCaseName"
399+
@toHistoryPanel="handleToHistoryPanel"
394400
@updated="loadStores"
395401
style="height: 100%;"
396402
data-intro="This is the test case editor. You can edit the test case here."

0 commit comments

Comments
 (0)