e2eSpecAdmission.test.ts 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. import { readFileSync } from "node:fs";
  2. import { describe, expect, it } from "vitest";
  3. import { resolve } from "node:path";
  4. import { resolveE2EScheduledSpecFiles } from "#e2e/helpers/e2e-spec-resolution";
  5. import {
  6. hasRequiredSshE2EEnvironment,
  7. MANUAL_REVIEW_SPEC_GLOB,
  8. resolveEnvironmentGatedFormalSpecExcludes,
  9. } from "../scripts/e2e-formal-spec-selection.mjs";
  10. describe("desktop E2E environment-gated formal spec admission", () => {
  11. it("excludes every manual-review domain from the default recursive glob", () => {
  12. const scheduled = resolveE2EScheduledSpecFiles({
  13. baseDir: resolve("packages/desktop"),
  14. specs: ["./test/e2e/**/*.test.ts"],
  15. exclude: [MANUAL_REVIEW_SPEC_GLOB],
  16. });
  17. expect(scheduled).toContain("test/e2e/smoke.test.ts");
  18. expect(scheduled.some((spec) => spec.includes("/manual-review/"))).toBe(false);
  19. });
  20. it.each(["bots", "settings", "feedback"])(
  21. "keeps explicit %s candidates discoverable",
  22. (domain) => {
  23. const scheduled = resolveE2EScheduledSpecFiles({
  24. baseDir: resolve("packages/desktop"),
  25. specs: [`./test/e2e/${domain}/manual-review/**/*.test.ts`],
  26. exclude: [],
  27. });
  28. expect(scheduled.length).toBeGreaterThan(0);
  29. expect(scheduled.every((spec) => spec.includes(`/${domain}/manual-review/`))).toBe(true);
  30. },
  31. );
  32. it("excludes real SSH specs from default runs without complete credentials", () => {
  33. expect(hasRequiredSshE2EEnvironment({})).toBe(false);
  34. expect(resolveEnvironmentGatedFormalSpecExcludes({ env: {}, targeted: false })).toContain(
  35. "./test/e2e/conversation-session/conversation-session-ssh-remote*.test.ts",
  36. );
  37. });
  38. it("keeps explicit SSH runs fail-closed and admits configured default runs", () => {
  39. const env = {
  40. ZCODE_E2E_SSH_HOST: "ssh.example.test",
  41. ZCODE_E2E_SSH_USERNAME: "root",
  42. ZCODE_E2E_SSH_PASSWORD: "secret-from-test-env",
  43. };
  44. expect(hasRequiredSshE2EEnvironment(env)).toBe(true);
  45. expect(resolveEnvironmentGatedFormalSpecExcludes({ env, targeted: false })).toEqual([]);
  46. expect(resolveEnvironmentGatedFormalSpecExcludes({ env: {}, targeted: true })).toEqual([]);
  47. });
  48. it("uses the shared admission helper in the WDIO exclude list", () => {
  49. const source = readFileSync(new URL("../wdio.conf.ts", import.meta.url), "utf8");
  50. expect(source).toContain("resolveEnvironmentGatedFormalSpecExcludes({");
  51. expect(source).toContain("hasRequiredSshE2EEnvironment(process.env)");
  52. });
  53. });