check-document-libreoffice.test.ts 1.3 KB

12345678910111213141516171819202122232425262728293031
  1. import { execFile } from "node:child_process";
  2. import { promisify } from "node:util";
  3. import { cp, mkdtemp, rm, writeFile } from "node:fs/promises";
  4. import { tmpdir } from "node:os";
  5. import { join, resolve } from "node:path";
  6. import { describe, expect, it } from "vitest";
  7. const exec = promisify(execFile);
  8. const check = resolve("scripts/check-document-libreoffice.mjs");
  9. describe("document LibreOffice distribution gate", () => {
  10. it("accepts identical launchers and rejects a changed profile", async () => {
  11. const root = await mkdtemp(join(tmpdir(), "document-launcher-gate-"));
  12. try {
  13. for (const name of ["documents", "pdf", "presentations", "spreadsheets"]) {
  14. await cp(
  15. `apps/zcode-cli/packages/${name}-plugin/scripts`,
  16. join(root, `${name}-plugin`, "scripts"),
  17. { recursive: true },
  18. );
  19. }
  20. await expect(exec(process.execPath, [check, root])).resolves.toMatchObject({ stderr: "" });
  21. await writeFile(
  22. join(root, "pdf-plugin/scripts/libreoffice-profile/user/registrymodifications.xcu"),
  23. "changed",
  24. );
  25. await expect(exec(process.execPath, [check, root])).rejects.toMatchObject({ code: 1 });
  26. } finally {
  27. await rm(root, { recursive: true, force: true });
  28. }
  29. });
  30. });