Skip to content

Commit 54d66f4

Browse files
committed
fix: lack of error msg of download binary file
1 parent 217f9f4 commit 54d66f4

File tree

5 files changed

+415
-404
lines changed

5 files changed

+415
-404
lines changed

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

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -128,11 +128,8 @@ const handleTestResult = (e: any): void => {
128128
if (!isHistoryTestCase.value) {
129129
handleTestResultError(e)
130130
}
131-
const isFilePath = e.body.startsWith("isFilePath-")
132-
133-
if(isFilePath){
134-
isResponseFile.value = true
135-
} else if(e.body !== ''){
131+
isResponseFile.value = e.body.startsWith("isFilePath-")
132+
if(!isResponseFile.value && e.body !== ''){
136133
testResult.value.bodyLength = e.body.length
137134
try {
138135
// Try to parse as JSON, fallback to plain text if parsing fails
@@ -149,11 +146,11 @@ const handleTestResult = (e: any): void => {
149146
}
150147
}
151148
152-
Cache.SetTestCaseResponseCache(suite + '-' + name, {
153-
body: testResult.value.bodyObject,
154-
output: e.output,
155-
statusCode: testResult.value.statusCode
156-
} as TestCaseResponse)
149+
Cache.SetTestCaseResponseCache(suite + '-' + name, {
150+
body: testResult.value.bodyObject,
151+
output: e.output,
152+
statusCode: testResult.value.statusCode
153+
} as TestCaseResponse)
157154
158155
parameters.value = [];
159156
}
@@ -436,7 +433,9 @@ function downloadResponseFile(){
436433
} else {
437434
console.error('No data to download.');
438435
}
439-
})
436+
}, (e) => {
437+
UIAPI.ErrorTip(e);
438+
});
440439
}
441440
442441
function setDefaultValues(e) {

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ async function DefaultResponseProcess(response: any): Promise<any> {
6767

6868
// For OK responses, handle content based on Content-Type
6969
const contentType = response.headers.get('Content-Type') ?? '';
70-
if (contentType.startsWith('text/plain')) {
70+
if (isTextReadableExpectJSON(contentType)) {
7171
// For text/plain, directly return the text
7272
return await response.text();
7373
}
@@ -90,6 +90,11 @@ async function DefaultResponseProcess(response: any): Promise<any> {
9090
}
9191
}
9292

93+
const isTextReadableExpectJSON = (contentType: string): boolean => {
94+
// Check if the content type is text-based
95+
return contentType.startsWith('text/') || contentType === 'application/javascript';
96+
}
97+
9398
interface AppVersion {
9499
version: string
95100
commit: string

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export interface Suite {
3737

3838
export interface TestResult {
3939
body: string
40-
bodyObject: {}
40+
bodyObject: {} | null
4141
bodyText: string
4242
bodyLength: number
4343
output: string
@@ -46,7 +46,7 @@ export interface TestResult {
4646
header: Pair[]
4747

4848
// inner fields
49-
originBodyObject:{}
49+
originBodyObject:{} | null
5050
}
5151

5252
export interface Pair {

0 commit comments

Comments
 (0)