release: WRNexusJS 0.8.3
This commit is contained in:
@@ -62,7 +62,9 @@ test("production streams request regions into the build-time static shell", asyn
|
||||
test("normal production output remains free of development HMR", async () => {
|
||||
const handlers = createProductionHandlers(manifest, {});
|
||||
const response = await handlers.fetch(new Request("http://localhost/"), server);
|
||||
expect(await (response as Response).text()).not.toContain("/__wrnexus/hmr");
|
||||
const html = await (response as Response).text();
|
||||
expect(html).not.toContain("/__wrnexus/hmr");
|
||||
expect(html).toContain('data-wrn-route-params="{}"');
|
||||
});
|
||||
|
||||
test("production client-load endpoint returns only the requested named result", async () => {
|
||||
@@ -121,3 +123,43 @@ test("production prefers fast gzip for dynamic HTML and cached Brotli for immuta
|
||||
)) as Response;
|
||||
expect(head.headers.get("content-encoding")).toBeNull();
|
||||
});
|
||||
|
||||
test("client-load preserves the active route query string", async () => {
|
||||
const queryManifest: ProdManifest = {
|
||||
...manifest,
|
||||
pages: [
|
||||
...manifest.pages,
|
||||
{
|
||||
raw: "/query",
|
||||
mod: {
|
||||
default: () => "<main>Query page</main>",
|
||||
__wrnexusClientLoad: async (ctx: { url: URL }) => ({
|
||||
identity: ctx.url.searchParams.get("as"),
|
||||
}),
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
const handlers = createProductionHandlers(queryManifest, {});
|
||||
const response = (await handlers.fetch(
|
||||
new Request(
|
||||
"http://localhost/__wrnexus/client-load?route=%2Fquery&search=%3Fas%3Drohan&name=identity",
|
||||
),
|
||||
server,
|
||||
)) as Response;
|
||||
expect(response.status).toBe(200);
|
||||
expect(await response.json()).toEqual({ data: "rohan" });
|
||||
});
|
||||
|
||||
test("production serves generated WRN browser modules from the client directory", async () => {
|
||||
const directory = mkdtempSync(join(tmpdir(), "wrnexus-client-modules-"));
|
||||
writeFileSync(join(directory, "settings-abc123.mjs"), "export const ready = true;\n");
|
||||
const handlers = createProductionHandlers(manifest, { clientModulesDir: directory });
|
||||
const response = (await handlers.fetch(
|
||||
new Request("http://localhost/__wrnexus/client/settings-abc123.mjs"),
|
||||
server,
|
||||
)) as Response;
|
||||
expect(response.status).toBe(200);
|
||||
expect(response.headers.get("content-type")).toContain("text/javascript");
|
||||
expect(await response.text()).toContain("ready = true");
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user