46 lines
1.8 KiB
TypeScript
46 lines
1.8 KiB
TypeScript
import { test, expect } from './fixtures';
|
|
import { request as playwrightRequest } from '@playwright/test';
|
|
import path from 'path';
|
|
import fs from 'fs';
|
|
|
|
test('Default Exercises Creation', async ({ createUniqueUser }) => {
|
|
// 1. Create a user
|
|
const user = await createUniqueUser();
|
|
|
|
// 2. Fetch exercises for the user
|
|
// Create authenticated context
|
|
const apiContext = await playwrightRequest.newContext({
|
|
baseURL: 'http://127.0.0.1:3001',
|
|
extraHTTPHeaders: {
|
|
'Authorization': `Bearer ${user.token}`
|
|
}
|
|
});
|
|
|
|
const exercisesRes = await apiContext.get('/api/exercises');
|
|
await expect(exercisesRes).toBeOK();
|
|
const responseJson = await exercisesRes.json();
|
|
console.log('DEBUG: Fetched exercises response:', JSON.stringify(responseJson, null, 2));
|
|
const exercises = responseJson.data;
|
|
|
|
// 3. Verify default exercises are present
|
|
// Checking a subset of influential exercises from the populated list
|
|
const expectedNames = ['Bench Press', 'Squat', 'Deadlift', 'Push-Ups', 'Pull-Ups', 'Running', 'Plank', 'Handstand', 'Sprint', 'Bulgarian Split-Squats'];
|
|
|
|
for (const name of expectedNames) {
|
|
const found = exercises.find((e: any) => e.name === name);
|
|
expect(found, `Exercise ${name} should exist`).toBeDefined();
|
|
}
|
|
|
|
// 4. Verify properties
|
|
const dumbbellCurl = exercises.find((e: any) => e.name === 'Dumbbell Curl');
|
|
expect(dumbbellCurl.isUnilateral).toBe(true);
|
|
expect(dumbbellCurl.type).toBe('STRENGTH');
|
|
|
|
const handstand = exercises.find((e: any) => e.name === 'Handstand');
|
|
expect(handstand.type).toBe('BODYWEIGHT');
|
|
expect(handstand.bodyWeightPercentage).toBe(1.0);
|
|
|
|
const pushUps = exercises.find((e: any) => e.name === 'Push-Ups');
|
|
expect(pushUps.bodyWeightPercentage).toBe(0.65);
|
|
});
|