spana-test 0.9.0 → 0.10.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/dist/agent/index.d.ts +2 -2
- package/dist/agent/index.js +6 -6
- package/dist/{allure-RAEK4SIH.js → allure-FGVR5LND.js} +5 -1
- package/dist/allure-FGVR5LND.js.map +1 -0
- package/dist/{app-DSh1ejLh.d.ts → app-xIYd2jde.d.ts} +44 -1
- package/dist/{chunk-ALPQES3J.js → chunk-66D3C7NB.js} +142 -28
- package/dist/chunk-66D3C7NB.js.map +1 -0
- package/dist/{chunk-IGTK5MHB.js → chunk-6GBAPW6K.js} +12 -8
- package/dist/chunk-6GBAPW6K.js.map +1 -0
- package/dist/{chunk-JZZ2W2XH.js → chunk-7QFJ7MDH.js} +2 -1
- package/dist/chunk-7QFJ7MDH.js.map +1 -0
- package/dist/{chunk-3UVSUVHW.js → chunk-B35G77DN.js} +694 -404
- package/dist/chunk-B35G77DN.js.map +1 -0
- package/dist/{chunk-UEWZ2EXL.js → chunk-B473XZOM.js} +90 -13
- package/dist/chunk-B473XZOM.js.map +1 -0
- package/dist/{chunk-Y2RZNOKU.js → chunk-C2HBFEMQ.js} +2 -2
- package/dist/{chunk-PLE7RFQE.js → chunk-DP7MGXHN.js} +26 -1
- package/dist/chunk-DP7MGXHN.js.map +1 -0
- package/dist/{chunk-FP6PVHHR.js → chunk-IXON7DMB.js} +2 -2
- package/dist/{chunk-2KRVN4WN.js → chunk-Y6KMJJ2T.js} +3 -3
- package/dist/cli.js +16 -11
- package/dist/cli.js.map +1 -1
- package/dist/config-loader-WLPQ5WVH.js +9 -0
- package/dist/{console-BGAK7Z2L.js → console-DIYEJSSP.js} +9 -2
- package/dist/console-DIYEJSSP.js.map +1 -0
- package/dist/{doctor-command-YTCQ2SC7.js → doctor-command-QIYBI7ZF.js} +3 -3
- package/dist/{flow-CSMwD9Fh.d.ts → flow-CI5parw2.d.ts} +24 -3
- package/dist/gherkin/steps.d.ts +2 -2
- package/dist/{html-JO2YNRWX.js → html-FLMWPFQD.js} +2 -1
- package/dist/html-FLMWPFQD.js.map +1 -0
- package/dist/index.d.ts +17 -5
- package/dist/index.js +23 -9
- package/dist/index.js.map +1 -1
- package/dist/{junit-HLC62MK6.js → junit-CGB3LKHD.js} +3 -2
- package/dist/junit-CGB3LKHD.js.map +1 -0
- package/dist/{runner-TF4OKPYP.js → runner-JID2YWRE.js} +6 -2
- package/dist/{server-4YLBAZEM.js → server-6KQSTQIG.js} +12 -12
- package/dist/{server-IS4K5FCT.js → server-UIRGHUYM.js} +2 -2
- package/dist/{session-K7FCRKOC.js → session-BE6U34DA.js} +5 -5
- package/dist/{session-CgvT-Oso.d.ts → session-Bt_mbUWg.d.ts} +1 -1
- package/dist/{studio-command-RFPV2DS7.js → studio-command-TXQTIWRS.js} +2 -2
- package/dist/{test-command-UEJG5AI6.js → test-command-CCSQPKWU.js} +106 -27
- package/dist/test-command-CCSQPKWU.js.map +1 -0
- package/dist/{validator-BLOLIHUY.js → validator-YWNHCU2S.js} +3 -3
- package/package.json +1 -1
- package/dist/allure-RAEK4SIH.js.map +0 -1
- package/dist/chunk-3UVSUVHW.js.map +0 -1
- package/dist/chunk-ALPQES3J.js.map +0 -1
- package/dist/chunk-IGTK5MHB.js.map +0 -1
- package/dist/chunk-JZZ2W2XH.js.map +0 -1
- package/dist/chunk-PLE7RFQE.js.map +0 -1
- package/dist/chunk-UEWZ2EXL.js.map +0 -1
- package/dist/config-loader-F5YAY7RP.js +0 -9
- package/dist/console-BGAK7Z2L.js.map +0 -1
- package/dist/html-JO2YNRWX.js.map +0 -1
- package/dist/junit-HLC62MK6.js.map +0 -1
- package/dist/test-command-UEJG5AI6.js.map +0 -1
- /package/dist/{chunk-Y2RZNOKU.js.map → chunk-C2HBFEMQ.js.map} +0 -0
- /package/dist/{chunk-FP6PVHHR.js.map → chunk-IXON7DMB.js.map} +0 -0
- /package/dist/{chunk-2KRVN4WN.js.map → chunk-Y6KMJJ2T.js.map} +0 -0
- /package/dist/{config-loader-F5YAY7RP.js.map → config-loader-WLPQ5WVH.js.map} +0 -0
- /package/dist/{doctor-command-YTCQ2SC7.js.map → doctor-command-QIYBI7ZF.js.map} +0 -0
- /package/dist/{runner-TF4OKPYP.js.map → runner-JID2YWRE.js.map} +0 -0
- /package/dist/{server-4YLBAZEM.js.map → server-6KQSTQIG.js.map} +0 -0
- /package/dist/{server-IS4K5FCT.js.map → server-UIRGHUYM.js.map} +0 -0
- /package/dist/{session-K7FCRKOC.js.map → session-BE6U34DA.js.map} +0 -0
- /package/dist/{studio-command-RFPV2DS7.js.map → studio-command-TXQTIWRS.js.map} +0 -0
- /package/dist/{validator-BLOLIHUY.js.map → validator-YWNHCU2S.js.map} +0 -0
|
@@ -2651,6 +2651,8 @@ var AndroidWebViewCdpChannel = class {
|
|
|
2651
2651
|
allocatedByUs = false;
|
|
2652
2652
|
activeSocketName = null;
|
|
2653
2653
|
cdp = null;
|
|
2654
|
+
routes = [];
|
|
2655
|
+
enableInterception;
|
|
2654
2656
|
constructor(options) {
|
|
2655
2657
|
this.options = options;
|
|
2656
2658
|
}
|
|
@@ -2709,7 +2711,24 @@ var AndroidWebViewCdpChannel = class {
|
|
|
2709
2711
|
fetchFn: this.options.fetchFn,
|
|
2710
2712
|
createWebSocket: this.options.createWebSocket
|
|
2711
2713
|
});
|
|
2714
|
+
const cdp = this.cdp;
|
|
2715
|
+
cdp.onEvent("Fetch.requestPaused", (params, sessionId) => {
|
|
2716
|
+
const requestId = params?.requestId;
|
|
2717
|
+
if (typeof requestId !== "string") return;
|
|
2718
|
+
const route = this.routes.findLast(
|
|
2719
|
+
(candidate) => candidate.matches(String(params?.request?.url ?? ""))
|
|
2720
|
+
);
|
|
2721
|
+
const resume = () => cdp.sendCommand("Fetch.continueRequest", { requestId }, sessionId);
|
|
2722
|
+
const operation = route ? route.response ? cdp.sendCommand("Fetch.fulfillRequest", { requestId, ...route.response }, sessionId) : cdp.sendCommand(
|
|
2723
|
+
"Fetch.failRequest",
|
|
2724
|
+
{ requestId, errorReason: "BlockedByClient" },
|
|
2725
|
+
sessionId
|
|
2726
|
+
) : resume();
|
|
2727
|
+
void operation.catch(() => route ? resume().catch(() => {
|
|
2728
|
+
}) : void 0);
|
|
2729
|
+
});
|
|
2712
2730
|
await this.cdp.connect();
|
|
2731
|
+
if (this.routes.length) await this.ensureInterception();
|
|
2713
2732
|
} catch (error) {
|
|
2714
2733
|
await this.disconnect();
|
|
2715
2734
|
throw error;
|
|
@@ -2750,6 +2769,60 @@ var AndroidWebViewCdpChannel = class {
|
|
|
2750
2769
|
await this.connect();
|
|
2751
2770
|
}
|
|
2752
2771
|
await this.cdp.selectTarget(targetId);
|
|
2772
|
+
this.enableInterception = void 0;
|
|
2773
|
+
if (this.routes.length) await this.ensureInterception();
|
|
2774
|
+
}
|
|
2775
|
+
async ensureInterception() {
|
|
2776
|
+
this.enableInterception ??= this.cdp.sendCommand("Fetch.enable", {
|
|
2777
|
+
patterns: [{ urlPattern: "*" }]
|
|
2778
|
+
});
|
|
2779
|
+
try {
|
|
2780
|
+
await this.enableInterception;
|
|
2781
|
+
} catch (error) {
|
|
2782
|
+
this.enableInterception = void 0;
|
|
2783
|
+
throw error;
|
|
2784
|
+
}
|
|
2785
|
+
}
|
|
2786
|
+
async addRoute(matcher, response) {
|
|
2787
|
+
if (!this.isConnected()) await this.connect();
|
|
2788
|
+
await this.ensureInterception();
|
|
2789
|
+
const regex = typeof matcher === "string" ? matcher.includes("*") ? new RegExp(
|
|
2790
|
+
matcher.split(/(\*\*|\*)/).map(
|
|
2791
|
+
(part) => part === "**" ? ".*" : part === "*" ? "[^/]*" : part.replaceAll(/[.+?^${}()|[\]\\]/g, "\\$&")
|
|
2792
|
+
).join("")
|
|
2793
|
+
) : void 0 : new RegExp(matcher.source, matcher.flags.replaceAll(/[gy]/g, ""));
|
|
2794
|
+
this.routes.push({
|
|
2795
|
+
matches: regex ? (url) => regex.test(url) : (url) => url.includes(matcher),
|
|
2796
|
+
response
|
|
2797
|
+
});
|
|
2798
|
+
}
|
|
2799
|
+
async mockNetwork(matcher, response) {
|
|
2800
|
+
if (response.body !== void 0 && response.json !== void 0) {
|
|
2801
|
+
throw new Error("mockNetwork() response cannot include both body and json.");
|
|
2802
|
+
}
|
|
2803
|
+
const headers = { ...response.headers };
|
|
2804
|
+
const type = response.contentType ?? (response.json === void 0 ? void 0 : "application/json");
|
|
2805
|
+
if (type && !Object.keys(headers).some((key) => key.toLowerCase() === "content-type")) {
|
|
2806
|
+
headers["content-type"] = type;
|
|
2807
|
+
}
|
|
2808
|
+
await this.addRoute(matcher, {
|
|
2809
|
+
responseCode: response.status ?? 200,
|
|
2810
|
+
responseHeaders: Object.entries(headers).map(([name, value]) => ({ name, value })),
|
|
2811
|
+
body: Buffer.from(
|
|
2812
|
+
response.json !== void 0 ? JSON.stringify(response.json) : response.body ?? ""
|
|
2813
|
+
).toString("base64")
|
|
2814
|
+
});
|
|
2815
|
+
}
|
|
2816
|
+
async blockNetwork(matcher) {
|
|
2817
|
+
await this.addRoute(matcher);
|
|
2818
|
+
}
|
|
2819
|
+
async clearNetworkMocks() {
|
|
2820
|
+
this.routes.length = 0;
|
|
2821
|
+
if (this.enableInterception && this.isConnected()) {
|
|
2822
|
+
await this.enableInterception;
|
|
2823
|
+
await this.cdp.sendCommand("Fetch.disable");
|
|
2824
|
+
this.enableInterception = void 0;
|
|
2825
|
+
}
|
|
2753
2826
|
}
|
|
2754
2827
|
async reload() {
|
|
2755
2828
|
if (!this.isConnected()) {
|
|
@@ -2758,6 +2831,7 @@ var AndroidWebViewCdpChannel = class {
|
|
|
2758
2831
|
await this.cdp.reload();
|
|
2759
2832
|
}
|
|
2760
2833
|
async disconnect() {
|
|
2834
|
+
this.enableInterception = void 0;
|
|
2761
2835
|
if (this.cdp) {
|
|
2762
2836
|
await this.cdp.disconnect();
|
|
2763
2837
|
this.cdp = null;
|
|
@@ -3822,11 +3896,11 @@ function createSpanaBridgeChannel(options = {}) {
|
|
|
3822
3896
|
}
|
|
3823
3897
|
function createCompositeDomChannel(channels) {
|
|
3824
3898
|
const active = () => channels.find((c) => c.isConnected()) ?? channels[0];
|
|
3825
|
-
const ensureOneConnected = async () => {
|
|
3826
|
-
const already =
|
|
3899
|
+
const ensureOneConnected = async (candidates = channels, unavailableMessage = "No DOM channel available") => {
|
|
3900
|
+
const already = candidates.find((c) => c.isConnected());
|
|
3827
3901
|
if (already) return already;
|
|
3828
3902
|
let lastError;
|
|
3829
|
-
for (const ch of
|
|
3903
|
+
for (const ch of candidates) {
|
|
3830
3904
|
try {
|
|
3831
3905
|
await ch.connect();
|
|
3832
3906
|
return ch;
|
|
@@ -3834,7 +3908,7 @@ function createCompositeDomChannel(channels) {
|
|
|
3834
3908
|
lastError = err;
|
|
3835
3909
|
}
|
|
3836
3910
|
}
|
|
3837
|
-
throw lastError ?? new Error(
|
|
3911
|
+
throw lastError ?? new Error(unavailableMessage);
|
|
3838
3912
|
};
|
|
3839
3913
|
return {
|
|
3840
3914
|
get kind() {
|
|
@@ -3895,20 +3969,23 @@ function createCompositeDomChannel(channels) {
|
|
|
3895
3969
|
}
|
|
3896
3970
|
},
|
|
3897
3971
|
mockNetwork: async (matcher, response) => {
|
|
3898
|
-
const ch = await ensureOneConnected(
|
|
3899
|
-
|
|
3900
|
-
|
|
3972
|
+
const ch = await ensureOneConnected(
|
|
3973
|
+
channels.filter((c) => c.mockNetwork),
|
|
3974
|
+
"mockNetwork() requires a WebView with spana-bridge or Android WebView debugging enabled"
|
|
3975
|
+
);
|
|
3901
3976
|
await ch.mockNetwork(matcher, response);
|
|
3902
3977
|
},
|
|
3903
3978
|
blockNetwork: async (matcher) => {
|
|
3904
|
-
const ch = await ensureOneConnected(
|
|
3905
|
-
|
|
3906
|
-
|
|
3979
|
+
const ch = await ensureOneConnected(
|
|
3980
|
+
channels.filter((c) => c.blockNetwork),
|
|
3981
|
+
"blockNetwork() requires a WebView with spana-bridge or Android WebView debugging enabled"
|
|
3982
|
+
);
|
|
3907
3983
|
await ch.blockNetwork(matcher);
|
|
3908
3984
|
},
|
|
3909
3985
|
clearNetworkMocks: async () => {
|
|
3910
|
-
|
|
3911
|
-
|
|
3986
|
+
await Promise.all(
|
|
3987
|
+
channels.filter((ch) => ch.isConnected() || ch.kind === "cdp").map((ch) => ch.clearNetworkMocks?.())
|
|
3988
|
+
);
|
|
3912
3989
|
},
|
|
3913
3990
|
getConsoleLogs: async () => {
|
|
3914
3991
|
const ch = await ensureOneConnected();
|
|
@@ -4360,4 +4437,4 @@ export {
|
|
|
4360
4437
|
resolveElectrobunLaunchPlan,
|
|
4361
4438
|
makeElectrobunDriver
|
|
4362
4439
|
};
|
|
4363
|
-
//# sourceMappingURL=chunk-
|
|
4440
|
+
//# sourceMappingURL=chunk-B473XZOM.js.map
|