Skip to content

Commit c46490b

Browse files
committed
feat: delete testcase all history
1 parent 2a7bd37 commit c46490b

File tree

18 files changed

+1960
-594
lines changed

18 files changed

+1960
-594
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@
2525
"cancelFullScreen": "Cancel Full Screen",
2626
"viewHistory": "View History Test Case Result",
2727
"revert": "Revert",
28-
"goToHistory": "Go to History"
28+
"goToHistory": "Go to History",
29+
"deleteAllHistory": "Delete All History"
2930
},
3031
"title": {
3132
"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
@@ -25,7 +25,8 @@
2525
"cancelFullScreen": "取消全屏",
2626
"viewHistory": "查看历史记录",
2727
"revert": "回退",
28-
"goToHistory": "跳转历史记录"
28+
"goToHistory": "跳转历史记录",
29+
"deleteAllHistory": "删除所有历史记录"
2930
},
3031
"title": {
3132
"createTestSuite": "创建测试用例集",

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -549,6 +549,17 @@ const goToHistory = async (formEl) => {
549549
})
550550
}
551551
552+
const deleteAllHistory = async (formEl) => {
553+
if (!formEl) return
554+
caseRevertLoading.value = true
555+
API.DeleteAllHistoryTestCase(props.suite, props.name, handleDeleteResponse);
556+
caseRevertLoading.value = false
557+
historyDialogOpened.value = false
558+
historyForm.value.selectedID = ''
559+
const target = document.getElementById('compareView');
560+
target.innerHTML = '';
561+
}
562+
552563
const options = GetHTTPMethods()
553564
const requestActiveTab = ref(Cache.GetPreference().requestActiveTab)
554565
watch(requestActiveTab, Cache.WatchRequestActiveTab)
@@ -1080,6 +1091,12 @@ Magic.Keys(() => {
10801091
:loading="caseRevertLoading"
10811092
>{{ t('button.goToHistory') }}
10821093
</el-button>
1094+
<el-button
1095+
type="primary"
1096+
@click="deleteAllHistory(viewHistoryRef)"
1097+
:loading="caseRevertLoading"
1098+
>{{ t('button.deleteAllHistory') }}
1099+
</el-button>
10831100
</div>
10841101
</el-col>
10851102
</el-row>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ function loadHistoryTestSuites(storeName: string) {
8080
},
8181
}
8282
return async () => {
83-
await fetch('/server.Runner/GetHistorySuites', requestOptions)
83+
await fetch('/api/v1/historySuites', requestOptions)
8484
.then((response) => response.json())
8585
.then((d) => {
8686
if (!d.data) {

console/atest-ui/src/views/net.ts

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -566,41 +566,33 @@ const GetTestSuiteYaml = (suite: string, callback: (d: any) => void, errHandle?:
566566
function GetHistoryTestCaseWithResult(req: HistoryTestCase,
567567
callback: (d: any) => void, errHandle?: (e: any) => void | null) {
568568
const requestOptions = {
569-
method: 'POST',
570569
headers: {
571570
'X-Store-Name': Cache.GetCurrentStore().name,
572571
'X-Auth': getToken()
573-
},
574-
body: JSON.stringify({
575-
ID : req.historyCaseID
576-
})
572+
}
577573
}
578-
fetch('/server.Runner/GetHistoryTestCaseWithResult', requestOptions)
574+
fetch(`/api/v1/historyTestCaseWithResult/${req.historyCaseID}`, requestOptions)
579575
.then(DefaultResponseProcess)
580576
.then(callback).catch(errHandle)
581577
}
582578

583579
function GetHistoryTestCase(req: HistoryTestCase,
584580
callback: (d: any) => void, errHandle?: (e: any) => void | null) {
585581
const requestOptions = {
586-
method: 'POST',
587582
headers: {
588583
'X-Store-Name': Cache.GetCurrentStore().name,
589584
'X-Auth': getToken()
590-
},
591-
body: JSON.stringify({
592-
ID : req.historyCaseID
593-
})
585+
}
594586
}
595-
fetch('/server.Runner/GetHistoryTestCase', requestOptions)
587+
fetch(`/api/v1/historyTestCase/${req.historyCaseID}`, requestOptions)
596588
.then(DefaultResponseProcess)
597589
.then(callback).catch(errHandle)
598590
}
599591

600592
function DeleteHistoryTestCase(req: HistoryTestCase,
601593
callback: (d: any) => void, errHandle?: (e: any) => void | null) {
602594
const requestOptions = {
603-
method: 'POST',
595+
method: 'DELETE',
604596
headers: {
605597
'X-Store-Name': Cache.GetCurrentStore().name,
606598
'X-Auth': getToken()
@@ -609,16 +601,33 @@ function DeleteHistoryTestCase(req: HistoryTestCase,
609601
ID : req.historyCaseID
610602
})
611603
}
612-
fetch('/server.Runner/DeleteHistoryTestCase', requestOptions)
604+
fetch(`/api/v1/historyTestCase/${req.historyCaseID}`, requestOptions)
613605
.then(callback).catch(errHandle)
614606
}
615607

608+
function DeleteAllHistoryTestCase(suiteName: string, caseName: string,
609+
callback: (d: any) => void, errHandle?: (e: any) => void | null) {
610+
const requestOptions = {
611+
method: 'DELETE',
612+
headers: {
613+
'X-Store-Name': Cache.GetCurrentStore().name,
614+
'X-Auth': getToken()
615+
},
616+
body: JSON.stringify({
617+
suiteName : suiteName,
618+
caseName: caseName,
619+
})
620+
}
621+
fetch(`/api/v1/suites/${suiteName}/cases/${caseName}`, requestOptions)
622+
.then(callback).catch(errHandle)
623+
}
624+
616625
export const API = {
617626
DefaultResponseProcess,
618627
GetVersion,
619628
CreateTestSuite, UpdateTestSuite, ImportTestSuite, GetTestSuite, DeleteTestSuite, ConvertTestSuite,GetTestSuiteYaml,
620629
CreateTestCase, UpdateTestCase, GetTestCase, ListTestCase, DeleteTestCase, RunTestCase,
621-
GetHistoryTestCaseWithResult, DeleteHistoryTestCase, GetHistoryTestCase, GetTestCaseAllHistory,
630+
GetHistoryTestCaseWithResult, DeleteHistoryTestCase, GetHistoryTestCase, GetTestCaseAllHistory, DeleteAllHistoryTestCase,
622631
GenerateCode, ListCodeGenerator,
623632
PopularHeaders,
624633
CreateOrUpdateStore, GetStores, DeleteStore, VerifyStore,

pkg/server/remote_server.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -765,6 +765,14 @@ func (s *server) DeleteHistoryTestCase(ctx context.Context, in *HistoryTestCase)
765765
return
766766
}
767767

768+
func (s *server) DeleteAllHistoryTestCase(ctx context.Context, in *HistoryTestCase) (reply *HelloReply, err error) {
769+
loader := s.getLoader(ctx)
770+
defer loader.Close()
771+
reply = &HelloReply{}
772+
err = loader.DeleteAllHistoryTestCase(in.SuiteName, in.CaseName)
773+
return
774+
}
775+
768776
func (s *server) DuplicateTestCase(ctx context.Context, in *TestCaseDuplicate) (reply *HelloReply, err error) {
769777
loader := s.getLoader(ctx)
770778
defer loader.Close()

0 commit comments

Comments
 (0)