modelProviderCatalogE2EMock.test.ts 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. import { describe, expect, it } from "vitest";
  2. import {
  3. resolveSubagentLoginCatalogConfigVersion,
  4. resolveSubagentLoginCatalogPayload,
  5. SUBAGENT_LOGIN_CATALOG_POST_LOGIN_CONFIG_VERSION,
  6. SUBAGENT_LOGIN_CATALOG_PRE_LOGIN_CONFIG_VERSION,
  7. } from "./e2e/helpers/model-provider-catalog-mock-server.js";
  8. describe("model provider catalog E2E mock", () => {
  9. it("keeps the login catalog immutable for each config version", () => {
  10. expect(resolveSubagentLoginCatalogConfigVersion(false)).toBe(
  11. SUBAGENT_LOGIN_CATALOG_PRE_LOGIN_CONFIG_VERSION,
  12. );
  13. expect(resolveSubagentLoginCatalogConfigVersion(true)).toBe(
  14. SUBAGENT_LOGIN_CATALOG_POST_LOGIN_CONFIG_VERSION,
  15. );
  16. expect(SUBAGENT_LOGIN_CATALOG_PRE_LOGIN_CONFIG_VERSION).not.toBe(
  17. SUBAGENT_LOGIN_CATALOG_POST_LOGIN_CONFIG_VERSION,
  18. );
  19. const preLoginCatalog = resolveSubagentLoginCatalogPayload({
  20. configVersion: SUBAGENT_LOGIN_CATALOG_PRE_LOGIN_CONFIG_VERSION,
  21. oauthTokenIssued: false,
  22. });
  23. const samePreLoginVersionAfterOAuth = resolveSubagentLoginCatalogPayload({
  24. configVersion: SUBAGENT_LOGIN_CATALOG_PRE_LOGIN_CONFIG_VERSION,
  25. oauthTokenIssued: true,
  26. });
  27. const postLoginCatalog = resolveSubagentLoginCatalogPayload({
  28. configVersion: SUBAGENT_LOGIN_CATALOG_POST_LOGIN_CONFIG_VERSION,
  29. oauthTokenIssued: true,
  30. });
  31. expect(samePreLoginVersionAfterOAuth).toEqual(preLoginCatalog);
  32. expect(
  33. preLoginCatalog.data.builtinProviders.some(
  34. (provider) => provider.id === "account:bigmodel-individual-coding-plan",
  35. ),
  36. ).toBe(false);
  37. expect(
  38. postLoginCatalog.data.builtinProviders.some(
  39. (provider) => provider.id === "account:bigmodel-individual-coding-plan",
  40. ),
  41. ).toBe(true);
  42. });
  43. });