Workout Management tests ready
This commit is contained in:
@@ -94,7 +94,7 @@ test.describe('II. Workout Management', () => {
|
||||
await expect(page.getByText('Plan To Delete')).not.toBeVisible();
|
||||
});
|
||||
|
||||
test.skip('2.4 A. Workout Plans - Reorder Exercises', async ({ page, createUniqueUser, request }) => {
|
||||
test('2.4 A. Workout Plans - Reorder Exercises', async ({ page, createUniqueUser, request }) => {
|
||||
page.on('console', msg => console.log('PAGE LOG:', msg.text()));
|
||||
const user = await loginAndSetup(page, createUniqueUser);
|
||||
// Need exercises
|
||||
@@ -133,9 +133,43 @@ test.describe('II. Workout Management', () => {
|
||||
.last();
|
||||
await card.getByRole('button', { name: 'Edit Plan' }).click();
|
||||
|
||||
// Check initial order by visibility for now
|
||||
await expect(page.locator('div').filter({ hasText: 'Ex One' }).first()).toBeVisible();
|
||||
await expect(page.locator('div').filter({ hasText: 'Ex Two' }).last()).toBeVisible();
|
||||
const card1 = page.locator('[draggable="true"]').filter({ hasText: 'Ex One' });
|
||||
const card2 = page.locator('[draggable="true"]').filter({ hasText: 'Ex Two' });
|
||||
|
||||
// Initial state check
|
||||
await expect(page.locator('[draggable="true"]').first()).toContainText('Ex One');
|
||||
|
||||
// Drag using handles with explicit wait
|
||||
const sourceHandle = card1.locator('.lucide-grip-vertical');
|
||||
const targetHandle = card2.locator('.lucide-grip-vertical');
|
||||
|
||||
await expect(sourceHandle).toBeVisible();
|
||||
await expect(targetHandle).toBeVisible();
|
||||
|
||||
console.log('Starting Drag...');
|
||||
await sourceHandle.dragTo(targetHandle);
|
||||
console.log('Drag complete');
|
||||
|
||||
// Wait for reorder to settle
|
||||
await page.waitForTimeout(1000);
|
||||
|
||||
// Verify Swap immediately
|
||||
await expect(page.locator('[draggable="true"]').first()).toContainText('Ex Two');
|
||||
|
||||
await page.getByRole('button', { name: 'Save' }).click();
|
||||
|
||||
// Reload and verify persistence
|
||||
await page.reload();
|
||||
await page.getByRole('button', { name: 'Plans' }).first().click();
|
||||
|
||||
const cardRevisit = page.locator('div')
|
||||
.filter({ hasText: 'Reorder Plan' })
|
||||
.filter({ has: page.getByRole('button', { name: 'Edit Plan' }) })
|
||||
.last();
|
||||
await cardRevisit.getByRole('button', { name: 'Edit Plan' }).click();
|
||||
|
||||
await expect(page.locator('[draggable="true"]').first()).toContainText('Ex Two');
|
||||
await expect(page.locator('[draggable="true"]').last()).toContainText('Ex One');
|
||||
});
|
||||
|
||||
test('2.5 A. Workout Plans - Start Session from Plan', async ({ page, createUniqueUser, request }) => {
|
||||
@@ -149,6 +183,7 @@ test.describe('II. Workout Management', () => {
|
||||
},
|
||||
headers: { 'Authorization': `Bearer ${user.token}` }
|
||||
});
|
||||
console.log(await resp.json());
|
||||
expect(resp.ok()).toBeTruthy();
|
||||
|
||||
await page.reload();
|
||||
@@ -171,19 +206,22 @@ test.describe('II. Workout Management', () => {
|
||||
await loginAndSetup(page, createUniqueUser);
|
||||
|
||||
await page.getByRole('button', { name: 'Profile' }).click();
|
||||
await page.getByRole('button', { name: /Manage Exercises/i }).click();
|
||||
await page.locator('button:has-text("Manage Exercises")').click();
|
||||
|
||||
await page.getByRole('button', { name: /New Exercise/i }).click();
|
||||
// Use force click as button might be obstructed or animating
|
||||
await page.getByRole('button', { name: /New Exercise/i }).click({ force: true });
|
||||
|
||||
await page.getByLabel('Name').fill('Custom Bicep Curl');
|
||||
await expect(page.getByText('Free Weights & Machines', { exact: false })).toBeVisible();
|
||||
await expect(page.locator('div[role="dialog"]')).toBeVisible();
|
||||
await page.locator('div[role="dialog"]').getByLabel('Name').fill('Custom Bicep Curl');
|
||||
await expect(page.locator('div[role="dialog"]').getByText('Free Weights & Machines', { exact: false })).toBeVisible();
|
||||
|
||||
await page.getByRole('button', { name: 'Create' }).click();
|
||||
await page.locator('div[role="dialog"]').getByRole('button', { name: 'Create' }).click();
|
||||
await page.waitForTimeout(1000);
|
||||
|
||||
// Reload and filter
|
||||
await page.reload();
|
||||
await page.getByRole('button', { name: 'Profile' }).click();
|
||||
await page.getByRole('button', { name: /Manage Exercises/i }).click();
|
||||
await page.locator('button:has-text("Manage Exercises")').click();
|
||||
|
||||
await page.getByLabel(/Filter by name/i).fill('Custom Bicep Curl');
|
||||
await expect(page.getByText('Custom Bicep Curl')).toBeVisible();
|
||||
@@ -195,15 +233,18 @@ test.describe('II. Workout Management', () => {
|
||||
await page.getByRole('button', { name: 'Profile' }).click();
|
||||
await page.getByRole('button', { name: /Manage Exercises/i }).click();
|
||||
|
||||
await page.getByRole('button', { name: /New Exercise/i }).click();
|
||||
await page.getByRole('button', { name: /New Exercise/i }).click({ force: true });
|
||||
|
||||
await page.getByLabel('Name').fill('Adv Pushup');
|
||||
// Scope to dialog to avoid background matches
|
||||
await page.locator('div[role="dialog"] button').filter({ hasText: /Bodyweight/i }).click();
|
||||
await expect(page.locator('div[role="dialog"]')).toBeVisible();
|
||||
await page.locator('div[role="dialog"]').getByLabel('Name').fill('Adv Pushup');
|
||||
|
||||
// Scope to dialog and use force click for type selection
|
||||
await page.locator('div[role="dialog"]').getByRole('button', { name: /Bodyweight/i }).click({ force: true });
|
||||
|
||||
await expect(page.getByLabel('Body Weight')).toBeVisible();
|
||||
await page.getByLabel('Body Weight').fill('50');
|
||||
await page.getByRole('button', { name: 'Create' }).click();
|
||||
await page.locator('div[role="dialog"]').getByRole('button', { name: 'Create' }).click();
|
||||
await page.waitForTimeout(1000);
|
||||
|
||||
// Reload and filter
|
||||
await page.reload();
|
||||
@@ -215,47 +256,95 @@ test.describe('II. Workout Management', () => {
|
||||
await expect(page.getByText('Bodyweight', { exact: false }).first()).toBeVisible();
|
||||
});
|
||||
|
||||
test('2.8 B. Exercise Library - Edit Exercise Name', async ({ page, createUniqueUser, request }) => {
|
||||
const user = await loginAndSetup(page, createUniqueUser);
|
||||
await request.post('/api/exercises', {
|
||||
data: { name: 'Typo Name', type: 'STRENGTH' },
|
||||
headers: { 'Authorization': `Bearer ${user.token}` }
|
||||
});
|
||||
await page.reload();
|
||||
test('2.8 B. Exercise Library - Edit Exercise Name', async ({ page, createUniqueUser }) => {
|
||||
// Updated to use UI creation for robustness
|
||||
await loginAndSetup(page, createUniqueUser);
|
||||
|
||||
await page.getByRole('button', { name: 'Profile' }).click();
|
||||
await page.getByRole('button', { name: /Manage Exercises/i }).click();
|
||||
await page.locator('button:has-text("Manage Exercises")').click();
|
||||
|
||||
const row = page.locator('div').filter({ hasText: 'Typo Name' }).last();
|
||||
await row.locator('button').filter({ has: page.locator('svg.lucide-pencil') }).click();
|
||||
// Use force click as button might be obstructed or animating
|
||||
await page.getByRole('button', { name: /New Exercise/i }).click({ force: true });
|
||||
|
||||
await expect(page.locator('div[role="dialog"]')).toBeVisible();
|
||||
await page.locator('div[role="dialog"]').getByLabel('Name').fill('Typo Name');
|
||||
await expect(page.locator('div[role="dialog"]').getByText('Free Weights & Machines', { exact: false })).toBeVisible();
|
||||
|
||||
await page.locator('div[role="dialog"]').getByRole('button', { name: 'Create' }).click();
|
||||
await page.waitForTimeout(1000);
|
||||
|
||||
// Reload and filter
|
||||
await page.reload();
|
||||
await page.getByRole('button', { name: 'Profile' }).click();
|
||||
await page.locator('button:has-text("Manage Exercises")').click();
|
||||
|
||||
await page.getByLabel(/Filter by name/i).fill('Typo Name');
|
||||
await expect(page.getByText('Typo Name')).toBeVisible();
|
||||
|
||||
// Filter specifically for the container that has both text and button
|
||||
const row = page.locator('div')
|
||||
.filter({ hasText: 'Typo Name' })
|
||||
.filter({ has: page.getByLabel('Edit Exercise') })
|
||||
.last();
|
||||
|
||||
await expect(row).toBeVisible();
|
||||
await row.getByLabel('Edit Exercise').click();
|
||||
|
||||
await page.locator('div[role="dialog"] input').first().fill('Fixed Name');
|
||||
await page.getByRole('button', { name: 'Save' }).click();
|
||||
await page.locator('div[role="dialog"]').getByRole('button', { name: 'Save', exact: true }).click();
|
||||
|
||||
// Clear filter to see the renamed exercise
|
||||
await page.getByLabel(/Filter by name/i).fill('');
|
||||
await expect(page.getByText('Fixed Name')).toBeVisible();
|
||||
await expect(page.getByText('Typo Name')).not.toBeVisible();
|
||||
});
|
||||
|
||||
test('2.9 B. Exercise Library - Archive/Unarchive', async ({ page, createUniqueUser, request }) => {
|
||||
const user = await loginAndSetup(page, createUniqueUser);
|
||||
await request.post('/api/exercises', {
|
||||
data: { name: 'Archive Me', type: 'STRENGTH' },
|
||||
headers: { 'Authorization': `Bearer ${user.token}` }
|
||||
});
|
||||
await page.reload();
|
||||
test('2.9 B. Exercise Library - Archive/Unarchive', async ({ page, createUniqueUser }) => {
|
||||
// Updated to use UI creation for robustness
|
||||
await loginAndSetup(page, createUniqueUser);
|
||||
|
||||
await page.getByRole('button', { name: 'Profile' }).click();
|
||||
await page.getByRole('button', { name: /Manage Exercises/i }).click();
|
||||
await page.locator('button:has-text("Manage Exercises")').click();
|
||||
|
||||
const row = page.locator('div').filter({ hasText: 'Archive Me' }).last();
|
||||
// Use force click as button might be obstructed or animating
|
||||
await page.getByRole('button', { name: /New Exercise/i }).click({ force: true });
|
||||
|
||||
await expect(page.locator('div[role="dialog"]')).toBeVisible();
|
||||
await page.locator('div[role="dialog"]').getByLabel('Name').fill('Archive Me');
|
||||
await expect(page.locator('div[role="dialog"]').getByText('Free Weights & Machines', { exact: false })).toBeVisible();
|
||||
|
||||
await page.locator('div[role="dialog"]').getByRole('button', { name: 'Create' }).click();
|
||||
await page.waitForTimeout(1000);
|
||||
|
||||
// Reload and filter
|
||||
await page.reload();
|
||||
await page.getByRole('button', { name: 'Profile' }).click();
|
||||
await page.locator('button:has-text("Manage Exercises")').click();
|
||||
|
||||
await page.getByLabel(/Filter by name/i).fill('Archive Me');
|
||||
await expect(page.getByText('Archive Me')).toBeVisible();
|
||||
|
||||
const row = page.locator('div.flex.justify-between').filter({ hasText: 'Archive Me' }).last();
|
||||
// Archive button (box-archive or similar)
|
||||
await row.locator('button').filter({ has: page.locator('svg.lucide-archive') }).click();
|
||||
await row.locator('[aria-label="Archive Exercise"]').click();
|
||||
|
||||
// It should disappear or fade. "Show Archived" is false by default.
|
||||
await expect(page.getByText('Archive Me')).not.toBeVisible();
|
||||
|
||||
// Toggle Show Archived
|
||||
await page.getByLabel('Show Archived').check();
|
||||
// Label might not be linked, so we filter by text and find the adjacent checkbox
|
||||
await page.locator('div').filter({ hasText: /Show Archived/i }).last().locator('input[type="checkbox"]').check();
|
||||
await expect(page.getByText('Archive Me')).toBeVisible();
|
||||
|
||||
// Unarchive
|
||||
const archivedRow = page.locator('div')
|
||||
.filter({ hasText: 'Archive Me' })
|
||||
.filter({ has: page.getByLabel('Unarchive Exercise') })
|
||||
.last();
|
||||
await archivedRow.getByLabel('Unarchive Exercise').click();
|
||||
|
||||
// Verify it persists after unchecking "Show Archived"
|
||||
await page.locator('div').filter({ hasText: /Show Archived/i }).last().locator('input[type="checkbox"]').uncheck();
|
||||
await expect(page.getByText('Archive Me')).toBeVisible();
|
||||
});
|
||||
|
||||
@@ -280,8 +369,23 @@ test.describe('II. Workout Management', () => {
|
||||
await expect(page.getByText('IgnoreThatOne')).not.toBeVisible();
|
||||
});
|
||||
|
||||
test.skip('2.11 B. Exercise Library - Capitalization (Mobile)', async ({ page }) => {
|
||||
// ...
|
||||
test('2.11 B. Exercise Library - Capitalization (Mobile)', async ({ page, createUniqueUser }) => {
|
||||
// Simulate Mobile Viewport
|
||||
await page.setViewportSize({ width: 390, height: 844 }); // iPhone 12 Pro
|
||||
await loginAndSetup(page, createUniqueUser);
|
||||
|
||||
await page.getByRole('button', { name: 'Profile' }).click();
|
||||
await page.locator('button:has-text("Manage Exercises")').click();
|
||||
|
||||
// Use force as FAB might be different on mobile, but text is same
|
||||
await page.getByRole('button', { name: /New Exercise/i }).click({ force: true });
|
||||
|
||||
await expect(page.locator('div[role="dialog"]')).toBeVisible();
|
||||
|
||||
// Verify autocapitalize attribute is set to 'words' or 'sentences'
|
||||
// In ExerciseModal.tsx it is set to 'words'
|
||||
const nameInput = page.locator('div[role="dialog"]').getByLabel('Name');
|
||||
await expect(nameInput).toHaveAttribute('autocapitalize', 'words');
|
||||
});
|
||||
|
||||
test('2.12 B. Exercise Library - Unilateral', async ({ page, createUniqueUser }) => {
|
||||
@@ -289,12 +393,15 @@ test.describe('II. Workout Management', () => {
|
||||
await page.getByRole('button', { name: 'Profile' }).click();
|
||||
await page.getByRole('button', { name: /Manage Exercises/i }).click();
|
||||
|
||||
await page.getByRole('button', { name: /New Exercise/i }).click();
|
||||
await page.getByLabel('Name').fill('Single Leg Squat');
|
||||
await page.getByRole('button', { name: /New Exercise/i }).click({ force: true });
|
||||
|
||||
await page.locator('input[type="checkbox"]').first().check();
|
||||
await expect(page.locator('div[role="dialog"]')).toBeVisible();
|
||||
await page.locator('div[role="dialog"]').getByLabel('Name').fill('Single Leg Squat');
|
||||
|
||||
await page.getByRole('button', { name: 'Create' }).click();
|
||||
await page.getByLabel(/Unilateral exercise/).check();
|
||||
|
||||
await page.locator('div[role="dialog"]').getByRole('button', { name: 'Create' }).click();
|
||||
await page.waitForTimeout(1000);
|
||||
|
||||
// Reload and filter
|
||||
await page.reload();
|
||||
@@ -311,12 +418,15 @@ test.describe('II. Workout Management', () => {
|
||||
await page.getByRole('button', { name: 'Profile' }).click();
|
||||
await page.getByRole('button', { name: /Manage Exercises/i }).click();
|
||||
|
||||
await page.getByRole('button', { name: /New Exercise/i }).click();
|
||||
await page.getByLabel('Name').fill('Plank Test');
|
||||
await page.getByRole('button', { name: /New Exercise/i }).click({ force: true });
|
||||
|
||||
await page.locator('button').filter({ hasText: /Static/i }).click();
|
||||
await expect(page.locator('div[role="dialog"]')).toBeVisible();
|
||||
await page.locator('div[role="dialog"]').getByLabel('Name').fill('Plank Test');
|
||||
|
||||
await page.getByRole('button', { name: 'Create' }).click();
|
||||
await page.locator('div[role="dialog"]').getByRole('button', { name: /Static/i }).click({ force: true });
|
||||
|
||||
await page.locator('div[role="dialog"]').getByRole('button', { name: 'Create' }).click();
|
||||
await page.waitForTimeout(1000);
|
||||
|
||||
// Reload and filter
|
||||
await page.reload();
|
||||
@@ -349,4 +459,4 @@ async function loginAndSetup(page: any, createUniqueUser: any) {
|
||||
// Login might already be done or dashboard loaded fast
|
||||
}
|
||||
return user;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user