feat: handle test script execution failure (#2104)

Co-authored-by: Andrew Bastin <andrewbastin.k@gmail.com>
This commit is contained in:
Rishabh Agarwal
2022-02-01 14:29:18 +05:30
committed by GitHub
parent aaecba043b
commit 9c21013a06
4 changed files with 33 additions and 3 deletions

View File

@@ -62,6 +62,25 @@
</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
v-else
class="flex flex-col items-center justify-center p-4 text-secondaryLight"

View File

@@ -71,9 +71,15 @@ export const runRESTRequest$ = (): TaskEither<
headers: res.headers,
})()
// TODO: Handle script executation fails (isLeft)
if (isRight(runResult)) {
setRESTTestResults(translateToSandboxTestResults(runResult.right))
} else {
setRESTTestResults({
description: "",
expectResults: [],
tests: [],
scriptError: true,
})
}
subscription.unsubscribe()
@@ -95,7 +101,9 @@ function translateToSandboxTestResults(
}
}
return {
description: "",
expectResults: testDesc.expectResults,
tests: testDesc.children.map(translateChildTests),
scriptError: false,
}
}

View File

@@ -13,4 +13,5 @@ export type HoppTestResult = {
tests: HoppTestData[]
expectResults: HoppTestExpectResult[]
description: string
scriptError: boolean
}

View File

@@ -182,7 +182,8 @@
"network_fail": "Could not send request",
"no_duration": "No duration",
"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": {
"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.",
"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.",
"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": {
"more": "Hide more",