feat: show environment updates in test results

This commit is contained in:
liyasthomas
2022-02-19 06:08:08 +05:30
parent 59c6e21636
commit d246cf53d4
2 changed files with 61 additions and 1 deletions

View File

@@ -3,7 +3,9 @@
<div <div
v-if=" v-if="
testResults && testResults &&
(testResults.expectResults.length || testResults.tests.length) (testResults.expectResults.length ||
testResults.tests.length ||
haveEnvVariables)
" "
> >
<div <div
@@ -20,6 +22,31 @@
/> />
</div> </div>
<div class="border-b divide-y-4 divide-dividerLight border-dividerLight"> <div class="border-b divide-y-4 divide-dividerLight border-dividerLight">
<div v-if="haveEnvVariables" class="flex flex-col">
<details class="flex flex-col divide-y divide-dividerLight" open>
<summary
class="flex items-center justify-between flex-1 min-w-0 cursor-pointer transition focus:outline-none text-secondaryLight text-tiny group"
>
<span
class="px-4 py-2 truncate transition group-hover:text-secondary capitalize-first"
>
{{ t("environment.title") }}
</span>
</summary>
<div class="divide-y divide-dividerLight">
<HttpTestResultEnv
v-for="(env, index) in testResults.envDiff.global.updations"
:key="`env-${env.key}-${index}`"
:env="env"
/>
<HttpTestResultEnv
v-for="(env, index) in testResults.envDiff.selected.updations"
:key="`env-${env.key}-${index}`"
:env="env"
/>
</div>
</details>
</div>
<div v-if="testResults.tests" class="divide-y-4 divide-dividerLight"> <div v-if="testResults.tests" class="divide-y-4 divide-dividerLight">
<HttpTestResultEntry <HttpTestResultEntry
v-for="(result, index) in testResults.tests" v-for="(result, index) in testResults.tests"
@@ -111,6 +138,7 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { computed } from "@nuxtjs/composition-api"
import { useReadonlyStream, useI18n } from "~/helpers/utils/composables" import { useReadonlyStream, useI18n } from "~/helpers/utils/composables"
import { restTestResults$, setRESTTestResults } from "~/newstore/RESTSession" import { restTestResults$, setRESTTestResults } from "~/newstore/RESTSession"
@@ -119,4 +147,12 @@ const t = useI18n()
const testResults = useReadonlyStream(restTestResults$, null) const testResults = useReadonlyStream(restTestResults$, null)
const clearContent = () => setRESTTestResults(null) const clearContent = () => setRESTTestResults(null)
const haveEnvVariables = computed(() => {
if (!testResults.value) return false
return (
testResults.value.envDiff.global.updations.length ||
testResults.value.envDiff.selected.updations.length
)
})
</script> </script>

View File

@@ -0,0 +1,24 @@
<template>
<div class="flex items-center px-4 py-2">
<i class="mr-4 material-icons text-accentLight"> lock </i>
<span class="text-secondaryDark">
{{ env.key }}
</span>
<span class="text-secondaryDark">
{{ ` \xA0 — \xA0 ${env.value}` }}
</span>
<span class="text-secondaryLight">
{{ ` \xA0 ← \xA0 ${env.previousValue}` }}
</span>
</div>
</template>
<script setup lang="ts">
defineProps<{
env: {
key: string
value: string
previousValue: string
}
}>()
</script>