mirror of
https://github.com/vitest-dev/vitest.git
synced 2025-12-08 18:26:03 +00:00
36 lines
970 B
Vue
36 lines
970 B
Vue
<script setup lang="ts">
|
|
import type { TestAnnotation } from 'vitest'
|
|
import { computed } from 'vue'
|
|
import { getAttachmentUrl, isExternalAttachment } from '~/composables/attachments'
|
|
|
|
const props = defineProps<{
|
|
annotation: TestAnnotation
|
|
}>()
|
|
|
|
const href = computed<string>(() => {
|
|
const attachment = props.annotation.attachment!
|
|
const potentialUrl = attachment.path || attachment.body
|
|
if (typeof potentialUrl === 'string' && (potentialUrl.startsWith('http://') || potentialUrl.startsWith('https://'))) {
|
|
return potentialUrl
|
|
}
|
|
else {
|
|
return getAttachmentUrl(attachment)
|
|
}
|
|
})
|
|
</script>
|
|
|
|
<template>
|
|
<a
|
|
v-if="annotation.attachment && annotation.attachment.contentType?.startsWith('image/')"
|
|
target="_blank"
|
|
class="inline-block mt-2"
|
|
:style="{ maxWidth: '600px' }"
|
|
:href="href"
|
|
:referrerPolicy="isExternalAttachment(annotation.attachment) ? 'no-referrer' : undefined"
|
|
>
|
|
<img
|
|
:src="href"
|
|
>
|
|
</a>
|
|
</template>
|