e2eStartupCredentials.test.ts 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. import { describe, expect, it } from "vitest";
  2. import { createE2EStartupCredentialSeed } from "./e2e/helpers/e2e-startup-credentials.js";
  3. const restoredOAuthCredentials = {
  4. "oauth:active_provider": "zai",
  5. "oauth:zai:access_token": "fake-access-token",
  6. "oauth:zai:user_info": "{}",
  7. zcodejwttoken: "fake-zcode-jwt",
  8. };
  9. describe("desktop e2e startup credentials", () => {
  10. it.each([
  11. "coding-plan-upgrade-webview-refresh-provider.test.ts",
  12. "marketing-touch-rewards.test.ts",
  13. ])("%s 保留本地 Start 余额/请求鉴权所需 JWT", (spec) => {
  14. expect(
  15. createE2EStartupCredentialSeed({
  16. specs: [spec],
  17. legacyAuthToken: "fake-auth-token",
  18. restoredOAuthCredentials,
  19. }).zcodejwttoken,
  20. ).toBe("fake-zcode-jwt");
  21. });
  22. it("供应商响应式 spec 保留本地 balance mock 所需的 JWT", () => {
  23. expect(
  24. createE2EStartupCredentialSeed({
  25. specs: ["/repo/packages/desktop/test/e2e/provider-family-responsive.test.ts"],
  26. legacyAuthToken: "fake-auth-token",
  27. restoredOAuthCredentials,
  28. }).zcodejwttoken,
  29. ).toBe("fake-zcode-jwt");
  30. });
  31. it("纯 Provider 冷恢复 spec 不播种会访问账号控制面的假登录态", () => {
  32. expect(
  33. createE2EStartupCredentialSeed({
  34. specs: [
  35. "/repo/packages/desktop/test/e2e/conversation-session/manual-review/pending/conversation-session-unbound-resume.test.ts",
  36. ],
  37. legacyAuthToken: "fake-auth-token",
  38. restoredOAuthCredentials,
  39. }),
  40. ).toEqual({});
  41. });
  42. it.each([
  43. "conversation-session-v4-composer-toolbar.test.ts",
  44. "conversation-session-draft-model-switch-first-send.test.ts",
  45. "conversation-session-composer-draft-switching.test.ts",
  46. "conversation-session-ssh-provisioning-failure.test.ts",
  47. ])("Composer Draft spec %s 不播种无关账号身份", (spec) => {
  48. expect(
  49. createE2EStartupCredentialSeed({
  50. specs: [`/repo/packages/desktop/test/e2e/conversation-session/${spec}`],
  51. legacyAuthToken: "fake-auth-token",
  52. restoredOAuthCredentials,
  53. }),
  54. ).toEqual({});
  55. });
  56. it.each([
  57. "conversation-session-automation-cron-create.test.ts",
  58. "conversation-session-fork-merged-assistant.test.ts",
  59. "conversation-session-goal-run-cases.test.ts",
  60. "conversation-session-running-guide-steer.test.ts",
  61. "conversation-session-tool-cross-product.test.ts",
  62. "conversation-session-v4-fork-edit-branch.test.ts",
  63. ])("fork/goal/tool spec %s 不播种无关账号身份", (spec) => {
  64. expect(
  65. createE2EStartupCredentialSeed({
  66. specs: [`/repo/packages/desktop/test/e2e/conversation-session/${spec}`],
  67. legacyAuthToken: "fake-auth-token",
  68. restoredOAuthCredentials,
  69. }),
  70. ).toEqual({});
  71. });
  72. it("普通 spec 保留 OAuth 展示态但不注入会触发失效广播的 zcode JWT", () => {
  73. expect(
  74. createE2EStartupCredentialSeed({
  75. specs: [
  76. "/repo/packages/desktop/test/e2e/conversation-session/conversation-session-v4-sendnow.test.ts",
  77. ],
  78. legacyAuthToken: "fake-auth-token",
  79. restoredOAuthCredentials,
  80. }),
  81. ).toEqual({
  82. auth_token: "fake-auth-token",
  83. "oauth:active_provider": "zai",
  84. "oauth:zai:access_token": "fake-access-token",
  85. "oauth:zai:user_info": "{}",
  86. });
  87. });
  88. it("JWT 401 自动退出专项 spec 保留完整 restored OAuth fixture", () => {
  89. expect(
  90. createE2EStartupCredentialSeed({
  91. specs: [
  92. "/repo/packages/desktop/test/e2e/manual-review/pending/jwt-401-auto-logout.test.ts",
  93. ],
  94. legacyAuthToken: "fake-auth-token",
  95. restoredOAuthCredentials,
  96. }),
  97. ).toEqual({
  98. auth_token: "fake-auth-token",
  99. ...restoredOAuthCredentials,
  100. });
  101. });
  102. it("Start Plan 手动领取 spec 保留调用 claim API 所需的 zcode JWT", () => {
  103. expect(
  104. createE2EStartupCredentialSeed({
  105. specs: ["/repo/packages/desktop/test/e2e/ui-shell/marketing-touch-entitlement.test.ts"],
  106. legacyAuthToken: "fake-auth-token",
  107. restoredOAuthCredentials,
  108. }),
  109. ).toEqual({
  110. auth_token: "fake-auth-token",
  111. ...restoredOAuthCredentials,
  112. });
  113. });
  114. });