@@ -146,6 +146,101 @@ test.describe("Active session view", () => {
146146 await page . click ( "button:has-text('Cancel Session')" ) ;
147147 await expect ( page . locator ( ".app-title" ) ) . toHaveText ( "💪 LogOut" ) ;
148148 } ) ;
149+
150+ test ( "complete workout flow: search exercise, add reps, complete" , async ( {
151+ page,
152+ } ) => {
153+ // Start a new session
154+ await page . goto ( `${ BASE } /` ) ;
155+ await page . click ( ".new-session-button" ) ;
156+ await expect ( page . locator ( ".session-header__title" ) ) . toContainText (
157+ "Active Session"
158+ ) ;
159+
160+ // Search for pullups
161+ const searchInput = page . locator ( 'input[placeholder="Search for an exercise..."]' ) ;
162+ await searchInput . fill ( "pullups" ) ;
163+
164+ // Wait for search results to appear
165+ await expect ( page . locator ( ".search-results" ) ) . toBeVisible ( ) ;
166+
167+ // Click the first result
168+ const firstResult = page . locator ( ".search-result-item" ) . first ( ) ;
169+ await expect ( firstResult ) . toBeVisible ( ) ;
170+ await firstResult . click ( ) ;
171+
172+ // Verify exercise form is shown
173+ await expect ( page . locator ( ".exercise-form" ) ) . toBeVisible ( ) ;
174+
175+ // Fill in reps (and optionally weight)
176+ const repsInput = page . locator ( 'input[placeholder="Reps"]' ) ;
177+ if ( await repsInput . isVisible ( ) ) {
178+ await repsInput . fill ( "10" ) ;
179+ }
180+
181+ // Complete the exercise
182+ await page . click ( "button:has-text('Complete Exercise')" ) ;
183+
184+ // Verify the exercise appears in completed exercises
185+ await expect ( page . locator ( ".completed-exercises-section" ) ) . toBeVisible ( ) ;
186+
187+ // Finish the session
188+ await page . click ( "button:has-text('Finish Session')" ) ;
189+
190+ // Verify we're back at home and session is saved
191+ await expect ( page . locator ( ".app-title" ) ) . toHaveText ( "💪 LogOut" ) ;
192+ } ) ;
193+ } ) ;
194+
195+ test . describe ( "Exercise editing" , ( ) => {
196+ test ( "edit exercise instructions and verify changes persist" , async ( {
197+ page,
198+ } ) => {
199+ // Go to exercises list
200+ await page . goto ( `${ BASE } /exercises` ) ;
201+ await expect ( page . locator ( "h1" ) ) . toHaveText ( "Exercise Database" ) ;
202+
203+ // Search for pushups
204+ const searchInput = page . locator ( ".search-input" ) ;
205+ await searchInput . fill ( "pushups" ) ;
206+
207+ // Wait for search results
208+ await page . waitForTimeout ( 500 ) ; // Give search time to filter
209+
210+ // Click on the first exercise card to open details
211+ const firstExercise = page . locator ( ".exercise-card" ) . first ( ) ;
212+ await expect ( firstExercise ) . toBeVisible ( ) ;
213+
214+ // Get the exercise name for verification later
215+ const exerciseName = await firstExercise . locator ( ".exercise-card__name, h3" ) . first ( ) . textContent ( ) ;
216+
217+ // Click on the exercise name to view details
218+ await firstExercise . locator ( ".exercise-card__name, h3" ) . first ( ) . click ( ) ;
219+
220+ // Look for edit button or instructions field
221+ // Note: This part depends on the actual UI structure which may need adjustment
222+ // If there's an edit button, click it
223+ const editButton = page . locator ( "button:has-text('Edit')" ) ;
224+ if ( await editButton . isVisible ( { timeout : 2000 } ) . catch ( ( ) => false ) ) {
225+ await editButton . click ( ) ;
226+
227+ // Find instructions textarea/input and modify it
228+ const instructionsField = page . locator ( 'textarea, input[type="text"]' ) . filter ( { hasText : / i n s t r u c t i o n / i } ) . first ( ) ;
229+ if ( await instructionsField . isVisible ( { timeout : 2000 } ) . catch ( ( ) => false ) ) {
230+ await instructionsField . fill ( "Custom test instructions" ) ;
231+
232+ // Save changes
233+ await page . click ( "button:has-text('Save')" ) ;
234+
235+ // Navigate back and verify
236+ await page . goBack ( ) ;
237+ await firstExercise . locator ( ".exercise-card__name, h3" ) . first ( ) . click ( ) ;
238+
239+ // Verify instructions were saved
240+ await expect ( page . locator ( "text=Custom test instructions" ) ) . toBeVisible ( ) ;
241+ }
242+ }
243+ } ) ;
149244} ) ;
150245
151246test . describe ( "PWA assets" , ( ) => {
0 commit comments