@scalar/pre-post-request-scripts 0.3.9 → 0.3.10

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.
Files changed (53) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/PostResponseScripts-CrM65oAM.js +202 -0
  3. package/dist/PostResponseScripts-CrM65oAM.js.map +1 -0
  4. package/dist/TestResults-DIM8u91u.js +224 -0
  5. package/dist/TestResults-DIM8u91u.js.map +1 -0
  6. package/dist/ViewLayoutCollapse-BMrPz_sj.js +96 -0
  7. package/dist/ViewLayoutCollapse-BMrPz_sj.js.map +1 -0
  8. package/dist/components/ViewLayout/index.d.ts +1 -1
  9. package/dist/execute-scripts-BV13zq7B.js +125 -0
  10. package/dist/execute-scripts-BV13zq7B.js.map +1 -0
  11. package/dist/index.d.ts +2 -2
  12. package/dist/index.js +4 -7
  13. package/dist/libs/execute-scripts/index.d.ts +1 -1
  14. package/dist/libs/execute-scripts/index.js +2 -4
  15. package/dist/libs/execute-scripts/postman-sandbox-adapter.d.ts +2 -2
  16. package/dist/plugins/post-response-scripts/components/PostResponseScripts/index.d.ts +1 -1
  17. package/dist/plugins/post-response-scripts/components/PostResponseScripts/index.js +2 -4
  18. package/dist/plugins/post-response-scripts/components/TestResults/TestResultIndicator.vue.d.ts +1 -1
  19. package/dist/plugins/post-response-scripts/components/TestResults/TestResultItem.vue.d.ts +1 -1
  20. package/dist/plugins/post-response-scripts/components/TestResults/TestResults.vue.d.ts +1 -1
  21. package/dist/plugins/post-response-scripts/components/TestResults/TestSummary.vue.d.ts +1 -1
  22. package/dist/plugins/post-response-scripts/components/TestResults/index.d.ts +1 -1
  23. package/dist/plugins/post-response-scripts/components/TestResults/index.js +2 -4
  24. package/dist/plugins/post-response-scripts/index.d.ts +1 -1
  25. package/dist/plugins/post-response-scripts/index.js +3 -4
  26. package/dist/post-response-scripts-ikk1wrl9.js +61 -0
  27. package/dist/post-response-scripts-ikk1wrl9.js.map +1 -0
  28. package/dist/style.css +64 -1
  29. package/package.json +8 -12
  30. package/dist/_virtual/_plugin-vue_export-helper.js +0 -9
  31. package/dist/components/ViewLayout/ValueEmitter.vue.js +0 -21
  32. package/dist/components/ViewLayout/ValueEmitter.vue2.js +0 -4
  33. package/dist/components/ViewLayout/ViewLayoutCollapse.vue.js +0 -89
  34. package/dist/components/ViewLayout/ViewLayoutCollapse.vue2.js +0 -4
  35. package/dist/consts/example-scripts.js +0 -88
  36. package/dist/libs/execute-scripts/context/console.js +0 -12
  37. package/dist/libs/execute-scripts/execute-post-response-script.js +0 -13
  38. package/dist/libs/execute-scripts/postman-sandbox-adapter.js +0 -88
  39. package/dist/plugins/post-response-scripts/components/PostResponseScripts/ExampleScripts.vue.js +0 -32
  40. package/dist/plugins/post-response-scripts/components/PostResponseScripts/ExampleScripts.vue2.js +0 -4
  41. package/dist/plugins/post-response-scripts/components/PostResponseScripts/PostResponseScripts.vue.js +0 -53
  42. package/dist/plugins/post-response-scripts/components/PostResponseScripts/PostResponseScripts.vue2.js +0 -4
  43. package/dist/plugins/post-response-scripts/components/PostResponseScripts/ScriptEditor.vue.js +0 -7
  44. package/dist/plugins/post-response-scripts/components/PostResponseScripts/ScriptEditor.vue2.js +0 -33
  45. package/dist/plugins/post-response-scripts/components/TestResults/TestResultIndicator.vue.js +0 -48
  46. package/dist/plugins/post-response-scripts/components/TestResults/TestResultIndicator.vue2.js +0 -4
  47. package/dist/plugins/post-response-scripts/components/TestResults/TestResultItem.vue.js +0 -34
  48. package/dist/plugins/post-response-scripts/components/TestResults/TestResultItem.vue2.js +0 -4
  49. package/dist/plugins/post-response-scripts/components/TestResults/TestResults.vue.js +0 -68
  50. package/dist/plugins/post-response-scripts/components/TestResults/TestResults.vue2.js +0 -4
  51. package/dist/plugins/post-response-scripts/components/TestResults/TestSummary.vue.js +0 -32
  52. package/dist/plugins/post-response-scripts/components/TestResults/TestSummary.vue2.js +0 -4
  53. package/dist/plugins/post-response-scripts/post-response-scripts-plugin.js +0 -65
