TestResultReport.vue 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <template>
  2. <div class="flex p-2 items-center">
  3. <SmartProgressRing
  4. class="text-red-500"
  5. :radius="16"
  6. :stroke="4"
  7. :progress="(failedTests / totalTests) * 100"
  8. />
  9. <div class="ml-2">
  10. <span v-if="failedTests" class="text-red-500">
  11. {{ failedTests }} failing,
  12. </span>
  13. <span v-if="passedTests" class="text-green-500">
  14. {{ passedTests }} successful,
  15. </span>
  16. <span> out of {{ totalTests }} tests. </span>
  17. </div>
  18. </div>
  19. </template>
  20. <script setup lang="ts">
  21. import { computed, PropType } from "@nuxtjs/composition-api"
  22. import { HoppTestResult } from "~/helpers/types/HoppTestResult"
  23. const props = defineProps({
  24. testResults: {
  25. type: Object as PropType<HoppTestResult>,
  26. required: true,
  27. },
  28. })
  29. const totalTests = computed(() => props.testResults.expectResults.length)
  30. const failedTests = computed(
  31. () =>
  32. props.testResults.expectResults.filter(
  33. (result: { status: string }) => result.status === "fail"
  34. ).length
  35. )
  36. const passedTests = computed(
  37. () =>
  38. props.testResults.expectResults.filter(
  39. (result: { status: string }) => result.status === "pass"
  40. ).length
  41. )
  42. </script>