Files
ConvertX/tests/buildScripts.test.ts
Jörg KrzeslakandCopilot 0aa8c6fc3e fix: address review comments on client script migration
- drop failed uploads and keep Convert disabled until all uploads succeed
- reset the selected format when the last file is removed
- select targets on click (keyboard support) and keep focus on mousedown
- set the submit input's value for the upload state label
- delete history jobs in batches of at most 100
- rebuild client bundles in watch mode for dev and hot
- derive bundled client scripts from page references in build test
- tighten test fixture and names in client and eden tests

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-11-18 22:43:35 +01:00

41 lines
1.3 KiB
TypeScript

import { describe, expect, test } from "bun:test";
import { readdirSync, readFileSync } from "node:fs";
import pkg from "../package.json";
const scripts = pkg.scripts as Record<string, string>;
const pagesDir = new URL("../src/pages/", import.meta.url);
const pageScripts = readdirSync(pagesDir)
.filter((file) => file.endsWith(".tsx"))
.flatMap((file) =>
Array.from(
readFileSync(new URL(file, pagesDir), "utf8").matchAll(
/<script src=\{?[`"][^`"]*?(\w+)\.js[`"]/g,
),
(match) => match[1]!,
),
)
.sort();
describe("client bundles are generated (public/*.js is gitignored)", () => {
test("finds the scripts that pages load", () => {
expect(pageScripts).toEqual(["history", "results", "script"]);
});
test("build:client bundles every client script that a page loads", () => {
for (const script of pageScripts) {
expect(scripts["build:client"]).toContain(`public/${script}.ts`);
}
});
test.each(["dev", "hot"])("%s builds the client scripts first", (name) => {
expect(scripts[`pre${name}`]).toBe("bun run build:client");
});
test.each(["dev", "hot"])("%s rebuilds the client scripts when they change", (name) => {
expect(scripts[name]).toContain("build:client --watch");
expect(scripts[`${name}:server`]).toContain("src/index.tsx");
});
});