Skip to content

test(e2e): replace per-provider add-flow tests with representative journeys and registry contract tests - #991

Merged
Astro-Han merged 8 commits into
mainfrom
test/e2e-989-provider-suite-consolidation
Jul 14, 2026
Merged

Astro-Han merged 8 commits into
mainfrom
test/e2e-989-provider-suite-consolidation

Conversation

@Astro-Han

Copy link
Copy Markdown
Contributor

Summary

The providers E2E suite had grown to 29 expanded cases, 25 of which were copies of one add-flow template differing only in registry data (slug, base URL, default model, catalog tab, brand mark) — asserting PROVIDER_DEFAULTS constants through a real Electron window each. Suite time and the window-teardown flake surface grew linearly with the catalog, and every new provider PR copied the previous test. Closes #989.

This PR keeps four E2E tests, each with a distinct reason to exist:

  • a canonical API-key add journey (Cerebras: search, tab switch, form defaults, and the colorAssetRenderContract mechanism in both light and dark) — it validates the flow, not Cerebras's data;
  • Cloudflare Workers AI — the only account-id form with a derived endpoint template;
  • LM Studio — the only no-auth local runtime, and the representative maskRenderContract (monochrome) counterpart to the color-mark path;
  • the keyboard-focus-restore test, kept verbatim.

Per-provider facts move to automatic, invariant-based coverage that needs zero updates when a provider is added:

  • packages/core/src/__tests__/provider-catalog-contract.test.ts iterates CATALOG_PROVIDER_TYPES: non-empty label/description, valid catalog group, resolvable endpoint source (baseUrl parses / baseUrlTemplate resolves / custom connection), well-formed fallback model set, and static-fallback discovery must ship a non-empty snapshot.
  • icon-governance-contract.test.ts gains a completeness check: every catalog provider must have an explicit ProviderBrandMark case — a new provider without a mark now fails instead of silently rendering the generic fallback.

No existing provider violates any invariant. The convention (no per-provider add-flow E2E; extend the contract tests instead) is documented in the spec file header.

Verification

  • Core tests: 984 pass (includes the new contract test). Desktop typecheck (main/renderer/storybook): clean. Desktop main suite: 2518 pass / 0 fail.
  • providers.spec.ts locally: 4 passed in 7.5s (was 29 cases / ~4 min).
  • Known coverage note: the Volcengine Coding Plan test also asserted the 刷新模型列表 button renders disabled for fallback-discovery providers. The underlying fact is locked by the core contract matrix (must-not-request-models-endpoint); the button-state UI reflection is no longer covered at the E2E layer — if wanted, a renderer unit test is the right home, not a per-provider Electron E2E.

Astro-Han added a commit that referenced this pull request Jul 14, 2026
nextSlug swept uppercase letters into '-' without lowercasing first, so
the mixed-case provider types 'MiniMax' / 'MiniMax-cn' derived '-ini-ax'
/ '-ini-ax-cn' — slugs validateSlug rejects — leaving the add form
unable to save those providers with its pre-filled slug.

Prerequisite for the new default-slug derivation contract (PR #991
review finding 4): the data-driven assertion that every catalog
provider's derived slug passes validateSlug goes red without this fix.
nextSlug's only call site is the add form's create-time initializer, so
existing stored connections are untouched and no migration is needed.

Refs #989
Astro-Han added a commit that referenced this pull request Jul 14, 2026
Address PR #991 review findings 1-3:

- Judge concrete baseUrl and resolved baseUrlTemplate values with
  validateConnectionBaseUrl — the same gate the connection IPC applies —
  instead of a bare new URL() check that still admitted javascript: /
  file: schemes production rejects.
- Require a non-empty default model snapshot for hosted providers. An
  empty snapshot leaves the add form without a recommended default and
  connection readiness at missing_model, which is only acceptable for
  instance-specific catalogs (category local/custom) with live model
  discovery.
- Drop 'recommended' from the legal base catalog groups: the 推荐 tab is
  an overlay sourced from RECOMMENDED_PROVIDER_TYPES, so a provider
  declaring catalogGroup 'recommended' would render in no tab at all.
  (No current provider does; splitting the union type is out of scope.)

