Calio/tests/browser/native-interactions.check.js
Elijah c3b9376508
All checks were successful
Verify and publish Calio container / build-and-push (push) Successful in 28s
Native-feel polish: autosaving settings, stacked sheets, desktop type scale
- Settings apply as they change; theme/accent preview instantly and a
  background sync no longer discards in-progress edits
- Food journal stays open beneath edit/add/delete sheets
- Toasts render in the top layer above open sheets, with an error tone
- Follow the new day when the PWA resumes after midnight
- Add-food sheet: day/time row, one-tap meal picker, blank nutrient fields
- Library cards gain a Log action; compact rows on phones
- Desktop type scale raised from 7-12px to 10-15px (desktop.css)
- Hover styles limited to hover-capable devices; touch press dimming and
  no text selection on app chrome
- Sheets slide opaque on the UIKit curve; drag-to-dismiss tracks 1:1,
  supports flicks and departs from the dragged position
- Removed calorie bubbles fade out; no progress dot at 0 kcal
- Friendly network/proxy error messages; fresh outbox check before update

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-22 10:57:36 -07:00

82 lines
4.1 KiB
JavaScript

// Development-only browser regression probe. Run on an unlocked localhost preview
// with Runtime.evaluate (awaitPromise: true). It changes navigation and draft input
// only. Settings autosave, so the cutoff it edits is saved and then restored;
// it never 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 && !e.closest('.page-panel[aria-hidden="true"]'));
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.preferenceEditsSurviveNavigation = 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 };
})()