mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-19 17:52:21 +00:00
Test which changes lay the right panels out for the Stories card
Co-authored-by: Manjunath Paparaju <[email protected]>
This commit is contained in:
1 parent
866eadbe5e
commit
3c0aec90ef
3 files changed
+43
-3
No files matched your search
@@ -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) !==
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
Reference in new issue
Block a user