@apifn/core 0.1.0 → 0.2.0
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/README.md +16 -2
- package/dist/chunk-NWH3AIKS.js +68 -0
- package/dist/chunk-NWH3AIKS.js.map +1 -0
- package/dist/index.cjs +478 -30
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +30 -6
- package/dist/index.d.ts +30 -6
- package/dist/index.js +414 -30
- package/dist/index.js.map +1 -1
- package/dist/openapi-reference-context.cjs +92 -0
- package/dist/openapi-reference-context.cjs.map +1 -0
- package/dist/openapi-reference-context.d.cts +24 -0
- package/dist/openapi-reference-context.d.ts +24 -0
- package/dist/openapi-reference-context.js +8 -0
- package/dist/openapi-reference-context.js.map +1 -0
- package/dist/testfn.cjs +85 -25
- package/dist/testfn.cjs.map +1 -1
- package/dist/testfn.d.cts +9 -1
- package/dist/testfn.d.ts +9 -1
- package/dist/testfn.js +85 -25
- package/dist/testfn.js.map +1 -1
- package/package.json +12 -2
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/openapi/reference-context.ts
|
|
21
|
+
var reference_context_exports = {};
|
|
22
|
+
__export(reference_context_exports, {
|
|
23
|
+
openAPIReferenceContext: () => openAPIReferenceContext
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(reference_context_exports);
|
|
26
|
+
var REFERENCE_MODES = /* @__PURE__ */ new Set(["object", "example", "link"]);
|
|
27
|
+
var OBJECT_MAPS = /* @__PURE__ */ new Set(["parameters", "requestBodies", "headers", "securitySchemes", "callbacks", "responses"]);
|
|
28
|
+
var NAME_MAPS = /* @__PURE__ */ new Set([
|
|
29
|
+
"properties",
|
|
30
|
+
"patternProperties",
|
|
31
|
+
"$defs",
|
|
32
|
+
"definitions",
|
|
33
|
+
"dependentSchemas",
|
|
34
|
+
"schemas",
|
|
35
|
+
"links",
|
|
36
|
+
"pathItems",
|
|
37
|
+
"paths",
|
|
38
|
+
"webhooks",
|
|
39
|
+
"content",
|
|
40
|
+
"encoding",
|
|
41
|
+
"variables"
|
|
42
|
+
]);
|
|
43
|
+
var LITERALS = /* @__PURE__ */ new Set(["example", "default", "const", "enum"]);
|
|
44
|
+
function childMode(key, value) {
|
|
45
|
+
if (LITERALS.has(key) || key.startsWith("x-")) return "literal";
|
|
46
|
+
if (key === "examples") return Array.isArray(value) ? "literal" : "examples";
|
|
47
|
+
if (key === "components") return "components";
|
|
48
|
+
if (key === "links") return "links";
|
|
49
|
+
if (key === "paths") return "extNames";
|
|
50
|
+
if (key === "responses") return "extObjects";
|
|
51
|
+
if (key === "requestBody") return "object";
|
|
52
|
+
if (OBJECT_MAPS.has(key)) return "objects";
|
|
53
|
+
return NAME_MAPS.has(key) ? "names" : "node";
|
|
54
|
+
}
|
|
55
|
+
function entryMode(mode, key, value) {
|
|
56
|
+
switch (mode) {
|
|
57
|
+
case "names":
|
|
58
|
+
return "node";
|
|
59
|
+
case "extNames":
|
|
60
|
+
return key.startsWith("x-") ? "literal" : "node";
|
|
61
|
+
case "objects":
|
|
62
|
+
return "object";
|
|
63
|
+
case "extObjects":
|
|
64
|
+
return key.startsWith("x-") ? "literal" : "object";
|
|
65
|
+
case "components":
|
|
66
|
+
if (key.startsWith("x-")) return "literal";
|
|
67
|
+
if (key === "examples" || key === "links") return key;
|
|
68
|
+
return OBJECT_MAPS.has(key) ? "objects" : "names";
|
|
69
|
+
case "examples":
|
|
70
|
+
return "example";
|
|
71
|
+
case "links":
|
|
72
|
+
return "link";
|
|
73
|
+
case "link":
|
|
74
|
+
return key === "parameters" || key === "requestBody" ? "literal" : childMode(key, value);
|
|
75
|
+
default:
|
|
76
|
+
return null;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
var MAP_MODES = /* @__PURE__ */ new Set(["names", "extNames", "objects", "extObjects", "components", "examples", "links"]);
|
|
80
|
+
var MAP_ITEMS = { names: "node", extNames: "node", objects: "object", extObjects: "object" };
|
|
81
|
+
var openAPIReferenceContext = Object.freeze({
|
|
82
|
+
childMode,
|
|
83
|
+
entryMode,
|
|
84
|
+
isReferenceObject: (mode) => REFERENCE_MODES.has(mode),
|
|
85
|
+
isMap: (mode) => MAP_MODES.has(mode),
|
|
86
|
+
arrayItemMode: (mode) => MAP_ITEMS[mode] ?? mode
|
|
87
|
+
});
|
|
88
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
89
|
+
0 && (module.exports = {
|
|
90
|
+
openAPIReferenceContext
|
|
91
|
+
});
|
|
92
|
+
//# sourceMappingURL=openapi-reference-context.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/openapi/reference-context.ts"],"sourcesContent":["/**\n * How a value is read: `node` (an OpenAPI or schema object, whose keys are keywords), `names` (a\n * map from names to nodes, such as `properties`), `extNames` (a names map that also takes `x-`\n * extensions: Paths and Responses), `components`, `examples` (a map of Example Objects), `example`\n * (one Example Object or its `$ref`), `links` and `link` (Link Objects, whose `parameters` and\n * `requestBody` are data), `objects` and `object` (a map of, or one, OpenAPI object that may be a\n * Reference Object: a Parameter, Response, Request Body, Header, Security Scheme or Callback),\n * `extObjects` (Responses: `objects` that also take `x-` extensions) or `literal` (data). A Callback\n * Object is an `object`: its `x-` keys are data and its expressions Path Items.\n */\nexport type OpenAPIReferenceMode =\n | \"node\" | \"names\" | \"extNames\" | \"objects\" | \"extObjects\" | \"object\" | \"components\" | \"examples\" | \"example\" | \"links\" | \"link\"\n | \"literal\";\n\n/** Modes whose `$ref` is a Reference Object: only `summary` and `description` beside it apply. */\nconst REFERENCE_MODES = new Set<OpenAPIReferenceMode>([\"object\", \"example\", \"link\"]);\n/** Maps whose entries may be Reference Objects (not Schema Objects). */\nconst OBJECT_MAPS = new Set([\"parameters\", \"requestBodies\", \"headers\", \"securitySchemes\", \"callbacks\", \"responses\"]);\n\n/** Keywords whose value maps names (any string, `default` and `$ref` included) to nodes. */\nconst NAME_MAPS = new Set([\n \"properties\", \"patternProperties\", \"$defs\", \"definitions\", \"dependentSchemas\", \"schemas\", \"links\", \"pathItems\",\n \"paths\", \"webhooks\", \"content\", \"encoding\", \"variables\",\n]);\n/** Keywords whose value is data. */\nconst LITERALS = new Set([\"example\", \"default\", \"const\", \"enum\"]);\n\n/** How the value under `key` of a node is read. */\nfunction childMode(key: string, value: unknown): OpenAPIReferenceMode {\n if (LITERALS.has(key) || key.startsWith(\"x-\")) return \"literal\";\n if (key === \"examples\") return Array.isArray(value) ? \"literal\" : \"examples\";\n if (key === \"components\") return \"components\";\n if (key === \"links\") return \"links\";\n if (key === \"paths\") return \"extNames\";\n if (key === \"responses\") return \"extObjects\";\n if (key === \"requestBody\") return \"object\";\n if (OBJECT_MAPS.has(key)) return \"objects\";\n return NAME_MAPS.has(key) ? \"names\" : \"node\";\n}\n\n/** How the value under `key` of a map read in `mode` is read (null: `mode` is not a map). */\nfunction entryMode(mode: OpenAPIReferenceMode, key: string, value: unknown): OpenAPIReferenceMode | null {\n switch (mode) {\n case \"names\":\n return \"node\";\n case \"extNames\":\n return key.startsWith(\"x-\") ? \"literal\" : \"node\";\n case \"objects\":\n return \"object\";\n case \"extObjects\":\n return key.startsWith(\"x-\") ? \"literal\" : \"object\";\n case \"components\":\n if (key.startsWith(\"x-\")) return \"literal\";\n if (key === \"examples\" || key === \"links\") return key;\n return OBJECT_MAPS.has(key) ? \"objects\" : \"names\";\n case \"examples\":\n return \"example\";\n case \"links\":\n return \"link\";\n case \"link\":\n return key === \"parameters\" || key === \"requestBody\" ? \"literal\" : childMode(key, value);\n default:\n return null;\n }\n}\n\nconst MAP_MODES = new Set<OpenAPIReferenceMode>([\"names\", \"extNames\", \"objects\", \"extObjects\", \"components\", \"examples\", \"links\"]);\n/** How the items of an array read in a map mode are read. */\nconst MAP_ITEMS: Partial<Record<OpenAPIReferenceMode, OpenAPIReferenceMode>> = { names: \"node\", extNames: \"node\", objects: \"object\", extObjects: \"object\" };\n\nexport const openAPIReferenceContext = Object.freeze({\n childMode,\n entryMode,\n isReferenceObject: (mode: OpenAPIReferenceMode) => REFERENCE_MODES.has(mode),\n isMap: (mode: OpenAPIReferenceMode) => MAP_MODES.has(mode),\n arrayItemMode: (mode: OpenAPIReferenceMode) => MAP_ITEMS[mode] ?? mode,\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAeA,IAAM,kBAAkB,oBAAI,IAA0B,CAAC,UAAU,WAAW,MAAM,CAAC;AAEnF,IAAM,cAAc,oBAAI,IAAI,CAAC,cAAc,iBAAiB,WAAW,mBAAmB,aAAa,WAAW,CAAC;AAGnH,IAAM,YAAY,oBAAI,IAAI;AAAA,EACxB;AAAA,EAAc;AAAA,EAAqB;AAAA,EAAS;AAAA,EAAe;AAAA,EAAoB;AAAA,EAAW;AAAA,EAAS;AAAA,EACnG;AAAA,EAAS;AAAA,EAAY;AAAA,EAAW;AAAA,EAAY;AAC9C,CAAC;AAED,IAAM,WAAW,oBAAI,IAAI,CAAC,WAAW,WAAW,SAAS,MAAM,CAAC;AAGhE,SAAS,UAAU,KAAa,OAAsC;AACpE,MAAI,SAAS,IAAI,GAAG,KAAK,IAAI,WAAW,IAAI,EAAG,QAAO;AACtD,MAAI,QAAQ,WAAY,QAAO,MAAM,QAAQ,KAAK,IAAI,YAAY;AAClE,MAAI,QAAQ,aAAc,QAAO;AACjC,MAAI,QAAQ,QAAS,QAAO;AAC5B,MAAI,QAAQ,QAAS,QAAO;AAC5B,MAAI,QAAQ,YAAa,QAAO;AAChC,MAAI,QAAQ,cAAe,QAAO;AAClC,MAAI,YAAY,IAAI,GAAG,EAAG,QAAO;AACjC,SAAO,UAAU,IAAI,GAAG,IAAI,UAAU;AACxC;AAGA,SAAS,UAAU,MAA4B,KAAa,OAA6C;AACvG,UAAQ,MAAM;AAAA,IACZ,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO,IAAI,WAAW,IAAI,IAAI,YAAY;AAAA,IAC5C,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO,IAAI,WAAW,IAAI,IAAI,YAAY;AAAA,IAC5C,KAAK;AACH,UAAI,IAAI,WAAW,IAAI,EAAG,QAAO;AACjC,UAAI,QAAQ,cAAc,QAAQ,QAAS,QAAO;AAClD,aAAO,YAAY,IAAI,GAAG,IAAI,YAAY;AAAA,IAC5C,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO,QAAQ,gBAAgB,QAAQ,gBAAgB,YAAY,UAAU,KAAK,KAAK;AAAA,IACzF;AACE,aAAO;AAAA,EACX;AACF;AAEA,IAAM,YAAY,oBAAI,IAA0B,CAAC,SAAS,YAAY,WAAW,cAAc,cAAc,YAAY,OAAO,CAAC;AAEjI,IAAM,YAAyE,EAAE,OAAO,QAAQ,UAAU,QAAQ,SAAS,UAAU,YAAY,SAAS;AAEnJ,IAAM,0BAA0B,OAAO,OAAO;AAAA,EACnD;AAAA,EACA;AAAA,EACA,mBAAmB,CAAC,SAA+B,gBAAgB,IAAI,IAAI;AAAA,EAC3E,OAAO,CAAC,SAA+B,UAAU,IAAI,IAAI;AAAA,EACzD,eAAe,CAAC,SAA+B,UAAU,IAAI,KAAK;AACpE,CAAC;","names":[]}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How a value is read: `node` (an OpenAPI or schema object, whose keys are keywords), `names` (a
|
|
3
|
+
* map from names to nodes, such as `properties`), `extNames` (a names map that also takes `x-`
|
|
4
|
+
* extensions: Paths and Responses), `components`, `examples` (a map of Example Objects), `example`
|
|
5
|
+
* (one Example Object or its `$ref`), `links` and `link` (Link Objects, whose `parameters` and
|
|
6
|
+
* `requestBody` are data), `objects` and `object` (a map of, or one, OpenAPI object that may be a
|
|
7
|
+
* Reference Object: a Parameter, Response, Request Body, Header, Security Scheme or Callback),
|
|
8
|
+
* `extObjects` (Responses: `objects` that also take `x-` extensions) or `literal` (data). A Callback
|
|
9
|
+
* Object is an `object`: its `x-` keys are data and its expressions Path Items.
|
|
10
|
+
*/
|
|
11
|
+
type OpenAPIReferenceMode = "node" | "names" | "extNames" | "objects" | "extObjects" | "object" | "components" | "examples" | "example" | "links" | "link" | "literal";
|
|
12
|
+
/** How the value under `key` of a node is read. */
|
|
13
|
+
declare function childMode(key: string, value: unknown): OpenAPIReferenceMode;
|
|
14
|
+
/** How the value under `key` of a map read in `mode` is read (null: `mode` is not a map). */
|
|
15
|
+
declare function entryMode(mode: OpenAPIReferenceMode, key: string, value: unknown): OpenAPIReferenceMode | null;
|
|
16
|
+
declare const openAPIReferenceContext: Readonly<{
|
|
17
|
+
childMode: typeof childMode;
|
|
18
|
+
entryMode: typeof entryMode;
|
|
19
|
+
isReferenceObject: (mode: OpenAPIReferenceMode) => boolean;
|
|
20
|
+
isMap: (mode: OpenAPIReferenceMode) => boolean;
|
|
21
|
+
arrayItemMode: (mode: OpenAPIReferenceMode) => OpenAPIReferenceMode;
|
|
22
|
+
}>;
|
|
23
|
+
|
|
24
|
+
export { type OpenAPIReferenceMode, openAPIReferenceContext };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How a value is read: `node` (an OpenAPI or schema object, whose keys are keywords), `names` (a
|
|
3
|
+
* map from names to nodes, such as `properties`), `extNames` (a names map that also takes `x-`
|
|
4
|
+
* extensions: Paths and Responses), `components`, `examples` (a map of Example Objects), `example`
|
|
5
|
+
* (one Example Object or its `$ref`), `links` and `link` (Link Objects, whose `parameters` and
|
|
6
|
+
* `requestBody` are data), `objects` and `object` (a map of, or one, OpenAPI object that may be a
|
|
7
|
+
* Reference Object: a Parameter, Response, Request Body, Header, Security Scheme or Callback),
|
|
8
|
+
* `extObjects` (Responses: `objects` that also take `x-` extensions) or `literal` (data). A Callback
|
|
9
|
+
* Object is an `object`: its `x-` keys are data and its expressions Path Items.
|
|
10
|
+
*/
|
|
11
|
+
type OpenAPIReferenceMode = "node" | "names" | "extNames" | "objects" | "extObjects" | "object" | "components" | "examples" | "example" | "links" | "link" | "literal";
|
|
12
|
+
/** How the value under `key` of a node is read. */
|
|
13
|
+
declare function childMode(key: string, value: unknown): OpenAPIReferenceMode;
|
|
14
|
+
/** How the value under `key` of a map read in `mode` is read (null: `mode` is not a map). */
|
|
15
|
+
declare function entryMode(mode: OpenAPIReferenceMode, key: string, value: unknown): OpenAPIReferenceMode | null;
|
|
16
|
+
declare const openAPIReferenceContext: Readonly<{
|
|
17
|
+
childMode: typeof childMode;
|
|
18
|
+
entryMode: typeof entryMode;
|
|
19
|
+
isReferenceObject: (mode: OpenAPIReferenceMode) => boolean;
|
|
20
|
+
isMap: (mode: OpenAPIReferenceMode) => boolean;
|
|
21
|
+
arrayItemMode: (mode: OpenAPIReferenceMode) => OpenAPIReferenceMode;
|
|
22
|
+
}>;
|
|
23
|
+
|
|
24
|
+
export { type OpenAPIReferenceMode, openAPIReferenceContext };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/testfn.cjs
CHANGED
|
@@ -5789,7 +5789,37 @@ module.exports = __toCommonJS(testfn_exports);
|
|
|
5789
5789
|
var path = __toESM(require("path"), 1);
|
|
5790
5790
|
var fs = __toESM(require("fs"), 1);
|
|
5791
5791
|
var import_core = require("@testfn/core");
|
|
5792
|
+
var REQUEST_ID_PREFIX = "apifn:";
|
|
5793
|
+
function requestId(directory, requestPath) {
|
|
5794
|
+
return REQUEST_ID_PREFIX + JSON.stringify([directory, requestPath]);
|
|
5795
|
+
}
|
|
5796
|
+
function isRequestPathId(id) {
|
|
5797
|
+
if (!id.startsWith(REQUEST_ID_PREFIX)) return false;
|
|
5798
|
+
try {
|
|
5799
|
+
const parts = JSON.parse(id.slice(REQUEST_ID_PREFIX.length));
|
|
5800
|
+
return Array.isArray(parts) && parts.length === 2 && parts.every((part) => typeof part === "string");
|
|
5801
|
+
} catch {
|
|
5802
|
+
return false;
|
|
5803
|
+
}
|
|
5804
|
+
}
|
|
5805
|
+
function visitRequests(collection, visit) {
|
|
5806
|
+
function walk(items, suitePath) {
|
|
5807
|
+
for (const item of items) {
|
|
5808
|
+
if (item.kind === "request") {
|
|
5809
|
+
visit(item, suitePath.length ? suitePath.join(" > ") : collection.info.name);
|
|
5810
|
+
} else if (item.kind === "folder" && item.children) {
|
|
5811
|
+
walk(item.children, [...suitePath, item.name]);
|
|
5812
|
+
}
|
|
5813
|
+
}
|
|
5814
|
+
}
|
|
5815
|
+
walk(collection.items, []);
|
|
5816
|
+
}
|
|
5792
5817
|
var ApifnTestAdapter = class extends import_core.BaseAdapter {
|
|
5818
|
+
constructor(collectionOptions = {}) {
|
|
5819
|
+
super();
|
|
5820
|
+
this.collectionOptions = collectionOptions;
|
|
5821
|
+
}
|
|
5822
|
+
collectionOptions;
|
|
5793
5823
|
name = "apifn";
|
|
5794
5824
|
supports(framework) {
|
|
5795
5825
|
return framework.toLowerCase() === "apifn";
|
|
@@ -5833,23 +5863,15 @@ var ApifnTestAdapter = class extends import_core.BaseAdapter {
|
|
|
5833
5863
|
for (const dir of discoveredDirs) {
|
|
5834
5864
|
try {
|
|
5835
5865
|
const collection = await readCollection(dir);
|
|
5836
|
-
|
|
5837
|
-
|
|
5838
|
-
|
|
5839
|
-
|
|
5840
|
-
|
|
5841
|
-
|
|
5842
|
-
|
|
5843
|
-
|
|
5844
|
-
|
|
5845
|
-
tags: ["api"]
|
|
5846
|
-
});
|
|
5847
|
-
} else if (item.kind === "folder" && item.children) {
|
|
5848
|
-
walk(item.children, [...suitePath, item.name]);
|
|
5849
|
-
}
|
|
5850
|
-
}
|
|
5851
|
-
};
|
|
5852
|
-
walk(collection.items, []);
|
|
5866
|
+
visitRequests(collection, (item, suite) => {
|
|
5867
|
+
testCases.push({
|
|
5868
|
+
id: requestId(dir, item.path),
|
|
5869
|
+
file: dir,
|
|
5870
|
+
name: item.name,
|
|
5871
|
+
suite,
|
|
5872
|
+
tags: ["api"]
|
|
5873
|
+
});
|
|
5874
|
+
});
|
|
5853
5875
|
} catch (err) {
|
|
5854
5876
|
console.warn(`[apifn/testfn] Failed to read collection at ${dir}:`, err);
|
|
5855
5877
|
}
|
|
@@ -5857,7 +5879,10 @@ var ApifnTestAdapter = class extends import_core.BaseAdapter {
|
|
|
5857
5879
|
return testCases;
|
|
5858
5880
|
}
|
|
5859
5881
|
async run(tests, options) {
|
|
5860
|
-
const { runCollection, readCollection } = await import("@apifn/collections");
|
|
5882
|
+
const { runCollection, readCollection, COLLECTION_RUNNER_TRUST_OPTIONS } = await import("@apifn/collections");
|
|
5883
|
+
if (COLLECTION_RUNNER_TRUST_OPTIONS !== true) {
|
|
5884
|
+
throw new Error("The ApiFn TestFn adapter requires @apifn/collections 0.0.5 or later.");
|
|
5885
|
+
}
|
|
5861
5886
|
const results = [];
|
|
5862
5887
|
const collectionsToRun = /* @__PURE__ */ new Map();
|
|
5863
5888
|
for (const t of tests) {
|
|
@@ -5875,20 +5900,55 @@ var ApifnTestAdapter = class extends import_core.BaseAdapter {
|
|
|
5875
5900
|
});
|
|
5876
5901
|
};
|
|
5877
5902
|
for (const [dir, testsInCollection] of collectionsToRun.entries()) {
|
|
5903
|
+
const completedCases = /* @__PURE__ */ new Set();
|
|
5878
5904
|
try {
|
|
5879
5905
|
const collection = await readCollection(dir);
|
|
5880
|
-
const
|
|
5906
|
+
const requestsByName = /* @__PURE__ */ new Map();
|
|
5907
|
+
const pathsById = /* @__PURE__ */ new Map();
|
|
5908
|
+
const casesByPath = /* @__PURE__ */ new Map();
|
|
5909
|
+
visitRequests(collection, (item, suite) => {
|
|
5910
|
+
const matches = requestsByName.get(item.name) ?? [];
|
|
5911
|
+
matches.push({ path: item.path, suite });
|
|
5912
|
+
requestsByName.set(item.name, matches);
|
|
5913
|
+
pathsById.set(requestId(dir, item.path), item.path);
|
|
5914
|
+
});
|
|
5915
|
+
for (const test of testsInCollection) {
|
|
5916
|
+
const matches = isRequestPathId(test.id) ? [] : requestsByName.get(test.name)?.filter((request) => !test.suite || test.suite === request.suite) ?? [];
|
|
5917
|
+
const selectedPath = pathsById.get(test.id) ?? (matches.length === 1 ? matches[0].path : void 0);
|
|
5918
|
+
if (selectedPath !== void 0) {
|
|
5919
|
+
const known = casesByPath.get(selectedPath) ?? [];
|
|
5920
|
+
known.push(test);
|
|
5921
|
+
casesByPath.set(selectedPath, known);
|
|
5922
|
+
} else {
|
|
5923
|
+
completedCases.add(test);
|
|
5924
|
+
const ambiguous = matches.length > 1;
|
|
5925
|
+
results.push({
|
|
5926
|
+
id: test.id,
|
|
5927
|
+
status: ambiguous ? "failed" : "skipped",
|
|
5928
|
+
duration: 0,
|
|
5929
|
+
error: {
|
|
5930
|
+
message: ambiguous ? "Multiple collection requests match this test. Discover the tests again to select a request by path." : "Test not found in collection"
|
|
5931
|
+
}
|
|
5932
|
+
});
|
|
5933
|
+
updateProgress(test);
|
|
5934
|
+
}
|
|
5935
|
+
}
|
|
5936
|
+
const runOptions = {
|
|
5881
5937
|
// Default to the first environment or a dummy one if none exists
|
|
5882
5938
|
environment: Object.keys(collection.environments)[0] ?? "default",
|
|
5883
5939
|
parallel: options.parallel !== void 0 && options.parallel > 1,
|
|
5884
5940
|
concurrency: typeof options.parallel === "number" ? options.parallel : void 0,
|
|
5885
5941
|
timeout: options.timeout,
|
|
5886
5942
|
retries: options.retries,
|
|
5887
|
-
overrides: options.env
|
|
5888
|
-
|
|
5943
|
+
overrides: options.env,
|
|
5944
|
+
allowScripts: this.collectionOptions.allowScripts === true,
|
|
5945
|
+
processEnv: this.collectionOptions.processEnv,
|
|
5946
|
+
includePaths: [...casesByPath.keys()]
|
|
5947
|
+
};
|
|
5948
|
+
const report = casesByPath.size ? await runCollection(collection, runOptions) : { results: [] };
|
|
5889
5949
|
for (const reqRes of report.results) {
|
|
5890
|
-
const
|
|
5891
|
-
|
|
5950
|
+
for (const tc of casesByPath.get(reqRes.path) ?? []) {
|
|
5951
|
+
completedCases.add(tc);
|
|
5892
5952
|
let status = "passed";
|
|
5893
5953
|
let testError;
|
|
5894
5954
|
if (reqRes.status === "failed" || reqRes.status === "error") {
|
|
@@ -5918,9 +5978,8 @@ ${msg}`
|
|
|
5918
5978
|
updateProgress(tc);
|
|
5919
5979
|
}
|
|
5920
5980
|
}
|
|
5921
|
-
const runTestNames = new Set(report.results.map((r) => r.name));
|
|
5922
5981
|
for (const tc of testsInCollection) {
|
|
5923
|
-
if (!
|
|
5982
|
+
if (!completedCases.has(tc)) {
|
|
5924
5983
|
results.push({
|
|
5925
5984
|
id: tc.id,
|
|
5926
5985
|
status: "skipped",
|
|
@@ -5932,6 +5991,7 @@ ${msg}`
|
|
|
5932
5991
|
}
|
|
5933
5992
|
} catch (err) {
|
|
5934
5993
|
for (const tc of testsInCollection) {
|
|
5994
|
+
if (completedCases.has(tc)) continue;
|
|
5935
5995
|
results.push({
|
|
5936
5996
|
id: tc.id,
|
|
5937
5997
|
status: "failed",
|