Skip to content

Commit

Permalink
feat: add back to origin test case
Browse files Browse the repository at this point in the history
  • Loading branch information
SamYSF committed Sep 24, 2024
1 parent 71e1aaf commit 52d93e6
Show file tree
Hide file tree
Showing 6 changed files with 80 additions and 32 deletions.
20 changes: 16 additions & 4 deletions console/atest-ui/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,24 @@ const handleChangeLan = (command: string) => {
}
};
const ID = ref(null);
const ID = ref(null)
const toHistoryPanel = ({ ID: selectID, panelName: historyPanelName }) => {
ID.value = selectID;
panelName.value = historyPanelName;
panelName.value = historyPanelName
}
const suiteName = ref(null)
const caseName = ref(null)
const toTargetTestcase = ({ targetSuite, targetCase , panelName: testingPanelName }) => {
suiteName.value = targetSuite
caseName.value = targetCase
panelName.value = testingPanelName
}
const clearTargetTestcase = () =>{
suiteName.value = null
caseName.value = null
}
</script>

<template>
Expand Down Expand Up @@ -146,8 +158,8 @@ const toHistoryPanel = ({ ID: selectID, panelName: historyPanelName }) => {
</el-dropdown>
</el-col>
</div>
<TestingPanel v-if="panelName === 'testing'" @toHistoryPanel="toHistoryPanel"/>
<TestingHistoryPanel v-else-if="panelName === 'history'" :ID="ID"/>
<TestingPanel v-if="panelName === 'testing'" @toHistoryPanel="toHistoryPanel" @clearTargetTestcase="clearTargetTestcase" :targetSuite="suiteName" :targetCase="caseName"/>
<TestingHistoryPanel v-else-if="panelName === 'history'" @toTargetTestcase="toTargetTestcase" :ID="ID"/>
<MockManager v-else-if="panelName === 'mock'" />
<StoreManager v-else-if="panelName === 'store'" />
<SecretManager v-else-if="panelName === 'secret'" />
Expand Down
1 change: 1 addition & 0 deletions console/atest-ui/src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"viewHistory": "View History Test Case Result",
"revert": "Revert",
"goToHistory": "Go to History",
"goToTargetTestcase": "Go to Target TestCase",
"deleteAllHistory": "Delete All History"
},
"title": {
Expand Down
1 change: 1 addition & 0 deletions console/atest-ui/src/locales/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"viewHistory": "查看历史记录",
"revert": "回退",
"goToHistory": "跳转历史记录",
"goToTargetTestcase": "跳转目标测试用例",
"deleteAllHistory": "删除所有历史记录"
},
"title": {
Expand Down
5 changes: 4 additions & 1 deletion console/atest-ui/src/views/TestCase.vue
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const props = defineProps({
historySuiteName: String,
historyCaseID: String
})
const emit = defineEmits(['updated','toHistoryPanel'])
const emit = defineEmits(['updated','toHistoryPanel', 'toTargetTestcase'])
let querySuggestedAPIs = NewSuggestedAPIsQuery(Cache.GetCurrentStore().name!, props.suite!)
const testResultActiveTab = ref(Cache.GetPreference().responseActiveTab)
Expand Down Expand Up @@ -606,6 +606,8 @@ const goToHistory = async (formEl) => {
})
}
function goToTargetTestcase(){ emit('toTargetTestcase', { targetSuite: props.suite, targetCase: props.name, panelName: 'testing' })}
const deleteAllHistory = async (formEl) => {
if (!formEl) return
caseRevertLoading.value = true
Expand Down Expand Up @@ -830,6 +832,7 @@ Magic.Keys(() => {
v-if="!Cache.GetCurrentStore().readOnly && !isHistoryTestCase"
>{{ t('button.save') }}</el-button>
<el-button type="danger" @click="deleteCase" :icon="Delete">{{ t('button.delete') }}</el-button>
<el-button type="primary" @click="goToTargetTestcase" v-if="isHistoryTestCase">{{ t('button.goToTargetTestcase') }}</el-button>
<el-button type="primary" @click="openDuplicateTestCaseDialog" :icon="CopyDocument" v-if="!isHistoryTestCase">{{ t('button.duplicate') }}</el-button>
<el-button type="primary" @click="openCodeDialog">{{ t('button.generateCode') }}</el-button>
<el-button type="primary" v-if="!isHistoryTestCase && Cache.GetCurrentStore().kind.name == 'atest-store-orm'" @click="openHistoryDialog">{{ t('button.viewHistory') }}</el-button>
Expand Down
7 changes: 6 additions & 1 deletion console/atest-ui/src/views/TestingHistoryPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,11 @@ const deviceAuthNext = () => {
}
}
const emit = defineEmits(['toTargetTestcase']);
const handleToTargetTestcase = (payload) => {
emit('toTargetTestcase', payload);
};
</script>

<template>
Expand Down Expand Up @@ -282,7 +287,7 @@ const deviceAuthNext = () => {
</el-aside>

<el-main style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px;">
<TestCase v-if="viewName === 'testcase'" :suite="testSuite" :kindName="testKind" :name="testCaseName"
<TestCase v-if="viewName === 'testcase'" @toTargetTestcase="handleToTargetTestcase" :suite="testSuite" :kindName="testKind" :name="testCaseName"
:historySuiteName="historySuiteName" :historyCaseID="historyCaseID" @updated="loadStores" style="height: 100%;"
data-intro="This is the test case editor. You can edit the test case here." />
</el-main>
Expand Down
78 changes: 52 additions & 26 deletions console/atest-ui/src/views/TestingPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ interface Tree {
children?: Tree[]
}
const props = defineProps({
targetSuite: String,
targetCase: String,
})
const testCaseName = ref('')
const testSuite = ref('')
const testSuiteKind = ref('')
Expand Down Expand Up @@ -181,23 +185,41 @@ function loadStores(lastSuitName?: string, lastCaseName?: string) {
let targetSuite = {} as Tree
let targetChild = {} as Tree
if (key.suite !== '' && key.testcase !== '') {
for (var i = 0; i < treeData.value.length; i++) {
const item = treeData.value[i]
if (item.id === key.suite && item.children) {
for (var j = 0; j < item.children.length; j++) {
const child = item.children[j]
if (child.id === key.testcase) {
targetSuite = item
targetChild = child
break
}
const suite = props.targetSuite
const testCase = props.targetCase
if (suite && testCase && testCase !== '' && suite !== '') {
for (const data of treeData.value) {
if (data.label == suite) {
const foundChild = data.children?.find(child => child.label === testCase)
if (foundChild) {
targetSuite = data
targetChild = foundChild
handleTreeClick(targetChild)
updateTreeSelection(targetSuite, targetChild)
return
}
}
}
break
}
}
}
emit('clearTargetTestcase')
ElMessage.error(`Oops, not found for suite:${suite} with testcase:${testCase}`)
} else {if (key.suite !== '' && key.testcase !== '') {
for (var i = 0; i < treeData.value.length; i++) {
const item = treeData.value[i]
if (item.id === key.suite && item.children) {
for (var j = 0; j < item.children.length; j++) {
const child = item.children[j]
if (child.id === key.testcase) {
targetSuite = item
targetChild = child
break
}
}
break
}
}
}}
if (!targetChild.id || targetChild.id === '') {
targetSuite = treeData.value[0]
if (targetSuite.children && targetSuite.children.length > 0) {
Expand All @@ -206,14 +228,7 @@ function loadStores(lastSuitName?: string, lastCaseName?: string) {
}
viewName.value = 'testsuite'
currentNodekey.value = targetChild.id
treeRef.value!.setCurrentKey(targetChild.id)
treeRef.value!.setCheckedKeys([targetChild.id], false)
testSuite.value = targetSuite.label
Cache.SetCurrentStore(targetSuite.store)
testSuiteKind.value = targetChild.kind
updateTreeSelection(targetSuite, targetChild)
} else {
viewName.value = ""
}
Expand All @@ -229,6 +244,17 @@ function loadStores(lastSuitName?: string, lastCaseName?: string) {
}
loadStores()
function updateTreeSelection(targetSuite: Tree, targetChild: Tree) {
currentNodekey.value = targetChild.id
treeRef.value!.setCurrentKey(targetChild.id)
treeRef.value!.setCheckedKeys([targetChild.id], false)
testSuite.value = targetSuite.label
Cache.SetCurrentStore(targetSuite.store)
testSuiteKind.value = targetChild.kind
}
const dialogVisible = ref(false)
const importDialogVisible = ref(false)
const suiteCreatingLoading = ref(false)
Expand Down Expand Up @@ -280,9 +306,9 @@ const submitForm = async (formEl: FormInstance | undefined) => {
})
}
const emit = defineEmits(['toHistoryPanel']);
const emit = defineEmits(['toHistoryPanel', 'clearTargetTestcase'])
const handleToHistoryPanel = (payload) => {
emit('toHistoryPanel', payload);
emit('toHistoryPanel', payload)
};
const importSuiteFormRules = reactive<FormRules<Suite>>({
Expand Down

0 comments on commit 52d93e6

Please sign in to comment.