@@ -1,88 +0,0 @@
1
- const e = [
2
- {
3
- title: "Check the status code",
4
- script: `pm.test("Status code is 200", () => {
5
- pm.response.to.have.status(200)
6
- })`,
7
- mockResponse: {
8
- status: 200,
9
- body: { success: !0 }
10
- }
11
- },
12
- // TODO: We didn't add the proper response duration yet.
13
- // {
14
- // title: 'Check response time',
15
- // script: `pm.test("Response time is acceptable", () => {
16
- // pm.expect(pm.response.responseTime).to.be.below(200)
17
- // })`,
18
- // mockResponse: {
19
- // status: 200,
20
- // body: { success: true },
21
- // },
22
- // },
23
- {
24
- title: "Check JSON response",
25
- script: `pm.test("Response is valid JSON", () => {
26
- const responseData = pm.response.json()
27
- pm.expect(responseData).to.be.an('object')
28
- })`,
29
- mockResponse: {
30
- status: 200,
31
- body: { data: "test" },
32
- headers: { "Content-Type": "application/json" }
33
- }
34
- },
35
- {
36
- title: "Check response headers",
37
- script: `pm.test("Content-Type header is present", () => {
38
- pm.response.to.have.header('Content-Type')
39
- })`,
40
- mockResponse: {
41
- status: 200,
42
- body: { success: !0 },
43
- headers: { "Content-Type": "application/json" }
44
- }
45
- },
46
- {
47
- title: "Validate JSON schema",
48
- script: `pm.test("Response matches schema", () => {
49
- const schema = {
50
- type: 'object',
51
- required: ['id', 'name'],
52
- properties: {
53
- id: { type: 'number' },
54
- name: { type: 'string' }
55
- }
56
- }
57
- pm.response.to.have.jsonSchema(schema)
58
- })`,
59
- mockResponse: {
60
- status: 200,
61
- body: { id: 1, name: "Test Item" },
62
- headers: { "Content-Type": "application/json" }
63
- }
64
- },
65
- {
66
- title: "Check response body",
67
- script: `pm.test("Response body contains string", () => {
68
- pm.expect(pm.response.text()).to.include('success')
69
- })`,
70
- mockResponse: {
71
- status: 200,
72
- body: "This is a successful response"
73
- }
74
- },
75
- {
76
- title: "Successful POST request",
77
- script: `pm.test("Successful POST request", () => {
78
- pm.expect(pm.response.code).to.be.oneOf([201, 202])
79
- })`,
80
- mockResponse: {
81
- status: 201,
82
- body: { success: !0 }
83
- }
84
- }
85
- ];
86
- export {
87
- e as EXAMPLE_SCRIPTS
88
- };
@@ -1,12 +0,0 @@
1
- const e = () => ({
2
- log: (...o) => console.log("[Script]", ...o),
3
- error: (...o) => console.error("[Script Error]", ...o),
4
- warn: (...o) => console.warn("[Script Warning]", ...o),
5
- info: (...o) => console.info("[Script Info]", ...o),
6
- debug: (...o) => console.debug("[Script Debug]", ...o),
7
- trace: (...o) => console.trace("[Script Trace]", ...o),
8
- table: (o, r) => console.table(o, r)
9
- });
10
- export {
11
- e as createConsoleContext
12
- };
@@ -1,13 +0,0 @@
1
- import { createConsoleContext as t } from "./context/console.js";
2
- import { executeInPostmanSandbox as s } from "./postman-sandbox-adapter.js";
3
- const p = async (e, o) => {
4
- e && await s({
5
- script: e,
6
- response: o.response,
7
- onTestResultsUpdate: o.onTestResultsUpdate,
8
- scriptConsole: t()
9
- });
10
- };
11
- export {
12
- p as executePostResponseScript
13
- };
@@ -1,88 +0,0 @@
1
- import l from "postman-sandbox";
2
- const g = async (e) => {
3
- const t = await e.text(), o = Array.from(new TextEncoder().encode(t));
4
- return {
5
- code: e.status,
6
- status: e.statusText || String(e.status),
7
- header: Array.from(e.headers.entries()).map(([s, n]) => ({ key: s, value: n })),
8
- stream: {
9
- type: "Buffer",
10
- data: o
11
- }
12
- };
13
- }, w = () => new Promise((e, t) => {
14
- l.createContext((o, s) => {
15
- if (o) {
16
- t(o);
17
- return;
18
- }
19
- e(s);
20
- });
21
- }), y = (e) => e && typeof e == "object" && "message" in e && typeof e.message == "string" ? e.message : String(e), h = (e, t, o) => {
22
- const s = t.name || `Assertion ${t.index + 1}`, n = {
23
- title: s,
24
- passed: t.passed,
25
- duration: o,
26
- error: t.error?.message,
27
- status: t.passed ? "passed" : "failed"
28
- }, a = e.findIndex((i) => i.title === s);
29
- if (a === -1) {
30
- e.push(n);
31
- return;
32
- }
33
- e[a] = n;
34
- }, A = async ({
35
- script: e,
36
- response: t,
37
- onTestResultsUpdate: o,
38
- scriptConsole: s
39
- }) => {
40
- const n = [];
41
- let a = 0, i = 0;
42
- const r = await w(), f = (x, d) => {
43
- d.forEach((c) => {
44
- const u = Number((performance.now() - a).toFixed(2));
45
- a = performance.now(), h(n, c, u);
46
- }), o?.([...n]);
47
- }, m = (x, d, ...c) => {
48
- (s[d] ?? s.log)(...c);
49
- };
50
- try {
51
- r.on("execution.assertion", f), r.on("console", m);
52
- const x = await g(t);
53
- i = performance.now(), a = i, await new Promise((d) => {
54
- r.execute(
55
- {
56
- listen: "test",
57
- script: {
58
- exec: [e]
59
- }
60
- },
61
- {
62
- disableLegacyAPIs: !0,
63
- context: {
64
- response: x
65
- }
66
- },
67
- (c) => {
68
- if (c) {
69
- const u = Number((performance.now() - i).toFixed(2)), p = y(c);
70
- s.error(`[Post-Response Script] Error (${u}ms):`, p), n.push({
71
- title: "Script Execution",
72
- passed: !1,
73
- duration: u,
74
- error: p,
75
- status: "failed"
76
- }), o?.([...n]);
77
- }
78
- d();
79
- }
80
- );
81
- });
82
- } finally {
83
- r.off("execution.assertion", f), r.off("console", m), r.dispose();
84
- }
85
- };
86
- export {
87
- A as executeInPostmanSandbox
88
- };
@@ -1,32 +0,0 @@
1
- import { defineComponent as m, createElementBlock as l, openBlock as o, Fragment as u, renderList as d, unref as p, createElementVNode as f, toDisplayString as _ } from "vue";
2
- import { EXAMPLE_SCRIPTS as x } from "../../../../consts/example-scripts.js";
3
- const b = { class: "flex flex-wrap gap-1" }, E = ["onClick"], h = /* @__PURE__ */ m({
4
- __name: "ExampleScripts",
5
- props: {
6
- modelValue: {}
7
- },
8
- emits: ["update:modelValue"],
9
- setup(i, { emit: s }) {
10
- const n = i, a = s, c = (r) => {
11
- let e = r;
12
- n.modelValue.trim() !== "" && (e = `
13
-
14
- ${e}`), a("update:modelValue", n.modelValue.trim() + e);
15
- };
16
- return (r, e) => (o(), l("ul", b, [
17
- (o(!0), l(u, null, d(p(x), (t) => (o(), l("li", {
18
- key: t.title,
19
- 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"
20
- }, [
21
- f("button", {
22
- class: "w-full",
23
- type: "button",
24
- onClick: (V) => c(t.script)
25
- }, _(t.title), 9, E)
26
- ]))), 128))
27
- ]));
28
- }
29
- });
30
- export {
31
- h as default
32
- };
@@ -1,4 +0,0 @@
1
- import f from "./ExampleScripts.vue.js";
2
- export {
3
- f as default
4
- };
@@ -1,53 +0,0 @@
1
- import { defineComponent as u, computed as c, createElementBlock as i, openBlock as p, createVNode as o, unref as f, withCtx as s, createElementVNode as n, createCommentVNode as _, createTextVNode as x } from "vue";
2
- import V from "./ExampleScripts.vue.js";
3
- import v from "./ScriptEditor.vue.js";
4
- import h from "../../../../components/ViewLayout/ViewLayoutCollapse.vue.js";
5
- const w = { class: "w-full" }, N = { class: "mr-2" }, S = {
6
- key: 0,
7
- class: "bg-green h-2 w-2 rounded-full"
8
- }, b = { class: "border-y p-3" }, E = /* @__PURE__ */ u({
9
- __name: "PostResponseScripts",
10
- props: {
11
- operation: {}
12
- },
13
- emits: ["operation:update:extension"],
14
- setup(a, { emit: d }) {
15
- const m = d, t = c(() => a.operation["x-post-response"] || ""), r = (l) => {
16
- m("operation:update:extension", {
17
- "x-post-response": l
18
- });
19
- };
20
- return (l, e) => (p(), i("div", w, [
21
- o(f(h), {
22
- class: "w-full",
23
- defaultOpen: !0
24
- }, {
25
- title: s(() => [...e[0] || (e[0] = [
26
- x("Scripts", -1)
27
- ])]),
28
- suffix: s(() => [
29
- n("div", N, [
30
- t.value.length > 0 ? (p(), i("div", S)) : _("", !0)
31
- ])
32
- ]),
33
- default: s(() => [
34
- e[1] || (e[1] = n("div", { class: "text-c-3 flex h-8 items-center border-y px-3 text-sm" }, " Post-Response ", -1)),
35
- o(v, {
36
- modelValue: t.value,
37
- "onUpdate:modelValue": r
38
- }, null, 8, ["modelValue"]),
39
- n("div", b, [
40
- o(V, {
41
- modelValue: t.value,
42
- "onUpdate:modelValue": r
43
- }, null, 8, ["modelValue"])
44
- ])
45
- ]),
46
- _: 1
47
- })
48
- ]));
49
- }
50
- });
51
- export {
52
- E as default
53
- };
@@ -1,4 +0,0 @@
1
- import f from "./PostResponseScripts.vue.js";
2
- export {
3
- f as default
4
- };
@@ -1,7 +0,0 @@
1
- import o from "./ScriptEditor.vue2.js";
2
- /* empty css */
3
- import t from "../../../../_virtual/_plugin-vue_export-helper.js";
4
- const f = /* @__PURE__ */ t(o, [["__scopeId", "data-v-a9df3276"]]);
5
- export {
6
- f as default
7
- };
@@ -1,33 +0,0 @@
1
- import { defineComponent as s, ref as c, toRef as a, createElementBlock as l, openBlock as m, createElementVNode as d } from "vue";
2
- import { javascript as p } from "@codemirror/lang-javascript";
3
- import { useCodeMirror as u } from "@scalar/use-codemirror";
4
- const f = { class: "script-editor text-sm" }, g = /* @__PURE__ */ s({
5
- __name: "ScriptEditor",
6
- props: {
7
- modelValue: {}
8
- },
9
- emits: ["update:modelValue"],
10
- setup(t, { emit: r }) {
11
- const n = t, i = r, e = c(null);
12
- return u({
13
- codeMirrorRef: e,
14
- content: a(() => n.modelValue),
15
- language: void 0,
16
- // We want to use some custom configuration for the syntax highlighting.
17
- extensions: [p()],
18
- lineNumbers: !0,
19
- onChange: (o) => {
20
- i("update:modelValue", o);
21
- }
22
- }), (o, _) => (m(), l("div", f, [
23
- d("div", {
24
- ref_key: "codeMirrorRef",
25
- ref: e,
26
- class: "editor-container"
27
- }, null, 512)
28
- ]));
29
- }
30
- });
31
- export {
32
- g as default
33
- };
@@ -1,48 +0,0 @@
1
- import { defineComponent as x, computed as i, createElementBlock as s, openBlock as n, normalizeProps as r, guardReactiveProps as T, unref as e, createBlock as g, createCommentVNode as a, normalizeClass as v, toDisplayString as c, mergeProps as k } from "vue";
2
- import { useBindCx as y, cva as u, ScalarIcon as B } from "@scalar/components";
3
- const z = {
4
- key: 1,
5
- class: "ml-1.25 capitalize"
6
- }, P = /* @__PURE__ */ x({
7
- __name: "TestResultIndicator",
8
- props: {
9
- state: {},
10
- failedTestsCount: {},
11
- pendingTestsCount: {},
12
- totalTestsCount: {},
13
- inline: { type: Boolean }
14
- },
15
- setup(t) {
16
- const { cx: o } = y(), l = i(() => t.state === "passed" ? { name: "Checkmark", color: "text-green p-0.25" } : t.state === "failed" ? { name: "Close", color: "text-red" } : { name: "Ellipses", color: "text-c-1" }), d = u({
17
- base: "flex items-center gap-1.5 rounded-full border pr-2 pl-1.25",
18
- variants: {
19
- status: {
20
- passed: "text-green",
21
- failed: "text-red",
22
- pending: "text-orange"
23
- }
24
- }
25
- }), m = u({
26
- base: "text-c-2",
27
- variants: {
28
- inline: {
29
- true: "text-xs",
30
- false: "text-sm"
31
- }
32
- }
33
- }), f = i(() => t.totalTestsCount === void 0 ? "" : t.failedTestsCount ? `${t.failedTestsCount}/${t.totalTestsCount}` : `${t.totalTestsCount - (t.pendingTestsCount || 0) - (t.failedTestsCount || 0)}/${t.totalTestsCount}`);
34
- return (C, $) => (n(), s("div", r(T(e(o)(e(d)({ status: t.state })))), [
35
- t.state ? (n(), g(e(B), {
36
- key: 0,
37
- class: v(l.value.color),
38
- icon: l.value.name,
39
- size: "sm"
40
- }, null, 8, ["class", "icon"])) : a("", !0),
41
- t.inline ? a("", !0) : (n(), s("span", z, c(t.state), 1)),
42
- t.totalTestsCount !== void 0 ? (n(), s("span", r(k({ key: 2 }, e(o)(e(m)({ inline: t.inline })))), c(f.value), 17)) : a("", !0)
43
- ], 16));
44
- }
45
- });
46
- export {
47
- P as default
48
- };
@@ -1,4 +0,0 @@
1
- import f from "./TestResultIndicator.vue.js";
2
- export {
3
- f as default
4
- };
@@ -1,34 +0,0 @@
1
- import { defineComponent as n, computed as a, createElementBlock as c, openBlock as l, createElementVNode as t, createCommentVNode as i, normalizeClass as o, createVNode as u, unref as d, toDisplayString as s } from "vue";
2
- import { ScalarIcon as m } from "@scalar/components";
3
- const p = { class: "flex flex-col" }, f = { class: "flex items-center gap-3 p-2" }, x = { class: "text-c-2 overflow-hidden text-ellipsis whitespace-nowrap" }, h = { class: "text-c-3 ml-auto whitespace-nowrap" }, g = {
4
- key: 0,
5
- class: "bg-b-danger text-c-1 flex items-center pr-3 pb-1.5 pl-9"
6
- }, C = /* @__PURE__ */ n({
7
- __name: "TestResultItem",
8
- props: {
9
- result: {},
10
- currentState: {}
11
- },
12
- setup(e) {
13
- const r = a(() => e.result.passed ? { icon: "Checkmark", color: "text-green p-0.25" } : !e.result.passed && e.currentState !== "pending" ? { icon: "Close", color: "text-red" } : { icon: "Ellipses", color: "text-c-1" });
14
- return (v, b) => (l(), c("div", p, [
15
- t("div", {
16
- class: o(["flex h-8 items-center gap-2 pr-3 pl-2.25", e.result.error && "bg-b-danger"])
17
- }, [
18
- t("div", f, [
19
- u(d(m), {
20
- class: o(r.value.color),
21
- icon: r.value.icon,
22
- size: "sm"
23
- }, null, 8, ["class", "icon"]),
24
- t("span", x, s(e.result.title), 1)
25
- ]),
26
- t("span", h, s(e.result.duration) + " ms ", 1)
27
- ], 2),
28
- e.result.error ? (l(), c("div", g, s(e.result.error), 1)) : i("", !0)
29
- ]));
30
- }
31
- });
32
- export {
33
- C as default
34
- };
@@ -1,4 +0,0 @@
1
- import f from "./TestResultItem.vue.js";
2
- export {
3
- f as default
4
- };
@@ -1,68 +0,0 @@
1
- import { defineComponent as T, computed as s, createBlock as o, createCommentVNode as c, openBlock as a, unref as g, withCtx as i, createElementVNode as C, createElementBlock as h, Fragment as p, renderList as x, createVNode as k, createTextVNode as y } from "vue";
2
- import N from "./TestResultIndicator.vue.js";
3
- import V from "./TestResultItem.vue.js";
4
- import $ from "./TestSummary.vue.js";
5
- import w from "../../../../components/ViewLayout/ViewLayoutCollapse.vue.js";
6
- const B = { class: "max-h-[calc(100%-32px)] divide-y overflow-y-auto border-t" }, F = /* @__PURE__ */ T({
7
- __name: "TestResults",
8
- props: {
9
- results: {}
10
- },
11
- setup(e) {
12
- const u = s(
13
- () => e.results?.value?.filter((t) => t.status === "passed")
14
- ), n = s(
15
- () => e.results?.value?.filter((t) => t.status === "pending")
16
- ), d = s(
17
- () => e.results?.value?.filter((t) => t.status === "failed")
18
- ), f = s(
19
- () => u.value?.length === e.results?.value?.length
20
- ), m = s(() => f.value ? "passed" : n.value?.length ? "pending" : "failed"), v = s(
21
- () => e.results?.value?.reduce(
22
- (t, l) => t + l.duration,
23
- 0
24
- ) ?? 0
25
- );
26
- return (t, l) => e.results?.value?.length ? (a(), o(g(w), {
27
- key: 0,
28
- class: "overflow-auto text-sm",
29
- defaultOpen: !0
30
- }, {
31
- title: i(() => [...l[0] || (l[0] = [
32
- y(" Tests ", -1)
33
- ])]),
34
- suffix: i(() => [
35
- k(N, {
36
- failedTestsCount: d.value?.length,
37
- inline: "",
38
- passedTestsCount: u.value?.length,
39
- pendingTestsCount: n.value?.length,
40
- state: m.value,
41
- totalTestsCount: e.results?.value?.length
42
- }, null, 8, ["failedTestsCount", "passedTestsCount", "pendingTestsCount", "state", "totalTestsCount"])
43
- ]),
44
- default: i(() => [
45
- C("div", B, [
46
- (a(!0), h(p, null, x(e.results?.value, (r) => (a(), o(V, {
47
- key: r.title,
48
- currentState: r.status,
49
- result: r
50
- }, null, 8, ["currentState", "result"]))), 128)),
51
- e.results ? (a(), o($, {
52
- key: 0,
53
- allTestsPassed: f.value,
54
- failedTests: d.value ?? [],
55
- passedTests: u.value ?? [],
56
- pendingTests: n.value ?? [],
57
- results: e.results?.value,
58
- totalDuration: v.value
59
- }, null, 8, ["allTestsPassed", "failedTests", "passedTests", "pendingTests", "results", "totalDuration"])) : c("", !0)
60
- ])
61
- ]),
62
- _: 1
63
- })) : c("", !0);
64
- }
65
- });
66
- export {
67
- F as default
68
- };
@@ -1,4 +0,0 @@
1
- import f from "./TestResults.vue.js";
2
- export {
3
- f as default
4
- };
@@ -1,32 +0,0 @@
1
- import { defineComponent as a, createElementBlock as t, openBlock as s, createVNode as l, createCommentVNode as o, createElementVNode as d, toDisplayString as n } from "vue";
2
- import i from "./TestResultIndicator.vue.js";
3
- const c = { class: "flex h-8 items-center gap-1.5 pr-3 pl-1" }, u = {
4
- key: 0,
5
- class: "text-orange"
6
- }, T = { class: "text-c-3 ml-auto" }, p = /* @__PURE__ */ a({
7
- __name: "TestSummary",
8
- props: {
9
- results: {},
10
- passedTests: {},
11
- failedTests: {},
12
- pendingTests: {},
13
- allTestsPassed: { type: Boolean },
14
- totalDuration: {}
15
- },
16
- setup(e) {
17
- return (m, r) => (s(), t("div", c, [
18
- l(i, {
19
- failedTestsCount: e.failedTests?.length,
20
- passedTestsCount: e.passedTests?.length,
21
- pendingTestsCount: e.pendingTests?.length,
22
- state: e.allTestsPassed ? "passed" : "failed",
23
- totalTestsCount: e.results?.length
24
- }, null, 8, ["failedTestsCount", "passedTestsCount", "pendingTestsCount", "state", "totalTestsCount"]),
25
- e.pendingTests?.length ? (s(), t("span", u, n(e.pendingTests?.length) + " Pending ", 1)) : o("", !0),
26
- d("span", T, n(e.totalDuration.toFixed(1)) + " ms ", 1)
27
- ]));
28
- }
29
- });
30
- export {
31
- p as default
32
- };
@@ -1,4 +0,0 @@
1
- import f from "./TestSummary.vue.js";
2
- export {
3
- f as default
4
- };
@@ -1,65 +0,0 @@
1
- import { ref as n } from "vue";
2
- import p from "./components/TestResults/TestResults.vue.js";
3
- import r from "./components/PostResponseScripts/PostResponseScripts.vue.js";
4
- import { executePostResponseScript as i } from "../../libs/execute-scripts/execute-post-response-script.js";
5
- const l = () => {
6
- const e = n([]);
7
- return () => ({
8
- name: "post-response-scripts",
9
- views: {
10
- "request.section": [
11
- {
12
- title: "Scripts",
13
- component: r
14
- }
15
- ],
16
- "response.section": [
17
- {
18
- title: "Tests",
19
- component: p,
20
- props: {
21
- results: e
22
- }
23
- }
24
- ]
25
- },
26
- hooks: {
27
- // Reset test results when a new request is sent
28
- onBeforeRequest() {
29
- e.value = [];
30
- },
31
- // Execute post-response scripts when a response is received
32
- async onResponseReceived({ response: s, operation: o }) {
33
- await i(o["x-post-response"], {
34
- response: s,
35
- onTestResultsUpdate: (t) => e.value = [...t]
36
- });
37
- }
38
- }
39
- });
40
- }, R = () => {
41
- const e = n([]);
42
- return {
43
- components: {
44
- request: { component: r },
45
- response: { component: p, additionalProps: { results: e } }
46
- },
47
- hooks: {
48
- // Reset test results when a new request is sent
49
- beforeRequest: () => {
50
- e.value = [];
51
- },
52
- // Execute post-response scripts when a response is received
53
- responseReceived: async ({ response: s, operation: o }) => {
54
- await i(o["x-post-response"], {
55
- response: s,
56
- onTestResultsUpdate: (t) => e.value = [...t]
57
- });
58
- }
59
- }
60
- };
61
- };
62
- export {
63
- l as postResponseScriptsPlugin,
64
- R as postResponseScriptsPluginV2
65
- };