fix: the API request from UI missed the header (#155)
This commit is contained in:
parent
a799208a0c
commit
e985dd7ccf
|
@ -9,7 +9,7 @@ const props = defineProps({
|
||||||
operationId: String
|
operationId: String
|
||||||
})
|
})
|
||||||
// const emit = defineEmits(['update:address', 'update:method', 'update:operationId'])
|
// const emit = defineEmits(['update:address', 'update:method', 'update:operationId'])
|
||||||
const querySuggestedAPIs = NewSuggestedAPIsQuery(props.suite!)
|
const querySuggestedAPIs = NewSuggestedAPIsQuery('', props.suite!)
|
||||||
|
|
||||||
const handleSelect = (item: TestCase) => {
|
const handleSelect = (item: TestCase) => {
|
||||||
// emit('update:address', item.request.api)
|
// emit('update:address', item.request.api)
|
||||||
|
|
|
@ -14,7 +14,7 @@ const props = defineProps({
|
||||||
})
|
})
|
||||||
const emit = defineEmits(['updated'])
|
const emit = defineEmits(['updated'])
|
||||||
|
|
||||||
let querySuggestedAPIs = NewSuggestedAPIsQuery(props.suite!)
|
let querySuggestedAPIs = NewSuggestedAPIsQuery(props.store!, props.suite!)
|
||||||
const testResultActiveTab = ref('output')
|
const testResultActiveTab = ref('output')
|
||||||
const requestLoading = ref(false)
|
const requestLoading = ref(false)
|
||||||
const testResult = ref({ header: [] as Pair[] } as TestResult)
|
const testResult = ref({ header: [] as Pair[] } as TestResult)
|
||||||
|
@ -65,6 +65,9 @@ function generateCode() {
|
||||||
const suite = props.suite
|
const suite = props.suite
|
||||||
const requestOptions = {
|
const requestOptions = {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
|
headers: {
|
||||||
|
'X-Store-Name': props.store
|
||||||
|
},
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
TestSuite: suite,
|
TestSuite: suite,
|
||||||
TestCase: name,
|
TestCase: name,
|
||||||
|
@ -424,7 +427,7 @@ const queryPupularHeaders = (queryString: string, cb: (arg: any) => void) => {
|
||||||
v-model="testCaseWithSuite.data.request.api"
|
v-model="testCaseWithSuite.data.request.api"
|
||||||
:fetch-suggestions="querySuggestedAPIs"
|
:fetch-suggestions="querySuggestedAPIs"
|
||||||
placeholder="API Address"
|
placeholder="API Address"
|
||||||
style="width: 70%; margin-left: 5px; margin-right: 5px"
|
style="width: 50%; margin-left: 5px; margin-right: 5px"
|
||||||
>
|
>
|
||||||
<template #default="{ item }">
|
<template #default="{ item }">
|
||||||
<div class="value">{{ item.request.method }}</div>
|
<div class="value">{{ item.request.method }}</div>
|
||||||
|
|
|
@ -11,7 +11,7 @@ const props = defineProps({
|
||||||
store: String,
|
store: String,
|
||||||
})
|
})
|
||||||
const emit = defineEmits(['updated'])
|
const emit = defineEmits(['updated'])
|
||||||
let querySuggestedAPIs = NewSuggestedAPIsQuery(props.name!)
|
let querySuggestedAPIs = NewSuggestedAPIsQuery(props.store!, props.name!)
|
||||||
|
|
||||||
const suite = ref({
|
const suite = ref({
|
||||||
name: '',
|
name: '',
|
||||||
|
@ -87,7 +87,7 @@ const rules = reactive<FormRules<Suite>>({
|
||||||
|
|
||||||
function openNewTestCaseDialog() {
|
function openNewTestCaseDialog() {
|
||||||
dialogVisible.value = true
|
dialogVisible.value = true
|
||||||
querySuggestedAPIs = NewSuggestedAPIsQuery(props.name!)
|
querySuggestedAPIs = NewSuggestedAPIsQuery(props.store!, props.name!)
|
||||||
}
|
}
|
||||||
|
|
||||||
const submitForm = async (formEl: FormInstance | undefined) => {
|
const submitForm = async (formEl: FormInstance | undefined) => {
|
||||||
|
|
|
@ -20,7 +20,7 @@ global.fetch = jest.fn((key: string) =>
|
||||||
|
|
||||||
describe('NewSuggestedAPIsQuery', () => {
|
describe('NewSuggestedAPIsQuery', () => {
|
||||||
test('empty data', () => {
|
test('empty data', () => {
|
||||||
const func = NewSuggestedAPIsQuery('')
|
const func = NewSuggestedAPIsQuery('', '')
|
||||||
expect(func).not.toBeNull()
|
expect(func).not.toBeNull()
|
||||||
|
|
||||||
func('xxx', function(e) {
|
func('xxx', function(e) {
|
||||||
|
@ -31,7 +31,7 @@ describe('NewSuggestedAPIsQuery', () => {
|
||||||
test('have data', () => {
|
test('have data', () => {
|
||||||
matchFake('/server.Runner/GetSuggestedAPIs', `{"data":[{"request":{"api":"xxx"}}]}`)
|
matchFake('/server.Runner/GetSuggestedAPIs', `{"data":[{"request":{"api":"xxx"}}]}`)
|
||||||
|
|
||||||
const func = NewSuggestedAPIsQuery('suite')
|
const func = NewSuggestedAPIsQuery('', 'suite')
|
||||||
expect(func).not.toBeNull()
|
expect(func).not.toBeNull()
|
||||||
|
|
||||||
func('xxx', function(e) {
|
func('xxx', function(e) {
|
||||||
|
@ -42,7 +42,7 @@ describe('NewSuggestedAPIsQuery', () => {
|
||||||
expect(e.length).toBe(0)
|
expect(e.length).toBe(0)
|
||||||
})
|
})
|
||||||
|
|
||||||
const anotherFunc = NewSuggestedAPIsQuery('')
|
const anotherFunc = NewSuggestedAPIsQuery('', '')
|
||||||
expect(anotherFunc).not.toBeNull()
|
expect(anotherFunc).not.toBeNull()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
@ -56,9 +56,9 @@ export interface TestCaseResponse {
|
||||||
|
|
||||||
// Suggested APIs query
|
// Suggested APIs query
|
||||||
const localCache = ref({} as TestCaseWithValue[])
|
const localCache = ref({} as TestCaseWithValue[])
|
||||||
export function NewSuggestedAPIsQuery(suite: string) {
|
export function NewSuggestedAPIsQuery(store: string, suite: string) {
|
||||||
return function (queryString: string, cb: (arg: any) => void) {
|
return function (queryString: string, cb: (arg: any) => void) {
|
||||||
loadCache(suite, function () {
|
loadCache(store, suite, function () {
|
||||||
const results = queryString
|
const results = queryString
|
||||||
? localCache.value.filter(CreateFilter(queryString))
|
? localCache.value.filter(CreateFilter(queryString))
|
||||||
: localCache.value
|
: localCache.value
|
||||||
|
@ -72,7 +72,7 @@ export function CreateFilter(queryString: string) {
|
||||||
return v.value.toLowerCase().indexOf(queryString.toLowerCase()) !== -1
|
return v.value.toLowerCase().indexOf(queryString.toLowerCase()) !== -1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function loadCache(suite: string, callback: Function) {
|
function loadCache(store: string, suite: string, callback: Function) {
|
||||||
if (localCache.value.length > 0) {
|
if (localCache.value.length > 0) {
|
||||||
callback()
|
callback()
|
||||||
return
|
return
|
||||||
|
@ -84,6 +84,9 @@ function loadCache(suite: string, callback: Function) {
|
||||||
|
|
||||||
const requestOptions = {
|
const requestOptions = {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
|
headers: {
|
||||||
|
'X-Store-Name': store
|
||||||
|
},
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
name: suite
|
name: suite
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue