@scalar/pre-post-request-scripts 0.3.12 → 0.3.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/dist/_virtual/_plugin-vue_export-helper.js +8 -0
- package/dist/components/ViewLayout/ValueEmitter.vue.js +7 -0
- package/dist/components/ViewLayout/ValueEmitter.vue.js.map +1 -0
- package/dist/components/ViewLayout/ValueEmitter.vue.script.js +18 -0
- package/dist/components/ViewLayout/ValueEmitter.vue.script.js.map +1 -0
- package/dist/components/ViewLayout/ViewLayoutCollapse.vue.js +7 -0
- package/dist/components/ViewLayout/ViewLayoutCollapse.vue.js.map +1 -0
- package/dist/{ViewLayoutCollapse-BMrPz_sj.js → components/ViewLayout/ViewLayoutCollapse.vue.script.js} +5 -22
- package/dist/components/ViewLayout/ViewLayoutCollapse.vue.script.js.map +1 -0
- package/dist/components/ViewLayout/index.d.ts +1 -1
- package/dist/consts/example-scripts.js +82 -0
- package/dist/consts/example-scripts.js.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -3
- package/dist/libs/execute-scripts/context/console.js +14 -0
- package/dist/libs/execute-scripts/context/console.js.map +1 -0
- package/dist/libs/execute-scripts/execute-post-response-script.js +16 -0
- package/dist/libs/execute-scripts/execute-post-response-script.js.map +1 -0
- package/dist/libs/execute-scripts/index.d.ts +1 -1
- package/dist/libs/execute-scripts/index.js +1 -1
- package/dist/libs/execute-scripts/postman-sandbox-adapter.d.ts +2 -2
- package/dist/{execute-scripts-BV13zq7B.js → libs/execute-scripts/postman-sandbox-adapter.js} +2 -24
- package/dist/libs/execute-scripts/postman-sandbox-adapter.js.map +1 -0
- package/dist/plugins/post-response-scripts/components/PostResponseScripts/ExampleScripts.vue.js +7 -0
- package/dist/plugins/post-response-scripts/components/PostResponseScripts/ExampleScripts.vue.js.map +1 -0
- package/dist/plugins/post-response-scripts/components/PostResponseScripts/ExampleScripts.vue.script.js +35 -0
- package/dist/plugins/post-response-scripts/components/PostResponseScripts/ExampleScripts.vue.script.js.map +1 -0
- package/dist/plugins/post-response-scripts/components/PostResponseScripts/PostResponseScripts.vue.js +7 -0
- package/dist/plugins/post-response-scripts/components/PostResponseScripts/PostResponseScripts.vue.js.map +1 -0
- package/dist/plugins/post-response-scripts/components/PostResponseScripts/PostResponseScripts.vue.script.js +49 -0
- package/dist/plugins/post-response-scripts/components/PostResponseScripts/PostResponseScripts.vue.script.js.map +1 -0
- package/dist/plugins/post-response-scripts/components/PostResponseScripts/ScriptEditor.vue.js +9 -0
- package/dist/plugins/post-response-scripts/components/PostResponseScripts/ScriptEditor.vue.js.map +1 -0
- package/dist/plugins/post-response-scripts/components/PostResponseScripts/ScriptEditor.vue.script.js +36 -0
- package/dist/plugins/post-response-scripts/components/PostResponseScripts/ScriptEditor.vue.script.js.map +1 -0
- package/dist/plugins/post-response-scripts/components/PostResponseScripts/index.d.ts +1 -1
- package/dist/plugins/post-response-scripts/components/PostResponseScripts/index.js +1 -1
- package/dist/plugins/post-response-scripts/components/TestResults/TestResultIndicator.vue.js +7 -0
- package/dist/plugins/post-response-scripts/components/TestResults/TestResultIndicator.vue.js.map +1 -0
- package/dist/plugins/post-response-scripts/components/TestResults/TestResultIndicator.vue.script.js +70 -0
- package/dist/plugins/post-response-scripts/components/TestResults/TestResultIndicator.vue.script.js.map +1 -0
- package/dist/plugins/post-response-scripts/components/TestResults/TestResultItem.vue.js +7 -0
- package/dist/plugins/post-response-scripts/components/TestResults/TestResultItem.vue.js.map +1 -0
- package/dist/plugins/post-response-scripts/components/TestResults/TestResultItem.vue.script.js +45 -0
- package/dist/plugins/post-response-scripts/components/TestResults/TestResultItem.vue.script.js.map +1 -0
- package/dist/plugins/post-response-scripts/components/TestResults/TestResults.vue.js +7 -0
- package/dist/plugins/post-response-scripts/components/TestResults/TestResults.vue.js.map +1 -0
- package/dist/plugins/post-response-scripts/components/TestResults/TestResults.vue.script.js +73 -0
- package/dist/plugins/post-response-scripts/components/TestResults/TestResults.vue.script.js.map +1 -0
- package/dist/plugins/post-response-scripts/components/TestResults/TestSummary.vue.js +7 -0
- package/dist/plugins/post-response-scripts/components/TestResults/TestSummary.vue.js.map +1 -0
- package/dist/plugins/post-response-scripts/components/TestResults/TestSummary.vue.script.js +45 -0
- package/dist/plugins/post-response-scripts/components/TestResults/TestSummary.vue.script.js.map +1 -0
- package/dist/plugins/post-response-scripts/components/TestResults/index.d.ts +1 -1
- package/dist/plugins/post-response-scripts/components/TestResults/index.js +1 -1
- package/dist/plugins/post-response-scripts/index.d.ts +1 -1
- package/dist/plugins/post-response-scripts/index.js +1 -2
- package/dist/{post-response-scripts-ikk1wrl9.js → plugins/post-response-scripts/post-response-scripts-plugin.js} +5 -5
- package/dist/plugins/post-response-scripts/post-response-scripts-plugin.js.map +1 -0
- package/package.json +5 -5
- package/dist/PostResponseScripts-CrM65oAM.js +0 -202
- package/dist/PostResponseScripts-CrM65oAM.js.map +0 -1
- package/dist/TestResults-DIM8u91u.js +0 -224
- package/dist/TestResults-DIM8u91u.js.map +0 -1
- package/dist/ViewLayoutCollapse-BMrPz_sj.js.map +0 -1
- package/dist/execute-scripts-BV13zq7B.js.map +0 -1
- package/dist/post-response-scripts-ikk1wrl9.js.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PostResponseScripts-CrM65oAM.js","names":[],"sources":["../src/consts/example-scripts.ts","../src/plugins/post-response-scripts/components/PostResponseScripts/ExampleScripts.vue","../src/plugins/post-response-scripts/components/PostResponseScripts/ExampleScripts.vue","../src/plugins/post-response-scripts/components/PostResponseScripts/ScriptEditor.vue","../src/plugins/post-response-scripts/components/PostResponseScripts/ScriptEditor.vue","../src/plugins/post-response-scripts/components/PostResponseScripts/PostResponseScripts.vue","../src/plugins/post-response-scripts/components/PostResponseScripts/PostResponseScripts.vue"],"sourcesContent":["type ExampleScript = {\n title: string\n script: string\n mockResponse: {\n body?: any\n status?: number\n headers?: Record<string, string>\n text?: () => string\n }\n}\n\nexport const EXAMPLE_SCRIPTS: ExampleScript[] = [\n {\n title: 'Check the status code',\n script: `pm.test(\"Status code is 200\", () => {\n pm.response.to.have.status(200)\n})`,\n mockResponse: {\n status: 200,\n body: { success: true },\n },\n },\n // TODO: We didn't add the proper response duration yet.\n // {\n // title: 'Check response time',\n // script: `pm.test(\"Response time is acceptable\", () => {\n // pm.expect(pm.response.responseTime).to.be.below(200)\n // })`,\n // mockResponse: {\n // status: 200,\n // body: { success: true },\n // },\n // },\n {\n title: 'Check JSON response',\n script: `pm.test(\"Response is valid JSON\", () => {\n const responseData = pm.response.json()\n pm.expect(responseData).to.be.an('object')\n})`,\n mockResponse: {\n status: 200,\n body: { data: 'test' },\n headers: { 'Content-Type': 'application/json' },\n },\n },\n {\n title: 'Check response headers',\n script: `pm.test(\"Content-Type header is present\", () => {\n pm.response.to.have.header('Content-Type')\n})`,\n mockResponse: {\n status: 200,\n body: { success: true },\n headers: { 'Content-Type': 'application/json' },\n },\n },\n {\n title: 'Validate JSON schema',\n script: `pm.test(\"Response matches schema\", () => {\n const schema = {\n type: 'object',\n required: ['id', 'name'],\n properties: {\n id: { type: 'number' },\n name: { type: 'string' }\n }\n }\n pm.response.to.have.jsonSchema(schema)\n})`,\n mockResponse: {\n status: 200,\n body: { id: 1, name: 'Test Item' },\n headers: { 'Content-Type': 'application/json' },\n },\n },\n {\n title: 'Check response body',\n script: `pm.test(\"Response body contains string\", () => {\n pm.expect(pm.response.text()).to.include('success')\n})`,\n mockResponse: {\n status: 200,\n body: 'This is a successful response',\n },\n },\n {\n title: 'Successful POST request',\n script: `pm.test(\"Successful POST request\", () => {\n pm.expect(pm.response.code).to.be.oneOf([201, 202])\n})`,\n mockResponse: {\n status: 201,\n body: { success: true },\n },\n },\n]\n","<script setup lang=\"ts\">\nimport { EXAMPLE_SCRIPTS } from '@/consts/example-scripts'\n\nconst props = defineProps<{\n modelValue: string\n}>()\n\nconst emit = defineEmits<{\n (e: 'update:modelValue', value: string): void\n}>()\n\nconst addExample = (example: string) => {\n let addition = example\n // Look at current value. If it's not empty, add a new line.\n if (props.modelValue.trim() !== '') {\n addition = `\\n\\n${addition}`\n }\n\n emit('update:modelValue', props.modelValue.trim() + addition)\n}\n</script>\n\n<template>\n <ul class=\"flex flex-wrap gap-1\">\n <li\n v-for=\"example in EXAMPLE_SCRIPTS\"\n :key=\"example.title\"\n class=\"bg-b-2 text-c-2 hover:bg-b-3 inline-flex flex-col rounded-full px-3 py-1 text-xs font-medium\">\n <button\n class=\"w-full\"\n type=\"button\"\n @click=\"addExample(example.script)\">\n {{ example.title }}\n </button>\n </li>\n </ul>\n</template>\n","<script setup lang=\"ts\">\nimport { EXAMPLE_SCRIPTS } from '@/consts/example-scripts'\n\nconst props = defineProps<{\n modelValue: string\n}>()\n\nconst emit = defineEmits<{\n (e: 'update:modelValue', value: string): void\n}>()\n\nconst addExample = (example: string) => {\n let addition = example\n // Look at current value. If it's not empty, add a new line.\n if (props.modelValue.trim() !== '') {\n addition = `\\n\\n${addition}`\n }\n\n emit('update:modelValue', props.modelValue.trim() + addition)\n}\n</script>\n\n<template>\n <ul class=\"flex flex-wrap gap-1\">\n <li\n v-for=\"example in EXAMPLE_SCRIPTS\"\n :key=\"example.title\"\n class=\"bg-b-2 text-c-2 hover:bg-b-3 inline-flex flex-col rounded-full px-3 py-1 text-xs font-medium\">\n <button\n class=\"w-full\"\n type=\"button\"\n @click=\"addExample(example.script)\">\n {{ example.title }}\n </button>\n </li>\n </ul>\n</template>\n","<script setup lang=\"ts\">\nimport { javascript } from '@codemirror/lang-javascript'\nimport { useCodeMirror } from '@scalar/use-codemirror'\nimport { ref, toRef } from 'vue'\n\nconst props = defineProps<{\n modelValue: string\n}>()\n\nconst emit = defineEmits<{\n (e: 'update:modelValue', value: string): void\n}>()\n\nconst codeMirrorRef = ref<HTMLDivElement | null>(null)\n\nuseCodeMirror({\n codeMirrorRef,\n content: toRef(() => props.modelValue),\n language: undefined,\n // We want to use some custom configuration for the syntax highlighting.\n extensions: [javascript()],\n lineNumbers: true,\n onChange: (value) => {\n emit('update:modelValue', value)\n },\n})\n</script>\n\n<template>\n <div class=\"script-editor text-sm\">\n <div\n ref=\"codeMirrorRef\"\n class=\"editor-container\" />\n </div>\n</template>\n\n<style scoped>\n.script-editor {\n width: 100%;\n height: 100%;\n position: relative;\n}\n\n.editor-container {\n width: 100%;\n height: 100%;\n background: var(--scalar-background-1);\n border-radius: var(--scalar-radius);\n overflow: hidden;\n padding-left: 3px;\n}\n\n:deep(.cm-editor) {\n height: 100%;\n outline: none;\n background: var(--scalar-background-1);\n}\n\n:deep(.cm-content) {\n font-family: var(--scalar-font-code);\n font-size: var(--scalar-small);\n padding: 8px 2px;\n}\n\n:deep(.cm-gutters) {\n border-right: none;\n color: var(--scalar-color-3);\n background: var(--scalar-background-1);\n font-size: var(--scalar-mini);\n line-height: 1.44;\n}\n\n:deep(.cm-gutters:before) {\n content: '';\n position: absolute;\n top: 2px;\n left: 2px;\n width: calc(100% - 2px);\n height: calc(100% - 4px);\n border-radius: var(--scalar-radius) 0 0 var(--scalar-radius);\n}\n\n:deep(.cm-gutterElement) {\n font-family: var(--scalar-font-code) !important;\n display: flex;\n align-items: center;\n justify-content: flex-end;\n position: relative;\n}\n\n:deep(.cm-scroller) {\n overflow: auto;\n}\n\n:deep(.cm-activeLine),\n:deep(.cm-activeLineGutter) {\n background-color: var(--scalar-background-2);\n}\n\n:deep(.cm-selectionMatch),\n:deep(.cm-matchingBracket) {\n border-radius: var(--scalar-radius);\n background: var(--scalar-background-4) !important;\n}\n\n:deep(.cm-tooltip) {\n background: var(--scalar-background-1) !important;\n border: 1px solid var(--scalar-border-color) !important;\n border-radius: var(--scalar-radius);\n box-shadow: var(--scalar-shadow-2);\n}\n</style>\n","<script setup lang=\"ts\">\nimport { javascript } from '@codemirror/lang-javascript'\nimport { useCodeMirror } from '@scalar/use-codemirror'\nimport { ref, toRef } from 'vue'\n\nconst props = defineProps<{\n modelValue: string\n}>()\n\nconst emit = defineEmits<{\n (e: 'update:modelValue', value: string): void\n}>()\n\nconst codeMirrorRef = ref<HTMLDivElement | null>(null)\n\nuseCodeMirror({\n codeMirrorRef,\n content: toRef(() => props.modelValue),\n language: undefined,\n // We want to use some custom configuration for the syntax highlighting.\n extensions: [javascript()],\n lineNumbers: true,\n onChange: (value) => {\n emit('update:modelValue', value)\n },\n})\n</script>\n\n<template>\n <div class=\"script-editor text-sm\">\n <div\n ref=\"codeMirrorRef\"\n class=\"editor-container\" />\n </div>\n</template>\n\n<style scoped>\n.script-editor {\n width: 100%;\n height: 100%;\n position: relative;\n}\n\n.editor-container {\n width: 100%;\n height: 100%;\n background: var(--scalar-background-1);\n border-radius: var(--scalar-radius);\n overflow: hidden;\n padding-left: 3px;\n}\n\n:deep(.cm-editor) {\n height: 100%;\n outline: none;\n background: var(--scalar-background-1);\n}\n\n:deep(.cm-content) {\n font-family: var(--scalar-font-code);\n font-size: var(--scalar-small);\n padding: 8px 2px;\n}\n\n:deep(.cm-gutters) {\n border-right: none;\n color: var(--scalar-color-3);\n background: var(--scalar-background-1);\n font-size: var(--scalar-mini);\n line-height: 1.44;\n}\n\n:deep(.cm-gutters:before) {\n content: '';\n position: absolute;\n top: 2px;\n left: 2px;\n width: calc(100% - 2px);\n height: calc(100% - 4px);\n border-radius: var(--scalar-radius) 0 0 var(--scalar-radius);\n}\n\n:deep(.cm-gutterElement) {\n font-family: var(--scalar-font-code) !important;\n display: flex;\n align-items: center;\n justify-content: flex-end;\n position: relative;\n}\n\n:deep(.cm-scroller) {\n overflow: auto;\n}\n\n:deep(.cm-activeLine),\n:deep(.cm-activeLineGutter) {\n background-color: var(--scalar-background-2);\n}\n\n:deep(.cm-selectionMatch),\n:deep(.cm-matchingBracket) {\n border-radius: var(--scalar-radius);\n background: var(--scalar-background-4) !important;\n}\n\n:deep(.cm-tooltip) {\n background: var(--scalar-background-1) !important;\n border: 1px solid var(--scalar-border-color) !important;\n border-radius: var(--scalar-radius);\n box-shadow: var(--scalar-shadow-2);\n}\n</style>\n","<script setup lang=\"ts\">\nimport type { Operation } from '@scalar/oas-utils/entities/spec'\nimport { computed } from 'vue'\n\nimport { ViewLayoutCollapse } from '@/components/ViewLayout'\n\nimport ExampleScripts from './ExampleScripts.vue'\nimport ScriptEditor from './ScriptEditor.vue'\n\nconst { operation } = defineProps<{\n operation: Pick<Operation, 'x-post-response'>\n}>()\n\nconst emit = defineEmits<{\n (e: 'operation:update:extension', payload: any): void\n}>()\n\nconst script = computed(() => (operation['x-post-response'] as string) || '')\n\nconst updatePostResponseScript = (value: string) => {\n emit('operation:update:extension', {\n 'x-post-response': value,\n })\n}\n</script>\n\n<template>\n <div class=\"w-full\">\n <ViewLayoutCollapse\n class=\"w-full\"\n :defaultOpen=\"true\">\n <template #title>Scripts</template>\n <template #suffix>\n <!-- Show an indicator whether we have a script -->\n <div class=\"mr-2\">\n <div\n v-if=\"script.length > 0\"\n class=\"bg-green h-2 w-2 rounded-full\" />\n </div>\n </template>\n\n <div class=\"text-c-3 flex h-8 items-center border-y px-3 text-sm\">\n Post-Response\n </div>\n\n <ScriptEditor\n :modelValue=\"script\"\n @update:modelValue=\"updatePostResponseScript\" />\n\n <div class=\"border-y p-3\">\n <ExampleScripts\n :modelValue=\"script\"\n @update:modelValue=\"updatePostResponseScript\" />\n </div>\n </ViewLayoutCollapse>\n </div>\n</template>\n","<script setup lang=\"ts\">\nimport type { Operation } from '@scalar/oas-utils/entities/spec'\nimport { computed } from 'vue'\n\nimport { ViewLayoutCollapse } from '@/components/ViewLayout'\n\nimport ExampleScripts from './ExampleScripts.vue'\nimport ScriptEditor from './ScriptEditor.vue'\n\nconst { operation } = defineProps<{\n operation: Pick<Operation, 'x-post-response'>\n}>()\n\nconst emit = defineEmits<{\n (e: 'operation:update:extension', payload: any): void\n}>()\n\nconst script = computed(() => (operation['x-post-response'] as string) || '')\n\nconst updatePostResponseScript = (value: string) => {\n emit('operation:update:extension', {\n 'x-post-response': value,\n })\n}\n</script>\n\n<template>\n <div class=\"w-full\">\n <ViewLayoutCollapse\n class=\"w-full\"\n :defaultOpen=\"true\">\n <template #title>Scripts</template>\n <template #suffix>\n <!-- Show an indicator whether we have a script -->\n <div class=\"mr-2\">\n <div\n v-if=\"script.length > 0\"\n class=\"bg-green h-2 w-2 rounded-full\" />\n </div>\n </template>\n\n <div class=\"text-c-3 flex h-8 items-center border-y px-3 text-sm\">\n Post-Response\n </div>\n\n <ScriptEditor\n :modelValue=\"script\"\n @update:modelValue=\"updatePostResponseScript\" />\n\n <div class=\"border-y p-3\">\n <ExampleScripts\n :modelValue=\"script\"\n @update:modelValue=\"updatePostResponseScript\" />\n </div>\n </ViewLayoutCollapse>\n </div>\n</template>\n"],"mappings":";;;;;AAWA,IAAa,kBAAmC;CAC9C;EACE,OAAO;EACP,QAAQ;;;EAGR,cAAc;GACZ,QAAQ;GACR,MAAM,EAAE,SAAS,MAAM;GACxB;EACF;CAYD;EACE,OAAO;EACP,QAAQ;;;;EAIR,cAAc;GACZ,QAAQ;GACR,MAAM,EAAE,MAAM,QAAQ;GACtB,SAAS,EAAE,gBAAgB,oBAAoB;GAChD;EACF;CACD;EACE,OAAO;EACP,QAAQ;;;EAGR,cAAc;GACZ,QAAQ;GACR,MAAM,EAAE,SAAS,MAAM;GACvB,SAAS,EAAE,gBAAgB,oBAAoB;GAChD;EACF;CACD;EACE,OAAO;EACP,QAAQ;;;;;;;;;;;EAWR,cAAc;GACZ,QAAQ;GACR,MAAM;IAAE,IAAI;IAAG,MAAM;IAAa;GAClC,SAAS,EAAE,gBAAgB,oBAAoB;GAChD;EACF;CACD;EACE,OAAO;EACP,QAAQ;;;EAGR,cAAc;GACZ,QAAQ;GACR,MAAM;GACP;EACF;CACD;EACE,OAAO;EACP,QAAQ;;;EAGR,cAAc;GACZ,QAAQ;GACR,MAAM,EAAE,SAAS,MAAM;GACxB;EACF;CACF;;;;;;;;;;;;EE5FD,MAAM,QAAQ;EAId,MAAM,OAAO;EAIb,MAAM,c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WAE0C,IAAA,mBAAA,IAAA,KAAA,CAAA,CAAA,CAAA,CAAA;2BAMxC;+BAFN,mBAEM,OAAA,EAFD,OAAM,wDAAsD,EAAC,mBAElE,GAAA;KAEA,YAEkD,sBAAA;MAD/C,YAAY,OAAA;MACZ,uBAAmB;;KAEtB,mBAIM,OAJN,YAIM,CAHJ,YAEkD,wBAAA;MAD/C,YAAY,OAAA;MACZ,uBAAmB"}
|
|
@@ -1,224 +0,0 @@
|
|
|
1
|
-
import { t as ViewLayoutCollapse_default } from "./ViewLayoutCollapse-BMrPz_sj.js";
|
|
2
|
-
import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createTextVNode, createVNode, defineComponent, guardReactiveProps, mergeProps, normalizeClass, normalizeProps, openBlock, renderList, toDisplayString, unref, withCtx } from "vue";
|
|
3
|
-
import { ScalarIcon, cva, useBindCx } from "@scalar/components";
|
|
4
|
-
//#region src/plugins/post-response-scripts/components/TestResults/TestResultIndicator.vue?vue&type=script&setup=true&lang.ts
|
|
5
|
-
var _hoisted_1$3 = {
|
|
6
|
-
key: 1,
|
|
7
|
-
class: "ml-1.25 capitalize"
|
|
8
|
-
};
|
|
9
|
-
//#endregion
|
|
10
|
-
//#region src/plugins/post-response-scripts/components/TestResults/TestResultIndicator.vue
|
|
11
|
-
var TestResultIndicator_default = /* @__PURE__ */ defineComponent({
|
|
12
|
-
__name: "TestResultIndicator",
|
|
13
|
-
props: {
|
|
14
|
-
state: {},
|
|
15
|
-
failedTestsCount: {},
|
|
16
|
-
pendingTestsCount: {},
|
|
17
|
-
totalTestsCount: {},
|
|
18
|
-
inline: { type: Boolean }
|
|
19
|
-
},
|
|
20
|
-
setup(__props) {
|
|
21
|
-
const { cx } = useBindCx();
|
|
22
|
-
const icon = computed(() => {
|
|
23
|
-
if (__props.state === "passed") return {
|
|
24
|
-
name: "Checkmark",
|
|
25
|
-
color: "text-green p-0.25"
|
|
26
|
-
};
|
|
27
|
-
if (__props.state === "failed") return {
|
|
28
|
-
name: "Close",
|
|
29
|
-
color: "text-red"
|
|
30
|
-
};
|
|
31
|
-
return {
|
|
32
|
-
name: "Ellipses",
|
|
33
|
-
color: "text-c-1"
|
|
34
|
-
};
|
|
35
|
-
});
|
|
36
|
-
const statusVariants = cva({
|
|
37
|
-
base: "flex items-center gap-1.5 rounded-full border pr-2 pl-1.25",
|
|
38
|
-
variants: { status: {
|
|
39
|
-
passed: "text-green",
|
|
40
|
-
failed: "text-red",
|
|
41
|
-
pending: "text-orange"
|
|
42
|
-
} }
|
|
43
|
-
});
|
|
44
|
-
const textVariants = cva({
|
|
45
|
-
base: "text-c-2",
|
|
46
|
-
variants: { inline: {
|
|
47
|
-
true: "text-xs",
|
|
48
|
-
false: "text-sm"
|
|
49
|
-
} }
|
|
50
|
-
});
|
|
51
|
-
const getTestCountDisplay = computed(() => {
|
|
52
|
-
if (__props.totalTestsCount === void 0) return "";
|
|
53
|
-
if (__props.failedTestsCount) return `${__props.failedTestsCount}/${__props.totalTestsCount}`;
|
|
54
|
-
return `${__props.totalTestsCount - (__props.pendingTestsCount || 0) - (__props.failedTestsCount || 0)}/${__props.totalTestsCount}`;
|
|
55
|
-
});
|
|
56
|
-
return (_ctx, _cache) => {
|
|
57
|
-
return openBlock(), createElementBlock("div", normalizeProps(guardReactiveProps(unref(cx)(unref(statusVariants)({ status: __props.state })))), [
|
|
58
|
-
__props.state ? (openBlock(), createBlock(unref(ScalarIcon), {
|
|
59
|
-
key: 0,
|
|
60
|
-
class: normalizeClass(icon.value.color),
|
|
61
|
-
icon: icon.value.name,
|
|
62
|
-
size: "sm"
|
|
63
|
-
}, null, 8, ["class", "icon"])) : createCommentVNode("", true),
|
|
64
|
-
!__props.inline ? (openBlock(), createElementBlock("span", _hoisted_1$3, toDisplayString(__props.state), 1)) : createCommentVNode("", true),
|
|
65
|
-
__props.totalTestsCount !== void 0 ? (openBlock(), createElementBlock("span", normalizeProps(mergeProps({ key: 2 }, unref(cx)(unref(textVariants)({ inline: __props.inline })))), toDisplayString(getTestCountDisplay.value), 17)) : createCommentVNode("", true)
|
|
66
|
-
], 16);
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
});
|
|
70
|
-
//#endregion
|
|
71
|
-
//#region src/plugins/post-response-scripts/components/TestResults/TestResultItem.vue?vue&type=script&setup=true&lang.ts
|
|
72
|
-
var _hoisted_1$2 = { class: "flex flex-col" };
|
|
73
|
-
var _hoisted_2$1 = { class: "flex items-center gap-3 p-2" };
|
|
74
|
-
var _hoisted_3$1 = { class: "text-c-2 overflow-hidden text-ellipsis whitespace-nowrap" };
|
|
75
|
-
var _hoisted_4 = { class: "text-c-3 ml-auto whitespace-nowrap" };
|
|
76
|
-
var _hoisted_5 = {
|
|
77
|
-
key: 0,
|
|
78
|
-
class: "bg-b-danger text-c-1 flex items-center pr-3 pb-1.5 pl-9"
|
|
79
|
-
};
|
|
80
|
-
//#endregion
|
|
81
|
-
//#region src/plugins/post-response-scripts/components/TestResults/TestResultItem.vue
|
|
82
|
-
var TestResultItem_default = /* @__PURE__ */ defineComponent({
|
|
83
|
-
__name: "TestResultItem",
|
|
84
|
-
props: {
|
|
85
|
-
result: {},
|
|
86
|
-
currentState: {}
|
|
87
|
-
},
|
|
88
|
-
setup(__props) {
|
|
89
|
-
const resultStatus = computed(() => {
|
|
90
|
-
if (__props.result.passed) return {
|
|
91
|
-
icon: "Checkmark",
|
|
92
|
-
color: "text-green p-0.25"
|
|
93
|
-
};
|
|
94
|
-
if (!__props.result.passed && __props.currentState !== "pending") return {
|
|
95
|
-
icon: "Close",
|
|
96
|
-
color: "text-red"
|
|
97
|
-
};
|
|
98
|
-
return {
|
|
99
|
-
icon: "Ellipses",
|
|
100
|
-
color: "text-c-1"
|
|
101
|
-
};
|
|
102
|
-
});
|
|
103
|
-
return (_ctx, _cache) => {
|
|
104
|
-
return openBlock(), createElementBlock("div", _hoisted_1$2, [createElementVNode("div", { class: normalizeClass(["flex h-8 items-center gap-2 pr-3 pl-2.25", __props.result.error && "bg-b-danger"]) }, [createElementVNode("div", _hoisted_2$1, [createVNode(unref(ScalarIcon), {
|
|
105
|
-
class: normalizeClass(resultStatus.value.color),
|
|
106
|
-
icon: resultStatus.value.icon,
|
|
107
|
-
size: "sm"
|
|
108
|
-
}, null, 8, ["class", "icon"]), createElementVNode("span", _hoisted_3$1, toDisplayString(__props.result.title), 1)]), createElementVNode("span", _hoisted_4, toDisplayString(__props.result.duration) + " ms ", 1)], 2), __props.result.error ? (openBlock(), createElementBlock("div", _hoisted_5, toDisplayString(__props.result.error), 1)) : createCommentVNode("", true)]);
|
|
109
|
-
};
|
|
110
|
-
}
|
|
111
|
-
});
|
|
112
|
-
//#endregion
|
|
113
|
-
//#region src/plugins/post-response-scripts/components/TestResults/TestSummary.vue?vue&type=script&setup=true&lang.ts
|
|
114
|
-
var _hoisted_1$1 = { class: "flex h-8 items-center gap-1.5 pr-3 pl-1" };
|
|
115
|
-
var _hoisted_2 = {
|
|
116
|
-
key: 0,
|
|
117
|
-
class: "text-orange"
|
|
118
|
-
};
|
|
119
|
-
var _hoisted_3 = { class: "text-c-3 ml-auto" };
|
|
120
|
-
//#endregion
|
|
121
|
-
//#region src/plugins/post-response-scripts/components/TestResults/TestSummary.vue
|
|
122
|
-
var TestSummary_default = /* @__PURE__ */ defineComponent({
|
|
123
|
-
__name: "TestSummary",
|
|
124
|
-
props: {
|
|
125
|
-
results: {},
|
|
126
|
-
passedTests: {},
|
|
127
|
-
failedTests: {},
|
|
128
|
-
pendingTests: {},
|
|
129
|
-
allTestsPassed: { type: Boolean },
|
|
130
|
-
totalDuration: {}
|
|
131
|
-
},
|
|
132
|
-
setup(__props) {
|
|
133
|
-
return (_ctx, _cache) => {
|
|
134
|
-
return openBlock(), createElementBlock("div", _hoisted_1$1, [
|
|
135
|
-
createVNode(TestResultIndicator_default, {
|
|
136
|
-
failedTestsCount: __props.failedTests?.length,
|
|
137
|
-
passedTestsCount: __props.passedTests?.length,
|
|
138
|
-
pendingTestsCount: __props.pendingTests?.length,
|
|
139
|
-
state: __props.allTestsPassed ? "passed" : "failed",
|
|
140
|
-
totalTestsCount: __props.results?.length
|
|
141
|
-
}, null, 8, [
|
|
142
|
-
"failedTestsCount",
|
|
143
|
-
"passedTestsCount",
|
|
144
|
-
"pendingTestsCount",
|
|
145
|
-
"state",
|
|
146
|
-
"totalTestsCount"
|
|
147
|
-
]),
|
|
148
|
-
__props.pendingTests?.length ? (openBlock(), createElementBlock("span", _hoisted_2, toDisplayString(__props.pendingTests?.length) + " Pending ", 1)) : createCommentVNode("", true),
|
|
149
|
-
createElementVNode("span", _hoisted_3, toDisplayString(__props.totalDuration.toFixed(1)) + " ms ", 1)
|
|
150
|
-
]);
|
|
151
|
-
};
|
|
152
|
-
}
|
|
153
|
-
});
|
|
154
|
-
//#endregion
|
|
155
|
-
//#region src/plugins/post-response-scripts/components/TestResults/TestResults.vue?vue&type=script&setup=true&lang.ts
|
|
156
|
-
var _hoisted_1 = { class: "max-h-[calc(100%-32px)] divide-y overflow-y-auto border-t" };
|
|
157
|
-
//#endregion
|
|
158
|
-
//#region src/plugins/post-response-scripts/components/TestResults/TestResults.vue
|
|
159
|
-
var TestResults_default = /* @__PURE__ */ defineComponent({
|
|
160
|
-
__name: "TestResults",
|
|
161
|
-
props: { results: {} },
|
|
162
|
-
setup(__props) {
|
|
163
|
-
const passedTests = computed(() => __props.results?.value?.filter((result) => result.status === "passed"));
|
|
164
|
-
const pendingTests = computed(() => __props.results?.value?.filter((result) => result.status === "pending"));
|
|
165
|
-
const failedTests = computed(() => __props.results?.value?.filter((result) => result.status === "failed"));
|
|
166
|
-
const allTestsPassed = computed(() => passedTests.value?.length === __props.results?.value?.length);
|
|
167
|
-
const currentState = computed(() => {
|
|
168
|
-
if (allTestsPassed.value) return "passed";
|
|
169
|
-
if (pendingTests.value?.length) return "pending";
|
|
170
|
-
return "failed";
|
|
171
|
-
});
|
|
172
|
-
const totalDuration = computed(() => __props.results?.value?.reduce((acc, curr) => acc + curr.duration, 0) ?? 0);
|
|
173
|
-
return (_ctx, _cache) => {
|
|
174
|
-
return __props.results?.value?.length ? (openBlock(), createBlock(unref(ViewLayoutCollapse_default), {
|
|
175
|
-
key: 0,
|
|
176
|
-
class: "overflow-auto text-sm",
|
|
177
|
-
defaultOpen: true
|
|
178
|
-
}, {
|
|
179
|
-
title: withCtx(() => [..._cache[0] || (_cache[0] = [createTextVNode(" Tests ", -1)])]),
|
|
180
|
-
suffix: withCtx(() => [createVNode(TestResultIndicator_default, {
|
|
181
|
-
failedTestsCount: failedTests.value?.length,
|
|
182
|
-
inline: "",
|
|
183
|
-
passedTestsCount: passedTests.value?.length,
|
|
184
|
-
pendingTestsCount: pendingTests.value?.length,
|
|
185
|
-
state: currentState.value,
|
|
186
|
-
totalTestsCount: __props.results?.value?.length
|
|
187
|
-
}, null, 8, [
|
|
188
|
-
"failedTestsCount",
|
|
189
|
-
"passedTestsCount",
|
|
190
|
-
"pendingTestsCount",
|
|
191
|
-
"state",
|
|
192
|
-
"totalTestsCount"
|
|
193
|
-
])]),
|
|
194
|
-
default: withCtx(() => [createElementVNode("div", _hoisted_1, [(openBlock(true), createElementBlock(Fragment, null, renderList(__props.results?.value, (result) => {
|
|
195
|
-
return openBlock(), createBlock(TestResultItem_default, {
|
|
196
|
-
key: result.title,
|
|
197
|
-
currentState: result.status,
|
|
198
|
-
result
|
|
199
|
-
}, null, 8, ["currentState", "result"]);
|
|
200
|
-
}), 128)), __props.results ? (openBlock(), createBlock(TestSummary_default, {
|
|
201
|
-
key: 0,
|
|
202
|
-
allTestsPassed: allTestsPassed.value,
|
|
203
|
-
failedTests: failedTests.value ?? [],
|
|
204
|
-
passedTests: passedTests.value ?? [],
|
|
205
|
-
pendingTests: pendingTests.value ?? [],
|
|
206
|
-
results: __props.results?.value,
|
|
207
|
-
totalDuration: totalDuration.value
|
|
208
|
-
}, null, 8, [
|
|
209
|
-
"allTestsPassed",
|
|
210
|
-
"failedTests",
|
|
211
|
-
"passedTests",
|
|
212
|
-
"pendingTests",
|
|
213
|
-
"results",
|
|
214
|
-
"totalDuration"
|
|
215
|
-
])) : createCommentVNode("", true)])]),
|
|
216
|
-
_: 1
|
|
217
|
-
})) : createCommentVNode("", true);
|
|
218
|
-
};
|
|
219
|
-
}
|
|
220
|
-
});
|
|
221
|
-
//#endregion
|
|
222
|
-
export { TestResults_default as t };
|
|
223
|
-
|
|
224
|
-
//# sourceMappingURL=TestResults-DIM8u91u.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"TestResults-DIM8u91u.js","names":[],"sources":["../src/plugins/post-response-scripts/components/TestResults/TestResultIndicator.vue","../src/plugins/post-response-scripts/components/TestResults/TestResultIndicator.vue","../src/plugins/post-response-scripts/components/TestResults/TestResultItem.vue","../src/plugins/post-response-scripts/components/TestResults/TestResultItem.vue","../src/plugins/post-response-scripts/components/TestResults/TestSummary.vue","../src/plugins/post-response-scripts/components/TestResults/TestSummary.vue","../src/plugins/post-response-scripts/components/TestResults/TestResults.vue","../src/plugins/post-response-scripts/components/TestResults/TestResults.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { cva, ScalarIcon, useBindCx, type Icon } from '@scalar/components'\nimport { computed } from 'vue'\n\nimport type { TestResult } from '@/libs/execute-scripts'\n\nconst { state, totalTestsCount, pendingTestsCount, failedTestsCount } =\n defineProps<{\n state?: TestResult['status']\n failedTestsCount: number | undefined\n pendingTestsCount: number | undefined\n totalTestsCount: number | undefined\n inline?: boolean\n }>()\n\nconst { cx } = useBindCx()\n\nconst icon = computed(() => {\n if (state === 'passed') {\n return { name: 'Checkmark', color: 'text-green p-0.25' }\n }\n\n if (state === 'failed') {\n return { name: 'Close', color: 'text-red' }\n }\n\n return { name: 'Ellipses', color: 'text-c-1' }\n})\n\nconst statusVariants = cva({\n base: 'flex items-center gap-1.5 rounded-full border pr-2 pl-1.25',\n variants: {\n status: {\n passed: 'text-green',\n failed: 'text-red',\n pending: 'text-orange',\n },\n },\n})\n\nconst textVariants = cva({\n base: 'text-c-2',\n variants: {\n inline: {\n true: 'text-xs',\n false: 'text-sm',\n },\n },\n})\n\n// Display the number of tests that passed e.g 1/3\nconst getTestCountDisplay = computed(() => {\n // When there are no tests, show nothing\n if (totalTestsCount === undefined) {\n return ''\n }\n\n // When they failed, show failed/total\n if (failedTestsCount) {\n return `${failedTestsCount}/${totalTestsCount}`\n }\n\n // When they passed, show passed/total\n const completedTests =\n totalTestsCount - (pendingTestsCount || 0) - (failedTestsCount || 0)\n return `${completedTests}/${totalTestsCount}`\n})\n</script>\n\n<template>\n <div v-bind=\"cx(statusVariants({ status: state }))\">\n <ScalarIcon\n v-if=\"state\"\n :class=\"icon.color\"\n :icon=\"icon.name as Icon\"\n size=\"sm\" />\n <span\n v-if=\"!inline\"\n class=\"ml-1.25 capitalize\">\n {{ state }}\n </span>\n <span\n v-if=\"totalTestsCount !== undefined\"\n v-bind=\"cx(textVariants({ inline }))\">\n {{ getTestCountDisplay }}\n </span>\n </div>\n</template>\n","<script setup lang=\"ts\">\nimport { cva, ScalarIcon, useBindCx, type Icon } from '@scalar/components'\nimport { computed } from 'vue'\n\nimport type { TestResult } from '@/libs/execute-scripts'\n\nconst { state, totalTestsCount, pendingTestsCount, failedTestsCount } =\n defineProps<{\n state?: TestResult['status']\n failedTestsCount: number | undefined\n pendingTestsCount: number | undefined\n totalTestsCount: number | undefined\n inline?: boolean\n }>()\n\nconst { cx } = useBindCx()\n\nconst icon = computed(() => {\n if (state === 'passed') {\n return { name: 'Checkmark', color: 'text-green p-0.25' }\n }\n\n if (state === 'failed') {\n return { name: 'Close', color: 'text-red' }\n }\n\n return { name: 'Ellipses', color: 'text-c-1' }\n})\n\nconst statusVariants = cva({\n base: 'flex items-center gap-1.5 rounded-full border pr-2 pl-1.25',\n variants: {\n status: {\n passed: 'text-green',\n failed: 'text-red',\n pending: 'text-orange',\n },\n },\n})\n\nconst textVariants = cva({\n base: 'text-c-2',\n variants: {\n inline: {\n true: 'text-xs',\n false: 'text-sm',\n },\n },\n})\n\n// Display the number of tests that passed e.g 1/3\nconst getTestCountDisplay = computed(() => {\n // When there are no tests, show nothing\n if (totalTestsCount === undefined) {\n return ''\n }\n\n // When they failed, show failed/total\n if (failedTestsCount) {\n return `${failedTestsCount}/${totalTestsCount}`\n }\n\n // When they passed, show passed/total\n const completedTests =\n totalTestsCount - (pendingTestsCount || 0) - (failedTestsCount || 0)\n return `${completedTests}/${totalTestsCount}`\n})\n</script>\n\n<template>\n <div v-bind=\"cx(statusVariants({ status: state }))\">\n <ScalarIcon\n v-if=\"state\"\n :class=\"icon.color\"\n :icon=\"icon.name as Icon\"\n size=\"sm\" />\n <span\n v-if=\"!inline\"\n class=\"ml-1.25 capitalize\">\n {{ state }}\n </span>\n <span\n v-if=\"totalTestsCount !== undefined\"\n v-bind=\"cx(textVariants({ inline }))\">\n {{ getTestCountDisplay }}\n </span>\n </div>\n</template>\n","<script setup lang=\"ts\">\nimport { ScalarIcon, type Icon } from '@scalar/components'\nimport { computed } from 'vue'\n\nimport type { TestResult } from '@/libs/execute-scripts'\n\nconst { currentState, result } = defineProps<{\n result: TestResult\n currentState: TestResult['status']\n}>()\n\nconst resultStatus = computed(() => {\n if (result.passed) {\n return { icon: 'Checkmark', color: 'text-green p-0.25' }\n }\n\n if (!result.passed && currentState !== 'pending') {\n return { icon: 'Close', color: 'text-red' }\n }\n\n return { icon: 'Ellipses', color: 'text-c-1' }\n})\n</script>\n\n<template>\n <div class=\"flex flex-col\">\n <div\n class=\"flex h-8 items-center gap-2 pr-3 pl-2.25\"\n :class=\"result.error && 'bg-b-danger'\">\n <!-- Title -->\n <div class=\"flex items-center gap-3 p-2\">\n <ScalarIcon\n :class=\"resultStatus.color\"\n :icon=\"resultStatus.icon as Icon\"\n size=\"sm\" />\n\n <span class=\"text-c-2 overflow-hidden text-ellipsis whitespace-nowrap\">\n {{ result.title }}\n </span>\n </div>\n <!-- Duration -->\n <span class=\"text-c-3 ml-auto whitespace-nowrap\">\n {{ result.duration }} ms\n </span>\n </div>\n <!-- Error -->\n <div\n v-if=\"result.error\"\n class=\"bg-b-danger text-c-1 flex items-center pr-3 pb-1.5 pl-9\">\n {{ result.error }}\n </div>\n </div>\n</template>\n","<script setup lang=\"ts\">\nimport { ScalarIcon, type Icon } from '@scalar/components'\nimport { computed } from 'vue'\n\nimport type { TestResult } from '@/libs/execute-scripts'\n\nconst { currentState, result } = defineProps<{\n result: TestResult\n currentState: TestResult['status']\n}>()\n\nconst resultStatus = computed(() => {\n if (result.passed) {\n return { icon: 'Checkmark', color: 'text-green p-0.25' }\n }\n\n if (!result.passed && currentState !== 'pending') {\n return { icon: 'Close', color: 'text-red' }\n }\n\n return { icon: 'Ellipses', color: 'text-c-1' }\n})\n</script>\n\n<template>\n <div class=\"flex flex-col\">\n <div\n class=\"flex h-8 items-center gap-2 pr-3 pl-2.25\"\n :class=\"result.error && 'bg-b-danger'\">\n <!-- Title -->\n <div class=\"flex items-center gap-3 p-2\">\n <ScalarIcon\n :class=\"resultStatus.color\"\n :icon=\"resultStatus.icon as Icon\"\n size=\"sm\" />\n\n <span class=\"text-c-2 overflow-hidden text-ellipsis whitespace-nowrap\">\n {{ result.title }}\n </span>\n </div>\n <!-- Duration -->\n <span class=\"text-c-3 ml-auto whitespace-nowrap\">\n {{ result.duration }} ms\n </span>\n </div>\n <!-- Error -->\n <div\n v-if=\"result.error\"\n class=\"bg-b-danger text-c-1 flex items-center pr-3 pb-1.5 pl-9\">\n {{ result.error }}\n </div>\n </div>\n</template>\n","<script setup lang=\"ts\">\nimport type { TestResult } from '@/libs/execute-scripts'\n\nimport TestResultIndicator from './TestResultIndicator.vue'\n\ndefineProps<{\n results: TestResult[]\n passedTests: TestResult[]\n failedTests: TestResult[]\n pendingTests: TestResult[]\n allTestsPassed: boolean\n totalDuration: number\n}>()\n</script>\n\n<template>\n <div class=\"flex h-8 items-center gap-1.5 pr-3 pl-1\">\n <TestResultIndicator\n :failedTestsCount=\"failedTests?.length\"\n :passedTestsCount=\"passedTests?.length\"\n :pendingTestsCount=\"pendingTests?.length\"\n :state=\"allTestsPassed ? 'passed' : 'failed'\"\n :totalTestsCount=\"results?.length\" />\n <span\n v-if=\"pendingTests?.length\"\n class=\"text-orange\">\n {{ pendingTests?.length }}\n Pending\n </span>\n <span class=\"text-c-3 ml-auto\"> {{ totalDuration.toFixed(1) }} ms </span>\n </div>\n</template>\n","<script setup lang=\"ts\">\nimport type { TestResult } from '@/libs/execute-scripts'\n\nimport TestResultIndicator from './TestResultIndicator.vue'\n\ndefineProps<{\n results: TestResult[]\n passedTests: TestResult[]\n failedTests: TestResult[]\n pendingTests: TestResult[]\n allTestsPassed: boolean\n totalDuration: number\n}>()\n</script>\n\n<template>\n <div class=\"flex h-8 items-center gap-1.5 pr-3 pl-1\">\n <TestResultIndicator\n :failedTestsCount=\"failedTests?.length\"\n :passedTestsCount=\"passedTests?.length\"\n :pendingTestsCount=\"pendingTests?.length\"\n :state=\"allTestsPassed ? 'passed' : 'failed'\"\n :totalTestsCount=\"results?.length\" />\n <span\n v-if=\"pendingTests?.length\"\n class=\"text-orange\">\n {{ pendingTests?.length }}\n Pending\n </span>\n <span class=\"text-c-3 ml-auto\"> {{ totalDuration.toFixed(1) }} ms </span>\n </div>\n</template>\n","<script setup lang=\"ts\">\nimport { computed, type Ref } from 'vue'\n\nimport type { TestResult } from '@/libs/execute-scripts'\n\nimport { ViewLayoutCollapse } from '../../../../components/ViewLayout'\nimport TestResultIndicator from './TestResultIndicator.vue'\nimport TestResultItem from './TestResultItem.vue'\nimport TestSummary from './TestSummary.vue'\n\nconst { results } = defineProps<{\n results?: Ref<TestResult[]> | undefined\n}>()\n\nconst passedTests = computed(() =>\n results?.value?.filter((result: TestResult) => result.status === 'passed'),\n)\n\nconst pendingTests = computed(() =>\n results?.value?.filter((result: TestResult) => result.status === 'pending'),\n)\n\nconst failedTests = computed(() =>\n results?.value?.filter((result: TestResult) => result.status === 'failed'),\n)\n\nconst allTestsPassed = computed(\n () => passedTests.value?.length === results?.value?.length,\n)\n\nconst currentState = computed(() => {\n if (allTestsPassed.value) {\n return 'passed'\n }\n\n if (pendingTests.value?.length) {\n return 'pending'\n }\n\n return 'failed'\n})\n\nconst totalDuration = computed(\n () =>\n results?.value?.reduce(\n (acc: number, curr: TestResult) => acc + curr.duration,\n 0,\n ) ?? 0,\n)\n</script>\n\n<template>\n <ViewLayoutCollapse\n v-if=\"results?.value?.length\"\n class=\"overflow-auto text-sm\"\n :defaultOpen=\"true\">\n <template #title> Tests </template>\n <template #suffix>\n <TestResultIndicator\n :failedTestsCount=\"failedTests?.length\"\n inline\n :passedTestsCount=\"passedTests?.length\"\n :pendingTestsCount=\"pendingTests?.length\"\n :state=\"currentState\"\n :totalTestsCount=\"results?.value?.length\" />\n </template>\n\n <div class=\"max-h-[calc(100%-32px)] divide-y overflow-y-auto border-t\">\n <!-- Results -->\n <TestResultItem\n v-for=\"result in results?.value\"\n :key=\"result.title\"\n :currentState=\"result.status\"\n :result=\"result\" />\n\n <TestSummary\n v-if=\"results\"\n :allTestsPassed=\"allTestsPassed\"\n :failedTests=\"failedTests ?? []\"\n :passedTests=\"passedTests ?? []\"\n :pendingTests=\"pendingTests ?? []\"\n :results=\"results?.value\"\n :totalDuration=\"totalDuration\" />\n </div>\n </ViewLayoutCollapse>\n</template>\n","<script setup lang=\"ts\">\nimport { computed, type Ref } from 'vue'\n\nimport type { TestResult } from '@/libs/execute-scripts'\n\nimport { ViewLayoutCollapse } from '../../../../components/ViewLayout'\nimport TestResultIndicator from './TestResultIndicator.vue'\nimport TestResultItem from './TestResultItem.vue'\nimport TestSummary from './TestSummary.vue'\n\nconst { results } = defineProps<{\n results?: Ref<TestResult[]> | undefined\n}>()\n\nconst passedTests = computed(() =>\n results?.value?.filter((result: TestResult) => result.status === 'passed'),\n)\n\nconst pendingTests = computed(() =>\n results?.value?.filter((result: TestResult) => result.status === 'pending'),\n)\n\nconst failedTests = computed(() =>\n results?.value?.filter((result: TestResult) => result.status === 'failed'),\n)\n\nconst allTestsPassed = computed(\n () => passedTests.value?.length === results?.value?.length,\n)\n\nconst currentState = computed(() => {\n if (allTestsPassed.value) {\n return 'passed'\n }\n\n if (pendingTests.value?.length) {\n return 'pending'\n }\n\n return 'failed'\n})\n\nconst totalDuration = computed(\n () =>\n results?.value?.reduce(\n (acc: number, curr: TestResult) => acc + curr.duration,\n 0,\n ) ?? 0,\n)\n</script>\n\n<template>\n <ViewLayoutCollapse\n v-if=\"results?.value?.length\"\n class=\"overflow-auto text-sm\"\n :defaultOpen=\"true\">\n <template #title> Tests </template>\n <template #suffix>\n <TestResultIndicator\n :failedTestsCount=\"failedTests?.length\"\n inline\n :passedTestsCount=\"passedTests?.length\"\n :pendingTestsCount=\"pendingTests?.length\"\n :state=\"currentState\"\n :totalTestsCount=\"results?.value?.length\" />\n </template>\n\n <div class=\"max-h-[calc(100%-32px)] divide-y overflow-y-auto border-t\">\n <!-- Results -->\n <TestResultItem\n v-for=\"result in results?.value\"\n :key=\"result.title\"\n :currentState=\"result.status\"\n :result=\"result\" />\n\n <TestSummary\n v-if=\"results\"\n :allTestsPassed=\"allTestsPassed\"\n :failedTests=\"failedTests ?? []\"\n :passedTests=\"passedTests ?? []\"\n :pendingTests=\"pendingTests ?? []\"\n :results=\"results?.value\"\n :totalDuration=\"totalDuration\" />\n </div>\n </ViewLayoutCollapse>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;ECeA,MAAM,EAAE,OAAO,WAAU;EAEzB,MAAM,OAAO,eAAe;AAC1B,OAAI,QAAA,UAAU,SACZ,QAAO;IAAE,MAAM;IAAa,OAAO;IAAoB;AAGzD,OAAI,QAAA,UAAU,SACZ,QAAO;IAAE,MAAM;IAAS,OAAO;IAAW;AAG5C,UAAO;IAAE,MAAM;IAAY,OAAO;IAAW;IAC9C;EAED,MAAM,iBAAiB,IAAI;GACzB,MAAM;GACN,UAAU,EACR,QAAQ;IACN,QAAQ;IACR,QAAQ;IACR,SAAS;IACV,EACF;GACF,CAAA;EA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AAY,OAAO,WAAW,QAAA,SAAS,OAAO,OACtD;EAEA,MAAM,eAAe,eAAe;AAClC,OAAI,eAAe,MACjB,QAAO;AAGT,OAAI,aAAa,OAAO,OACtB,QAAO;AAGT,UAAO;IACR;EAED,MAAM,gBAAgB,eAElB,QAAA,SAAS,OAAO,QACb,KAAa,SAAqB,MAAM,KAAK,UAC9C,EACD,IAAI,EACT;;UAKU,QAAA,SAAS,OAAO,UAAA,WAAA,EADxB,YAgCqB,MAAA,2BAAA,EAAA;;IA9BnB,OAAM;IACL,aAAa;;IACH,OAAK,cAAQ,CAAA,GAAA,OAAA,OAAA,OAAA,KAAA,CAAA,gBAAP,WAAO,GAAA,CAAA,EAAA,CAAA;IACb,QAAM,cAO+B,CAN9C,YAM8C,6BAAA;KAL3C,kBAAkB,YAAA,OAAa;KAChC,QAAA;KACC,kBAAkB,YAAA,OAAa;KAC/B,mBAAmB,aAAA,OAAc;KACjC,OAAO,aAAA;KACP,iBAAiB,QAAA,SAAS,OAAO;;;;;;;;2BAmBhC,CAhBN,mBAgBM,OAhBN,YAgBM,EAAA,UAAA,KAAA,EAdJ,mBAIqB,UAAA,MAAA,WAHF,QAAA,SAAS,QAAnB,WAAM;yBADf,YAIqB,wBAAA;MAFlB,KAAK,OAAO;MACZ,cAAc,OAAO;MACb;;eAGH,QAAA,WAAA,WAAA,EADR,YAOmC,qBAAA;;KALhC,gBAAgB,eAAA;KAChB,aAAa,YAAA,SAAW,EAAA;KACxB,aAAa,YAAA,SAAW,EAAA;KACxB,cAAc,aAAA,SAAY,EAAA;KAC1B,SAAS,QAAA,SAAS;KAClB,eAAe,cAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ViewLayoutCollapse-BMrPz_sj.js","names":["$slots","$attrs"],"sources":["../src/components/ViewLayout/ValueEmitter.vue","../src/components/ViewLayout/ValueEmitter.vue","../src/components/ViewLayout/ViewLayoutCollapse.vue","../src/components/ViewLayout/ViewLayoutCollapse.vue"],"sourcesContent":["<script lang=\"ts\">\n/**\n * This component takes in any value and emits it back\n *\n * This is useful when we need to catch the open state of a disclosure from its v-slot\n */\nexport default {\n name: 'ValueEmitter',\n}\n</script>\n\n<script setup lang=\"ts\" generic=\"T\">\nimport { onBeforeUnmount, watch } from 'vue'\n\nconst { value } = defineProps<{ value: T }>()\nconst emit = defineEmits<{\n (e: 'change', value: T): void\n (e: 'unmount'): void\n}>()\n\nwatch(\n () => value,\n (newValue) => emit('change', newValue),\n { immediate: true },\n)\n\nonBeforeUnmount(() => emit('unmount'))\n</script>\n\n<!-- eslint-disable-next-line vue/valid-template-root -->\n<template>\n <!-- We use this hack to emit the slot value back to the parent -->\n</template>\n","<script lang=\"ts\">\n/**\n * This component takes in any value and emits it back\n *\n * This is useful when we need to catch the open state of a disclosure from its v-slot\n */\nexport default {\n name: 'ValueEmitter',\n}\n</script>\n\n<script setup lang=\"ts\" generic=\"T\">\nimport { onBeforeUnmount, watch } from 'vue'\n\nconst { value } = defineProps<{ value: T }>()\nconst emit = defineEmits<{\n (e: 'change', value: T): void\n (e: 'unmount'): void\n}>()\n\nwatch(\n () => value,\n (newValue) => emit('change', newValue),\n { immediate: true },\n)\n\nonBeforeUnmount(() => emit('unmount'))\n</script>\n\n<!-- eslint-disable-next-line vue/valid-template-root -->\n<template>\n <!-- We use this hack to emit the slot value back to the parent -->\n</template>\n","<script lang=\"ts\">\n/**\n * Simple collapsible section component that can be used to wrap content that should be collapsed and expanded\n *\n * Would like to replace with details/summary elements, but they are not supported in all browsers yet?\n */\nexport default {\n name: 'CollapsibleSection',\n}\n</script>\n\n<script setup lang=\"ts\">\nimport { Disclosure, DisclosureButton, DisclosurePanel } from '@headlessui/vue'\nimport { ScalarIcon } from '@scalar/components'\nimport { useId } from 'vue'\n\nimport ValueEmitter from './ValueEmitter.vue'\n\nconst {\n defaultOpen = true,\n itemCount = 0,\n isStatic,\n} = defineProps<{\n /** Whether the disclosure is open by default. */\n defaultOpen?: boolean\n /** Number of items to show in badge when collapsed. */\n itemCount?: number\n /** Whether the disclosure is static and cannot be toggled. */\n isStatic?: boolean\n}>()\n\nconst emit = defineEmits<{\n (e: 'update:modelValue', value: boolean): void\n}>()\n\nconst headingId = useId()\n</script>\n\n<template>\n <Disclosure\n v-slot=\"{ open }\"\n as=\"div\"\n class=\"group/collapse text-c-2 focus-within:text-c-1 last:ui-open:border-b-0 border-b\"\n :class=\"isStatic && 'last-of-type:first-of-type:border-b-0'\"\n :defaultOpen=\"defaultOpen\"\n :static=\"isStatic\">\n <!-- We use this hack to emit the slot value back to the parent -->\n <ValueEmitter\n :value=\"open as boolean\"\n @change=\"(value) => emit('update:modelValue', value)\" />\n\n <section\n :aria-labelledby=\"headingId\"\n class=\"contents\">\n <div\n class=\"bg-b-2 flex items-center\"\n :class=\"isStatic && 'rounded-t-lg border border-b-0'\">\n <!-- Main disclosure button that toggles the panel -->\n <DisclosureButton\n class=\"hover:text-c-1 group box-content flex max-h-8 flex-1 items-center gap-2.5 overflow-hidden px-1 py-1.5 text-base font-medium outline-none md:px-1.5 xl:pr-0.5 xl:pl-2\"\n :class=\"isStatic && '!pl-3'\"\n :disabled=\"isStatic\">\n <ScalarIcon\n v-if=\"!isStatic\"\n class=\"text-c-3 group-hover:text-c-1 rounded-px ui-open:rotate-90 ui-not-open:rotate-0 outline-offset-2 group-focus-visible:outline\"\n icon=\"ChevronRight\"\n size=\"md\" />\n\n <!-- Heading with title -->\n <h2\n class=\"text-c-1 m-0 flex flex-1 items-center gap-1.5 leading-[20px]\">\n <span\n :id=\"headingId\"\n class=\"contents\">\n <slot\n name=\"title\"\n :open=\"open\" />\n <span\n v-if=\"!open\"\n class=\"sr-only\">\n (Collapsed)\n </span>\n </span>\n\n <!-- Badge showing item count when collapsed. -->\n <span\n v-if=\"!open && itemCount\"\n class=\"bg-b-2 text-c-2 inline-flex h-5 w-5 items-center justify-center rounded-full border text-xs font-semibold\">\n {{ itemCount }}\n <span class=\"sr-only\">Item{{ itemCount === 1 ? '' : 's' }}</span>\n </span>\n </h2>\n </DisclosureButton>\n\n <!-- Optional actions slot that hides when the panel is closed. -->\n <div\n v-if=\"$slots.actions\"\n class=\"ui-not-open:hidden flex items-center gap-2 pr-0.75\">\n <slot\n name=\"actions\"\n :open=\"open\" />\n </div>\n </div>\n\n <!-- The collapsible content panel. -->\n <DisclosurePanel\n v-bind=\"$attrs\"\n class=\"diclosure-panel h-full max-h-fit rounded-b\">\n <slot :open=\"open\" />\n </DisclosurePanel>\n </section>\n </Disclosure>\n</template>\n","<script lang=\"ts\">\n/**\n * Simple collapsible section component that can be used to wrap content that should be collapsed and expanded\n *\n * Would like to replace with details/summary elements, but they are not supported in all browsers yet?\n */\nexport default {\n name: 'CollapsibleSection',\n}\n</script>\n\n<script setup lang=\"ts\">\nimport { Disclosure, DisclosureButton, DisclosurePanel } from '@headlessui/vue'\nimport { ScalarIcon } from '@scalar/components'\nimport { useId } from 'vue'\n\nimport ValueEmitter from './ValueEmitter.vue'\n\nconst {\n defaultOpen = true,\n itemCount = 0,\n isStatic,\n} = defineProps<{\n /** Whether the disclosure is open by default. */\n defaultOpen?: boolean\n /** Number of items to show in badge when collapsed. */\n itemCount?: number\n /** Whether the disclosure is static and cannot be toggled. */\n isStatic?: boolean\n}>()\n\nconst emit = defineEmits<{\n (e: 'update:modelValue', value: boolean): void\n}>()\n\nconst headingId = useId()\n</script>\n\n<template>\n <Disclosure\n v-slot=\"{ open }\"\n as=\"div\"\n class=\"group/collapse text-c-2 focus-within:text-c-1 last:ui-open:border-b-0 border-b\"\n :class=\"isStatic && 'last-of-type:first-of-type:border-b-0'\"\n :defaultOpen=\"defaultOpen\"\n :static=\"isStatic\">\n <!-- We use this hack to emit the slot value back to the parent -->\n <ValueEmitter\n :value=\"open as boolean\"\n @change=\"(value) => emit('update:modelValue', value)\" />\n\n <section\n :aria-labelledby=\"headingId\"\n class=\"contents\">\n <div\n class=\"bg-b-2 flex items-center\"\n :class=\"isStatic && 'rounded-t-lg border border-b-0'\">\n <!-- Main disclosure button that toggles the panel -->\n <DisclosureButton\n class=\"hover:text-c-1 group box-content flex max-h-8 flex-1 items-center gap-2.5 overflow-hidden px-1 py-1.5 text-base font-medium outline-none md:px-1.5 xl:pr-0.5 xl:pl-2\"\n :class=\"isStatic && '!pl-3'\"\n :disabled=\"isStatic\">\n <ScalarIcon\n v-if=\"!isStatic\"\n class=\"text-c-3 group-hover:text-c-1 rounded-px ui-open:rotate-90 ui-not-open:rotate-0 outline-offset-2 group-focus-visible:outline\"\n icon=\"ChevronRight\"\n size=\"md\" />\n\n <!-- Heading with title -->\n <h2\n class=\"text-c-1 m-0 flex flex-1 items-center gap-1.5 leading-[20px]\">\n <span\n :id=\"headingId\"\n class=\"contents\">\n <slot\n name=\"title\"\n :open=\"open\" />\n <span\n v-if=\"!open\"\n class=\"sr-only\">\n (Collapsed)\n </span>\n </span>\n\n <!-- Badge showing item count when collapsed. -->\n <span\n v-if=\"!open && itemCount\"\n class=\"bg-b-2 text-c-2 inline-flex h-5 w-5 items-center justify-center rounded-full border text-xs font-semibold\">\n {{ itemCount }}\n <span class=\"sr-only\">Item{{ itemCount === 1 ? '' : 's' }}</span>\n </span>\n </h2>\n </DisclosureButton>\n\n <!-- Optional actions slot that hides when the panel is closed. -->\n <div\n v-if=\"$slots.actions\"\n class=\"ui-not-open:hidden flex items-center gap-2 pr-0.75\">\n <slot\n name=\"actions\"\n :open=\"open\" />\n </div>\n </div>\n\n <!-- The collapsible content panel. -->\n <DisclosurePanel\n v-bind=\"$attrs\"\n class=\"diclosure-panel h-full max-h-fit rounded-b\">\n <slot :open=\"open\" />\n </DisclosurePanel>\n </section>\n </Disclosure>\n</template>\n"],"mappings":";;;;;;CCOE,MAAM;;;;EAQR,MAAM,OAAO;AAKb,cACQ,QAAA,QACL,aAAa,KAAK,UAAU,SAAS,EACtC,EAAE,WAAW,MAAM,CACrB;AAEA,wBAAsB,KAAK,UAAU,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;CEnBnC,MA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,CAHJ,WAEiB,KAAA,QAAA,WAAA,EAAR,MAAI,CAAA,CAAA,CAAA,IAAA,mBAAA,IAAA,KAAA,CAAA,EAAA,EAAA,EAKjB,YAIkB,MAAA,gBAAA,EAJlB,WACUC,KAGQ,QAHF,EACd,OAAM,8CAA4C,CAAA,EAAA;4BAC7B,CAArB,WAAqB,KAAA,QAAA,WAAA,EAAR,MAAI,CAAA,CAAA,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"execute-scripts-BV13zq7B.js","names":[],"sources":["../src/libs/execute-scripts/context/console.ts","../src/libs/execute-scripts/postman-sandbox-adapter.ts","../src/libs/execute-scripts/execute-post-response-script.ts"],"sourcesContent":["export interface ConsoleContext {\n log: (...args: any[]) => void\n error: (...args: any[]) => void\n warn: (...args: any[]) => void\n info: (...args: any[]) => void\n debug: (...args: any[]) => void\n trace: (...args: any[]) => void\n table: (tabularData: any, properties?: readonly string[]) => void\n}\n\nexport const createConsoleContext = (): ConsoleContext => ({\n log: (...args: any[]) => console.log('[Script]', ...args),\n error: (...args: any[]) => console.error('[Script Error]', ...args),\n warn: (...args: any[]) => console.warn('[Script Warning]', ...args),\n info: (...args: any[]) => console.info('[Script Info]', ...args),\n debug: (...args: any[]) => console.debug('[Script Debug]', ...args),\n trace: (...args: any[]) => console.trace('[Script Trace]', ...args),\n table: (tabularData: any, properties?: readonly string[]) => console.table(tabularData, properties),\n})\n","import type { SandboxContext } from 'postman-sandbox'\nimport Sandbox from 'postman-sandbox'\n\nimport type { ConsoleContext } from './context/console'\nimport type { TestResult } from './execute-post-response-script'\n\ntype AssertionEvent = {\n name: string\n index: number\n passed: boolean\n skipped: boolean\n error: { message?: string } | null\n}\n\nconst toPostmanResponse = async (response: Response) => {\n const responseText = await response.text()\n const responseBytes = Array.from(new TextEncoder().encode(responseText))\n\n return {\n code: response.status,\n status: response.statusText || String(response.status),\n header: Array.from(response.headers.entries()).map(([key, value]) => ({ key, value })),\n stream: {\n type: 'Buffer',\n data: responseBytes,\n },\n }\n}\n\nconst createContext = (): Promise<SandboxContext> =>\n new Promise((resolve, reject) => {\n Sandbox.createContext((error: unknown, context: SandboxContext) => {\n if (error) {\n reject(error)\n return\n }\n\n resolve(context)\n })\n })\n\nconst toErrorMessage = (error: unknown): string => {\n if (error && typeof error === 'object' && 'message' in error && typeof error.message === 'string') {\n return error.message\n }\n\n return String(error)\n}\n\nconst upsertTestResult = (testResults: TestResult[], assertion: AssertionEvent, duration: number): void => {\n const title = assertion.name || `Assertion ${assertion.index + 1}`\n\n const nextResult: TestResult = {\n title,\n passed: assertion.passed,\n duration,\n error: assertion.error?.message,\n status: assertion.passed ? 'passed' : 'failed',\n }\n\n const existingResultIndex = testResults.findIndex((result) => result.title === title)\n if (existingResultIndex === -1) {\n testResults.push(nextResult)\n return\n }\n\n testResults[existingResultIndex] = nextResult\n}\n\nexport const executeInPostmanSandbox = async ({\n script,\n response,\n onTestResultsUpdate,\n scriptConsole,\n}: {\n script: string\n response: Response\n onTestResultsUpdate?: ((results: TestResult[]) => void) | undefined\n scriptConsole: ConsoleContext\n}): Promise<void> => {\n const testResults: TestResult[] = []\n let lastAssertionTime = 0\n let scriptExecutionStartedAt = 0\n const sandboxContext = await createContext()\n\n const handleAssertion = (_cursor: unknown, assertions: AssertionEvent[]) => {\n assertions.forEach((assertion) => {\n const duration = Number((performance.now() - lastAssertionTime).toFixed(2))\n lastAssertionTime = performance.now()\n upsertTestResult(testResults, assertion, duration)\n })\n onTestResultsUpdate?.([...testResults])\n }\n\n const handleConsole = (_cursor: unknown, level: keyof ConsoleContext, ...args: unknown[]) => {\n const consoleMethod = scriptConsole[level] ?? scriptConsole.log\n ;(consoleMethod as (...params: unknown[]) => void)(...args)\n }\n\n try {\n sandboxContext.on('execution.assertion', handleAssertion)\n sandboxContext.on('console', handleConsole)\n\n const postmanResponse = await toPostmanResponse(response)\n\n scriptExecutionStartedAt = performance.now()\n lastAssertionTime = scriptExecutionStartedAt\n\n await new Promise<void>((resolve) => {\n sandboxContext.execute(\n {\n listen: 'test',\n script: {\n exec: [script],\n },\n },\n {\n disableLegacyAPIs: true,\n context: {\n response: postmanResponse,\n },\n },\n (error: unknown) => {\n if (error) {\n const duration = Number((performance.now() - scriptExecutionStartedAt).toFixed(2))\n const errorMessage = toErrorMessage(error)\n\n scriptConsole.error(`[Post-Response Script] Error (${duration}ms):`, errorMessage)\n\n testResults.push({\n title: 'Script Execution',\n passed: false,\n duration,\n error: errorMessage,\n status: 'failed',\n })\n onTestResultsUpdate?.([...testResults])\n }\n\n resolve()\n },\n )\n })\n } finally {\n sandboxContext.off('execution.assertion', handleAssertion)\n sandboxContext.off('console', handleConsole)\n sandboxContext.dispose()\n }\n}\n","import { createConsoleContext } from './context/console'\nimport { executeInPostmanSandbox } from './postman-sandbox-adapter'\n\nexport type TestResult = {\n title: string\n passed: boolean\n duration: number\n error?: string\n status: 'pending' | 'passed' | 'failed'\n}\n\nexport const executePostResponseScript = async (\n script: string | undefined,\n data: {\n response: Response\n onTestResultsUpdate?: ((results: TestResult[]) => void) | undefined\n },\n): Promise<void> => {\n if (!script) {\n return\n }\n await executeInPostmanSandbox({\n script,\n response: data.response,\n onTestResultsUpdate: data.onTestResultsUpdate,\n scriptConsole: createConsoleContext(),\n })\n}\n"],"mappings":";;AAUA,IAAa,8BAA8C;CACzD,MAAM,GAAG,SAAgB,QAAQ,IAAI,YAAY,GAAG,KAAK;CACzD,QAAQ,GAAG,SAAgB,QAAQ,MAAM,kBAAkB,GAAG,KAAK;CACnE,OAAO,GAAG,SAAgB,QAAQ,KAAK,oBAAoB,GAAG,KAAK;CACnE,OAAO,GAAG,SAAgB,QAAQ,KAAK,iBAAiB,GAAG,KAAK;CAChE,QAAQ,GAAG,SAAgB,QAAQ,MAAM,kBAAkB,GAAG,KAAK;CACnE,QAAQ,GAAG,SAAgB,QAAQ,MAAM,kBAAkB,GAAG,KAAK;CACnE,QAAQ,aAAkB,eAAmC,QAAQ,MAAM,aAAa,WAAW;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wrl9.js","names":[],"sources":["../src/plugins/post-response-scripts/post-response-scripts-plugin.ts"],"sourcesContent":["import type { ClientPlugin } from '@scalar/oas-utils/helpers'\nimport type { ApiClientPlugin } from '@scalar/types/api-reference'\nimport { ref } from 'vue'\n\nimport { type TestResult, executePostResponseScript } from '@/libs/execute-scripts'\n\nimport { PostResponseScripts } from './components/PostResponseScripts'\nimport { TestResults } from './components/TestResults'\n\nexport const postResponseScriptsPlugin = (): ApiClientPlugin => {\n const results = ref<TestResult[]>([])\n\n return () => ({\n name: 'post-response-scripts',\n views: {\n 'request.section': [\n {\n title: 'Scripts',\n component: PostResponseScripts,\n },\n ],\n 'response.section': [\n {\n title: 'Tests',\n component: TestResults,\n props: {\n results,\n },\n },\n ],\n },\n hooks: {\n // Reset test results when a new request is sent\n onBeforeRequest() {\n results.value = []\n },\n // Execute post-response scripts when a response is received\n async onResponseReceived({ response, operation }) {\n await executePostResponseScript(operation['x-post-response'], {\n response,\n onTestResultsUpdate: (newResults) => (results.value = [...newResults]),\n })\n },\n },\n })\n}\n\n/** Post Response Scripts Plugin for client V2 */\nexport const postResponseScriptsPluginV2 = (): ClientPlugin => {\n const results = ref<TestResult[]>([])\n\n return {\n components: {\n request: { component: PostResponseScripts },\n response: { component: TestResults, additionalProps: { results } },\n },\n\n hooks: {\n // Reset test results when a new request is sent\n beforeRequest: () => {\n results.value = []\n },\n // Execute post-response scripts when a response is received\n responseReceived: async ({ response, operation }) => {\n await executePostResponseScript(operation['x-post-response'], {\n response,\n onTestResultsUpdate: (newResults) => (results.value = [...newResults]),\n })\n },\n },\n }\n}\n"],"mappings":";;;;;AASA,IAAa,kCAAmD;CAC9D,MAAM,UAAU,IAAkB,EAAE,CAAC;AAErC,eAAc;EACZ,MAAM;EACN,OAAO;GACL,mBAAmB,CACjB;IACE,OAAO;IACP,WAAW;IACZ,CACF;GACD,oBAAoB,CAClB;IACE,OAAO;IACP,WAAW;IACX,OAAO,EACL,SACD;IACF,CACF;GACF;EACD,OAAO;GAEL,kBAAkB;AAChB,YAAQ,QAAQ,EAAE;;GAGpB,MAAM,mBAAmB,EAAE,UAAU,aAAa;AAChD,UAAM,0BAA0B,UAAU,oBAAoB;KAC5D;KACA,sBAAsB,eAAgB,QAAQ,QAAQ,CAAC,GAAG,WAAW;KACtE,CAAC;;GAEL;EACF;;;AAIH,IAAa,oCAAkD;CAC7D,MAAM,UAAU,IAAkB,EAAE,CAAC;AAErC,QAAO;EACL,YAAY;GACV,SAAS,EAAE,WAAW,6BAAqB;GAC3C,UAAU;IAAE,WAAW;IAAa,iBAAiB,EAAE,SAAS;IAAE;GACnE;EAED,OAAO;GAEL,qBAAqB;AACnB,YAAQ,QAAQ,EAAE;;GAGpB,kBAAkB,OAAO,EAAE,UAAU,gBAAgB;AACnD,UAAM,0BAA0B,UAAU,oBAAoB;KAC5D;KACA,sBAAsB,eAAgB,QAAQ,QAAQ,CAAC,GAAG,WAAW;KACtE,CAAC;;GAEL;EACF"}
|