Refs #989
Data-driven structural invariants over CATALOG_PROVIDER_TYPES (label,
catalog group, endpoint source, default-model shape) that auto-cover new
providers with zero manual updates, replacing the per-provider add-flow
E2E clones as the source of provider-fact coverage.

Refs #989
…ive journeys

Collapse the per-provider add-flow clones in providers.spec.ts (29
expanded cases) down to four: one canonical API-key journey, the
account-scoped Cloudflare form, the no-auth local runtime, and the
keyboard-focus journey. Both brand-mark render contracts (color <img>
and currentColor mask) stay covered. Per-provider facts now live in the
core registry contract; add a desktop brand-mark completeness invariant
so every catalog provider still resolves to a real mark, not the generic
fallback.

Refs #989
The per-id loop already asserts every shipped id is non-empty, and
fallbackModels[0] trivially belongs to fallbackModels, so the block
asserted nothing. Refs #989
nextSlug swept uppercase letters into '-' without lowercasing first, so
the mixed-case provider types 'MiniMax' / 'MiniMax-cn' derived '-ini-ax'
/ '-ini-ax-cn' — slugs validateSlug rejects — leaving the add form
unable to save those providers with its pre-filled slug.

Prerequisite for the new default-slug derivation contract (PR #991
review finding 4): the data-driven assertion that every catalog
provider's derived slug passes validateSlug goes red without this fix.
nextSlug's only call site is the add form's create-time initializer, so
existing stored connections are untouched and no migration is needed.

Refs #989
Address PR #991 review findings 1-3:

- Judge concrete baseUrl and resolved baseUrlTemplate values with
  validateConnectionBaseUrl — the same gate the connection IPC applies —
  instead of a bare new URL() check that still admitted javascript: /
  file: schemes production rejects.
- Require a non-empty default model snapshot for hosted providers. An
  empty snapshot leaves the add form without a recommended default and
  connection readiness at missing_model, which is only acceptable for
  instance-specific catalogs (category local/custom) with live model
  discovery.
- Drop 'recommended' from the legal base catalog groups: the 推荐 tab is
  an overlay sourced from RECOMMENDED_PROVIDER_TYPES, so a provider
  declaring catalogGroup 'recommended' would render in no tab at all.
  (No current provider does; splitting the union type is out of scope.)

Refs #989
Data-driven over CATALOG_PROVIDER_TYPES: every provider's pre-filled
slug from nextSlug (and its collision-suffixed fallback) must pass
core's validateSlug, so derivation and save-validation can never
disagree the way the mixed-case MiniMax types did. Lives on the desktop
side because nextSlug is renderer code core cannot import.

Refs #989
@Astro-Han
Astro-Han force-pushed the test/e2e-989-provider-suite-consolidation branch from 0570884 to c4d18ea Compare July 14, 2026 17:07
The bounded -2..-99 search fell back to `${base}-${Date.now()}` without
checking `existing`, so a dense slug space could hand the add form an
already-taken slug the save path then rejects. `existing` is finite, so
an unbounded increment always terminates on a free suffix — less code
and deterministic. Extend the default-slug contract with a dense
collision case (base and -2..-99 all taken must yield -100, unused and
valid).

PR #991 second-round review fix 2.

Refs #989
The endpoint contract branched on `baseUrl !== ''`, so a whitespace-only
registry baseUrl reached validateConnectionBaseUrl — which deliberately
returns null for blank input because its semantics there are "no
override, fall back to the provider default". In the registry the value
IS the default, so a blank baseUrl means no usable endpoint and must be
routed to the template / custom-connection branches instead. Branch on
`baseUrl.trim() !== ''` and assert resolved baseUrlTemplates are
non-blank before the validator runs.

PR #991 second-round review fix 1.

Refs #989
@Astro-Han
Astro-Han merged commit 0915cbe into main Jul 14, 2026
3 checks passed
@Astro-Han
Astro-Han deleted the test/e2e-989-provider-suite-consolidation branch July 25, 2026 15:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test(e2e): replace per-provider add-flow tests with representative journeys and registry contract tests

1 participant