Skip to content

Commit 7de67ca

Browse files
chore: show server address on the test case page (#545)
* chore(deps): bump rollup from 3.25.1 to 3.29.5 in /console/atest-ui Bumps [rollup](https://github.com/rollup/rollup) from 3.25.1 to 3.29.5. - [Release notes](https://github.com/rollup/rollup/releases) - [Changelog](https://github.com/rollup/rollup/blob/master/CHANGELOG.md) - [Commits](rollup/rollup@v3.25.1...v3.29.5) --- updated-dependencies: - dependency-name: rollup dependency-type: indirect ... Signed-off-by: dependabot[bot] <[email protected]> * chore: show server address on the test case page --------- Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: rick <[email protected]>
1 parent fe9d168 commit 7de67ca

File tree

7 files changed

+521
-485
lines changed

7 files changed

+521
-485
lines changed

console/atest-ui/package-lock.json

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -886,20 +886,24 @@ Magic.Keys(() => {
886886
:key="item.value"
887887
:label="item.key"
888888
:value="item.value"
889-
/>
889+
>
890+
<el-text class="mx-1" :type="item.type">{{ item.key }}</el-text>
891+
</el-option>
890892
</el-select>
891893
</el-col>
892894
<el-col :span="18">
893895
<el-autocomplete
894896
v-model="testCaseWithSuite.data.request.api"
895897
style="width: 100%"
896898
:fetch-suggestions="querySuggestedAPIs"
897-
placeholder="API Address"
898899
:readonly="isHistoryTestCase">
899900
<template #default="{ item }">
900901
<div class="value">{{ item.request.method }}</div>
901902
<span class="link">{{ item.request.api }}</span>
902903
</template>
904+
<template #prefix v-if="!testCaseWithSuite.data.request.api.startsWith('http://') && !testCaseWithSuite.data.request.api.startsWith('https://')">
905+
{{ testCaseWithSuite.data.server }}
906+
</template>
903907
</el-autocomplete>
904908
</el-col>
905909
<el-col :span="3">

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<script setup lang="ts">
22
import TestCase from './TestCase.vue'
33
import TestSuite from './TestSuite.vue'
4+
import { GetHTTPMethod } from './types'
45
import TemplateFunctions from './TemplateFunctions.vue'
56
import { ref, watch } from 'vue'
67
import { ElTree, ElMessage } from 'element-plus'
@@ -283,10 +284,7 @@ const viewName = ref('')
283284
>
284285
<template #default="{ node, data }">
285286
<span class="custom-tree-node">
286-
<el-text class="mx-1" v-if="data.method === 'POST'" type="success">{{ node.label }}</el-text>
287-
<el-text class="mx-1" v-else-if="data.method === 'PUT'" type="warning">{{ node.label }}</el-text>
288-
<el-text class="mx-1" v-else-if="data.method === 'DELETE'" type="danger">{{ node.label }}</el-text>
289-
<el-text class="mx-1" v-else>{{ node.label }}</el-text>
287+
<el-text class="mx-1" :type="GetHTTPMethod(data.method).type">{{ node.label }}</el-text>
290288
</span>
291289
</template>
292290
</el-tree>

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

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ export interface TestResult {
4444
export interface Pair {
4545
key: string
4646
value: string
47+
type: string
4748
defaultValue: string
4849
description: string
4950
}
@@ -55,6 +56,7 @@ export interface TestCaseWithSuite {
5556

5657
export interface TestCase {
5758
name: string
59+
server: string
5860
request: TestCaseRequest
5961
response: TestCaseResponse
6062
}
@@ -122,35 +124,51 @@ export function GetHTTPMethods() {
122124
return [
123125
{
124126
value: 'GET',
125-
key: 'GET'
127+
key: 'GET',
128+
type: ''
126129
},
127130
{
128131
value: 'POST',
129-
key: 'POST'
132+
key: 'POST',
133+
type: 'success'
130134
},
131135
{
132136
value: 'DELETE',
133-
key: 'DELETE'
137+
key: 'DELETE',
138+
type: 'danger'
134139
},
135140
{
136141
value: 'PUT',
137-
key: 'PUT'
142+
key: 'PUT',
143+
type: 'warning'
138144
},
139145
{
140146
value: 'HEAD',
141-
key: 'HEAD'
147+
key: 'HEAD',
148+
type: ''
142149
},
143150
{
144151
value: 'PATCH',
145-
key: 'PATCH'
152+
key: 'PATCH',
153+
type: ''
146154
},
147155
{
148156
value: 'OPTIONS',
149-
key: 'OPTIONS'
157+
key: 'OPTIONS',
158+
type: ''
150159
}
151160
] as Pair[]
152161
}
153162

163+
export function GetHTTPMethod(name: string) {
164+
for (const method of GetHTTPMethods()) {
165+
if (method.key === name) {
166+
return method
167+
}
168+
}
169+
return {} as Pair
170+
}
171+
154172
export function FlattenObject(obj: any): any {
155173
function _flattenPairs(obj: any, prefix: string): [string, any][] {
156174
if (!_.isObject(obj)) {

pkg/server/remote_server.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -608,6 +608,11 @@ func (s *server) GetTestCase(ctx context.Context, in *TestCaseIdentity) (reply *
608608
defer loader.Close()
609609
if result, err = loader.GetTestCase(in.Suite, in.Testcase); err == nil {
610610
reply = ToGRPCTestCase(result)
611+
612+
var suite testing.TestSuite
613+
if suite, err = loader.GetTestSuite(in.Suite, false); err == nil {
614+
reply.Server = suite.API
615+
}
611616
}
612617
return
613618
}

0 commit comments

Comments
 (0)