e2eWorkerEnvironmentResolution.test.ts 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. import { describe, expect, it } from "vitest";
  2. import {
  3. isNativeKeychainCredentialSpec,
  4. resolveAskUserQuestionClockScaleForWorker,
  5. resolveE2ECredentialSecret,
  6. } from "./e2e/helpers/e2e-worker-environment.js";
  7. describe("E2E worker environment resolution", () => {
  8. it("injects the accelerated clock only for the auto-resolution case", () => {
  9. expect(
  10. resolveAskUserQuestionClockScaleForWorker({
  11. specs: [
  12. "./test/e2e/conversation-session/permissions/conversation-session-ask-user-question-auto-resolution-setting.test.ts",
  13. ],
  14. }),
  15. ).toBe("20");
  16. expect(
  17. resolveAskUserQuestionClockScaleForWorker({
  18. specs: ["./test/e2e/conversation-session/editing/conversation-session-v4-edit.test.ts"],
  19. }),
  20. ).toBeUndefined();
  21. });
  22. it("preserves an explicitly requested valid clock scale", () => {
  23. expect(
  24. resolveAskUserQuestionClockScaleForWorker({
  25. requestedScale: "25",
  26. specs: [
  27. "./test/e2e/conversation-session/permissions/conversation-session-ask-user-question-auto-resolution-setting.test.ts",
  28. ],
  29. }),
  30. ).toBe("25");
  31. });
  32. });
  33. it("keeps synthetic credential tests independent from OS keychain availability", () => {
  34. expect(resolveE2ECredentialSecret([], undefined)).toBe("e2e-credential-storage");
  35. expect(resolveE2ECredentialSecret([], "custom-fixture")).toBe("custom-fixture");
  36. expect(
  37. resolveE2ECredentialSecret(
  38. ["/auth-config/credentials/manual-review/pending/system-credential-storage.test.ts"],
  39. undefined,
  40. ),
  41. ).toBeUndefined();
  42. // 数据存储路径切换后的密钥登记只在真实系统库上有意义,同样不能注入托管密钥。
  43. expect(
  44. resolveE2ECredentialSecret(
  45. ["/auth-config/credentials/manual-review/pending/system-credential-data-root.test.ts"],
  46. undefined,
  47. ),
  48. ).toBeUndefined();
  49. });
  50. it("prepares the macOS keychain link only for native credential storage specs", () => {
  51. const pending = "/auth-config/credentials/manual-review/pending";
  52. expect(isNativeKeychainCredentialSpec(`${pending}/system-credential-storage.test.ts`)).toBe(true);
  53. expect(isNativeKeychainCredentialSpec(`${pending}/system-credential-data-root.test.ts`)).toBe(
  54. true,
  55. );
  56. expect(isNativeKeychainCredentialSpec(`${pending}\\system-credential-data-root.test.ts`)).toBe(
  57. true,
  58. );
  59. // owner 专项使用原生 API 边界替身,不访问开发者钥匙串。
  60. expect(isNativeKeychainCredentialSpec(`${pending}/system-credential-owner.test.ts`)).toBe(false);
  61. expect(isNativeKeychainCredentialSpec("/auth-config/login/oauth-completion-race.test.ts")).toBe(
  62. false,
  63. );
  64. });