mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-19 09:42:21 +00:00
Turn the first-run launcher into a three-step welcome
Replace the single dense welcome card with three short steps: an introduction to the modes, where to start (Space Missions, Environmental or Explore manually, Explore selected by default), then quick tips (the place tip points at the search bar) and links. Next and Back keep the selection, and only Enter God mode runs a mission; double clicks, Enter repeats and clicks during a step change cannot launch one. Skip and ESC close the card for the session, as before. Drop the Live Contacts tile and the old voice tip. Space Missions switches on its layer, which opens its own panel, so no first-run choice enters a Context mode or opens the Context panel any more, and that path is gone. The last step links to the repository and Halfpixel's channels, each opening in a new tab without opener or referrer. Its GEV Stories card closes the welcome and opens the in-app Stories Explore view; the Stories announcement stays hidden, and unseen, until the card has closed and Stories has loaded. The dim layer behind the card is a click-through tint with no blur. Update the 13 catalogs, CURRENT-STATE, the first-run QA harness and its mutations, and the scripts that dismissed the old card. Add a changelog fragment. Co-authored-by: Sameh Khamis <[email protected]>
This commit is contained in:
1 parent
0421813e26
commit
e342149a09
27 files changed
+2807
-515
No files matched your search
@@ -12,6 +12,7 @@ import {
|
||||
initFirstRunExperience,
|
||||
} from './firstRunExperience.js';
|
||||
import { useFirstRunStore } from './ui/stores/firstRun.js';
|
||||
import { useStoriesStore } from './ui/stores/stories.js';
|
||||
import WelcomeView from './ui/views/WelcomeView.vue';
|
||||
|
||||
function memoryStorage(key, { refuse = false } = {}) {
|
||||
@@ -31,7 +32,14 @@ function memoryStorage(key, { refuse = false } = {}) {
|
||||
}
|
||||
|
||||
/** The welcome view and an initialized launcher, revealed and painted. */
|
||||
async function launch(t, { styleManager = {}, refuse = false } = {}) {
|
||||
async function launch(
|
||||
t,
|
||||
{
|
||||
styleManager = {},
|
||||
dataManager = { setEnabled: async () => true },
|
||||
refuse = false,
|
||||
} = {},
|
||||
) {
|
||||
document.body.replaceChildren();
|
||||
// Where focus was before the launcher opened.
|
||||
const opener = document.body.appendChild(document.createElement('button'));
|
||||
@@ -47,7 +55,7 @@ async function launch(t, { styleManager = {}, refuse = false } = {}) {
|
||||
const sessionStorageRef = memoryStorage(FIRST_RUN_SESSION_KEY);
|
||||
const launcher = initFirstRunExperience({
|
||||
styleManager,
|
||||
dataManager: { setEnabled: async () => true },
|
||||
dataManager,
|
||||
documentRef: document,
|
||||
storage,
|
||||
sessionStorageRef,
|
||||
@@ -68,7 +76,31 @@ async function launch(t, { styleManager = {}, refuse = false } = {}) {
|
||||
Object.defineProperty(list, 'clientHeight', { get: () => box.clientHeight });
|
||||
for (const frame of frames.splice(0)) frame();
|
||||
await nextTick();
|
||||
return { launcher, root, list, box, opener, storage, sessionStorageRef };
|
||||
return {
|
||||
launcher,
|
||||
pinia,
|
||||
root,
|
||||
list,
|
||||
box,
|
||||
opener,
|
||||
storage,
|
||||
sessionStorageRef,
|
||||
frames,
|
||||
};
|
||||
}
|
||||
|
||||
async function move(root, frames, selector = '[data-first-run-next]') {
|
||||
root.querySelector(selector).click();
|
||||
await settle(frames);
|
||||
}
|
||||
|
||||
async function settle(frames) {
|
||||
for (let i = 0; i < 4; i++) {
|
||||
await nextTick();
|
||||
for (const frame of frames.splice(0)) frame();
|
||||
await new Promise((resolve) => setTimeout(resolve));
|
||||
}
|
||||
await nextTick();
|
||||
}
|
||||
|
||||
test('the card is hidden until initialized, then revealed with its copy', async (t) => {
|
||||
@@ -81,57 +113,150 @@ test('the card is hidden until initialized, then revealed with its copy', async
|
||||
assert.equal(hidden.className, '');
|
||||
app.unmount();
|
||||
|
||||
const { root, list } = await launch(t);
|
||||
const { root, list, frames } = await launch(t);
|
||||
assert.equal(root.hidden, false);
|
||||
assert.equal(root.classList.contains('visible'), true);
|
||||
assert.equal(root.hasAttribute('aria-hidden'), false);
|
||||
assert.equal(list.dataset.scrollable, 'true');
|
||||
assert.equal(
|
||||
root.querySelector('[data-first-run-status]').textContent,
|
||||
'Tip: the GEV MIC button in the dock lets you talk to the map.',
|
||||
assert.equal(root.querySelector('[data-first-run-status]').textContent, '');
|
||||
assert.equal(root.querySelector('[data-first-run-choice]'), null);
|
||||
assert.ok(
|
||||
document.activeElement === root.querySelector('[data-first-run-primary]'),
|
||||
);
|
||||
await move(root, frames);
|
||||
assert.deepEqual(
|
||||
[...root.querySelectorAll('[data-first-run-start]')].map(
|
||||
(node) => node.dataset.firstRunStart,
|
||||
),
|
||||
['space-missions', 'environmental', 'explore'],
|
||||
);
|
||||
const environmental = root.querySelector(
|
||||
'[data-first-run-start="environmental"]',
|
||||
);
|
||||
assert.equal(
|
||||
root.querySelector('[data-first-run-environmental-title]').textContent,
|
||||
environmental.querySelector('strong').textContent,
|
||||
'ENVIRONMENTAL',
|
||||
);
|
||||
assert.match(
|
||||
environmental.querySelector('small').textContent,
|
||||
/earthquakes.*fires/i,
|
||||
);
|
||||
assert.equal(
|
||||
root
|
||||
.querySelector('[data-first-run-start="explore"]')
|
||||
.getAttribute('aria-pressed'),
|
||||
'true',
|
||||
);
|
||||
assert.ok(
|
||||
document.activeElement === root.querySelector('[data-first-run-choice]'),
|
||||
'the first mission has focus',
|
||||
document.activeElement === root.querySelector('[data-first-run-primary]'),
|
||||
);
|
||||
});
|
||||
|
||||
test('a busy mission marks the choices aria-disabled, never disabled', async (t) => {
|
||||
let finish;
|
||||
const { root } = await launch(t, {
|
||||
styleManager: {
|
||||
setContextMode: () => new Promise((resolve) => (finish = resolve)),
|
||||
let calls = 0;
|
||||
const { root, frames } = await launch(t, {
|
||||
dataManager: {
|
||||
setEnabled: () => {
|
||||
calls++;
|
||||
return new Promise((resolve) => (finish = resolve));
|
||||
},
|
||||
},
|
||||
});
|
||||
const contacts = root.querySelector('[data-first-run-choice="contacts"]');
|
||||
contacts.focus();
|
||||
contacts.click();
|
||||
await move(root, frames);
|
||||
root.querySelector('[data-first-run-start="space-missions"]').click();
|
||||
await nextTick();
|
||||
const primary = root.querySelector('[data-first-run-next]');
|
||||
primary.click();
|
||||
await nextTick();
|
||||
const enter = root.querySelector('[data-first-run-primary]');
|
||||
assert.equal(
|
||||
enter,
|
||||
primary,
|
||||
'one persistent button keeps native click counting and focus',
|
||||
);
|
||||
assert.equal(enter.dataset.firstRunChoice, 'space-missions');
|
||||
enter.click();
|
||||
assert.equal(
|
||||
calls,
|
||||
0,
|
||||
'the new action cannot launch during the step transition',
|
||||
);
|
||||
await settle(frames);
|
||||
assert.ok(
|
||||
document.activeElement === enter,
|
||||
'the primary action retains focus',
|
||||
);
|
||||
assert.deepEqual(enter.getAttribute('aria-describedby').split(' '), [
|
||||
'first-run-title',
|
||||
'first-run-description',
|
||||
]);
|
||||
const announcement = root.querySelector('.first-run-step-announcement');
|
||||
assert.equal(announcement.getAttribute('aria-live'), 'polite');
|
||||
assert.equal(announcement.getAttribute('aria-atomic'), 'true');
|
||||
assert.equal(
|
||||
announcement.textContent,
|
||||
root.querySelector('#first-run-title').textContent,
|
||||
);
|
||||
for (const id of enter.getAttribute('aria-describedby').split(' ')) {
|
||||
assert.ok(root.querySelector(`#${id}`).textContent.trim());
|
||||
}
|
||||
enter.dispatchEvent(new MouseEvent('click', { bubbles: true, detail: 2 }));
|
||||
assert.equal(calls, 0, 'a second click from Next never confirms a mission');
|
||||
const repeated = new KeyboardEvent('keydown', {
|
||||
key: 'Enter',
|
||||
repeat: true,
|
||||
bubbles: true,
|
||||
cancelable: true,
|
||||
});
|
||||
enter.dispatchEvent(repeated);
|
||||
assert.equal(repeated.defaultPrevented, true);
|
||||
// A fresh keyboard/assistive click has detail 0 and remains supported.
|
||||
enter.click();
|
||||
assert.equal(calls, 1);
|
||||
await nextTick();
|
||||
assert.equal(root.dataset.state, 'loading');
|
||||
assert.equal(root.getAttribute('aria-busy'), 'true');
|
||||
for (const button of root.querySelectorAll('[data-first-run-choice]')) {
|
||||
assert.equal(button.getAttribute('aria-disabled'), 'true');
|
||||
assert.equal(button.disabled, false);
|
||||
}
|
||||
assert.ok(document.activeElement === contacts, 'focus stays on the choice');
|
||||
assert.equal(enter.getAttribute('aria-disabled'), 'true');
|
||||
assert.equal(enter.disabled, false);
|
||||
assert.ok(document.activeElement === enter, 'focus stays on the action');
|
||||
assert.equal(
|
||||
root.querySelector('[data-first-run-status]').textContent,
|
||||
'Starting live contacts…',
|
||||
'Opening space missions…',
|
||||
);
|
||||
root.querySelector('.first-run-back').click();
|
||||
await nextTick();
|
||||
assert.equal(
|
||||
root.querySelector('[data-first-run-next]'),
|
||||
null,
|
||||
'Back is inert while busy',
|
||||
);
|
||||
enter.click();
|
||||
assert.equal(calls, 1, 'a busy action cannot start a second request');
|
||||
// A failed mission says so and stays on the card.
|
||||
finish({ ok: false });
|
||||
finish(false);
|
||||
await new Promise((resolve) => setTimeout(resolve));
|
||||
await nextTick();
|
||||
assert.equal(root.dataset.state, 'ready');
|
||||
assert.equal(contacts.getAttribute('aria-disabled'), 'false');
|
||||
assert.equal(enter.getAttribute('aria-disabled'), 'false');
|
||||
assert.match(
|
||||
root.querySelector('[data-first-run-status]').textContent,
|
||||
/^Could not open that mission/,
|
||||
);
|
||||
await move(root, frames, '.first-run-back');
|
||||
assert.equal(
|
||||
root
|
||||
.querySelector('[data-first-run-start="space-missions"]')
|
||||
.getAttribute('aria-pressed'),
|
||||
'true',
|
||||
);
|
||||
root.querySelector('.first-run-back').focus();
|
||||
await move(root, frames, '.first-run-back');
|
||||
assert.equal(root.querySelector('.first-run-back'), null);
|
||||
assert.ok(
|
||||
document.activeElement === root.querySelector('[data-first-run-primary]'),
|
||||
'focus moves when Back is removed',
|
||||
);
|
||||
});
|
||||
|
||||
test('a refused write takes the tick back and says why', async (t) => {
|
||||
@@ -156,25 +281,90 @@ test('a saved tick stays ticked', async (t) => {
|
||||
assert.equal(storage.read(), 'suppressed');
|
||||
});
|
||||
|
||||
test('the DISMISS button closes the card the way ESC does', async (t) => {
|
||||
test('the SKIP button closes the card the way ESC does', async (t) => {
|
||||
const { root, sessionStorageRef } = await launch(t);
|
||||
root.querySelector('[data-first-run-dismiss]').click();
|
||||
await nextTick();
|
||||
assert.equal(root.classList.contains('visible'), false);
|
||||
assert.equal(root.getAttribute('aria-hidden'), 'true');
|
||||
assert.notEqual(sessionStorageRef.read(), null, 'dismissed for the session');
|
||||
root
|
||||
.querySelector('.first-run-step')
|
||||
.dispatchEvent(new Event('transitionend', { bubbles: true }));
|
||||
await nextTick();
|
||||
assert.equal(
|
||||
document.getElementById('first-run-launcher'),
|
||||
root,
|
||||
'child transitions do not finish dismissal',
|
||||
);
|
||||
root.dispatchEvent(new Event('transitionend'));
|
||||
await nextTick();
|
||||
assert.equal(document.getElementById('first-run-launcher') === null, true);
|
||||
});
|
||||
|
||||
test('BROWSE STORIES closes the card and opens Stories in place', async (t) => {
|
||||
const { root, pinia, frames, sessionStorageRef } = await launch(t);
|
||||
const stories = useStoriesStore(pinia);
|
||||
let opened = 0;
|
||||
let finishLoading;
|
||||
stories.connect({
|
||||
open: () => {
|
||||
opened++;
|
||||
return new Promise((resolve) => (finishLoading = resolve));
|
||||
},
|
||||
});
|
||||
await move(root, frames);
|
||||
await move(root, frames);
|
||||
const button = root.querySelector('[data-first-run-stories]');
|
||||
assert.ok(button, 'the Stories card offers its button on the last step');
|
||||
assert.equal(button.tagName, 'BUTTON', 'opens in the app, not a new tab');
|
||||
assert.equal(button.hasAttribute('href'), false);
|
||||
button.click();
|
||||
await nextTick();
|
||||
assert.equal(opened, 1, 'Stories opened once');
|
||||
assert.equal(root.classList.contains('visible'), false, 'the card closed');
|
||||
assert.notEqual(sessionStorageRef.read(), null, 'dismissed for the session');
|
||||
assert.equal(
|
||||
document.body.classList.contains('first-run-opening-stories'),
|
||||
true,
|
||||
'the Stories announcement stays hidden while Stories loads',
|
||||
);
|
||||
finishLoading();
|
||||
await new Promise((resolve) => setTimeout(resolve));
|
||||
assert.equal(
|
||||
document.body.classList.contains('first-run-opening-stories'),
|
||||
false,
|
||||
'and may show again once Stories has opened (or failed to)',
|
||||
);
|
||||
button.dispatchEvent(new MouseEvent('click', { detail: 1 }));
|
||||
await nextTick();
|
||||
assert.equal(opened, 1, 'a closing card cannot open Stories again');
|
||||
});
|
||||
|
||||
test('the Stories card is left out where Stories is not offered', async (t) => {
|
||||
const { root, pinia, frames } = await launch(t);
|
||||
const stories = useStoriesStore(pinia);
|
||||
stories.available = false;
|
||||
await move(root, frames);
|
||||
await move(root, frames);
|
||||
assert.equal(root.querySelector('.first-run-stories'), null);
|
||||
assert.equal(root.querySelector('[data-first-run-stories]'), null);
|
||||
});
|
||||
|
||||
test('the scroll fade clears when the tiles fit after a resize', async (t) => {
|
||||
const { list, box } = await launch(t);
|
||||
const { root, list, box, frames } = await launch(t);
|
||||
assert.equal(list.dataset.scrollable, 'true');
|
||||
box.scrollHeight = 200;
|
||||
window.dispatchEvent(new Event('resize'));
|
||||
await nextTick();
|
||||
assert.equal(list.dataset.scrollable, 'false');
|
||||
box.scrollHeight = 400;
|
||||
await move(root, frames);
|
||||
assert.equal(
|
||||
list.dataset.scrollable,
|
||||
'true',
|
||||
'new step refreshes overflow without a resize',
|
||||
);
|
||||
});
|
||||
|
||||
test('ESC closes the card, returns focus, and removes it without a transition', async (t) => {
|
||||
|
||||
Reference in new issue
Block a user