Side attribute editable for Unilateral exercises
This commit is contained in:
@@ -392,38 +392,73 @@ test.describe('III. Workout Tracking', () => {
|
||||
await page.getByRole('textbox', { name: /Select Exercise/i }).click();
|
||||
await page.getByText(exName).click();
|
||||
|
||||
// Expect Left/Right selector
|
||||
await expect(page.getByText(/Left/i)).toBeVisible();
|
||||
// Expect L/R/A selector
|
||||
await expect(page.getByRole('button', { name: 'L', exact: true })).toBeVisible();
|
||||
await expect(page.getByRole('button', { name: 'R', exact: true })).toBeVisible();
|
||||
await expect(page.getByRole('button', { name: 'A', exact: true })).toBeVisible();
|
||||
|
||||
// Log Left
|
||||
await page.getByText('Left').first().click();
|
||||
await page.getByLabel('Weight (kg)').fill('20');
|
||||
await page.getByLabel('Reps').first().fill('10');
|
||||
await page.getByRole('button', { name: /Log Set/i }).click();
|
||||
// Helper to log a set
|
||||
const logSet = async (side: 'L' | 'R' | 'A') => {
|
||||
// Find the logger container (has 'Log Set' button)
|
||||
const logger = page.locator('div').filter({ has: page.getByRole('button', { name: /Log Set/i }) }).last();
|
||||
await expect(logger).toBeVisible();
|
||||
|
||||
// Verify Side and Metrics
|
||||
// Select side
|
||||
// Note: Side buttons are also inside the logger, but using global getByRole is okay if unique.
|
||||
// Let's scope side as well for safety
|
||||
await logger.getByRole('button', { name: side, exact: true }).click();
|
||||
|
||||
// Fill inputs scoped to logger
|
||||
const weightInput = logger.getByLabel('Weight (kg)');
|
||||
await weightInput.click();
|
||||
await weightInput.fill('20');
|
||||
|
||||
// Reps - handle potential multiples if strict, but scoped should be unique
|
||||
await logger.getByLabel('Reps').fill('10');
|
||||
|
||||
await logger.getByRole('button', { name: /Log Set/i }).click();
|
||||
};
|
||||
|
||||
// Log Left (L)
|
||||
await logSet('L');
|
||||
|
||||
// Verify Side and Metrics in list (Left)
|
||||
await expect(page.getByText('Left', { exact: true })).toBeVisible();
|
||||
await expect(page.getByText('20 kg x 10 reps')).toBeVisible();
|
||||
await expect(page.getByText(/20.*10/)).toBeVisible();
|
||||
|
||||
// Log Right
|
||||
await page.getByText('Right').first().click();
|
||||
await page.getByLabel('Weight (kg)').fill('20');
|
||||
await page.getByLabel('Reps').first().fill('10');
|
||||
await page.getByRole('button', { name: /Log Set/i }).click();
|
||||
// Log Right (R)
|
||||
await logSet('R');
|
||||
|
||||
// Verify Right set
|
||||
await expect(page.getByText('Right', { exact: true })).toBeVisible();
|
||||
// Use last() or filter to verify the new set's metrics if needed, but 'Right' presence confirms logging
|
||||
// We'll proceed to editing
|
||||
|
||||
// Log Alternately
|
||||
if (await page.getByText('Alternately').count() > 0) {
|
||||
await page.getByText('Alternately').first().click();
|
||||
} else {
|
||||
// Fallback for i18n or exact text match if needed
|
||||
await page.getByRole('button', { name: /Alternately|Alt/i }).click();
|
||||
}
|
||||
|
||||
await page.getByLabel('Weight (kg)').fill('20');
|
||||
await page.getByLabel('Reps').first().fill('10');
|
||||
await page.getByRole('button', { name: /Log Set/i }).click();
|
||||
await expect(page.getByText(/Alternately|Alt/i).last()).toBeVisible();
|
||||
// Edit the Right set to be Alternately
|
||||
// Use a stable locator for the row (first item in history list)
|
||||
// The class 'bg-surface-container' and 'shadow-elevation-1' identifies the row card.
|
||||
// We use .first() because the list is reversed (newest first).
|
||||
const rightSetRow = page.locator('.bg-surface-container.rounded-xl.shadow-elevation-1').first();
|
||||
|
||||
await rightSetRow.getByRole('button', { name: 'Edit' }).click();
|
||||
|
||||
// Verify we are in edit mode by finding the Save button
|
||||
const saveButton = rightSetRow.getByRole('button', { name: /Save/i });
|
||||
await expect(saveButton).toBeVisible();
|
||||
|
||||
// Change side to Alternately (A)
|
||||
// Find 'A' button within the same row container which is now in edit mode
|
||||
const aButton = rightSetRow.getByRole('button', { name: 'A', exact: true });
|
||||
await expect(aButton).toBeVisible();
|
||||
await aButton.click();
|
||||
|
||||
// Save
|
||||
await saveButton.click();
|
||||
|
||||
// Verify update
|
||||
// Use regex for Alternately to handle case/whitespace
|
||||
await expect(page.getByText(/Alternately/i)).toBeVisible();
|
||||
});
|
||||
|
||||
test('3.15 C. Active Session - Log Special Type Set', async ({ page, createUniqueUser, request }) => {
|
||||
|
||||
Reference in New Issue
Block a user