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