TestResult.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. <template>
  2. <AppSection :label="$t('test.results')">
  3. <div
  4. v-if="
  5. testResults &&
  6. (testResults.expectResults.length || testResults.tests.length)
  7. "
  8. >
  9. <div
  10. class="
  11. bg-primary
  12. border-dividerLight border-b
  13. flex flex-1
  14. top-lowerSecondaryStickyFold
  15. pl-4
  16. z-10
  17. sticky
  18. items-center
  19. justify-between
  20. "
  21. >
  22. <label class="font-semibold text-secondaryLight">
  23. {{ $t("test.report") }}
  24. </label>
  25. <ButtonSecondary
  26. v-tippy="{ theme: 'tooltip' }"
  27. :title="$t('action.clear')"
  28. svg="trash-2"
  29. @click.native="clearContent()"
  30. />
  31. </div>
  32. <div class="divide-dividerLight border-dividerLight border-b divide-y-4">
  33. <div v-if="testResults.tests" class="divide-dividerLight divide-y-4">
  34. <HttpTestResultEntry
  35. v-for="(result, index) in testResults.tests"
  36. :key="`result-${index}`"
  37. :test-results="result"
  38. />
  39. </div>
  40. <div
  41. v-if="testResults.expectResults"
  42. class="divide-dividerLight divide-y"
  43. >
  44. <HttpTestResultReport
  45. v-if="testResults.expectResults.length"
  46. :test-results="testResults"
  47. />
  48. <div
  49. v-for="(result, index) in testResults.expectResults"
  50. :key="`result-${index}`"
  51. class="flex py-2 px-4 items-center"
  52. >
  53. <i
  54. class="mr-4 material-icons"
  55. :class="
  56. result.status === 'pass' ? 'text-green-500' : 'text-red-500'
  57. "
  58. >
  59. {{ result.status === "pass" ? "check" : "close" }}
  60. </i>
  61. <span v-if="result.message" class="text-secondaryDark">
  62. {{ result.message }}
  63. </span>
  64. <span class="text-secondaryLight">
  65. {{
  66. ` \xA0 — \xA0test ${
  67. result.status === "pass" ? $t("passed") : $t("failed")
  68. }`
  69. }}
  70. </span>
  71. </div>
  72. </div>
  73. </div>
  74. </div>
  75. <div
  76. v-else
  77. class="flex flex-col text-secondaryLight p-4 items-center justify-center"
  78. >
  79. <span class="text-center pb-2">
  80. {{ $t("empty.tests") }}
  81. </span>
  82. <span class="text-center pb-4">
  83. {{ $t("helpers.tests") }}
  84. </span>
  85. <ButtonSecondary
  86. outline
  87. :label="$t('action.learn_more')"
  88. to="https://docs.hoppscotch.io"
  89. blank
  90. svg="external-link"
  91. reverse
  92. />
  93. </div>
  94. </AppSection>
  95. </template>
  96. <script setup lang="ts">
  97. import { useReadonlyStream } from "~/helpers/utils/composables"
  98. import { restTestResults$, setRESTTestResults } from "~/newstore/RESTSession"
  99. const testResults = useReadonlyStream(restTestResults$, null)
  100. const clearContent = () => setRESTTestResults(null)
  101. </script>