Skip to content

feat: @W-22861359 add jp1 region preset to portal try-it auth panel#127

Draft
leandrogilcarrano wants to merge 4 commits into
poc/developfrom
worktree-feat-W-22861359-v2
Draft

feat: @W-22861359 add jp1 region preset to portal try-it auth panel#127
leandrogilcarrano wants to merge 4 commits into
poc/developfrom
worktree-feat-W-22861359-v2

Conversation

@leandrogilcarrano

Copy link
Copy Markdown
Contributor

Summary

  • Adds Japan (jp1) as a region preset in the Dev Portal try-it auth panel, visible only when the user picks the Regional (platform.mulesoft.com) server type.
  • Declares enum: [ca1, jp1] on the variables.region block of every API spec that exposes {region}.platform.mulesoft.com (27 specs).
  • Extracts restoreServerSelectionFromSessionStorage() from the IIFE in portal.js so tests can invoke the real production restore logic.
  • Adds 4 Jest tests covering visibility toggle, base URL, and sessionStorage round-trip.

Why not a shared \$ref fragment?

The original ask was to centralize the duplicated servers: block into a shared OAS fragment. OpenAPI 3.0 does NOT allow \$ref inside servers[].variables.<var>Server Variable Object is not a Reference Object per the spec, and AMF (the governed validator) rejects every spec that uses it there with server-variable-missing-default + missing-description errors. Verified empirically — see audit trail in docs/sdd/changes/jp1-region-shared-servers/migration-classification.md for the full pivot rationale, including a tracking table of which 27 specs got jp1 and which 9 are out of scope.

Validation

  • make test-portal206/206 passing (202 baseline + 4 new jp1 tests).
  • make validate-all-governed35 passed, 0 failed, 1 skipped (anypoint-api-governance, pre-existing skip).
  • Spot-check apis/api-manager and apis/api-portal-xapi → 0 violations.
  • Manual portal generation + HTTP serve confirmed jp1 renders correctly in migrated specs.

Out of scope (follow-up WI candidates)

The analyzer flagged 4 latent UX gaps that are NOT regressions of this change but worth tracking:

  • State-poisoning combinations (serverType=eu + stored region=jp1)
  • onServerChange clobbers user's jp1 selection on serverType toggle
  • Custom-region input has no validation against typing jp1 while EU is selected
  • Cosmetic: option.hidden vs surrounding style.display convention

Test plan

  • CI green: pre-push hook (test-portal + validate-all-governed)
  • Visual sanity in test-dev-portal after merge: jp1 visible in try-it for a migrated API (e.g. api-manager) when Regional (platform) is selected
  • Visual sanity: jp1 NOT visible when Regional (anypoint) is selected

- Add jp1 as static option in regionPreset select (visible only when serverType=platform)
- Declare enum [ca1, jp1] on variables.region in 27 specs that expose {region}.platform.mulesoft.com
- Extract restoreServerSelectionFromSessionStorage() so tests can invoke production restore directly
- Add 4 Jest tests covering visibility toggle, base URL, and sessionStorage round-trip

Note: original plan to centralize via shared $ref fragment was abandoned —
OpenAPI 3.0 forbids $ref inside servers[].variables (rejected by AMF).
@leandrogilcarrano leandrogilcarrano requested a review from a team as a code owner June 9, 2026 16:54
…y default

After review with the team:

- Revert the inline `enum: [ca1, jp1]` on 27 specs. OpenAPI 3.0 forbids `$ref`
  inside `servers[].variables.<var>`, so we cannot centralize regions in a shared
  fragment; and adding `enum` per-spec means every new region forces touching
  every spec. Cost outweighs benefit while the cardinality is small.

- Move the source of truth for known regions to `REGIONS_BY_HOST` in `portal.js`
  (anypoint: [eu1], platform: [ca1, jp1]). New regions = edit one constant.

- Hide the `jp1` option in the auth modal by default (`<option ... hidden>`).
  `onServerChange` reveals it only when serverType is `platform` (the only
  domain where `jp1` exists), preventing the invalid `jp1.anypoint.mulesoft.com`
  combination.

- Replace the per-operation server combobox with a plain text URL bar that
  reflects the active server/region from the auth modal. Selecting a different
  region requires re-login anyway, so a per-operation override added complexity
  without value.

- Add Jest test for the default-hidden initial state (208 total tests).
@leandrogilcarrano leandrogilcarrano marked this pull request as draft June 10, 2026 15:37
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.

1 participant