Refresh HiveGrid Cloud reference snapshot
This commit is contained in:
1 parent
5e99e14772
commit
7f88026f79
5955 files changed
+1177325
-188362
No files matched your search
@@ -1,5 +1,4 @@
|
||||
import { test, type Page, type Response } from "@playwright/test";
|
||||
import { encode } from "turbo-stream";
|
||||
|
||||
const SKIPPABLE_STATUSES = new Set([400, 403, 404]);
|
||||
const MOLLIE_HOST_PATTERN = /(^|\.)mollie\.com$/u;
|
||||
@@ -78,18 +77,46 @@ export function singleFetchActionError(message: string): { status: number; body:
|
||||
};
|
||||
}
|
||||
|
||||
async function encodeTurboStream(value: unknown): Promise<string> {
|
||||
const stream = encode(value);
|
||||
const reader = stream.getReader();
|
||||
const decoder = new TextDecoder();
|
||||
let out = "";
|
||||
for (;;) {
|
||||
const { done, value: chunk } = await reader.read();
|
||||
if (done) break;
|
||||
out += decoder.decode(chunk, { stream: true });
|
||||
function encodeSingleFetchJson(value: unknown): string {
|
||||
const values: string[] = [];
|
||||
const indices = new Map<unknown, number>();
|
||||
|
||||
function flatten(input: unknown): number {
|
||||
if (input === undefined) return -7;
|
||||
if (input === null) return -5;
|
||||
if (typeof input === "number") {
|
||||
if (Number.isNaN(input)) return -2;
|
||||
if (input === Number.NEGATIVE_INFINITY) return -3;
|
||||
if (Object.is(input, -0)) return -4;
|
||||
if (input === Number.POSITIVE_INFINITY) return -6;
|
||||
}
|
||||
|
||||
const existing = indices.get(input);
|
||||
if (existing !== undefined) return existing;
|
||||
|
||||
const index = values.length;
|
||||
indices.set(input, index);
|
||||
values.push("");
|
||||
|
||||
if (typeof input === "string" || typeof input === "number" || typeof input === "boolean") {
|
||||
values[index] = JSON.stringify(input);
|
||||
return index;
|
||||
}
|
||||
if (Array.isArray(input)) {
|
||||
values[index] = `[${input.map((item) => flatten(item)).join(",")}]`;
|
||||
return index;
|
||||
}
|
||||
if (typeof input === "object" && Object.getPrototypeOf(input) === Object.prototype) {
|
||||
const entries = Object.entries(input).map(([key, item]) => `"_${flatten(key)}":${flatten(item)}`);
|
||||
values[index] = `{${entries.join(",")}}`;
|
||||
return index;
|
||||
}
|
||||
|
||||
throw new TypeError("Single-fetch test fixtures must contain only JSON-compatible values");
|
||||
}
|
||||
out += decoder.decode();
|
||||
return out;
|
||||
|
||||
const root = flatten(value);
|
||||
return root < 0 ? `${root}\n` : `[${values.join(",")}]\n`;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -99,9 +126,9 @@ async function encodeTurboStream(value: unknown): Promise<string> {
|
||||
* turbo-stream and the client (`unwrapSingleFetchResult`) hands `.data` to
|
||||
* `useActionData()`. Fulfilling the `.data` POST with raw `application/json`
|
||||
* instead breaks RR7's turbo-stream decoder, so `actionData` is never populated
|
||||
* and the result/waiting UI never renders. We call the real `turbo-stream`
|
||||
* `encode` (same package RR7 uses) so arbitrarily-shaped payloads — e.g. a full
|
||||
* waiting-block execution — encode exactly as the server would. The
|
||||
* and the result/waiting UI never renders. The test helper emits the JSON-only
|
||||
* subset of React Router's inlined v2 wire format, which covers these fixture
|
||||
* payloads without retaining a vulnerable standalone serializer dependency. The
|
||||
* `X-Remix-Response: yes` header is required or RR7 rejects the response.
|
||||
*/
|
||||
export async function singleFetchActionData(
|
||||
@@ -111,7 +138,7 @@ export async function singleFetchActionData(
|
||||
return {
|
||||
status,
|
||||
contentType: "text/x-script",
|
||||
body: await encodeTurboStream({ data: payload }),
|
||||
body: encodeSingleFetchJson({ data: payload }),
|
||||
headers: { "x-remix-response": "yes" },
|
||||
};
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user