Skip to content

Commit

Permalink
fix: fix the remaining problem
Browse files Browse the repository at this point in the history
  • Loading branch information
SamYSF committed Sep 13, 2024
1 parent c89659c commit 22d5878
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 42 deletions.
5 changes: 3 additions & 2 deletions console/atest-ui/src/views/TestCase.vue
Original file line number Diff line number Diff line change
Expand Up @@ -838,6 +838,7 @@ Magic.Keys(() => {
placeholder="Method"
size="default"
test-id="case-editor-method"
:disabled="isHistoryTestCase"
>
<el-option
v-for="item in options"
Expand Down Expand Up @@ -1109,7 +1110,7 @@ Magic.Keys(() => {
</template>
</el-drawer>

<el-dialog v-model="historyDialogOpened" :title="t('button.viewHistory')" width="50%" draggable>
<el-dialog v-model="historyDialogOpened" :title="t('button.viewHistory')" width="60%" draggable>
<el-form
ref="viewHistoryRef"
:model="historyForm"
Expand Down Expand Up @@ -1137,7 +1138,7 @@ Magic.Keys(() => {
</el-select>
</el-col>
<el-col :span="4">
<div style="display: flex">
<div style="display: flex;flex-wrap: nowrap;justify-content: flex-end;">
<el-button
type="primary"
@click="submitForm(viewHistoryRef)"
Expand Down
39 changes: 5 additions & 34 deletions pkg/server/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,45 +239,15 @@ func ToNormalTestCaseResult(testCaseResult *TestCaseResult) (result testing.Test
}

func ToGRPCHistoryTestCaseResult(historyTestResult testing.HistoryTestResult) (result *HistoryTestResult) {
res := historyTestResult.Data.Data.Request
resp := historyTestResult.Data.Data.Expect

convertedHistoryTestCase := ConvertToGRPCHistoryTestCase(historyTestResult.Data)

result = &HistoryTestResult{
Message: historyTestResult.Message,
Error: historyTestResult.Error,
CreateTime: timestamppb.New(historyTestResult.CreateTime),

Data: &HistoryTestCase{
HistorySuiteName: historyTestResult.Data.HistorySuiteName,
CaseName: historyTestResult.Data.CaseName,
CreateTime: timestamppb.New(historyTestResult.CreateTime),
SuiteName: historyTestResult.Data.SuiteName,
SuiteApi: historyTestResult.Data.SuiteAPI,
SuiteParam: mapToPair(historyTestResult.Data.SuiteParam),

Request: &Request{
Api: res.API,
Method: res.Method,
Body: res.Body.String(),
Header: mapToPair(res.Header),
Cookie: mapToPair(res.Cookie),
Query: mapInterToPair(res.Query),
Form: mapToPair(res.Form),
},

Response: &Response{
StatusCode: int32(resp.StatusCode),
Body: resp.Body,
Schema: resp.Schema,
Verify: resp.Verify,
BodyFieldsExpect: mapInterToPair(resp.BodyFieldsExpect),
Header: mapToPair(resp.Header),
},
},
Data: convertedHistoryTestCase,
}

result.Data.SuiteSpec = ToGRPCTestSuiteSpec(historyTestResult.Data.SuiteSpec)

for _, testCaseResult := range historyTestResult.TestCaseResult {
result.TestCaseResult = append(result.TestCaseResult, &TestCaseResult{
StatusCode: int32(testCaseResult.StatusCode),
Expand All @@ -288,7 +258,8 @@ func ToGRPCHistoryTestCaseResult(historyTestResult testing.HistoryTestResult) (r
Id: testCaseResult.Id,
})
}
return

return result
}

func ToGRPCTestSuiteSpec(spec testing.APISpec) (result *APISpec) {
Expand Down
4 changes: 2 additions & 2 deletions pkg/testing/case.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ type HistoryTestCase struct {
CaseName string `yaml:"caseName,omitempty" json:"name,omitempty"`
SuiteName string `yaml:"suiteName,omitempty" json:"suiteName,omitempty"`
HistorySuiteName string `yaml:"historySuiteName,omitempty" json:"historySuiteName,omitempty"`
CreateTime time.Time `yaml:"createTime,omitempty" json:"createTime,omitempty"`
CreateTime time.Time `yaml:"createTime,omitempty" json:"createTime,omitempty"`
SuiteAPI string `yaml:"api,omitempty" json:"api,omitempty"`
SuiteSpec APISpec `yaml:"spec,omitempty" json:"spec,omitempty"`
SuiteParam map[string]string `yaml:"param,omitempty" json:"param,omitempty"`
Expand All @@ -62,7 +62,7 @@ type HistoryTestResult struct {
Error string `yaml:"error,omitempty" json:"error,omitempty"`
TestCaseResult []TestCaseResult `yaml:"testCaseResult,omitempty" json:"testCaseResult,omitempty"`
Data HistoryTestCase `yaml:"data,omitempty" json:"data,omitempty"`
CreateTime time.Time `yaml:"createTime,omitempty" json:"createTime,omitempty"`
CreateTime time.Time `yaml:"createTime,omitempty" json:"createTime,omitempty"`
}

type RPCDesc struct {
Expand Down
6 changes: 3 additions & 3 deletions pkg/testing/remote/converter.go
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ func pairToInterMap(pairs []*server.Pair) (data map[string]interface{}) {
return
}

func ConvertToGRPCTestCaseResult(testCaseResult testing.TestCaseResult, testSuite *testing.TestSuite) (result *server.HistoryTestResult) {
func ConvertToGRPCHistoryTestCaseResult(testCaseResult testing.TestCaseResult, testSuite *testing.TestSuite) (result *server.HistoryTestResult) {
result = &server.HistoryTestResult{
Error: testCaseResult.Error,
CreateTime: timestamppb.New(time.Now()),
Expand Down Expand Up @@ -340,15 +340,15 @@ func ConvertToNormalTestCaseResult(testResult *server.HistoryTestResult) (result
}

for _, testCaseResult := range testResult.TestCaseResult {
testCaseResult := testing.TestCaseResult{
testcaseResult := testing.TestCaseResult{
StatusCode: int(testCaseResult.StatusCode),
Body: testCaseResult.Body,
Header: pairToMap(testCaseResult.Header),
Error: testCaseResult.Error,
Id: testCaseResult.Id,
Output: testCaseResult.Output,
}
result.TestCaseResult = append(result.TestCaseResult, testCaseResult)
result.TestCaseResult = append(result.TestCaseResult, testcaseResult)
}
result.Data = ConvertToNormalHistoryTestCase(testResult.Data)

Expand Down
2 changes: 1 addition & 1 deletion pkg/testing/remote/grpc_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ func (g *gRPCLoader) DeleteTestCase(suite, testcase string) (err error) {
}

func (g *gRPCLoader) CreateHistoryTestCase(testcaseResult testing.TestCaseResult, testSuite *testing.TestSuite) (err error) {
payload := ConvertToGRPCTestCaseResult(testcaseResult, testSuite)
payload := ConvertToGRPCHistoryTestCaseResult(testcaseResult, testSuite)
_, err = g.client.CreateTestCaseHistory(g.ctx, payload)
return
}
Expand Down

0 comments on commit 22d5878

Please sign in to comment.