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.
JavaScript apple-watchbodyweightdockerfitnessfitness-trackergymhealthiosmcpnodejspasskeysprogressive-web-applicationspwareactself-hostedself-hostingvitewebauthnweightliftingworkout-tracker
Swipe hint waits for a quiet moment; UI tests reach the summary's button
Duarte Santos620b3fd17817
diff --git a/frontend/ios/App/AppUITests/OpenGymUITests.swift b/frontend/ios/App/AppUITests/OpenGymUITests.swiftindex ce185658a..f75a53359 100644--- a/frontend/ios/App/AppUITests/OpenGymUITests.swift+++ b/frontend/ios/App/AppUITests/OpenGymUITests.swift@@ -78,14 +78,17 @@ final class OpenGymUITests: XCTestCase {tap(app.buttons["Choose a different workout"], "Choose a different workout")tap(app.staticTexts["Full Body A"], "Full Body A")shot("2-workout")- tap(app.switches["Set 1 done"], "Set 1 done")+ let tick = app.switches["Set 1 done"]+ tap(tick, "Set 1 done")// The first rest asks for notifications; on a slow simulator the question can take a while.let countdown = button(startingWith: "1:")let allow = springboard.alerts.buttons["Allow"]var counting = false- for _ in 0..<40 {+ for i in 0..<40 {if allow.exists { allow.tap() }if countdown.exists { counting = true; break }+ // A tap that did not tick (something moved under it): once more, never on a ticked set.+ if i == 4, (tick.value as? String) == "0" { tick.tap() }sleep(1)}if allow.waitForExistence(timeout: 2) { allow.tap() }@@ -145,7 +148,22 @@ final class OpenGymUITests: XCTestCase {}tap(finish, "Finish")tap(button(startingWith: "Finish and save"), "Finish and save")- tap(app.buttons["Nice!"], "Nice! (the summary)", timeout: 20)+ // The summary is a centred card taller than the screen: its button is at the foot of the+ // card's own scroll, below what shows (CI 10-13: the tap landed under the card).+ let nice = app.buttons["Nice!"]+ XCTAssertTrue(nice.waitForExistence(timeout: 20), "Nice! (the summary) did not show up")+ let window = app.windows.firstMatch+ let bottom = window.frame.maxY - 80+ for _ in 0..<6 where nice.frame.maxY > bottom {+ // A drag in the middle of the card, upwards: scrolls the card, never dismisses it.+ window.coordinate(withNormalizedOffset: CGVector(dx: 0.5, dy: 0.65))+ .press(forDuration: 0.05, thenDragTo: window.coordinate(withNormalizedOffset: CGVector(dx: 0.5, dy: 0.3)))+ sleep(1)+ }+ shot("6-summary")+ nice.tap()+ for _ in 0..<5 where nice.exists { sleep(1) }+ if nice.exists { nice.tap() }shot("6-finished")tap(button(startingWith: "Settings"), "Settings")diff --git a/frontend/src/views/Workout.jsx b/frontend/src/views/Workout.jsxindex ab8f2d316..3f6e7cfcb 100644--- a/frontend/src/views/Workout.jsx+++ b/frontend/src/views/Workout.jsx@@ -1019,11 +1019,22 @@ function ActiveWorkout() {// The one-time swipe hint (v1.3.11): the first time the screen shows an unticked set with swiping// on, that row nudges toward delete and toward copy, with a chip under it saying so. Seen once// per person (S.hints, synced), not per device. In Cards only the exercise on screen qualifies.+ // It waits for a quiet moment: the nudge moves the row, and a tick tapped while it moves lands+ // where the circle was a moment ago, so the tap is lost (iOS UI test, CI 10-13: the first set+ // ticked a second after the workout opened never ticked). HINT_QUIET_MS without a touch first.const hintSeen = !!(S.hints && S.hints.swipeSets)const hintTm = useRef(null)useEffect(() => {if (!wc.swipeSets || hintSeen || !A.entries.length) return- const tm = setTimeout(() => {+ const startedAt = Date.now()+ let tm = null+ const quietIn = () => Math.max(HINT_DELAY_MS - (Date.now() - startedAt), lastTouchAt + HINT_QUIET_MS - Date.now())+ const later = () => {+ const wait = quietIn()+ if (wait > 0) { tm = setTimeout(later, wait); return }+ show()+ }+ const show = () => {const A2 = useStore.getState().S.activeif (!A2 || useStore.getState().S.hints?.swipeSets) returnconst c = Math.min(Math.max(A2.cur || 0, 0), A2.entries.length - 1)@@ -1040,7 +1051,8 @@ function ActiveWorkout() {setUI({ swipeHint: { ...at, id } })clearTimeout(hintTm.current)hintTm.current = setTimeout(() => { if (useUI.getState().swipeHint?.id === id) setUI({ swipeHint: null }) }, 6000)- }, 600)+ }+ later()return () => clearTimeout(tm)}, [wc.swipeSets, hintSeen, A.entries.length, cur, listMode])useEffect(() => () => { clearTimeout(hintTm.current); setUI({ swipeHint: null, setFlash: null }) }, [])@@ -2083,6 +2095,14 @@ function ActiveWorkout() {</WorkoutScrollAnchor>}+// The swipe hint's quiet moment (see the hint in the screen below): the last touch anywhere.+export const HINT_DELAY_MS = 600+export const HINT_QUIET_MS = 2500+let lastTouchAt = 0+if (typeof document !== 'undefined') document.addEventListener('pointerdown', () => { lastTouchAt = Date.now() }, true)+// Test seam: a fresh launch, nobody has touched anything yet.+export function _resetHintQuiet() { lastTouchAt = 0 }+export default function Workout() {const active = useStore(s => s.S.active)return active ? <ActiveWorkout /> : <StartChooser />diff --git a/frontend/src/views/Workout.swipe.test.jsx b/frontend/src/views/Workout.swipe.test.jsxindex 7a8409458..5c9a99555 100644--- a/frontend/src/views/Workout.swipe.test.jsx+++ b/frontend/src/views/Workout.swipe.test.jsx@@ -3,7 +3,7 @@ import React, { act } from 'react'import { createRoot } from 'react-dom/client'import { MemoryRouter } from 'react-router-dom'import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'-import Workout, { deleteActiveSet, undoDeleteSet, copyActiveSet, removeActiveExercise } from './Workout.jsx'+import Workout, { deleteActiveSet, undoDeleteSet, copyActiveSet, removeActiveExercise, _resetHintQuiet, HINT_QUIET_MS } from './Workout.jsx'import { DEF, useStore } from '../store/useStore.js'import { useUI } from '../store/useUI.js'import { closeOpenRow } from '../lib/use-swipe-row.js'@@ -60,6 +60,7 @@ function swipe(target, x0, x1, { dy = 0, pointerType = 'touch', clickAfter = tru}beforeEach(() => {+ _resetHintQuiet()vi.useFakeTimers()localStorage.clear()document.documentElement.dir = 'ltr'@@ -415,6 +416,21 @@ describe('the one-time hint', () => {} finally { widthSpy.mockRestore() }})+ // iOS UI test, CI 10-13: the nudge moved the first set while the test ticked it a second after+ // the workout opened, and the tap landed where the circle had been. A touch puts it off.+ it('waits for a quiet moment: not while the screen is being touched', () => {+ setActive([entry('1001', [row(80), row(80)])], { hints: {} })+ render()+ act(() => vi.advanceTimersByTime(300))+ document.body.dispatchEvent(new Event('pointerdown', { bubbles: true }))+ act(() => vi.advanceTimersByTime(700))+ expect(useUI.getState().swipeHint).toBeNull()+ act(() => vi.advanceTimersByTime(HINT_QUIET_MS - 700 - 50))+ expect(useUI.getState().swipeHint).toBeNull()+ act(() => vi.advanceTimersByTime(100))+ expect(useUI.getState().swipeHint).toMatchObject({ idx: 0, i: 0 })+ })+it('stays away with swiping off, or once seen', () => {setActive([entry('1001', [row(80)])], { hints: {}, wc: { swipeSets: false } })render()