Polish PWA gestures, transitions and nutrition averages
All checks were successful
Verify and publish Calio container / build-and-push (push) Successful in 32s
All checks were successful
Verify and publish Calio container / build-and-push (push) Successful in 32s
This commit is contained in:
parent
b19de6f9ea
commit
7288e56c02
16 changed files with 1019 additions and 245 deletions
81
tests/browser/native-interactions.check.js
Normal file
81
tests/browser/native-interactions.check.js
Normal file
|
|
@ -0,0 +1,81 @@
|
|||
// Development-only browser regression probe. Run on an unlocked localhost preview
|
||||
// with Runtime.evaluate (awaitPromise: true). It changes navigation and draft input
|
||||
// only, restores the draft, and never saves or deletes journal records.
|
||||
(async () => {
|
||||
const checks = {};
|
||||
const pause = (ms = 380) => new Promise(resolve => setTimeout(resolve, ms));
|
||||
const visible = selector => [...document.querySelectorAll(selector)].filter(e => e.getBoundingClientRect().width > 0);
|
||||
const page = () => document.querySelector('main').getAttribute('aria-label');
|
||||
const nav = async label => {
|
||||
visible('.bottom-nav button').find(e => e.textContent.trim() === label).click();
|
||||
await pause();
|
||||
};
|
||||
const swipe = async (selector, dx, dy = 1, cancel = false) => {
|
||||
const target = visible(selector)[0];
|
||||
const rect = target.getBoundingClientRect();
|
||||
const x = Math.max(30, Math.min(innerWidth - 30, rect.x + rect.width / 2));
|
||||
const y = rect.y + Math.min(rect.height / 2, 90);
|
||||
const emit = (type, px, py, ended = false) => {
|
||||
const touch = new Touch({ identifier: 11, target, clientX: px, clientY: py });
|
||||
target.dispatchEvent(new TouchEvent(type, { bubbles: true, cancelable: true, touches: ended ? [] : [touch], changedTouches: [touch] }));
|
||||
};
|
||||
emit('touchstart', x, y);
|
||||
emit('touchmove', x + dx / 2, y + dy / 2);
|
||||
emit('touchmove', x + dx, y + dy);
|
||||
emit(cancel ? 'touchcancel' : 'touchend', x + dx, y + dy, true);
|
||||
await pause();
|
||||
};
|
||||
await nav('Today');
|
||||
await swipe('.orb', 150);
|
||||
checks.firstTabDoesNotWrap = page() === 'Today';
|
||||
await swipe('.orb', -150, 1, true);
|
||||
checks.cancelDoesNotNavigate = page() === 'Today';
|
||||
await swipe('.orb', -150);
|
||||
checks.leftSwipeNavigates = page() === 'My library';
|
||||
await swipe('.page-heading h1', 4, -160);
|
||||
checks.verticalScrollDoesNotNavigate = page() === 'My library';
|
||||
const libraryTabs = visible('.library-controls .segmented button');
|
||||
libraryTabs.at(-1).click();
|
||||
await pause();
|
||||
visible('.trend-controls .segmented button')[1].click();
|
||||
await pause();
|
||||
await swipe('.page-heading h1', -150);
|
||||
checks.nextTabIsWeight = page() === 'Weight';
|
||||
await swipe('.page-heading h1', 150);
|
||||
checks.rightSwipeNavigates = page() === 'My library';
|
||||
checks.libraryStateIsRetained = visible('.library-controls .segmented .active')[0]?.textContent.trim() === 'Trends' && visible('.trend-controls .segmented .active')[0]?.textContent.trim() === 'Month';
|
||||
await nav('Settings');
|
||||
const cutoff = document.querySelector('[aria-label="Minimum calories for averages"]');
|
||||
const original = cutoff.value;
|
||||
const changeValue = value => {
|
||||
Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, 'value').set.call(cutoff, value);
|
||||
cutoff.dispatchEvent(new Event('input', { bubbles: true }));
|
||||
};
|
||||
changeValue('987');
|
||||
await swipe('[aria-label="Minimum calories for averages"]', -150);
|
||||
checks.inputsDoNotNavigate = page() === 'Settings';
|
||||
await swipe('.page-heading h1', -150);
|
||||
checks.lastTabDoesNotWrap = page() === 'Settings';
|
||||
await nav('Weight');
|
||||
await nav('Settings');
|
||||
checks.unsavedPreferencesSurviveNavigation = cutoff.value === '987';
|
||||
changeValue(original);
|
||||
visible('.bottom-nav button').find(e => e.textContent.trim() === 'Library').click();
|
||||
visible('.bottom-nav button').find(e => e.textContent.trim() === 'Weight').click();
|
||||
await pause();
|
||||
checks.rapidTapsUseLatestDestination = page() === 'Weight';
|
||||
await nav('Today');
|
||||
visible('.bottom-nav .nav-add')[0].click();
|
||||
await pause();
|
||||
checks.sheetOpens = Boolean(document.querySelector('dialog[open]'));
|
||||
await swipe('dialog input[type="date"]', -150);
|
||||
checks.dialogDoesNotNavigate = page() === 'Today';
|
||||
visible('dialog .sheet-head button')[0].click();
|
||||
await pause(20);
|
||||
checks.sheetHasExitAnimation = Boolean(document.querySelector('dialog.sheet-exiting'));
|
||||
await pause();
|
||||
checks.sheetCloses = !document.querySelector('dialog[open]');
|
||||
checks.scrollLockReleased = document.body.style.overflow === '';
|
||||
checks.noHorizontalOverflow = document.documentElement.scrollWidth <= innerWidth + 1;
|
||||
return { pass: Object.values(checks).every(Boolean), checks };
|
||||
})()
|
||||
Loading…
Add table
Add a link
Reference in a new issue