feat: test report pie chart
This commit is contained in:
@@ -1,10 +1,15 @@
|
|||||||
<template>
|
<template>
|
||||||
<AppSection :label="$t('test.results')">
|
<AppSection :label="$t('test.results')">
|
||||||
<div v-if="testResults && (testResults.expectResults || testResults.tests)">
|
<div
|
||||||
|
v-if="
|
||||||
|
testResults &&
|
||||||
|
(testResults.expectResults.length || testResults.tests.length)
|
||||||
|
"
|
||||||
|
>
|
||||||
<div
|
<div
|
||||||
class="
|
class="
|
||||||
bg-primary
|
bg-primary
|
||||||
border-b border-dividerLight
|
border-dividerLight border-b
|
||||||
flex flex-1
|
flex flex-1
|
||||||
top-lowerSecondaryStickyFold
|
top-lowerSecondaryStickyFold
|
||||||
pl-4
|
pl-4
|
||||||
@@ -24,25 +29,8 @@
|
|||||||
@click.native="clearContent()"
|
@click.native="clearContent()"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex p-2 items-center">
|
<div class="divide-dividerLight border-dividerLight border-b divide-y-4">
|
||||||
<SmartProgressRing
|
<div v-if="testResults.tests" class="divide-dividerLight divide-y-4">
|
||||||
class="text-red-500"
|
|
||||||
:radius="16"
|
|
||||||
:stroke="4"
|
|
||||||
:progress="(failedTests / totalTests) * 100"
|
|
||||||
/>
|
|
||||||
<div class="ml-2">
|
|
||||||
<span v-if="failedTests" class="text-red-500">
|
|
||||||
{{ failedTests }} failing,
|
|
||||||
</span>
|
|
||||||
<span v-if="passedTests" class="text-green-500">
|
|
||||||
{{ passedTests }} successful,
|
|
||||||
</span>
|
|
||||||
<span> out of {{ totalTests }} tests. </span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="divide-y divide-dividerLight">
|
|
||||||
<div v-if="testResults.tests">
|
|
||||||
<HttpTestResultEntry
|
<HttpTestResultEntry
|
||||||
v-for="(result, index) in testResults.tests"
|
v-for="(result, index) in testResults.tests"
|
||||||
:key="`result-${index}`"
|
:key="`result-${index}`"
|
||||||
@@ -51,8 +39,12 @@
|
|||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
v-if="testResults.expectResults"
|
v-if="testResults.expectResults"
|
||||||
class="divide-y divide-dividerLight"
|
class="divide-dividerLight divide-y"
|
||||||
>
|
>
|
||||||
|
<HttpTestResultReport
|
||||||
|
v-if="testResults.expectResults.length"
|
||||||
|
:test-results="testResults"
|
||||||
|
/>
|
||||||
<div
|
<div
|
||||||
v-for="(result, index) in testResults.expectResults"
|
v-for="(result, index) in testResults.expectResults"
|
||||||
:key="`result-${index}`"
|
:key="`result-${index}`"
|
||||||
@@ -103,25 +95,10 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { computed } from "@nuxtjs/composition-api"
|
|
||||||
import { useReadonlyStream } from "~/helpers/utils/composables"
|
import { useReadonlyStream } from "~/helpers/utils/composables"
|
||||||
import { restTestResults$, setRESTTestResults } from "~/newstore/RESTSession"
|
import { restTestResults$, setRESTTestResults } from "~/newstore/RESTSession"
|
||||||
|
|
||||||
const testResults = useReadonlyStream(restTestResults$, null)
|
const testResults = useReadonlyStream(restTestResults$, null)
|
||||||
|
|
||||||
const totalTests = computed(() => testResults.value?.expectResults.length)
|
|
||||||
const failedTests = computed(
|
|
||||||
() =>
|
|
||||||
testResults.value?.expectResults.filter(
|
|
||||||
(result: { status: string }) => result.status === "fail"
|
|
||||||
).length
|
|
||||||
)
|
|
||||||
const passedTests = computed(
|
|
||||||
() =>
|
|
||||||
testResults.value?.expectResults.filter(
|
|
||||||
(result: { status: string }) => result.status === "pass"
|
|
||||||
).length
|
|
||||||
)
|
|
||||||
|
|
||||||
const clearContent = () => setRESTTestResults(null)
|
const clearContent = () => setRESTTestResults(null)
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -2,18 +2,15 @@
|
|||||||
<div>
|
<div>
|
||||||
<span
|
<span
|
||||||
v-if="testResults.description"
|
v-if="testResults.description"
|
||||||
class="
|
class="flex font-bold text-secondaryDark py-2 px-4 items-center"
|
||||||
border-b border-dividerLight
|
|
||||||
flex
|
|
||||||
text-secondaryDark
|
|
||||||
py-2
|
|
||||||
px-4
|
|
||||||
items-center
|
|
||||||
"
|
|
||||||
>
|
>
|
||||||
{{ testResults.description }}
|
{{ testResults.description }}
|
||||||
</span>
|
</span>
|
||||||
<div v-if="testResults.expectResults" class="divide-y divide-dividerLight">
|
<div v-if="testResults.expectResults" class="divide-y divide-dividerLight">
|
||||||
|
<HttpTestResultReport
|
||||||
|
v-if="testResults.expectResults.length"
|
||||||
|
:test-results="testResults"
|
||||||
|
/>
|
||||||
<div
|
<div
|
||||||
v-for="(result, index) in testResults.expectResults"
|
v-for="(result, index) in testResults.expectResults"
|
||||||
:key="`result-${index}`"
|
:key="`result-${index}`"
|
||||||
|
|||||||
45
components/http/TestResultReport.vue
Normal file
45
components/http/TestResultReport.vue
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
<template>
|
||||||
|
<div class="flex p-2 items-center">
|
||||||
|
<SmartProgressRing
|
||||||
|
class="text-red-500"
|
||||||
|
:radius="16"
|
||||||
|
:stroke="4"
|
||||||
|
:progress="(failedTests / totalTests) * 100"
|
||||||
|
/>
|
||||||
|
<div class="ml-2">
|
||||||
|
<span v-if="failedTests" class="text-red-500">
|
||||||
|
{{ failedTests }} failing,
|
||||||
|
</span>
|
||||||
|
<span v-if="passedTests" class="text-green-500">
|
||||||
|
{{ passedTests }} successful,
|
||||||
|
</span>
|
||||||
|
<span> out of {{ totalTests }} tests. </span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { computed, PropType } from "@nuxtjs/composition-api"
|
||||||
|
import { HoppTestResult } from "~/helpers/types/HoppTestResult"
|
||||||
|
|
||||||
|
const props = defineProps({
|
||||||
|
testResults: {
|
||||||
|
type: Object as PropType<HoppTestResult>,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
const totalTests = computed(() => props.testResults.expectResults.length)
|
||||||
|
const failedTests = computed(
|
||||||
|
() =>
|
||||||
|
props.testResults.expectResults.filter(
|
||||||
|
(result: { status: string }) => result.status === "fail"
|
||||||
|
).length
|
||||||
|
)
|
||||||
|
const passedTests = computed(
|
||||||
|
() =>
|
||||||
|
props.testResults.expectResults.filter(
|
||||||
|
(result: { status: string }) => result.status === "pass"
|
||||||
|
).length
|
||||||
|
)
|
||||||
|
</script>
|
||||||
@@ -9,9 +9,8 @@ pw.test("Status code is 200", ()=> {
|
|||||||
{
|
{
|
||||||
name: "Response: Assert property from body",
|
name: "Response: Assert property from body",
|
||||||
script: `\n\n// Check JSON response property
|
script: `\n\n// Check JSON response property
|
||||||
pw.test("Status code is 200", ()=> {
|
pw.test("Check JSON response property", ()=> {
|
||||||
const body = pw.response.body.json();
|
pw.expect(pw.response.method).toBe("GET");
|
||||||
pw.expect(body.property).toBe("value");
|
|
||||||
});`,
|
});`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user