e2eWindowsRuntimeHostPreflight.test.ts 1.3 KB

12345678910111213141516171819202122232425262728
  1. import { readFileSync } from "node:fs";
  2. import { describe, expect, it } from "vitest";
  3. // Bug 根因:Windows 上 Agent CLI 只能经过 zcode-runtime-host.exe 启动,而 E2E 只跑
  4. // build:no-runtime-assets,CI 上没有该 exe,全部 case 报 runtime host missing / slash 目录为空。
  5. describe("E2E Windows runtime host preflight", () => {
  6. it("prepareDesktopAppBuild 在复用或重建桌面产物前确保 runtime host 就绪", () => {
  7. const source = readFileSync(new URL("../wdio.conf.ts", import.meta.url), "utf8").replace(
  8. /\r\n/g,
  9. "\n",
  10. );
  11. const start = source.indexOf("\nfunction prepareDesktopAppBuild() {");
  12. const end = source.indexOf("\n}\n", start);
  13. expect(start).toBeGreaterThan(-1);
  14. const body = source.slice(start, end);
  15. const packagedIndex = body.indexOf("E2E_PACKAGED_APP_BINARY_PATH");
  16. const ensureIndex = body.indexOf("ensureWindowsRuntimeHost();");
  17. const skipBuildIndex = body.indexOf("shouldReuseDesktopE2EBuild(");
  18. expect(packagedIndex).toBeGreaterThan(-1);
  19. expect(ensureIndex).toBeGreaterThan(packagedIndex);
  20. expect(skipBuildIndex).toBeGreaterThan(ensureIndex);
  21. expect(source).toMatch(
  22. /function ensureWindowsRuntimeHost\(\) \{[\s\S]*?scripts\/build-windows-runtime-host\.mjs[\s\S]*?"--if-windows"[\s\S]*?"--ensure"/,
  23. );
  24. });
  25. });