Skip to content

Commit

Permalink
fix: fix history page display
Browse files Browse the repository at this point in the history
  • Loading branch information
SamYSF committed Sep 13, 2024
1 parent 7802f5a commit 717beff
Show file tree
Hide file tree
Showing 16 changed files with 660 additions and 623 deletions.
45 changes: 25 additions & 20 deletions console/atest-ui/src/views/TestCase.vue
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ function generateCode() {
const ID = props.historyCaseID
if (isHistoryTestCase.value == true){
API.HistoryGenerateCode({
ID: ID,
id: ID,
generator: currentCodeGenerator.value
}, (e) => {
ElMessage({
Expand Down Expand Up @@ -401,6 +401,9 @@ function setTestCaseWithSuite(e, suite) {
suiteName: suite,
data: e
} as TestCaseWithSuite;
if (isHistoryTestCase.value == true){
testCaseWithSuite.value.data.request.api = `${testCaseWithSuite.value.data.suiteApi}${testCaseWithSuite.value.data.request.api}`
}
}
load()
Expand Down Expand Up @@ -515,14 +518,28 @@ function openHistoryDialog(){
})
}
function handleDialogClose(){
caseRevertLoading.value = false
historyDialogOpened.value = false
historyForm.value.selectedID = ''
const target = document.getElementById('compareView');
target.innerHTML = ''
}
function handleHistoryChange(value) {
selectedHistory.value = historyRecords.value.find(record => record.ID === value);
const {
caseName: name,
suiteName,
request,
response
response,
historyHeader,
} = selectedHistory.value;
request.header = historyHeader
request.header.push({
key: '',
value: ''
})
formatHistoryCase.value = {
name,
suiteName,
Expand Down Expand Up @@ -573,11 +590,7 @@ const submitForm = async (formEl) => {
load()
}
}, UIAPI.ErrorTip, saveLoading)
caseRevertLoading.value = false
historyDialogOpened.value = false
historyForm.value.selectedID = ''
const target = document.getElementById('compareView');
target.innerHTML = '';
handleDialogClose()
}
})
}
Expand All @@ -587,25 +600,17 @@ const goToHistory = async (formEl) => {
await formEl.validate((valid: boolean, fields) => {
if (valid) {
caseRevertLoading.value = true
emit('toHistoryPanel', { ID: selectedHistory.value.ID, panelName: 'history' });
caseRevertLoading.value = false
historyDialogOpened.value = false
historyForm.value.selectedID = ''
const target = document.getElementById('compareView');
target.innerHTML = '';
emit('toHistoryPanel', { ID: selectedHistory.value.ID, panelName: 'history' })
handleDialogClose()
}
})
}
const deleteAllHistory = async (formEl) => {
if (!formEl) return
caseRevertLoading.value = true
API.DeleteAllHistoryTestCase(props.suite, props.name, handleDeleteResponse);
caseRevertLoading.value = false
historyDialogOpened.value = false
historyForm.value.selectedID = ''
const target = document.getElementById('compareView');
target.innerHTML = '';
API.DeleteAllHistoryTestCase(props.suite, props.name, handleDeleteResponse)
handleDialogClose()
}
const options = GetHTTPMethods()
Expand Down Expand Up @@ -1107,7 +1112,7 @@ Magic.Keys(() => {
</template>
</el-drawer>

<el-dialog v-model="historyDialogOpened" :title="t('button.viewHistory')" width="60%" draggable>
<el-dialog @close="handleDialogClose" v-model="historyDialogOpened" :title="t('button.viewHistory')" width="60%" draggable>
<el-form
ref="viewHistoryRef"
:model="historyForm"
Expand Down
2 changes: 1 addition & 1 deletion console/atest-ui/src/views/net.ts
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ function HistoryGenerateCode(request: GenerateRequest,
'X-Auth': getToken()
},
body: JSON.stringify({
ID: request.ID,
ID: request.id,
Generator: request.generator
})
}
Expand Down
4 changes: 4 additions & 0 deletions go.work.sum
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ cloud.google.com/go/compute v1.23.3/go.mod h1:VCgBUoMnIVIR0CscqQiPJLAG25E3ZRZMzc
cloud.google.com/go/compute v1.24.0/go.mod h1:kw1/T+h/+tK2LJK0wiPPx1intgdAM3j/g3hFDlscY40=
cloud.google.com/go/compute/metadata v0.2.3 h1:mg4jlk7mCAj6xXp9UJ4fjI9VUI5rubuGBW5aJ7UnBMY=
cloud.google.com/go/compute/metadata v0.2.3/go.mod h1:VAV5nSsACxMJvgaAuX6Pk2AawlZn8kiOGuCv6gTkwuA=
cloud.google.com/go/compute/metadata v0.3.0 h1:Tz+eQXMEqDIKRsmY3cHTL6FVaynIjX2QxYC4trgAKZc=
cloud.google.com/go/compute/metadata v0.3.0/go.mod h1:zFmK7XCadkQkj6TtorcaGlCW1hT1fIilQDwofLpJ20k=
cloud.google.com/go/contactcenterinsights v1.10.0 h1:YR2aPedGVQPpFBZXJnPkqRj8M//8veIZZH5ZvICoXnI=
cloud.google.com/go/contactcenterinsights v1.10.0/go.mod h1:bsg/R7zGLYMVxFFzfh9ooLTruLRCG9fnzhH9KznHhbM=
Expand Down Expand Up @@ -1215,6 +1216,7 @@ github.com/googleapis/enterprise-certificate-proxy v0.2.3 h1:yk9/cqRKtT9wXZSsRH9
github.com/googleapis/enterprise-certificate-proxy v0.2.3/go.mod h1:AwSRAtLfXpU5Nm3pW+v7rGDHp09LsPtGY9MduiEsR9k=
github.com/googleapis/enterprise-certificate-proxy v0.3.2 h1:Vie5ybvEvT75RniqhfFxPRy3Bf7vr3h0cechB90XaQs=
github.com/googleapis/enterprise-certificate-proxy v0.3.2/go.mod h1:VLSiSSBs/ksPL8kq3OBOQ6WRI2QnaFynd1DCjZ62+V0=
github.com/googleapis/gax-go/v2 v2.0.5 h1:sjZBwGj9Jlw33ImPtvFviGYvseOtDM7hkSKB7+Tv3SM=
github.com/googleapis/gax-go/v2 v2.10.0/go.mod h1:4UOEnMCrxsSqQ940WnTiD6qJ63le2ev3xfyagutxiPw=
github.com/googleapis/gax-go/v2 v2.11.0 h1:9V9PWXEsWnPpQhu/PeQIkS4eGzMlTLGgt80cUUI8Ki4=
github.com/googleapis/gax-go/v2 v2.11.0/go.mod h1:DxmR61SGKkGLa2xigwuZIQpkCI2S5iydzRfb3peWZJI=
Expand Down Expand Up @@ -1788,6 +1790,7 @@ go.etcd.io/etcd/server/v3 v3.5.5/go.mod h1:rZ95vDw/jrvsbj9XpTqPrTAB9/kzchVdhRiry
go.etcd.io/etcd/server/v3 v3.5.10/go.mod h1:gBplPHfs6YI0L+RpGkTQO7buDbHv5HJGG/Bst0/zIPo=
go.etcd.io/gofail v0.1.0/go.mod h1:VZBCXYGZhHAinaBiiqYvuDynvahNsAyLFwB3kEHKz1M=
go.mozilla.org/pkcs7 v0.0.0-20200128120323-432b2356ecb1/go.mod h1:SNgMg+EgDFwmvSmLRTNKC5fegJjB7v23qTQ0XLGUNHk=
go.opencensus.io v0.22.4 h1:LYy1Hy3MJdrCdMwwzxA/dRok4ejH+RwNGbuoD9fCjto=
go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk=
go.opencensus.io v0.24.0 h1:y73uSU6J157QMP2kn2r30vwW1A2W2WFwSCGnAVxeaD0=
go.opencensus.io v0.24.0/go.mod h1:vNK8G9p7aAivkbmorf4v+7Hgx+Zs0yY+0fOtgBfjQKo=
Expand Down Expand Up @@ -2139,6 +2142,7 @@ gonum.org/v1/gonum v0.11.0 h1:f1IJhK4Km5tBJmaiJXtk/PkL4cdVX6J+tGiM187uT5E=
gonum.org/v1/netlib v0.0.0-20190313105609-8cb42192e0e0 h1:OE9mWmgKkjJyEmDAAtGMPjXu+YNeGvK9VTSHY6+Qihc=
gonum.org/v1/plot v0.10.1 h1:dnifSs43YJuNMDzB7v8wV64O4ABBHReuAVAoBxqBqS4=
google.golang.org/api v0.0.0-20160322025152-9bf6e6e569ff/go.mod h1:4mhQ8q/RsB7i+udVvVy5NUi08OU8ZlA0gRVgrF7VFY0=
google.golang.org/api v0.30.0 h1:yfrXXP61wVuLb0vBcG6qaOoIoqYEzOQS8jum51jkv2w=
google.golang.org/api v0.35.0/go.mod h1:/XrVsuzM0rZmrsbjJutiuftIzeuTQcEeaYcSk/mQ1dg=
google.golang.org/api v0.36.0/go.mod h1:+z5ficQTmoYpPn8LCUNVpK5I7hwkpjbcgqA7I34qYtE=
google.golang.org/api v0.40.0/go.mod h1:fYKFpnQN0DsDSKRVRcQSDQNtqWPfM9i+zNPxepjRCQ8=
Expand Down
1 change: 1 addition & 0 deletions pkg/server/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ func ConvertToGRPCHistoryTestCase(historyTestcase testing.HistoryTestCase) (resu
SuiteSpec: ToGRPCTestSuiteSpec(historyTestcase.SuiteSpec),
SuiteApi: historyTestcase.SuiteAPI,
SuiteParam: mapToPair(historyTestcase.SuiteParam),
HistoryHeader: mapToPair(historyTestcase.HistoryHeader),

Request: &Request{
Api: req.API,
Expand Down
30 changes: 15 additions & 15 deletions pkg/server/remote_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,10 @@ func (s *server) Run(ctx context.Context, task *TestTask) (reply *TestResult, er

// reuse the API prefix
testCase.Request.RenderAPI(suite.API)
historyHeader := make(map[string]string)
for k, v := range testCase.Request.Header {
historyHeader[k] = v
}

output, testErr := suiteRunner.RunTestCase(&testCase, dataContext, ctx)
if getter, ok := suiteRunner.(runner.ResponseRecord); ok {
Expand All @@ -270,27 +274,23 @@ func (s *server) Run(ctx context.Context, task *TestTask) (reply *TestResult, er
reply.Error = testErr.Error()
break
}
// create history record
go func(historyHeader map[string]string) {
loader := s.getLoader(ctx)
defer loader.Close()
for _, testCaseResult := range reply.TestCaseResult {
err = loader.CreateHistoryTestCase(ToNormalTestCaseResult(testCaseResult), suite, historyHeader)
if err != nil {
remoteServerLogger.Info("error create history")
}
}
}(historyHeader)
}

if reply.Error != "" {
fmt.Fprintln(buf, reply.Error)
}
reply.Message = buf.String()
// create history record
go func() {
loader := s.getLoader(ctx)
defer loader.Close()
for _, testCaseResult := range reply.TestCaseResult {
for i, item := range suite.Items {
suite.Items[i].Request.API = fmt.Sprintf("%s/%s", suite.API, item.Request.API)
}
err = loader.CreateHistoryTestCase(ToNormalTestCaseResult(testCaseResult), suite)
if err != nil {
remoteServerLogger.Info("error create history")
}
}
}()

return
}

Expand Down
Loading

0 comments on commit 717beff

Please sign in to comment.