diff --git a/packages/hoppscotch-app/components/http/TestResult.vue b/packages/hoppscotch-app/components/http/TestResult.vue index 8fa546153..4e907285c 100644 --- a/packages/hoppscotch-app/components/http/TestResult.vue +++ b/packages/hoppscotch-app/components/http/TestResult.vue @@ -38,11 +38,37 @@ v-for="(env, index) in testResults.envDiff.global.updations" :key="`env-${env.key}-${index}`" :env="env" + status="updations" + /> + + + + @@ -151,8 +177,12 @@ const clearContent = () => setRESTTestResults(null) const haveEnvVariables = computed(() => { if (!testResults.value) return false return ( + testResults.value.envDiff.global.additions.length || testResults.value.envDiff.global.updations.length || - testResults.value.envDiff.selected.updations.length + testResults.value.envDiff.global.deletions.length || + testResults.value.envDiff.selected.additions.length || + testResults.value.envDiff.selected.updations.length || + testResults.value.envDiff.selected.deletions.length ) }) diff --git a/packages/hoppscotch-app/components/http/TestResultEnv.vue b/packages/hoppscotch-app/components/http/TestResultEnv.vue index 393de1167..261022f79 100644 --- a/packages/hoppscotch-app/components/http/TestResultEnv.vue +++ b/packages/hoppscotch-app/components/http/TestResultEnv.vue @@ -1,24 +1,52 @@ diff --git a/packages/hoppscotch-app/helpers/RequestRunner.ts b/packages/hoppscotch-app/helpers/RequestRunner.ts index 4c41f16df..5265e4142 100644 --- a/packages/hoppscotch-app/helpers/RequestRunner.ts +++ b/packages/hoppscotch-app/helpers/RequestRunner.ts @@ -11,6 +11,7 @@ import { TestDescriptor, } from "@hoppscotch/js-sandbox" import { isRight } from "fp-ts/Either" +import cloneDeep from "lodash/cloneDeep" import { getCombinedEnvVariables, getFinalEnvsFromPreRequest, @@ -91,8 +92,6 @@ export const runRESTRequest$ = (): TaskEither< })() if (isRight(runResult)) { - debugger - setRESTTestResults(translateToSandboxTestResults(runResult.right)) setGlobalEnvVariables(runResult.right.envs.global) @@ -156,22 +155,23 @@ const getUpdatedEnvVariables = ( updated, A.filterMap( flow( - O.fromPredicate( - (x) => current.findIndex((y) => x.key === y.key) === -1 + O.of, + O.bindTo("env"), + O.bind("index", ({ env }) => + pipe( + current.findIndex((x) => x.key === env.key), + O.fromPredicate((x) => x !== -1) + ) ), O.chain( O.fromPredicate( - (x) => current.findIndex((y) => x.value !== y.value) === -1 + ({ env, index }) => env.value !== current[index].value ) ), - O.map((x) => { - const match = current.find((y) => x.key === y.key)!.value - - return { - ...x, - previousValue: match, - } - }) + O.map(({ env, index }) => ({ + ...env, + previousValue: current[index].value, + })) ) ) ) @@ -187,8 +187,8 @@ function translateToSandboxTestResults( } } - const globals = getGlobalVariables() - const env = getCurrentEnvironment() + const globals = cloneDeep(getGlobalVariables()) + const env = cloneDeep(getCurrentEnvironment()) return { description: "", diff --git a/packages/hoppscotch-app/helpers/preRequest.ts b/packages/hoppscotch-app/helpers/preRequest.ts index d4e437c0f..75c5f3832 100644 --- a/packages/hoppscotch-app/helpers/preRequest.ts +++ b/packages/hoppscotch-app/helpers/preRequest.ts @@ -1,13 +1,14 @@ import { runPreRequestScript } from "@hoppscotch/js-sandbox" import { Environment } from "@hoppscotch/data" +import cloneDeep from "lodash/cloneDeep" import { getCurrentEnvironment, getGlobalVariables, } from "~/newstore/environments" export const getCombinedEnvVariables = () => ({ - global: getGlobalVariables(), - selected: getCurrentEnvironment().variables, + global: cloneDeep(getGlobalVariables()), + selected: cloneDeep(getCurrentEnvironment().variables), }) export const getFinalEnvsFromPreRequest = (