e2eWorkerEnvironmentResolution.test.ts 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. expect(
  51. resolveE2ECredentialSecret(
  52. ["/auth-config/credentials/manual-review/pending/system-credential-auto-reset.test.ts"],
  53. undefined,
  54. ),
  55. ).toBeUndefined();
  56. });
  57. it("prepares the macOS keychain link only for native credential storage specs", () => {
  58. const pending = "/auth-config/credentials/manual-review/pending";
  59. expect(isNativeKeychainCredentialSpec(`${pending}/system-credential-storage.test.ts`)).toBe(true);
  60. expect(isNativeKeychainCredentialSpec(`${pending}/system-credential-data-root.test.ts`)).toBe(
  61. true,
  62. );
  63. expect(isNativeKeychainCredentialSpec(`${pending}\\system-credential-data-root.test.ts`)).toBe(
  64. true,
  65. );
  66. expect(isNativeKeychainCredentialSpec(`${pending}/system-credential-auto-reset.test.ts`)).toBe(
  67. true,
  68. );
  69. // owner 专项使用原生 API 边界替身,不访问开发者钥匙串。
  70. expect(isNativeKeychainCredentialSpec(`${pending}/system-credential-owner.test.ts`)).toBe(false);
  71. expect(isNativeKeychainCredentialSpec("/auth-config/login/oauth-completion-race.test.ts")).toBe(
  72. false,
  73. );
  74. });