Skip to content

Commit 319dbaf

Browse files
authored
feat: support import test suite as in-line (#819)
* feat: support import test suite as in-line * test pass * fix unit tests --------- Co-authored-by: rick <[email protected]>
1 parent ac7670a commit 319dbaf

File tree

12 files changed

+136
-98
lines changed

12 files changed

+136
-98
lines changed

Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ COPY console/atest-ui .
55
RUN npm install --ignore-scripts --registry=https://registry.npmmirror.com
66
RUN npm run build-only
77

8-
FROM docker.io/golang:1.23 AS builder
8+
FROM docker.io/golang:1.24 AS builder
99

1010
ARG VERSION
1111
ARG GOPROXY
@@ -39,7 +39,7 @@ LABEL "com.github.actions.name"="API testing"
3939
LABEL "com.github.actions.description"="API testing"
4040
LABEL "com.github.actions.icon"="home"
4141
LABEL "com.github.actions.color"="red"
42-
LABEL org.opencontainers.image.description "This is an API testing tool that supports HTTP, gRPC, and GraphQL."
42+
LABEL org.opencontainers.image.description "This is an API testing tool that supports HTTP, gRPC, and GraphQL."
4343

4444
LABEL "repository"="https://github.com/linuxsuren/api-testing"
4545
LABEL "homepage"="https://github.com/linuxsuren/api-testing"
@@ -53,6 +53,6 @@ COPY --from=builder /workspace/README.md /README.md
5353

5454
# required for atest-store-git
5555
RUN apk add curl openssh-client bash openssl
56-
56+
5757
EXPOSE 8080
5858
CMD ["atest", "server", "--local-storage=/var/data/api-testing/*.yaml"]

console/atest-ui/package-lock.json

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

console/atest-ui/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"jsonpath-plus": "^10.3.0",
3030
"vue": "^3.3.4",
3131
"vue-codemirror": "^5.1.0",
32-
"vue-i18n": "^11.1.9",
32+
"vue-i18n": "^11.1.10",
3333
"vue-json-viewer": "^3.0.4",
3434
"vue-router": "^4.2.2"
3535
},

