fix(dashboard): stop MissionManager rendering mobile+desktop title together

The header rendered both a "Missions" desktop span AND a mobile span
containing the selected mission title simultaneously, relying on CSS to
hide the inactive variant. jsdom doesn't apply media queries, so
testing-library's getByText found the mission title in both the body
cards and the otherwise-hidden mobile header — failing 49 tests with
"Found multiple elements with the text: <title>". Render only the
active variant based on isMobile.

Also clear localStorage in beforeEach so the SWR mission cache from
prior tests doesn't pre-hydrate into the next render and surface its
own fixtures as duplicates.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
gsxdsm
2026-05-19 18:03:12 -07:00
parent f55b051163
commit acfc55b804
2 changed files with 10 additions and 4 deletions

View File

@@ -4205,10 +4205,13 @@ export function MissionManager({ isOpen, isInline = false, onClose, addToast, pr
)} )}
<Target size={18} className="mission-manager__header-icon" /> <Target size={18} className="mission-manager__header-icon" />
<h2 className="mission-manager__title" data-testid="mission-header-title"> <h2 className="mission-manager__title" data-testid="mission-header-title">
<span className="mission-manager__title-text mission-manager__title-text--desktop">Missions</span> {isMobile ? (
<span className="mission-manager__title-text mission-manager__title-text--mobile"> <span className="mission-manager__title-text mission-manager__title-text--mobile">
{selectedMission ? selectedMission.title : "Missions"} {selectedMission ? selectedMission.title : "Missions"}
</span> </span>
) : (
<span className="mission-manager__title-text mission-manager__title-text--desktop">Missions</span>
)}
</h2> </h2>
</div> </div>
{!isInline && ( {!isInline && (

View File

@@ -740,6 +740,9 @@ describe("MissionManager", () => {
beforeEach(() => { beforeEach(() => {
mockViewport("desktop"); mockViewport("desktop");
// Reset SWR cache so prior tests' mission lists don't pre-hydrate into the
// current render and surface duplicates of fixture titles.
localStorage.clear();
originalFetch = globalThis.fetch; originalFetch = globalThis.fetch;
originalEventSource = globalThis.EventSource; originalEventSource = globalThis.EventSource;
mockFetchAiSession.mockReset(); mockFetchAiSession.mockReset();