TestResultReport.vue 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <template>
  2. <div class="flex items-center p-2">
  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 {
  23. HoppTestExpectResult,
  24. HoppTestResult,
  25. } from "~/helpers/types/HoppTestResult"
  26. const props = defineProps({
  27. testResults: {
  28. type: Object as PropType<HoppTestResult>,
  29. required: true,
  30. expectResults: [] as HoppTestExpectResult[],
  31. },
  32. })
  33. const totalTests = computed(() => props.testResults.expectResults.length)
  34. const failedTests = computed(
  35. () =>
  36. props.testResults.expectResults.filter(
  37. (result: { status: string }) => result.status === "fail"
  38. ).length
  39. )
  40. const passedTests = computed(
  41. () =>
  42. props.testResults.expectResults.filter(
  43. (result: { status: string }) => result.status === "pass"
  44. ).length
  45. )
  46. </script>