Skip to content

Open-source gym & body-weight tracker, now in the App Store (iPhone + Apple Watch) and as an Android APK. Plan routines, log workouts, see which muscles are trained, import from Strong/Hevy/FitNotes. Self-host it or use it on the phone alone.

Edge swipe back: guard that every page back arrow is marked

Duarte Santose109594fe3b3
diff --git a/frontend/src/lib/edge-swipe-back.test.js b/frontend/src/lib/edge-swipe-back.test.js
index 1f5bc91a1..0d0ef9034 100644
--- a/frontend/src/lib/edge-swipe-back.test.js
+++ b/frontend/src/lib/edge-swipe-back.test.js
@@ -185,3 +185,19 @@ describe('the gesture', () => {
expect(rowDown).toHaveBeenCalledTimes(1)
})
})
+
+// The gesture finds a page's back button by data-back. A back arrow added later without it just
+// has no swipe, silently: every chevron button that navigates away (nav(...) or a back()) has it.
+describe('every page back arrow is marked', () => {
+ const files = import.meta.glob('../views/*.jsx', { query: '?raw', import: 'default', eager: true })
+ it('carries data-back', () => {
+ const unmarked = []
+ for (const [file, src] of Object.entries(files)) {
+ for (const line of src.split('\n')) {
+ if (!/chevronLeft/.test(line) || !/<button/.test(line)) continue
+ if (/onClick=\{(\(\) => nav\(|back\}|home\})/.test(line) && !/data-back/.test(line)) unmarked.push(file + ': ' + line.trim())
+ }
+ }
+ expect(unmarked).toEqual([])
+ })
+})