@fluojs/testing 1.0.6 → 3.0.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.ko.md +98 -16
- package/README.md +100 -16
- package/dist/babel-decorators-plugin.d.ts +1 -0
- package/dist/babel-decorators-plugin.d.ts.map +1 -1
- package/dist/babel-decorators-plugin.js +1 -0
- package/dist/byte-range-portability-consumer.test-fixture.d.ts +2 -0
- package/dist/byte-range-portability-consumer.test-fixture.d.ts.map +1 -0
- package/dist/byte-range-portability-consumer.test-fixture.js +11 -0
- package/dist/conformance/fetch-style-websocket-conformance.d.ts +1 -0
- package/dist/conformance/fetch-style-websocket-conformance.d.ts.map +1 -1
- package/dist/conformance/fetch-style-websocket-conformance.js +1 -1
- package/dist/conformance/platform-shell-lifecycle-conformance.d.ts +30 -0
- package/dist/conformance/platform-shell-lifecycle-conformance.d.ts.map +1 -0
- package/dist/conformance/platform-shell-lifecycle-conformance.js +259 -0
- package/dist/http.d.ts +2 -1
- package/dist/http.d.ts.map +1 -1
- package/dist/http.js +8 -3
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -2
- package/dist/mock-types.d.ts +2 -0
- package/dist/mock-types.d.ts.map +1 -0
- package/dist/mock-types.js +1 -0
- package/dist/mock.d.ts +3 -2
- package/dist/mock.d.ts.map +1 -1
- package/dist/mock.js +1 -1
- package/dist/module.d.ts.map +1 -1
- package/dist/module.js +103 -113
- package/dist/portability/error-representation-abort-portability.d.ts +36 -0
- package/dist/portability/error-representation-abort-portability.d.ts.map +1 -0
- package/dist/portability/error-representation-abort-portability.js +190 -0
- package/dist/portability/error-representation-portability-fixture.d.ts +58 -0
- package/dist/portability/error-representation-portability-fixture.d.ts.map +1 -0
- package/dist/portability/error-representation-portability-fixture.js +202 -0
- package/dist/portability/error-representation-portability.d.ts +50 -0
- package/dist/portability/error-representation-portability.d.ts.map +1 -0
- package/dist/portability/error-representation-portability.js +153 -0
- package/dist/portability/http-adapter-portability.d.ts +25 -8
- package/dist/portability/http-adapter-portability.d.ts.map +1 -1
- package/dist/portability/http-adapter-portability.js +446 -69
- package/dist/portability/response-cookie-portability.d.ts +16 -0
- package/dist/portability/response-cookie-portability.d.ts.map +1 -0
- package/dist/portability/response-cookie-portability.js +81 -0
- package/dist/portability/web-runtime-adapter-portability.d.ts +24 -8
- package/dist/portability/web-runtime-adapter-portability.d.ts.map +1 -1
- package/dist/portability/web-runtime-adapter-portability.js +356 -31
- package/dist/types.d.ts +68 -4
- package/dist/types.d.ts.map +1 -1
- package/package.json +19 -15
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type ModuleType } from '@fluojs/runtime';
|
|
2
|
+
/**
|
|
3
|
+
* Creates the shared controller fixture for portable response-cookie conformance.
|
|
4
|
+
*
|
|
5
|
+
* @returns A module that writes two cookies and then clears the first cookie.
|
|
6
|
+
*/
|
|
7
|
+
export declare function createResponseCookiePortabilityModule(): ModuleType;
|
|
8
|
+
/**
|
|
9
|
+
* Verifies that one adapter response retains each cookie as an ordered field.
|
|
10
|
+
*
|
|
11
|
+
* @param response Response produced by the adapter under test.
|
|
12
|
+
* @param adapterName Adapter name included in assertion failures.
|
|
13
|
+
* @returns Nothing. Throws when cookies are folded, reordered, or lost.
|
|
14
|
+
*/
|
|
15
|
+
export declare function assertPortableResponseCookies(response: Response, adapterName: string): void;
|
|
16
|
+
//# sourceMappingURL=response-cookie-portability.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"response-cookie-portability.d.ts","sourceRoot":"","sources":["../../src/portability/response-cookie-portability.ts"],"names":[],"mappings":"AAOA,OAAO,EAAgB,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAQhE;;;;GAIG;AACH,wBAAgB,qCAAqC,IAAI,UAAU,CAoClE;AAED;;;;;;GAMG;AACH,wBAAgB,6BAA6B,CAAC,QAAQ,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,GAAG,IAAI,CAY3F"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
function _applyDecs(e, t, n, r, o, i) { var a, c, u, s, f, l, p, d = Symbol.metadata || Symbol.for("Symbol.metadata"), m = Object.defineProperty, h = Object.create, y = [h(null), h(null)], v = t.length; function g(t, n, r) { return function (o, i) { n && (i = o, o = e); for (var a = 0; a < t.length; a++) i = t[a].apply(o, r ? [i] : []); return r ? i : o; }; } function b(e, t, n, r) { if ("function" != typeof e && (r || void 0 !== e)) throw new TypeError(t + " must " + (n || "be") + " a function" + (r ? "" : " or undefined")); return e; } function applyDec(e, t, n, r, o, i, u, s, f, l, p) { function d(e) { if (!p(e)) throw new TypeError("Attempted to access private element on non-instance"); } var h = [].concat(t[0]), v = t[3], w = !u, D = 1 === o, S = 3 === o, j = 4 === o, E = 2 === o; function I(t, n, r) { return function (o, i) { return n && (i = o, o = e), r && r(o), P[t].call(o, i); }; } if (!w) { var P = {}, k = [], F = S ? "get" : j || D ? "set" : "value"; if (f ? (l || D ? P = { get: _setFunctionName(function () { return v(this); }, r, "get"), set: function (e) { t[4](this, e); } } : P[F] = v, l || _setFunctionName(P[F], r, E ? "" : F)) : l || (P = Object.getOwnPropertyDescriptor(e, r)), !l && !f) { if ((c = y[+s][r]) && 7 !== (c ^ o)) throw Error("Decorating two elements with the same name (" + P[F].name + ") is not supported yet"); y[+s][r] = o < 3 ? 1 : o; } } for (var N = e, O = h.length - 1; O >= 0; O -= n ? 2 : 1) { var T = b(h[O], "A decorator", "be", !0), z = n ? h[O - 1] : void 0, A = {}, H = { kind: ["field", "accessor", "method", "getter", "setter", "class"][o], name: r, metadata: a, addInitializer: function (e, t) { if (e.v) throw new TypeError("attempted to call addInitializer after decoration was finished"); b(t, "An initializer", "be", !0), i.push(t); }.bind(null, A) }; if (w) c = T.call(z, N, H), A.v = 1, b(c, "class decorators", "return") && (N = c);else if (H.static = s, H.private = f, c = H.access = { has: f ? p.bind() : function (e) { return r in e; } }, j || (c.get = f ? E ? function (e) { return d(e), P.value; } : I("get", 0, d) : function (e) { return e[r]; }), E || S || (c.set = f ? I("set", 0, d) : function (e, t) { e[r] = t; }), N = T.call(z, D ? { get: P.get, set: P.set } : P[F], H), A.v = 1, D) { if ("object" == typeof N && N) (c = b(N.get, "accessor.get")) && (P.get = c), (c = b(N.set, "accessor.set")) && (P.set = c), (c = b(N.init, "accessor.init")) && k.unshift(c);else if (void 0 !== N) throw new TypeError("accessor decorators must return an object with get, set, or init properties or undefined"); } else b(N, (l ? "field" : "method") + " decorators", "return") && (l ? k.unshift(N) : P[F] = N); } return o < 2 && u.push(g(k, s, 1), g(i, s, 0)), l || w || (f ? D ? u.splice(-1, 0, I("get", s), I("set", s)) : u.push(E ? P[F] : b.call.bind(P[F])) : m(e, r, P)), N; } function w(e) { return m(e, d, { configurable: !0, enumerable: !0, value: a }); } return void 0 !== i && (a = i[d]), a = h(null == a ? null : a), f = [], l = function (e) { e && f.push(g(e)); }, p = function (t, r) { for (var i = 0; i < n.length; i++) { var a = n[i], c = a[1], l = 7 & c; if ((8 & c) == t && !l == r) { var p = a[2], d = !!a[3], m = 16 & c; applyDec(t ? e : e.prototype, a, m, d ? "#" + p : _toPropertyKey(p), l, l < 2 ? [] : t ? s = s || [] : u = u || [], f, !!t, d, r, t && d ? function (t) { return _checkInRHS(t) === e; } : o); } } }, p(8, 0), p(0, 0), p(8, 1), p(0, 1), l(u), l(s), c = f, v || w(e), { e: c, get c() { var n = []; return v && [w(e = applyDec(e, [t], r, e.name, 5, n)), g(n, 1)]; } }; }
|
|
2
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
3
|
+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
4
|
+
function _setFunctionName(e, t, n) { "symbol" == typeof t && (t = (t = t.description) ? "[" + t + "]" : ""); try { Object.defineProperty(e, "name", { configurable: !0, value: n ? n + " " + t : t }); } catch (e) {} return e; }
|
|
5
|
+
function _checkInRHS(e) { if (Object(e) !== e) throw TypeError("right-hand side of 'in' should be an object, got " + (null !== e ? typeof e : "null")); return e; }
|
|
6
|
+
import { Controller, clearCookie, Get, setCookie } from '@fluojs/http';
|
|
7
|
+
import { defineModule } from '@fluojs/runtime';
|
|
8
|
+
const EXPECTED_RESPONSE_COOKIES = ['session=hello%20world; Max-Age=90; Path=/account; Domain=example.test; Secure; HttpOnly; SameSite=Lax', 'refresh=token; Max-Age=180; Path=/account; SameSite=Strict', 'session=; Max-Age=0; Expires=Thu, 01 Jan 1970 00:00:00 GMT; Path=/account; Domain=example.test; Secure; HttpOnly; SameSite=Lax'];
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Creates the shared controller fixture for portable response-cookie conformance.
|
|
12
|
+
*
|
|
13
|
+
* @returns A module that writes two cookies and then clears the first cookie.
|
|
14
|
+
*/
|
|
15
|
+
export function createResponseCookiePortabilityModule() {
|
|
16
|
+
let _initProto, _initClass;
|
|
17
|
+
let _ResponseCookieContro;
|
|
18
|
+
class ResponseCookieController {
|
|
19
|
+
static {
|
|
20
|
+
({
|
|
21
|
+
e: [_initProto],
|
|
22
|
+
c: [_ResponseCookieContro, _initClass]
|
|
23
|
+
} = _applyDecs(this, [Controller('/response-cookies')], [[Get('/'), 2, "write"]]));
|
|
24
|
+
}
|
|
25
|
+
constructor() {
|
|
26
|
+
_initProto(this);
|
|
27
|
+
}
|
|
28
|
+
write(_input, context) {
|
|
29
|
+
setCookie(context.response, 'session', 'hello world', {
|
|
30
|
+
domain: 'example.test',
|
|
31
|
+
httpOnly: true,
|
|
32
|
+
maxAgeSeconds: 90,
|
|
33
|
+
path: '/account',
|
|
34
|
+
sameSite: 'lax',
|
|
35
|
+
secure: true
|
|
36
|
+
});
|
|
37
|
+
setCookie(context.response, 'refresh', 'token', {
|
|
38
|
+
maxAgeSeconds: 180,
|
|
39
|
+
path: '/account',
|
|
40
|
+
sameSite: 'strict'
|
|
41
|
+
});
|
|
42
|
+
clearCookie(context.response, 'session', {
|
|
43
|
+
domain: 'example.test',
|
|
44
|
+
httpOnly: true,
|
|
45
|
+
path: '/account',
|
|
46
|
+
sameSite: 'lax',
|
|
47
|
+
secure: true
|
|
48
|
+
});
|
|
49
|
+
return {
|
|
50
|
+
written: true
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
static {
|
|
54
|
+
_initClass();
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
class ResponseCookieModule {}
|
|
58
|
+
defineModule(ResponseCookieModule, {
|
|
59
|
+
controllers: [_ResponseCookieContro]
|
|
60
|
+
});
|
|
61
|
+
return ResponseCookieModule;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Verifies that one adapter response retains each cookie as an ordered field.
|
|
66
|
+
*
|
|
67
|
+
* @param response Response produced by the adapter under test.
|
|
68
|
+
* @param adapterName Adapter name included in assertion failures.
|
|
69
|
+
* @returns Nothing. Throws when cookies are folded, reordered, or lost.
|
|
70
|
+
*/
|
|
71
|
+
export function assertPortableResponseCookies(response, adapterName) {
|
|
72
|
+
const actual = response.headers.getSetCookie();
|
|
73
|
+
if (actual.length !== EXPECTED_RESPONSE_COOKIES.length) {
|
|
74
|
+
throw new Error(`${adapterName} returned ${actual.length} Set-Cookie fields instead of ${EXPECTED_RESPONSE_COOKIES.length}.`);
|
|
75
|
+
}
|
|
76
|
+
for (const [index, expected] of EXPECTED_RESPONSE_COOKIES.entries()) {
|
|
77
|
+
if (actual[index] !== expected) {
|
|
78
|
+
throw new Error(`${adapterName} returned an incorrect Set-Cookie field at index ${index}.`);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
rawBody?: Uint8Array;
|
|
6
|
-
}
|
|
7
|
-
}
|
|
1
|
+
import { type ContentNegotiationOptions, type ConditionalRequestOptions } from '@fluojs/http';
|
|
2
|
+
import { type ModuleType } from '@fluojs/runtime';
|
|
3
|
+
import { type WebHttpErrorRepresentationBootstrapOptions } from './error-representation-portability.js';
|
|
4
|
+
export type { WebHttpErrorRepresentationBootstrapOptions } from './error-representation-portability.js';
|
|
8
5
|
type WebRuntimePortabilityAppLike = {
|
|
9
6
|
close(): Promise<void>;
|
|
10
7
|
dispatch(request: Request): Promise<Response>;
|
|
@@ -14,6 +11,14 @@ type WebRuntimePortabilityAppLike = {
|
|
|
14
11
|
*/
|
|
15
12
|
export interface WebRuntimeHttpAdapterPortabilityHarnessOptions<TBootstrapOptions extends object, TApp extends WebRuntimePortabilityAppLike = WebRuntimePortabilityAppLike> {
|
|
16
13
|
bootstrap: (rootModule: ModuleType, options: TBootstrapOptions) => Promise<TApp>;
|
|
14
|
+
/** Adapts the shared error-representation fixture fields to this runtime's bootstrap options. */
|
|
15
|
+
createErrorRepresentationBootstrapOptions?: (options: WebHttpErrorRepresentationBootstrapOptions) => TBootstrapOptions;
|
|
16
|
+
/** Adapts shared conditional-request policy options to one web runtime bootstrap API. */
|
|
17
|
+
createConditionalRequestBootstrapOptions?: (options: {
|
|
18
|
+
readonly conditionalRequest: ConditionalRequestOptions;
|
|
19
|
+
readonly contentNegotiation: ContentNegotiationOptions;
|
|
20
|
+
readonly cors: false;
|
|
21
|
+
}) => TBootstrapOptions;
|
|
17
22
|
name: string;
|
|
18
23
|
}
|
|
19
24
|
/**
|
|
@@ -22,7 +27,19 @@ export interface WebRuntimeHttpAdapterPortabilityHarnessOptions<TBootstrapOption
|
|
|
22
27
|
export declare class WebRuntimeHttpAdapterPortabilityHarness<TBootstrapOptions extends object, TApp extends WebRuntimePortabilityAppLike = WebRuntimePortabilityAppLike> {
|
|
23
28
|
private readonly options;
|
|
24
29
|
constructor(options: WebRuntimeHttpAdapterPortabilityHarnessOptions<TBootstrapOptions, TApp>);
|
|
30
|
+
/** Verifies JSON, HTML, HEAD, 406, and committed error-response portability. */
|
|
31
|
+
assertSupportsHttpErrorRepresentations(): Promise<void>;
|
|
32
|
+
/** Verifies request abort propagation without an HTML or JSON fallback commit. */
|
|
33
|
+
assertDoesNotCommitAbortedHttpErrorRepresentations(): Promise<void>;
|
|
34
|
+
/** Verifies ordered, non-folded portable response cookies through Web Response headers. */
|
|
35
|
+
assertSupportsPortableResponseCookies(): Promise<void>;
|
|
36
|
+
/** Verifies 304/412 metadata and body suppression through fetch-style adapters. */
|
|
37
|
+
assertSupportsConditionalRequests(): Promise<void>;
|
|
38
|
+
/** Verifies single-byte-range metadata and payload slicing through fetch dispatch. */
|
|
39
|
+
assertSupportsSingleByteRanges(): Promise<void>;
|
|
25
40
|
assertPreservesQueryArraysAndDecoding(): Promise<void>;
|
|
41
|
+
/** Verifies `QUERY` and extension-method execution through the runtime's fetch dispatch seam. */
|
|
42
|
+
assertSupportsCustomHttpRouteMethods(): Promise<void>;
|
|
26
43
|
assertPreservesMalformedCookieValues(): Promise<void>;
|
|
27
44
|
assertPreservesRawBodyForJsonAndText(): Promise<void>;
|
|
28
45
|
/**
|
|
@@ -39,5 +56,4 @@ export declare class WebRuntimeHttpAdapterPortabilityHarness<TBootstrapOptions e
|
|
|
39
56
|
* @returns The create web runtime http adapter portability harness result.
|
|
40
57
|
*/
|
|
41
58
|
export declare function createWebRuntimeHttpAdapterPortabilityHarness<TBootstrapOptions extends object, TApp extends WebRuntimePortabilityAppLike = WebRuntimePortabilityAppLike>(options: WebRuntimeHttpAdapterPortabilityHarnessOptions<TBootstrapOptions, TApp>): WebRuntimeHttpAdapterPortabilityHarness<TBootstrapOptions, TApp>;
|
|
42
|
-
export {};
|
|
43
59
|
//# sourceMappingURL=web-runtime-adapter-portability.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"web-runtime-adapter-portability.d.ts","sourceRoot":"","sources":["../../src/portability/web-runtime-adapter-portability.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"web-runtime-adapter-portability.d.ts","sourceRoot":"","sources":["../../src/portability/web-runtime-adapter-portability.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,yBAAyB,EAM9B,KAAK,yBAAyB,EAI/B,MAAM,cAAc,CAAC;AACtB,OAAO,EAAgB,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAEhE,OAAO,EAEL,KAAK,0CAA0C,EAChD,MAAM,uCAAuC,CAAC;AAM/C,YAAY,EAAE,0CAA0C,EAAE,MAAM,uCAAuC,CAAC;AAExG,KAAK,4BAA4B,GAAG;IAClC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACvB,QAAQ,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;CAC/C,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,8CAA8C,CAC7D,iBAAiB,SAAS,MAAM,EAChC,IAAI,SAAS,4BAA4B,GAAG,4BAA4B;IAExE,SAAS,EAAE,CAAC,UAAU,EAAE,UAAU,EAAE,OAAO,EAAE,iBAAiB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACjF,iGAAiG;IACjG,yCAAyC,CAAC,EAAE,CAC1C,OAAO,EAAE,0CAA0C,KAChD,iBAAiB,CAAC;IACvB,yFAAyF;IACzF,wCAAwC,CAAC,EAAE,CACzC,OAAO,EAAE;QACP,QAAQ,CAAC,kBAAkB,EAAE,yBAAyB,CAAC;QACvD,QAAQ,CAAC,kBAAkB,EAAE,yBAAyB,CAAC;QACvD,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC;KACtB,KACE,iBAAiB,CAAC;IACvB,IAAI,EAAE,MAAM,CAAC;CACd;AA0CD;;GAEG;AACH,qBAAa,uCAAuC,CAClD,iBAAiB,SAAS,MAAM,EAChC,IAAI,SAAS,4BAA4B,GAAG,4BAA4B;IAE5D,OAAO,CAAC,QAAQ,CAAC,OAAO;gBAAP,OAAO,EAAE,8CAA8C,CAAC,iBAAiB,EAAE,IAAI,CAAC;IAE7G,gFAAgF;IAC1E,sCAAsC,IAAI,OAAO,CAAC,IAAI,CAAC;IAa7D,kFAAkF;IAC5E,kDAAkD,IAAI,OAAO,CAAC,IAAI,CAAC;IAazE,2FAA2F;IACrF,qCAAqC,IAAI,OAAO,CAAC,IAAI,CAAC;IAa5D,mFAAmF;IAC7E,iCAAiC,IAAI,OAAO,CAAC,IAAI,CAAC;IAwFxD,sFAAsF;IAChF,8BAA8B,IAAI,OAAO,CAAC,IAAI,CAAC;IAwJ/C,qCAAqC,IAAI,OAAO,CAAC,IAAI,CAAC;IAyC5D,iGAAiG;IAC3F,oCAAoC,IAAI,OAAO,CAAC,IAAI,CAAC;IAmDrD,oCAAoC,IAAI,OAAO,CAAC,IAAI,CAAC;IAgDrD,oCAAoC,IAAI,OAAO,CAAC,IAAI,CAAC;IAsE3D;;OAEG;IACG,wDAAwD,IAAI,OAAO,CAAC,IAAI,CAAC;IA0CzE,iCAAiC,IAAI,OAAO,CAAC,IAAI,CAAC;IAqDlD,0BAA0B,IAAI,OAAO,CAAC,IAAI,CAAC;CA8ClD;AAED;;;;;GAKG;AACH,wBAAgB,6CAA6C,CAC3D,iBAAiB,SAAS,MAAM,EAChC,IAAI,SAAS,4BAA4B,GAAG,4BAA4B,EAExE,OAAO,EAAE,8CAA8C,CAAC,iBAAiB,EAAE,IAAI,CAAC,GAC/E,uCAAuC,CAAC,iBAAiB,EAAE,IAAI,CAAC,CAElE"}
|