Test which changes lay the right panels out for the Stories card

Co-authored-by: Manjunath Paparaju <[email protected]>
This commit is contained in:
Sameh KhamisandManjunath Paparaju authored and Sameh Khamis committed 2026-11-18 17:00:10 -08:00
1 parent 866eadbe5e
commit 3c0aec90ef
3 files changed
+43 -3

No files matched your search

+2 -1
View File
@@ -982,7 +982,8 @@ test('the launcher keeps focus, restores it, and never disables the focused butt
// drops the keyboard to <body> 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',
+2 -2
View File
@@ -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) !==
+39
View File
@@ -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);
});