From 3c0aec90ef8fbd1aefb3229db55bee0b0f220eb9 Mon Sep 17 00:00:00 2001 From: Sameh Khamis Date: Wed, 18 Nov 2026 16:44:36 -0800 Subject: [PATCH] Test which changes lay the right panels out for the Stories card Co-authored-by: Manjunath Paparaju --- src/firstRunExperience.test.mjs | 3 ++- src/ui/panelLayoutController.js | 4 ++-- src/ui/panelRails.test.mjs | 39 +++++++++++++++++++++++++++++++++ 3 files changed, 43 insertions(+), 3 deletions(-) diff --git a/src/firstRunExperience.test.mjs b/src/firstRunExperience.test.mjs index 6f7dea2183..b6bb8e9c39 100644 --- a/src/firstRunExperience.test.mjs +++ b/src/firstRunExperience.test.mjs @@ -982,7 +982,8 @@ test('the launcher keeps focus, restores it, and never disables the focused butt // drops the keyboard to and strands the visitor outside the launcher // (firstRunLauncherView.test.mjs renders it). assert.doesNotMatch(module, /\.disabled = /); - // Tab is confined to the launcher, and ESC always releases it. + // Tab cycles inside the launcher once focus is in it, and ESC always + // releases it. const keyboard = fs.readFileSync( new URL('./ui/surfaceKeyboard.js', import.meta.url), 'utf8', diff --git a/src/ui/panelLayoutController.js b/src/ui/panelLayoutController.js index 1a3783eaa1..4518fcea50 100644 --- a/src/ui/panelLayoutController.js +++ b/src/ui/panelLayoutController.js @@ -67,14 +67,14 @@ const RIGHT_STACK_OBSTACLE_SELECTOR = [ '#gev-voice-control', '#world-timeline', ].join(', '); -/** True when a mutation adds or removes the Stories card (`#hPop`). */ +/** The body class the welcome sets while BROWSE STORIES loads. */ const OPENING_STORIES = 'first-run-opening-stories'; /** * True when a mutation can show or hide the Stories card (`#hPop`): the card * itself coming or going, or the welcome that hides it (`#first-run-launcher`, * and the body class it sets while BROWSE STORIES loads) ending. */ -function movesStoriesCard(record) { +export function movesStoriesCard(record) { if (record.type === 'attributes') return ( (record.oldValue || '').split(/\s+/).includes(OPENING_STORIES) !== diff --git a/src/ui/panelRails.test.mjs b/src/ui/panelRails.test.mjs index d284548b7c..416079aec7 100644 --- a/src/ui/panelRails.test.mjs +++ b/src/ui/panelRails.test.mjs @@ -878,3 +878,42 @@ test('left rail keeps collapsed panels shown beside Cockpit, still one open', () assert.equal(f.stack.classList.contains('layout-exclusive'), false); assert.equal(f.first.getAttribute('aria-hidden'), undefined); }); + +test('the right rail is laid out again when the Stories card can appear or go', async () => { + const { movesStoriesCard } = await import('./panelLayoutController.js'); + const node = (id, inner = null) => ({ + id, + querySelector: (selector) => + inner && selector.split(', ').includes(`#${inner}`) ? {} : null, + }); + const childList = (added = [], removed = []) => ({ + type: 'childList', + addedNodes: added, + removedNodes: removed, + }); + const bodyClass = (oldValue, now) => ({ + type: 'attributes', + oldValue, + target: { classList: { contains: (name) => now.includes(name) } }, + }); + // The card itself, or a wrapper holding it, comes or goes. + assert.equal(movesStoriesCard(childList([node('hPop')])), true); + assert.equal(movesStoriesCard(childList([], [node('', 'hPop')])), true); + // The welcome, which hides the card, is removed. + assert.equal( + movesStoriesCard(childList([], [node('first-run-launcher')])), + true, + ); + // Story playback's own changes do not lay the rail out. + assert.equal(movesStoriesCard(childList([node('story-frame')])), false); + // Only the welcome's loading class coming or going counts. + assert.equal( + movesStoriesCard(bodyClass('first-run-opening-stories', ['stories-mode'])), + true, + ); + assert.equal( + movesStoriesCard(bodyClass('', ['first-run-opening-stories'])), + true, + ); + assert.equal(movesStoriesCard(bodyClass('a', ['b'])), false); +});