windows-e2e-shards.test.ts 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558
  1. import { readFileSync } from "node:fs";
  2. import { EventEmitter } from "node:events";
  3. import { join, resolve } from "node:path";
  4. import { describe, expect, it, vi } from "vitest";
  5. import {
  6. createWindowsE2EShardPlan,
  7. executeWindowsE2EShardPlan,
  8. listDefaultFormalE2ESpecs,
  9. partitionE2ESpecsByWeight,
  10. resolveWindowsE2EShardTotal,
  11. } from "../scripts/run-windows-e2e-shards.mjs";
  12. const repoRoot = resolve("C:/repo");
  13. const desktopDir = join(repoRoot, "packages/desktop");
  14. function createPlan(overrides: Record<string, unknown> = {}) {
  15. return createWindowsE2EShardPlan({
  16. args: [],
  17. desktopDir,
  18. env: { ZCODE_E2E_RUN_ID: "local-full", ZCODE_E2E_SHARD_TOTAL: "2" },
  19. platform: "win32",
  20. repoRoot,
  21. ...overrides,
  22. });
  23. }
  24. describe("Windows E2E shard runner", () => {
  25. it("derives disjoint paths from automatic run IDs while preserving an explicit run ID", () => {
  26. const timestamp = new Date("2026-07-11T00:30:00.123Z");
  27. vi.useFakeTimers();
  28. vi.setSystemTime(timestamp);
  29. try {
  30. const firstPlan = createPlan({
  31. // 修复原因:默认 full run 已改为单 shard;路径隔离断言必须显式进入并发分片场景。
  32. env: { ZCODE_E2E_SHARD_TOTAL: "2" },
  33. processId: 4242,
  34. runIdEntropy: "entropy-a",
  35. runIdTimestamp: timestamp,
  36. });
  37. const secondPlan = createPlan({
  38. env: { ZCODE_E2E_SHARD_TOTAL: "2" },
  39. processId: 4242,
  40. runIdEntropy: "entropy-b",
  41. runIdTimestamp: timestamp,
  42. });
  43. expect(firstPlan.runId).not.toBe(secondPlan.runId);
  44. for (const key of [
  45. "ZCODE_E2E_HOME_DIR",
  46. "ZCODE_E2E_ARTIFACT_DIR",
  47. "ZCODE_E2E_NETWORK_CAPTURE_DIR",
  48. ] as const) {
  49. const firstPaths = new Set(firstPlan.children.map((child) => child.env[key]));
  50. const secondPaths = new Set(secondPlan.children.map((child) => child.env[key]));
  51. expect([...firstPaths].filter((path) => secondPaths.has(path))).toEqual([]);
  52. }
  53. const explicitPlan = createPlan({
  54. env: { ZCODE_E2E_RUN_ID: "explicit-compatible-run" },
  55. processId: 4242,
  56. runIdEntropy: "ignored-entropy",
  57. runIdTimestamp: timestamp,
  58. });
  59. expect(explicitPlan.runId).toBe("explicit-compatible-run");
  60. } finally {
  61. vi.useRealTimers();
  62. }
  63. });
  64. it("plans a default full Windows run as a single shard", () => {
  65. const plan = createPlan({
  66. env: { ZCODE_E2E_RUN_ID: "default-single" },
  67. });
  68. expect(plan.shardTotal).toBe(1);
  69. expect(plan.children).toHaveLength(1);
  70. expect(plan.children[0]?.args.some((arg) => arg.startsWith("--shard"))).toBe(false);
  71. expect(plan.children[0]?.env.ZCODE_E2E_HOME_DIR).toBe(
  72. join(desktopDir, ".e2e-home-default-single"),
  73. );
  74. });
  75. it("lists the default formal specs without manual-review or live provider cases", () => {
  76. const specs = listDefaultFormalE2ESpecs(resolve(process.cwd(), "packages/desktop"));
  77. // Bug 根因:formal case 由目录动态发现,固定总数会让新增或删除合法 case 误伤 pre-push。
  78. // 用稳定的 smoke 包含关系确认发现结果非空,其余断言只校验默认集合的语义边界。
  79. expect(specs).toContain("./test/e2e/infrastructure/smoke/smoke.test.ts");
  80. expect(specs).not.toContain("./test/e2e/infrastructure/smoke/upstream-provider.test.ts");
  81. expect(specs.some((spec) => spec.includes("/manual-review/"))).toBe(false);
  82. expect(specs.some((spec) => spec.includes("conversation-session-ssh-remote"))).toBe(false);
  83. const sshSpecs = listDefaultFormalE2ESpecs(resolve(process.cwd(), "packages/desktop"), {
  84. ZCODE_E2E_SSH_HOST: "ssh.example.test",
  85. ZCODE_E2E_SSH_USERNAME: "root",
  86. ZCODE_E2E_SSH_PASSWORD: "secret-from-test-env",
  87. });
  88. // 只有 SSH 凭据、没有 harness 容器时,远程队列用例不能进入共享主机的分片。
  89. expect(sshSpecs.some((spec) => spec.includes("conversation-session-ssh-remote"))).toBe(false);
  90. expect(sshSpecs).not.toContain(
  91. "./test/e2e/conversation-session/remote/configuration/conversation-session-r3-model-switch.test.ts",
  92. );
  93. const harnessSpecs = listDefaultFormalE2ESpecs(resolve(process.cwd(), "packages/desktop"), {
  94. ZCODE_E2E_SSH_HOST: "ssh.example.test",
  95. ZCODE_E2E_SSH_USERNAME: "root",
  96. ZCODE_E2E_SSH_PASSWORD: "secret-from-test-env",
  97. ZCODE_E2E_SSH_CONTAINER: "zcode-r3-server-example",
  98. });
  99. expect(harnessSpecs).toContain(
  100. "./test/e2e/conversation-session/remote/connection/conversation-session-ssh-remote-connection-p0.test.ts",
  101. );
  102. expect(harnessSpecs).toContain(
  103. "./test/e2e/conversation-session/remote/configuration/conversation-session-r3-model-switch.test.ts",
  104. );
  105. });
  106. it("uses deterministic LPT weights and a fallback for new specs", () => {
  107. const buckets = partitionE2ESpecsByWeight(
  108. ["./a.test.ts", "./b.test.ts", "./c.test.ts", "./new.test.ts"],
  109. 2,
  110. {
  111. defaultWeightMs: 40,
  112. weights: {
  113. "./a.test.ts": 100,
  114. "./b.test.ts": 80,
  115. "./c.test.ts": 20,
  116. },
  117. },
  118. );
  119. expect(buckets).toEqual([
  120. { estimatedWeightMs: 120, specs: ["./a.test.ts", "./c.test.ts"] },
  121. { estimatedWeightMs: 120, specs: ["./b.test.ts", "./new.test.ts"] },
  122. ]);
  123. });
  124. it("passes weighted spec groups explicitly instead of native contiguous shards", () => {
  125. const weightedSpecBuckets = [
  126. { estimatedWeightMs: 100, specs: ["./test/e2e/infrastructure/smoke/smoke.test.ts"] },
  127. { estimatedWeightMs: 90, specs: ["./test/e2e/infrastructure/smoke/container-boot.test.ts"] },
  128. ];
  129. const plan = createPlan({ weightedSpecBuckets });
  130. expect(plan.distributionKind).toBe("historical-lpt");
  131. expect(plan.children.map((child) => child.env.ZCODE_E2E_SPEC)).toEqual([
  132. "./test/e2e/infrastructure/smoke/smoke.test.ts",
  133. "./test/e2e/infrastructure/smoke/container-boot.test.ts",
  134. ]);
  135. expect(
  136. plan.children.every((child) => child.args.every((arg) => !arg.startsWith("--shard"))),
  137. ).toBe(true);
  138. });
  139. it("plans two isolated shards for an explicit two-shard run", () => {
  140. const plan = createPlan();
  141. expect(plan.shardTotal).toBe(2);
  142. expect(plan.children).toHaveLength(2);
  143. expect(plan.children.map((child) => child.shardId)).toEqual(["1/2", "2/2"]);
  144. expect(plan.children.map((child) => child.args.at(-1))).toEqual(["--shard=1/2", "--shard=2/2"]);
  145. for (const key of [
  146. "ZCODE_E2E_HOME_DIR",
  147. "ZCODE_E2E_RUN_ID",
  148. "ZCODE_E2E_ARTIFACT_DIR",
  149. "ZCODE_E2E_NETWORK_CAPTURE_DIR",
  150. ] as const) {
  151. expect(new Set(plan.children.map((child) => child.env[key])).size).toBe(2);
  152. }
  153. for (const child of plan.children) {
  154. expect(child.env.ZCODE_E2E_SKIP_BUILD).toBe("1");
  155. expect(child.env.ZCODE_E2E_SKIP_AGENT_BUILD).toBe("1");
  156. expect(child.summaryPath).toBe(join(child.artifactDir, "summary.json"));
  157. }
  158. });
  159. it("keeps every default HOME disjoint across concurrent runner run IDs", () => {
  160. const firstPlan = createPlan({
  161. // 修复原因:覆盖 env 会同时移除 createPlan 默认的 shard 数,需保留显式分片前提。
  162. env: {
  163. ZCODE_E2E_RUN_ID: "concurrent-run-a",
  164. ZCODE_E2E_SHARD_TOTAL: "2",
  165. },
  166. });
  167. const secondPlan = createPlan({
  168. env: {
  169. ZCODE_E2E_RUN_ID: "concurrent-run-b",
  170. ZCODE_E2E_SHARD_TOTAL: "2",
  171. },
  172. });
  173. const firstHomes = new Set(firstPlan.children.map((child) => child.env.ZCODE_E2E_HOME_DIR));
  174. const secondHomes = new Set(secondPlan.children.map((child) => child.env.ZCODE_E2E_HOME_DIR));
  175. expect([...firstHomes].filter((home) => secondHomes.has(home))).toEqual([]);
  176. expect([...firstHomes].every((home) => home.includes("concurrent-run-a"))).toBe(true);
  177. expect([...secondHomes].every((home) => home.includes("concurrent-run-b"))).toBe(true);
  178. });
  179. it("preserves an explicit HOME for a single-child run", () => {
  180. const explicitHomeRoot = resolve("C:/e2e-homes/single");
  181. const plan = createPlan({
  182. env: {
  183. ZCODE_E2E_HOME_DIR: explicitHomeRoot,
  184. ZCODE_E2E_RUN_ID: "explicit-single-home-run",
  185. },
  186. });
  187. expect(plan.shardTotal).toBe(1);
  188. expect(plan.children[0]?.env.ZCODE_E2E_HOME_DIR).toBe(explicitHomeRoot);
  189. });
  190. it("adds run and shard identity below an explicit sharded HOME base", () => {
  191. const explicitHomeRoot = resolve("C:/e2e-homes");
  192. const plan = createPlan({
  193. env: {
  194. ZCODE_E2E_HOME_DIR: explicitHomeRoot,
  195. ZCODE_E2E_RUN_ID: "explicit-home-run",
  196. ZCODE_E2E_SHARD_TOTAL: "2",
  197. },
  198. });
  199. expect(plan.children.map((child) => child.env.ZCODE_E2E_HOME_DIR)).toEqual([
  200. join(explicitHomeRoot, "explicit-home-run", "shard-1-of-2"),
  201. join(explicitHomeRoot, "explicit-home-run", "shard-2-of-2"),
  202. ]);
  203. });
  204. it("builds desktop and agent once before starting both children concurrently", async () => {
  205. const plan = createPlan();
  206. expect(plan.buildSteps[1]?.env.ZCODE_DESKTOP_AGENT_BUILD_MODE).toBe("turbo");
  207. const events: string[] = [];
  208. const childResolvers: Array<(result: { exitCode: number }) => void> = [];
  209. const execution = executeWindowsE2EShardPlan(plan, {
  210. now: (() => {
  211. let value = 1_000;
  212. return () => (value += 50);
  213. })(),
  214. summaryExists: () => true,
  215. spawnStep: vi.fn(async (step) => {
  216. events.push(`start:${step.id}`);
  217. if (step.kind === "build") {
  218. events.push(`finish:${step.id}`);
  219. return { exitCode: 0 };
  220. }
  221. return await new Promise<{ exitCode: number }>((resolveChild) => {
  222. childResolvers.push(resolveChild);
  223. });
  224. }),
  225. writeManifest: vi.fn(),
  226. printManifest: vi.fn(),
  227. });
  228. await vi.waitFor(() => expect(childResolvers).toHaveLength(2));
  229. expect(events).toEqual([
  230. "start:build-desktop",
  231. "finish:build-desktop",
  232. "start:build-agent",
  233. "finish:build-agent",
  234. "start:shard-1-of-2",
  235. "start:shard-2-of-2",
  236. ]);
  237. childResolvers[1]?.({ exitCode: 0 });
  238. childResolvers[0]?.({ exitCode: 0 });
  239. const manifest = await execution;
  240. expect(manifest.wallDurationMs).toBe(50);
  241. expect(manifest.children.map((child) => child.exitCode)).toEqual([0, 0]);
  242. });
  243. it.each([
  244. {
  245. label: "targeted CLI",
  246. args: ["--spec=./test/e2e/infrastructure/smoke/container-boot.test.ts", "--shards=10"],
  247. env: { ZCODE_E2E_SHARD_TOTAL: "4" },
  248. },
  249. {
  250. label: "targeted env",
  251. args: ["--shards=10"],
  252. env: {
  253. ZCODE_E2E_SPEC: "./test/e2e/infrastructure/smoke/container-boot.test.ts",
  254. ZCODE_E2E_SHARD_TOTAL: "4",
  255. },
  256. },
  257. {
  258. label: "capture",
  259. args: ["--shards=10"],
  260. env: { E2E_PROVIDER_HTTP_MODE: "capture", ZCODE_E2E_SHARD_TOTAL: "4" },
  261. },
  262. {
  263. label: "manual review",
  264. args: ["--shards=10"],
  265. env: { ZCODE_E2E_MANUAL_REVIEW: "1", ZCODE_E2E_SHARD_TOTAL: "4" },
  266. },
  267. ])("keeps $label runs single despite explicit shard overrides", ({ args, env }) => {
  268. const plan = createPlan({ args, env });
  269. expect(plan.shardTotal).toBe(1);
  270. expect(plan.children).toHaveLength(1);
  271. });
  272. it("keeps non-Windows runs single by default", () => {
  273. expect(resolveWindowsE2EShardTotal({ args: [], env: {}, platform: "darwin" })).toBe(1);
  274. });
  275. it("validates explicit overrides and strips the runner-only option", () => {
  276. const plan = createPlan({
  277. args: ["--logLevel=warn", "--shards=3", "--mochaOpts.timeout=9000"],
  278. env: { ZCODE_E2E_SHARD_TOTAL: "4", ZCODE_E2E_RUN_ID: "override" },
  279. });
  280. expect(plan.shardTotal).toBe(3);
  281. expect(plan.wdioArgs).toEqual(["--logLevel=warn", "--mochaOpts.timeout=9000"]);
  282. expect(plan.children.map((child) => child.args.at(-1))).toEqual([
  283. "--shard=1/3",
  284. "--shard=2/3",
  285. "--shard=3/3",
  286. ]);
  287. expect(() =>
  288. resolveWindowsE2EShardTotal({ args: ["--shards=0"], env: {}, platform: "win32" }),
  289. ).toThrow("positive integer");
  290. expect(() =>
  291. resolveWindowsE2EShardTotal({
  292. args: [],
  293. env: { ZCODE_E2E_SHARD_TOTAL: "two" },
  294. platform: "win32",
  295. }),
  296. ).toThrow("positive integer");
  297. });
  298. it("does not reshard a native WDIO shard from any override", () => {
  299. expect(
  300. resolveWindowsE2EShardTotal({
  301. args: ["--shard=1/2"],
  302. env: { ZCODE_E2E_SHARD_TOTAL: "4" },
  303. platform: "win32",
  304. }),
  305. ).toBe(1);
  306. expect(
  307. resolveWindowsE2EShardTotal({
  308. args: ["--shard=1/2", "--shards=3"],
  309. env: { ZCODE_E2E_SHARD_TOTAL: "4" },
  310. platform: "win32",
  311. }),
  312. ).toBe(1);
  313. });
  314. it("waits for every child, writes one manifest, and fails when any shard fails", async () => {
  315. const plan = createPlan();
  316. const completed: string[] = [];
  317. const writeManifest = vi.fn();
  318. const printManifest = vi.fn();
  319. let caught: unknown;
  320. try {
  321. await executeWindowsE2EShardPlan(plan, {
  322. now: () => 2_000,
  323. summaryExists: () => true,
  324. spawnStep: async (step) => {
  325. if (step.kind === "build") return { exitCode: 0 };
  326. completed.push(step.id);
  327. return { exitCode: step.shardIndex === 1 ? 7 : 0 };
  328. },
  329. writeManifest,
  330. printManifest,
  331. });
  332. } catch (error) {
  333. caught = error;
  334. }
  335. expect(completed).toEqual(["shard-1-of-2", "shard-2-of-2"]);
  336. expect(writeManifest).toHaveBeenCalledOnce();
  337. expect(printManifest).toHaveBeenCalledOnce();
  338. expect(caught).toMatchObject({
  339. message: expect.stringContaining("shard 1/2 exited with code 7"),
  340. manifest: {
  341. runId: "local-full",
  342. shardTotal: 2,
  343. wallDurationMs: 0,
  344. children: [
  345. {
  346. shardId: "1/2",
  347. exitCode: 7,
  348. artifactDir: plan.children[0]?.artifactDir,
  349. summaryPath: plan.children[0]?.summaryPath,
  350. },
  351. {
  352. shardId: "2/2",
  353. exitCode: 0,
  354. artifactDir: plan.children[1]?.artifactDir,
  355. summaryPath: plan.children[1]?.summaryPath,
  356. },
  357. ],
  358. },
  359. });
  360. });
  361. it("rejects a zero-exit shard that produced no summary", async () => {
  362. const plan = createPlan();
  363. await expect(
  364. executeWindowsE2EShardPlan(plan, {
  365. now: () => 2_000,
  366. spawnStep: async () => ({ exitCode: 0 }),
  367. summaryExists: () => false,
  368. writeManifest: vi.fn(),
  369. printManifest: vi.fn(),
  370. }),
  371. ).rejects.toMatchObject({
  372. message: expect.stringContaining("missing shard summary"),
  373. manifest: {
  374. children: expect.arrayContaining([
  375. expect.objectContaining({ exitCode: 1, error: expect.stringContaining("summary.json") }),
  376. ]),
  377. },
  378. });
  379. });
  380. it("records a rejected shard start, waits for the delayed shard, and writes one manifest", async () => {
  381. const plan = createPlan();
  382. const writeManifest = vi.fn();
  383. const printManifest = vi.fn();
  384. let finishDelayedShard: (() => void) | undefined;
  385. const execution = executeWindowsE2EShardPlan(plan, {
  386. now: () => 2_000,
  387. summaryExists: () => true,
  388. spawnStep: (step) => {
  389. if (step.kind === "build") return Promise.resolve({ exitCode: 0 });
  390. if (step.shardIndex === 1) return Promise.reject(new Error("spawn pnpm EAGAIN"));
  391. return new Promise<{ exitCode: number }>((resolveChild) => {
  392. finishDelayedShard = () => resolveChild({ exitCode: 0 });
  393. });
  394. },
  395. writeManifest,
  396. printManifest,
  397. });
  398. await vi.waitFor(() => expect(finishDelayedShard).toBeTypeOf("function"));
  399. await Promise.resolve();
  400. expect(writeManifest).not.toHaveBeenCalled();
  401. finishDelayedShard?.();
  402. await expect(execution).rejects.toMatchObject({
  403. message: expect.stringContaining("shard 1/2 failed to start: spawn pnpm EAGAIN"),
  404. manifest: {
  405. children: [
  406. expect.objectContaining({
  407. shardId: "1/2",
  408. exitCode: 1,
  409. error: "spawn pnpm EAGAIN",
  410. }),
  411. expect.objectContaining({ shardId: "2/2", exitCode: 0 }),
  412. ],
  413. },
  414. });
  415. expect(writeManifest).toHaveBeenCalledOnce();
  416. expect(printManifest).toHaveBeenCalledOnce();
  417. });
  418. it("terminates another cancellable shard after an unrecoverable start error", async () => {
  419. const plan = createPlan();
  420. let finishSecondShard: ((result: { exitCode: number; signal?: string }) => void) | undefined;
  421. const terminateSecondShard = vi.fn(() => {
  422. finishSecondShard?.({ exitCode: 1, signal: "SIGTERM" });
  423. });
  424. const execution = executeWindowsE2EShardPlan(plan, {
  425. now: () => 2_000,
  426. summaryExists: () => true,
  427. spawnStep: (step) => {
  428. if (step.kind === "build") return Promise.resolve({ exitCode: 0 });
  429. if (step.shardIndex === 1) return Promise.reject(new Error("spawn pnpm ENOMEM"));
  430. return {
  431. result: new Promise<{ exitCode: number; signal?: string }>((resolveChild) => {
  432. finishSecondShard = resolveChild;
  433. }),
  434. terminate: terminateSecondShard,
  435. };
  436. },
  437. writeManifest: vi.fn(),
  438. printManifest: vi.fn(),
  439. });
  440. await expect(execution).rejects.toMatchObject({
  441. manifest: {
  442. children: [
  443. expect.objectContaining({ error: "spawn pnpm ENOMEM" }),
  444. expect.objectContaining({ signal: "SIGTERM" }),
  445. ],
  446. },
  447. });
  448. expect(terminateSecondShard).toHaveBeenCalledOnce();
  449. });
  450. it("terminates active shards on a parent signal and reports the interrupted run", async () => {
  451. const plan = createPlan();
  452. const signalSource = new EventEmitter();
  453. const childResolvers = new Map<
  454. number,
  455. (result: { exitCode: number; signal?: string }) => void
  456. >();
  457. const terminates: Array<ReturnType<typeof vi.fn>> = [];
  458. const execution = executeWindowsE2EShardPlan(plan, {
  459. now: () => 2_000,
  460. summaryExists: () => true,
  461. signalSource,
  462. spawnStep: (step) => {
  463. if (step.kind === "build") return Promise.resolve({ exitCode: 0 });
  464. const terminate = vi.fn(() => {
  465. childResolvers.get(step.shardIndex)?.({ exitCode: 1, signal: "SIGTERM" });
  466. });
  467. terminates.push(terminate);
  468. return {
  469. result: new Promise<{ exitCode: number; signal?: string }>((resolveChild) => {
  470. childResolvers.set(step.shardIndex, resolveChild);
  471. }),
  472. terminate,
  473. };
  474. },
  475. writeManifest: vi.fn(),
  476. printManifest: vi.fn(),
  477. });
  478. await vi.waitFor(() => expect(childResolvers.size).toBe(2));
  479. signalSource.emit("SIGTERM");
  480. await expect(execution).rejects.toMatchObject({
  481. message: expect.stringContaining("parent received SIGTERM"),
  482. manifest: expect.objectContaining({ interruptedBySignal: "SIGTERM" }),
  483. });
  484. expect(terminates).toHaveLength(2);
  485. expect(terminates.every((terminate) => terminate.mock.calls.length === 1)).toBe(true);
  486. expect(signalSource.listenerCount("SIGINT")).toBe(0);
  487. expect(signalSource.listenerCount("SIGTERM")).toBe(0);
  488. });
  489. it("separates the single-shard default from the fixed 10-shard performance entry", () => {
  490. const desktopPackage = JSON.parse(
  491. readFileSync(resolve(process.cwd(), "packages/desktop/package.json"), "utf-8"),
  492. ) as { scripts: Record<string, string> };
  493. const rootPackage = JSON.parse(
  494. readFileSync(resolve(process.cwd(), "package.json"), "utf-8"),
  495. ) as { scripts: Record<string, string> };
  496. expect(desktopPackage.scripts["pretest:e2e"]).toBe(
  497. "pnpm --filter @zcode/e2e-report build:node",
  498. );
  499. expect(desktopPackage.scripts["test:e2e"]).toBe("node scripts/run-windows-e2e-shards.mjs");
  500. expect(rootPackage.scripts["test:e2e"]).toBe("pnpm --filter @zcode/desktop test:e2e");
  501. expect(desktopPackage.scripts["test:e2e:windows:sharded"]).toBe("pnpm test:e2e -- --shards=10");
  502. expect(rootPackage.scripts["test:e2e:windows:sharded"]).toBe(
  503. "pnpm --filter @zcode/desktop test:e2e:windows:sharded",
  504. );
  505. });
  506. });