Skip to content

Commit 6f9ff5d

Browse files
committed
feat: delete testcase all history
1 parent b724184 commit 6f9ff5d

File tree

18 files changed

+1962
-596
lines changed

18 files changed

+1962
-596
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)
@@ -1077,6 +1088,12 @@ Magic.Keys(() => {
10771088
:loading="caseRevertLoading"
10781089
>{{ t('button.goToHistory') }}
10791090
</el-button>
1091+
<el-button
1092+
type="primary"
1093+
@click="deleteAllHistory(viewHistoryRef)"
1094+
:loading="caseRevertLoading"
1095+
>{{ t('button.deleteAllHistory') }}
1096+
</el-button>
10801097
</div>
10811098
</el-col>
10821099
</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: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -564,41 +564,33 @@ const GetTestSuiteYaml = (suite: string, callback: (d: any) => void, errHandle?:
564564
function GetHistoryTestCaseWithResult(req: HistoryTestCase,
565565
callback: (d: any) => void, errHandle?: (e: any) => void | null) {
566566
const requestOptions = {
567-
method: 'POST',
568567
headers: {
569568
'X-Store-Name': Cache.GetCurrentStore().name,
570569
'X-Auth': getToken()
571-
},
572-
body: JSON.stringify({
573-
ID : req.historyCaseID
574-
})
570+
}
575571
}
576-
fetch('/server.Runner/GetHistoryTestCaseWithResult', requestOptions)
572+
fetch(`/api/v1/historyTestCaseWithResult/${req.historyCaseID}`, requestOptions)
577573
.then(DefaultResponseProcess)
578574
.then(callback).catch(errHandle)
579575
}
580576

581577
function GetHistoryTestCase(req: HistoryTestCase,
582578
callback: (d: any) => void, errHandle?: (e: any) => void | null) {
583579
const requestOptions = {
584-
method: 'POST',
585580
headers: {
586581
'X-Store-Name': Cache.GetCurrentStore().name,
587582
'X-Auth': getToken()
588-
},
589-
body: JSON.stringify({
590-
ID : req.historyCaseID
591-
})
583+
}
592584
}
593-
fetch('/server.Runner/GetHistoryTestCase', requestOptions)
585+
fetch(`/api/v1/historyTestCase/${req.historyCaseID}`, requestOptions)
594586
.then(DefaultResponseProcess)
595587
.then(callback).catch(errHandle)
596588
}
597589

598590
function DeleteHistoryTestCase(req: HistoryTestCase,
599591
callback: (d: any) => void, errHandle?: (e: any) => void | null) {
600592
const requestOptions = {
601-
method: 'POST',
593+
method: 'DELETE',
602594
headers: {
603595
'X-Store-Name': Cache.GetCurrentStore().name,
604596
'X-Auth': getToken()
@@ -607,10 +599,27 @@ function DeleteHistoryTestCase(req: HistoryTestCase,
607599
ID : req.historyCaseID
608600
})
609601
}
610-
fetch('/server.Runner/DeleteHistoryTestCase', requestOptions)
602+
fetch(`/api/v1/historyTestCase/${req.historyCaseID}`, requestOptions)
611603
.then(callback).catch(errHandle)
612604
}
613605

606+
function DeleteAllHistoryTestCase(suiteName: string, caseName: string,
607+
callback: (d: any) => void, errHandle?: (e: any) => void | null) {
608+
const requestOptions = {
609+
method: 'DELETE',
610+
headers: {
611+
'X-Store-Name': Cache.GetCurrentStore().name,
612+
'X-Auth': getToken()
613+
},
614+
body: JSON.stringify({
615+
suiteName : suiteName,
616+
caseName: caseName,
617+
})
618+
}
619+
fetch(`/api/v1/suites/${suiteName}/cases/${caseName}`, requestOptions)
620+
.then(callback).catch(errHandle)
621+
}
622+
614623
function RunHistoryTestCase(req: HistoryTestCase,
615624
callback: (d: any) => void, errHandle?: (e: any) => void | null) {
616625
const requestOptions = {
@@ -623,7 +632,7 @@ function RunHistoryTestCase(req: HistoryTestCase,
623632
ID : req.historyCaseID
624633
})
625634
}
626-
fetch('/server.Runner/RunHistoryTestCase', requestOptions)
635+
fetch(`/api/v1/historyTestCase/${req.historyCaseID}/run`, requestOptions)
627636
.then(DefaultResponseProcess)
628637
.then(callback).catch(errHandle)
629638
}
@@ -641,7 +650,7 @@ function GetTestCaseAllHistory(req: TestCase,
641650
name: req.name
642651
})
643652
}
644-
fetch('/server.Runner/GetTestCaseAllHistory', requestOptions)
653+
fetch(`/api/v1/suites/${req.suiteName}/cases/${req.name}`, requestOptions)
645654
.then(DefaultResponseProcess)
646655
.then(callback).catch(errHandle)
647656
}
@@ -652,7 +661,7 @@ export const API = {
652661
GetVersion,
653662
CreateTestSuite, UpdateTestSuite, ImportTestSuite, GetTestSuite, DeleteTestSuite, ConvertTestSuite,GetTestSuiteYaml,
654663
CreateTestCase, UpdateTestCase, GetTestCase, ListTestCase, DeleteTestCase, RunTestCase,
655-
GetHistoryTestCaseWithResult, DeleteHistoryTestCase,GetHistoryTestCase, RunHistoryTestCase, GetTestCaseAllHistory,
664+
GetHistoryTestCaseWithResult, DeleteHistoryTestCase,GetHistoryTestCase, RunHistoryTestCase, GetTestCaseAllHistory, DeleteAllHistoryTestCase,
656665
GenerateCode, ListCodeGenerator,
657666
PopularHeaders,
658667
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)