console/atest-ui/src/components/TestSuiteImportDialog.vue

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<script setup lang="ts">
22
import { useI18n } from 'vue-i18n'
33
import { reactive, ref } from 'vue'
4-
import type { Suite } from '@/views/types'
54
import { API } from '@/views/net'
65
import { ElMessage } from 'element-plus'
6+
import type { ImportSource } from '@/views/net'
77
import type { FormInstance, FormRules } from 'element-plus'
88
99
const { t } = useI18n()
@@ -16,14 +16,16 @@ const importSuiteFormRef = ref<FormInstance>()
1616
const importSuiteForm = reactive({
1717
url: '',
1818
store: '',
19-
kind: ''
20-
})
19+
kind: '',
20+
data: ''
21+
} as ImportSource)
2122
22-
const importSuiteFormRules = reactive<FormRules<Suite>>({
23+
const importSuiteFormRules = reactive<FormRules<ImportSource>>({
2324
url: [
24-
{ required: true, message: 'URL is required', trigger: 'blur' },
25+
{ required: importSuiteForm.kind !== 'native-inline', message: 'URL is required', trigger: 'blur' },
2526
{ type: 'url', message: 'Should be a valid URL value', trigger: 'blur' }
2627
],
28+
data: [{ required: importSuiteForm.kind === 'native-inline', message: 'Data is required', trigger: 'blur' }],
2729
store: [{ required: true, message: 'Location is required', trigger: 'blur' }],
2830
kind: [{ required: true, message: 'Kind is required', trigger: 'blur' }]
2931
})
@@ -36,7 +38,7 @@ const importSuiteFormSubmit = async (formEl: FormInstance | undefined) => {
3638
emit('created')
3739
formEl.resetFields()
3840
}, (e) => {
39-
ElMessage.error(e)
41+
ElMessage.error(e.message)
4042
})
4143
}
4244
})
@@ -69,12 +71,16 @@ const importSourceKinds = [{
6971
"name": "Native",
7072
"value": "native",
7173
"description": "http://your-server/api/v1/suites/xxx/yaml?x-store-name=xxx"
74+
}, {
75+
"name": "Native-Inline",
76+
"value": "native-inline",
77+
"description": "Native test suite content in YAML format"
7278
}]
73-
const placeholderOfImportURL = ref("")
79+
const importSourceDesc = ref("")
7480
const kindChanged = (e) => {
7581
importSourceKinds.forEach(k => {
7682
if (k.value === e) {
77-
placeholderOfImportURL.value = k.description
83+
importSourceDesc.value = k.description
7884
}
7985
});
8086
}
@@ -117,8 +123,15 @@ const kindChanged = (e) => {
117123
/>
118124
</el-select>
119125
</el-form-item>
120-
<el-form-item label="URL" prop="url">
121-
<el-input v-model="importSuiteForm.url" test-id="suite-import-form-api" :placeholder="placeholderOfImportURL" />
126+
<el-form-item label="Data" prop="data" v-if="importSuiteForm.kind === 'native-inline'">
127+
<el-input v-model="importSuiteForm.data"
128+
class="full-width" type="textarea"
129+
:placeholder="importSourceDesc" />
130+
</el-form-item>
131+
<el-form-item label="URL" prop="url" v-else>
132+
<el-input v-model="importSuiteForm.url" test-id="suite-import-form-api"
133+
class="full-width"
134+
:placeholder="importSourceDesc" />
122135
</el-form-item>
123136
<el-form-item>
124137
<el-button
@@ -130,3 +143,9 @@ const kindChanged = (e) => {
130143
</el-form>
131144
</el-dialog>
132145
</template>
146+
147+
<style scoped>
148+
.full-width {
149+
width: 100%;
150+
}
151+
</style>

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,10 +190,11 @@ function CreateTestSuite(suite: TestSuite,
190190
.then(callback).catch(emptyOrDefault(errHandle))
191191
}
192192

193-
interface ImportSource {
193+
export interface ImportSource {
194194
store: string
195195
url: string
196196
kind: string
197+
data: string
197198
}
198199

199200
function UpdateTestSuite(suite: any,

go.mod

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
module github.com/linuxsuren/api-testing
22

3-
go 1.23.0
3+
go 1.24.0
4+
5+
toolchain go1.24.3
46

57
require (
68
github.com/Masterminds/sprig/v3 v3.2.3
@@ -33,10 +35,10 @@ require (
3335
github.com/tidwall/gjson v1.18.0
3436
github.com/xeipuuv/gojsonschema v1.2.0
3537
go.uber.org/zap v1.27.0
36-
golang.org/x/oauth2 v0.30.0
37-
golang.org/x/sync v0.14.0
38-
google.golang.org/genproto/googleapis/api v0.0.0-20250324211829-b45e905df463
39-
google.golang.org/grpc v1.73.0
38+
golang.org/x/oauth2 v0.32.0
39+
golang.org/x/sync v0.16.0
40+
google.golang.org/genproto/googleapis/api v0.0.0-20250804133106-a7a43d27e69b
41+
google.golang.org/grpc v1.76.0
4042
google.golang.org/protobuf v1.36.10
4143
gopkg.in/yaml.v3 v3.0.1
4244
)
@@ -55,7 +57,7 @@ require (
5557
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
5658
github.com/rivo/uniseg v0.4.3 // indirect
5759
github.com/schollz/progressbar/v3 v3.13.0 // indirect
58-
golang.org/x/term v0.32.0 // indirect
60+
golang.org/x/term v0.33.0 // indirect
5961
)
6062

6163
require (
@@ -101,10 +103,10 @@ require (
101103
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect
102104
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
103105
go.uber.org/multierr v1.11.0 // indirect
104-
golang.org/x/crypto v0.38.0 // indirect
105-
golang.org/x/net v0.40.0 // indirect
106-
golang.org/x/sys v0.33.0 // indirect
107-
golang.org/x/text v0.25.0 // indirect
108-
google.golang.org/genproto/googleapis/rpc v0.0.0-20250324211829-b45e905df463 // indirect
106+
golang.org/x/crypto v0.40.0 // indirect
107+
golang.org/x/net v0.42.0 // indirect
108+
golang.org/x/sys v0.34.0 // indirect
109+
golang.org/x/text v0.27.0 // indirect
110+
google.golang.org/genproto/googleapis/rpc v0.0.0-20250804133106-a7a43d27e69b // indirect
109111
gopkg.in/yaml.v2 v2.4.0 // indirect
110112
)

0 commit comments

Comments
 (0)