From 02e90ca698b7e64e2410adc371cddbe0d4ee5a71 Mon Sep 17 00:00:00 2001 From: Sameh Khamis Date: Sat, 12 Sep 2026 23:25:09 -0700 Subject: [PATCH] test: keep Radio invariants independent of formatting --- src/cockpitMarkup.test.mjs | 10 +++++----- src/contextSessionOrdering.test.mjs | 2 +- src/firstRunExperience.test.mjs | 2 +- src/panelEscape.test.mjs | 2 +- src/radioMarkup.test.mjs | 10 +++++----- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/cockpitMarkup.test.mjs b/src/cockpitMarkup.test.mjs index 355dfc040..dc3201310 100644 --- a/src/cockpitMarkup.test.mjs +++ b/src/cockpitMarkup.test.mjs @@ -355,12 +355,12 @@ test('Cockpit side surfaces behave as two single-expanded accordions', () => { ); assert.match( radioBindings, - /!displayOpen && !radioOpen[\s\S]*?this\.actions\.isCockpitActive\(\)[\s\S]*?!this\.actions\.signalUserCollapsed\(\)[\s\S]*?setSignalCollapsed\(false\)/, + /!displayOpen\s*&&\s*!radioOpen[\s\S]*?this\.actions\.isCockpitActive\(\)[\s\S]*?!this\.actions\.signalUserCollapsed\(\)[\s\S]*?setSignalCollapsed\(false\)/, 'Live Signals should reopen only after both utility panels close and no manual collapse is retained', ); assert.match( radioBindings, - /event\.target\?\.closest\?\.\('#left-panel-stack, #cockpit-context'\)\) return;[\s\S]*?setCockpitDisclosure\('display', false\);/, + /event\.target\?\.closest\?\.\('#left-panel-stack, #cockpit-context'\)\)\s*return;[\s\S]*?setCockpitDisclosure\('display', false\);/, 'left-side interactions must not collapse the independent Cockpit utilities', ); }); @@ -503,18 +503,18 @@ test('Location navigation releases immediate routes before flight and deferred r }); test('Cockpit Radio station changes preserve first-person camera ownership', () => { - const cycleHelper = radioBindings.match(/const cycleRadio = \(direction, \{ rotate = true \} = \{\}\) => \{([\s\S]*?)\n \};/); + const cycleHelper = radioBindings.match(/const cycleRadio = \(direction, \{ rotate = true \} = \{\}\) => \{([\s\S]*?)\n \};/); assert.ok(cycleHelper, 'shared Radio cycle helper is missing'); assert.match(cycleHelper[1], /cycleStation\(direction, \{[\s\S]*?rotate,/); assert.match(radioBindings, /listen\(this\._radioPrevBtn, 'click', \(\) => cycleRadio\(-1\)\)/); assert.match(radioBindings, /listen\(this\._contextRadioMiniNextBtn, 'click', \(\) => cycleRadio\(1\)\)/); assert.match( radioBindings, - /listen\(this\._cockpitRadioPrevBtn, 'click', \(\) => cycleRadio\(-1, \{ rotate: false \}\)\)/, + /listen\(this\._cockpitRadioPrevBtn, 'click', \(\) =>\s*cycleRadio\(-1, \{ rotate: false \}\),?\s*\)/, ); assert.match( radioBindings, - /listen\(this\._cockpitRadioNextBtn, 'click', \(\) => cycleRadio\(1, \{ rotate: false \}\)\)/, + /listen\(this\._cockpitRadioNextBtn, 'click', \(\) =>\s*cycleRadio\(1, \{ rotate: false \}\),?\s*\)/, ); }); diff --git a/src/contextSessionOrdering.test.mjs b/src/contextSessionOrdering.test.mjs index e9f8ef8d7..4bc5f6704 100644 --- a/src/contextSessionOrdering.test.mjs +++ b/src/contextSessionOrdering.test.mjs @@ -192,7 +192,7 @@ test('only the expanded Radio Enable gesture requests the contained post-enable radioBindings.indexOf("this.listen(this._radioFilter, 'change'"), ); assert.match(radioControls, /revealAfterEnable = enabling && trigger === this\._radioEnableBtn/); - assert.match(radioControls, /if \(revealAfterEnable\) await this\._revealRadioControlsAfterExplicitEnable\(trigger\)/); + assert.match(radioControls, /if \(revealAfterEnable\)\s*await this\._revealRadioControlsAfterExplicitEnable\(trigger\)/); assert.equal((radioBindings.match(/_revealRadioControlsAfterExplicitEnable\(trigger\)/g) || []).length, 1); assert.match(radioControlsSource, /async _revealRadioControlsAfterExplicitEnable\(trigger\)/); }); diff --git a/src/firstRunExperience.test.mjs b/src/firstRunExperience.test.mjs index f127e88b5..b19f082ae 100644 --- a/src/firstRunExperience.test.mjs +++ b/src/firstRunExperience.test.mjs @@ -270,7 +270,7 @@ test('one ESC does one thing — the radio disclosure stops the launcher outrigh // disclosure's earlier capture handler closed the disclosure and the launcher // dismissed itself off the same key. The earlier listener is the only one that // can stop the later one — and only the immediate form does it. - const radioEsc = ui.slice(ui.indexOf("if (event.key !== 'Escape' || !this._contextRadioDock")); + const radioEsc = ui.slice(ui.indexOf("event.key !== 'Escape' ||")); const claim = radioEsc.slice(0, radioEsc.indexOf('setRadioDisclosure(false')); assert.match(claim, /event\.preventDefault\(\);/); assert.match(claim, /event\.stopImmediatePropagation\(\);/); diff --git a/src/panelEscape.test.mjs b/src/panelEscape.test.mjs index 6b44052fc..c44be1b97 100644 --- a/src/panelEscape.test.mjs +++ b/src/panelEscape.test.mjs @@ -160,7 +160,7 @@ test('Cockpit Escape collapses Contact or Live Signals before exiting Cockpit', test('Cockpit utility Escape leaves an expanded nested Parameters panel to the shared handler', () => { assert.match( radioBindings, - /const nestedPanel = event\.target\?\.closest\?\.\('\.panel-collapsible:not\(\.collapsed\), #param-slider-panel:not\(\.collapsed\)'\);[\s\S]*?if \(nestedPanel\) return;[\s\S]*?setCockpitDisclosure/, + /const nestedPanel = event\.target\?\.closest\?\.\(\s*'\.panel-collapsible:not\(\.collapsed\), #param-slider-panel:not\(\.collapsed\)',?\s*\);[\s\S]*?if \(nestedPanel\) return;[\s\S]*?setCockpitDisclosure/, ); assert.match( radioBindings, diff --git a/src/radioMarkup.test.mjs b/src/radioMarkup.test.mjs index 91a86b465..303a54246 100644 --- a/src/radioMarkup.test.mjs +++ b/src/radioMarkup.test.mjs @@ -259,9 +259,9 @@ test('Radio is nested inside Context with separate disclosure and power controls const cycleMethod = radioBindings.slice(cycleStart, radioBindings.indexOf('const toggleRadio', cycleStart)); assert.doesNotMatch(cycleMethod, /refreshTunerBand/); assert.match(radioBindings, /_radioTunerBandPinnedForNavigation = true/); - assert.match(radioBindings, /listen\(this\.canvas, 'pointerdown', releaseNavigationBand/); + assert.match(radioBindings, /listen\(\s*this\.canvas,\s*'pointerdown',\s*releaseNavigationBand/); assert.match(radioBindings, /previewTuningStation\(station\?\.id \|\| null, \{ rotate \}\)/); - assert.match(radioBindings, /tunerPreview\(\{ coordinate: this\._radioTunerCoordinate, rotate: commit \}\)/); + assert.match(radioBindings, /tunerPreview\(\{\s*coordinate: this\._radioTunerCoordinate,\s*rotate: commit,?\s*\}\)/); assert.match(radioBindings, /this\.radio\.cancelTuning\(\)/); assert.match(radioControlsSource, /classList\.remove\('radio-broadcasting'\)/); assert.match(radioBindings, /this\.radio\.getTunerStations\(750\)/); @@ -312,7 +312,7 @@ test('expanded Context routes its Radio icon to the embedded section and keeps c const revealMethod = radioControlsSource.slice(revealStart, revealEnd); assert.ok(revealStart >= 0 && revealEnd > revealStart, 'embedded Radio reveal helper is missing'); assert.match(revealMethod, /requestAnimationFrame\(\(\) => requestAnimationFrame/); - assert.match(revealMethod, /scroller\.scrollTo\(\{ top: next, behavior: reducedMotion \? 'auto' : 'smooth' \}\)/); + assert.match(revealMethod, /scroller\.scrollTo\(\{\s*top: next,\s*behavior: reducedMotion \? 'auto' : 'smooth',?\s*\}\)/); assert.match(revealMethod, /focus\?\.\(\{ preventScroll: true \}\)/); assert.doesNotMatch(revealMethod, /setEnabled|togglePlayback|selectStation|setContextMode/); @@ -320,8 +320,8 @@ test('expanded Context routes its Radio icon to the embedded section and keeps c const syncEnd = radioControlsSource.indexOf('\n destroy()', syncStart + 10); const syncMethod = radioControlsSource.slice(syncStart, syncEnd); assert.ok(syncStart >= 0 && syncEnd > syncStart, 'Context Radio launcher state sync is missing'); - assert.match(syncMethod, /contextExpanded[\s\S]*?aria-controls', 'radio-panel'[\s\S]*?aria-expanded', String\(radioExpanded\)/); - assert.match(syncMethod, /aria-controls', 'context-radio-mini'[\s\S]*?aria-expanded', String\(compactOpen\)/); + assert.match(syncMethod, /contextExpanded[\s\S]*?aria-controls', 'radio-panel'[\s\S]*?aria-expanded',\s*String\(radioExpanded\)/); + assert.match(syncMethod, /aria-controls',\s*'context-radio-mini'[\s\S]*?aria-expanded',\s*String\(compactOpen\)/); const renderMethod = radioPresentation; assert.match(renderMethod, /this\._syncContextRadioLauncherState\(\)/); assert.doesNotMatch(renderMethod, /compact Radio controls/);