Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add back to origin test case #535

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 toOriginTestcase = ({ originSuite, originCase, panelName: testingPanelName }) => {
suiteName.value = originSuite
caseName.value = originCase
panelName.value = testingPanelName
}

const clearOriginTestcase = () =>{
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" @clearOriginTestcase="clearOriginTestcase" :originSuite="suiteName" :originCase="caseName"/>
<TestingHistoryPanel v-else-if="panelName === 'history'" @toOriginTestcase="toOriginTestcase" :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",
"goToOriginTestcase": "Go to Origin 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": "跳转历史记录",
"goToOriginTestcase": "跳转原始测试用例",
"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', 'toOriginTestcase'])

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 goToOriginTestcase(){ emit('toOriginTestcase', { originSuite: props.suite, originCase: props.name, panelName: 'testing' })}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO, props.suite is the history test suite name instead of the original one


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="goToOriginTestcase" v-if="isHistoryTestCase">{{ t('button.goToOriginTestcase') }}</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
9 changes: 6 additions & 3 deletions console/atest-ui/src/views/TestingHistoryPanel.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<script setup lang="ts">
import TestCase from './TestCase.vue'
import TestSuite from './TestSuite.vue'
import TemplateFunctions from './TemplateFunctions.vue'
import { reactive, ref, watch } from 'vue'
import { ElTree, ElMessage } from 'element-plus'
import type { FormInstance, FormRules } from 'element-plus'
Expand Down Expand Up @@ -255,6 +254,11 @@ const deviceAuthNext = () => {
}
}

const emit = defineEmits(['toOriginTestcase']);
const handleToOriginTestcase = (payload) => {
emit('toOriginTestcase', payload);
};

</script>

<template>
Expand All @@ -278,11 +282,10 @@ const deviceAuthNext = () => {
@node-click="handleNodeClick"
data-intro="This is the test history tree. You can click the history test to browse it."
/>
<TemplateFunctions />
</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'" @toOriginTestcase="handleToOriginTestcase" :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
77 changes: 52 additions & 25 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({
originSuite: String,
originCase: String,
})
const testCaseName = ref('')
const testSuite = ref('')
const testSuiteKind = ref('')
Expand Down Expand Up @@ -181,23 +185,42 @@ 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 originSuite = props.originSuite
const originCase = props.originCase
if (originSuite && originCase && originCase !== '' && originSuite !== '') {
for (const data of treeData.value) {
if (data.label == originSuite) {
const foundChild = data.children?.find(child => child.label === originCase)
if (foundChild) {
targetSuite = data
targetChild = foundChild
handleTreeClick(targetChild)
updateTreeSelection(targetSuite, targetChild)
return
}
}
break
}
}
}

emit('clearOriginTestcase')
ElMessage.error(`Oops, not found for suite:${originSuite} with testcase:${originCase}`)
} 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 +229,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 +245,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 +307,9 @@ const submitForm = async (formEl: FormInstance | undefined) => {
})
}

const emit = defineEmits(['toHistoryPanel']);
const emit = defineEmits(['toHistoryPanel', 'clearOriginTestcase'])
const handleToHistoryPanel = (payload) => {
emit('toHistoryPanel', payload);
emit('toHistoryPanel', payload)
};

const importSuiteFormRules = reactive<FormRules<Suite>>({
Expand Down
Loading