All Tests Fixed with Initialize feature

This commit is contained in:
AG
2025-12-19 16:46:14 +02:00
parent 4e8feba5fe
commit af5c855c21
10 changed files with 285 additions and 76 deletions

View File

@@ -12,11 +12,18 @@ async function loginAndSetup(page: any, createUniqueUser: any) {
try {
const heading = page.getByRole('heading', { name: /Change Password/i });
const initAcc = page.getByRole('heading', { name: /Setup Your Account/i });
const dashboard = page.getByText('Free Workout');
await expect(heading.or(dashboard)).toBeVisible({ timeout: 5000 });
await expect(heading.or(initAcc).or(dashboard)).toBeVisible({ timeout: 5000 });
if (await heading.isVisible()) {
await page.getByLabel('New Password').fill('StrongNewPass123!');
await page.getByRole('button', { name: /Save|Change/i }).click();
await expect(initAcc.or(dashboard)).toBeVisible();
}
if (await initAcc.isVisible()) {
await page.getByRole('button', { name: /Get Started/i }).click();
await expect(dashboard).toBeVisible();
}
} catch (e) {
@@ -30,7 +37,7 @@ test.describe('III. Workout Tracking', () => {
test('3.1 B. Idle State - Start Free Workout', async ({ page, createUniqueUser }) => {
await loginAndSetup(page, createUniqueUser);
await expect(page.getByText('Start Empty Workout').or(page.getByText('Free Workout'))).toBeVisible();
await page.locator('div').filter({ hasText: 'My Weight' }).locator('input[type="number"]').fill('75.5');
await page.locator('div').filter({ hasText: 'Bodyweight (kg)' }).locator('input[type="number"]').fill('75.5');
await page.getByRole('button', { name: /Free Workout|Start Empty/i }).click();
await expect(page.getByRole('button', { name: 'Finish' })).toBeVisible();
@@ -60,17 +67,23 @@ test.describe('III. Workout Tracking', () => {
await page.getByRole('button', { name: 'Login' }).click();
const heading = page.getByRole('heading', { name: /Change Password/i });
const initAcc = page.getByRole('heading', { name: /Setup Your Account/i });
const dashboard = page.getByText('Start Empty Workout').or(page.getByText('Free Workout'));
await expect(heading.or(dashboard)).toBeVisible({ timeout: 10000 });
await expect(heading.or(initAcc).or(dashboard)).toBeVisible({ timeout: 10000 });
if (await heading.isVisible()) {
await page.getByLabel('New Password').fill('StrongNewPass123!');
await page.getByRole('button', { name: /Save|Change/i }).click();
await expect(initAcc.or(dashboard)).toBeVisible();
}
if (await initAcc.isVisible()) {
await page.getByRole('button', { name: /Get Started/i }).click();
await expect(dashboard).toBeVisible();
}
await expect(page.getByText('Start Empty Workout').or(page.getByText('Free Workout'))).toBeVisible();
const weightInput = page.locator('div').filter({ hasText: 'My Weight' }).locator('input[type="number"]');
const weightInput = page.locator('div').filter({ hasText: 'Bodyweight (kg)' }).locator('input[type="number"]');
await expect(weightInput).toBeVisible();
await expect(weightInput).toHaveValue('75.5');
});