e2eSpecAdmission.test.ts 1.4 KB

123456789101112131415161718192021222324252627282930313233
  1. import { readFileSync } from "node:fs";
  2. import { describe, expect, it } from "vitest";
  3. import {
  4. hasRequiredSshE2EEnvironment,
  5. resolveEnvironmentGatedFormalSpecExcludes,
  6. } from "../scripts/e2e-formal-spec-selection.mjs";
  7. describe("desktop E2E environment-gated formal spec admission", () => {
  8. it("excludes real SSH specs from default runs without complete credentials", () => {
  9. expect(hasRequiredSshE2EEnvironment({})).toBe(false);
  10. expect(
  11. resolveEnvironmentGatedFormalSpecExcludes({ env: {}, targeted: false }),
  12. ).toContain("./test/e2e/conversation-session/conversation-session-ssh-remote*.test.ts");
  13. });
  14. it("keeps explicit SSH runs fail-closed and admits configured default runs", () => {
  15. const env = {
  16. ZCODE_E2E_SSH_HOST: "ssh.example.test",
  17. ZCODE_E2E_SSH_USERNAME: "root",
  18. ZCODE_E2E_SSH_PASSWORD: "secret-from-test-env",
  19. };
  20. expect(hasRequiredSshE2EEnvironment(env)).toBe(true);
  21. expect(resolveEnvironmentGatedFormalSpecExcludes({ env, targeted: false })).toEqual([]);
  22. expect(resolveEnvironmentGatedFormalSpecExcludes({ env: {}, targeted: true })).toEqual([]);
  23. });
  24. it("uses the shared admission helper in the WDIO exclude list", () => {
  25. const source = readFileSync(new URL("../wdio.conf.ts", import.meta.url), "utf8");
  26. expect(source).toContain("resolveEnvironmentGatedFormalSpecExcludes({");
  27. expect(source).toContain("hasRequiredSshE2EEnvironment(process.env)");
  28. });
  29. });