fix(portal): playground region accessors fall back to sessionStorage [W-22945464]#145
Open
spezzirriemiliano wants to merge 3 commits into
Open
fix(portal): playground region accessors fall back to sessionStorage [W-22945464]#145spezzirriemiliano wants to merge 3 commits into
spezzirriemiliano wants to merge 3 commits into
Conversation
Add comprehensive test coverage for getSelectedServerType and getSelectedRegion to verify sessionStorage fallback behavior when DOM has default values. Tests verify: - sessionStorage fallback when DOM is at default 'us' but sessionStorage has non-default - DOM preference when DOM value is non-default - sessionStorage fallback when DOM elements are missing - null/default fallback when both DOM and sessionStorage are empty - custom region handling - region behavior for US (always null regardless of sessionStorage) All new tests currently fail — implementation follows. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Add comprehensive test coverage for getSelectedRegion to verify sessionStorage fallback behavior when regionPreset DOM element is missing. Tests verify: - sessionStorage fallback when serverSelect exists but regionPreset is missing - Fallback for all platform regions (ca1, jp1) - DOM region preference over sessionStorage when both are set - null return when serverSelect is us (regardless of sessionStorage) - null return when neither DOM nor sessionStorage has a region - custom region handling via regionCustomInput - null return when serverSelect is missing All new tests currently fail — implementation follows. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
leandrogilcarrano
approved these changes
Jun 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
anypoint.mulesoft.com(US) regardless of the region the user selected before logging in.getSelectedServerType()andgetSelectedRegion()inportal.jsfall back tosessionStorage(anypoint_server_type/anypoint_region) when the DOM is at its default or the relevant element is missing, eliminating theDOMContentLoadedrace that left.step-url-barrendered against the wrong control plane.Acceptance criteria
eu1in sessionStorage on a?playground=truepage →getSelectedBaseUrl()resolves through the fixed accessors toeu1.anypoint.mulesoft.com. Evidence: jestreturns sessionStorage value when DOM is at default us and storage has eu (bug repro)+getSelectedBaseUrlexisting block continues green (240/240).platform/ca1) and Japan (platform/jp1) resolve to the correct host via the same path. Evidence: jestreturns sessionStorage region when DOM has platform but no regionPreset for ca1and... for jp1.prefers DOM region over sessionStorage when both are set+prefers DOM value when DOM is non-default, even if storage says otherwise.getSelectedServerType()returns the persisted value when#serverSelectis missing or at default'us'while sessionStorage holds a different value. Evidence:_safeSessionGet('anypoint_server_type')branch inportal.js+ new tests.getSelectedRegion()returns the persisted region when#regionPreset/#regionCustomInputare missing or empty. Evidence: new fallback branch + tests for eu/ca1/jp1.'us'/null). Evidence: testsreturns us when both DOM and sessionStorage are emptyandreturns null when neither DOM nor sessionStorage has a region.scripts/tests/portal.test.jscontinue to pass. Evidence: 240/240 green.getSelectedServerTypeandgetSelectedRegiondescribe blocks.Test plan
cd scripts && npx jest portal.test.js→ 240 passed (includes 13 new tests for the W-22945464 fallback paths).make test-portal(pytest + jest) — pytest deps not installed in this worktree (PEP 668 externally managed env); diff is JS-only so jest is the authoritative gate locally. CI runs both.make pre-commit-hook— gracefully degraded locally (Python validators absent); CI is authoritative.Related
docs/superpowers/specs/2026-06-24-w-22945464-playground-region-fix-design.mddocs/superpowers/plans/2026-06-24-w-22945464-playground-region-fix-plan.mdNotes
sessionStorage.getItemin a_safeSessionGethelper that returnsnullwhen storage access throws (private mode / disabled storage), matching the edge case called out in the spec.