feat: handle test script execution failure (#2104)
Co-authored-by: Andrew Bastin <andrewbastin.k@gmail.com>
This commit is contained in:
@@ -62,6 +62,25 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div
|
||||||
|
v-else-if="testResults && testResults.scriptError"
|
||||||
|
class="flex flex-col items-center justify-center flex-1 p-4"
|
||||||
|
>
|
||||||
|
<img
|
||||||
|
:src="`/images/states/${$colorMode.value}/youre_lost.svg`"
|
||||||
|
loading="lazy"
|
||||||
|
class="inline-flex flex-col object-contain object-center w-32 h-32 my-4"
|
||||||
|
:alt="`${t('error.test_script_fail')}`"
|
||||||
|
/>
|
||||||
|
<span class="mb-2 font-semibold text-center">
|
||||||
|
{{ t("error.test_script_fail") }}
|
||||||
|
</span>
|
||||||
|
<span
|
||||||
|
class="max-w-sm mb-6 text-center whitespace-normal text-secondaryLight"
|
||||||
|
>
|
||||||
|
{{ t("helpers.test_script_fail") }}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
<div
|
<div
|
||||||
v-else
|
v-else
|
||||||
class="flex flex-col items-center justify-center p-4 text-secondaryLight"
|
class="flex flex-col items-center justify-center p-4 text-secondaryLight"
|
||||||
|
|||||||
@@ -71,9 +71,15 @@ export const runRESTRequest$ = (): TaskEither<
|
|||||||
headers: res.headers,
|
headers: res.headers,
|
||||||
})()
|
})()
|
||||||
|
|
||||||
// TODO: Handle script executation fails (isLeft)
|
|
||||||
if (isRight(runResult)) {
|
if (isRight(runResult)) {
|
||||||
setRESTTestResults(translateToSandboxTestResults(runResult.right))
|
setRESTTestResults(translateToSandboxTestResults(runResult.right))
|
||||||
|
} else {
|
||||||
|
setRESTTestResults({
|
||||||
|
description: "",
|
||||||
|
expectResults: [],
|
||||||
|
tests: [],
|
||||||
|
scriptError: true,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
subscription.unsubscribe()
|
subscription.unsubscribe()
|
||||||
@@ -95,7 +101,9 @@ function translateToSandboxTestResults(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
|
description: "",
|
||||||
expectResults: testDesc.expectResults,
|
expectResults: testDesc.expectResults,
|
||||||
tests: testDesc.children.map(translateChildTests),
|
tests: testDesc.children.map(translateChildTests),
|
||||||
|
scriptError: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,4 +13,5 @@ export type HoppTestResult = {
|
|||||||
tests: HoppTestData[]
|
tests: HoppTestData[]
|
||||||
expectResults: HoppTestExpectResult[]
|
expectResults: HoppTestExpectResult[]
|
||||||
description: string
|
description: string
|
||||||
|
scriptError: boolean
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -182,7 +182,8 @@
|
|||||||
"network_fail": "Could not send request",
|
"network_fail": "Could not send request",
|
||||||
"no_duration": "No duration",
|
"no_duration": "No duration",
|
||||||
"script_fail": "Could not execute pre-request script",
|
"script_fail": "Could not execute pre-request script",
|
||||||
"something_went_wrong": "Something went wrong"
|
"something_went_wrong": "Something went wrong",
|
||||||
|
"test_script_fail": "Could not execute post-request script"
|
||||||
},
|
},
|
||||||
"export": {
|
"export": {
|
||||||
"as_json": "Export as JSON",
|
"as_json": "Export as JSON",
|
||||||
@@ -217,7 +218,8 @@
|
|||||||
"post_request_tests": "Test scripts are written in JavaScript, and are run after the response is received.",
|
"post_request_tests": "Test scripts are written in JavaScript, and are run after the response is received.",
|
||||||
"pre_request_script": "Pre-request scripts are written in JavaScript, and are run before the request is sent.",
|
"pre_request_script": "Pre-request scripts are written in JavaScript, and are run before the request is sent.",
|
||||||
"script_fail": "It seems there is a glitch in the pre-request script. Check the error below and fix the script accordingly.",
|
"script_fail": "It seems there is a glitch in the pre-request script. Check the error below and fix the script accordingly.",
|
||||||
"tests": "Write a test script to automate debugging."
|
"tests": "Write a test script to automate debugging.",
|
||||||
|
"test_script_fail": "There seems to be an error with test script. Please fix the errors and run tests again"
|
||||||
},
|
},
|
||||||
"hide": {
|
"hide": {
|
||||||
"more": "Hide more",
|
"more": "Hide more",
|
||||||
|
|||||||
Reference in New Issue
Block a user