Trening: dodanie cwiczenia tworzy automatycznie pierwsza serie; limit niezapisanego bonusu liczony na cwiczenie (wczesniej na sesje)
This commit is contained in:
@@ -424,6 +424,46 @@ describe('sessions routes', () => {
|
||||
expect(cleanup.status).toBe(200);
|
||||
});
|
||||
|
||||
it('allows one pending extra per exercise (równolegle w różnych ćwiczeniach, nie dwa w tym samym)', async () => {
|
||||
const app = buildApp();
|
||||
const session = await app.get(`/api/v1/days/${dayId}`).set('Authorization', `Bearer ${token}`);
|
||||
const sessionId = session.body.day.sessions[0].id;
|
||||
const detail = await app
|
||||
.get(`/api/v1/sessions/${sessionId}`)
|
||||
.set('Authorization', `Bearer ${token}`);
|
||||
const ex = detail.body.session.exercises[0];
|
||||
|
||||
const a = await app
|
||||
.post(`/api/v1/sessions/exercises/${ex.id}/sets`)
|
||||
.set('Authorization', `Bearer ${token}`);
|
||||
expect(a.status).toBe(201);
|
||||
|
||||
// inne ćwiczenie może mieć własną niezapisaną serię bonusową w tym samym czasie
|
||||
const added = await app
|
||||
.post(`/api/v1/sessions/${sessionId}/exercises`)
|
||||
.set('Authorization', `Bearer ${token}`)
|
||||
.send({ exerciseId });
|
||||
expect(added.status).toBe(201);
|
||||
const b = await app
|
||||
.post(`/api/v1/sessions/exercises/${added.body.exerciseId}/sets`)
|
||||
.set('Authorization', `Bearer ${token}`);
|
||||
expect(b.status).toBe(201);
|
||||
|
||||
// ale nie druga w tym samym ćwiczeniu
|
||||
const dup = await app
|
||||
.post(`/api/v1/sessions/exercises/${added.body.exerciseId}/sets`)
|
||||
.set('Authorization', `Bearer ${token}`);
|
||||
expect(dup.status).toBe(400);
|
||||
expect(dup.body.error.message).toBe('An extra set is already in progress');
|
||||
|
||||
for (const setId of [a.body.setId, b.body.setId]) {
|
||||
const del = await app
|
||||
.delete(`/api/v1/sessions/sets/${setId}`)
|
||||
.set('Authorization', `Bearer ${token}`);
|
||||
expect(del.status).toBe(200);
|
||||
}
|
||||
});
|
||||
|
||||
it('records actual set results', async () => {
|
||||
const app = buildApp();
|
||||
const session = await app.get(`/api/v1/days/${dayId}`).set('Authorization', `Bearer ${token}`);
|
||||
|
||||
@@ -503,10 +503,10 @@ describe('addSet', () => {
|
||||
removed: false,
|
||||
},
|
||||
});
|
||||
// limit bonusu pomija serie nalezace do usunietych cwiczen
|
||||
// limit bonusu jest liczony dla tego cwiczenia (nie dla sesji)
|
||||
expect(prisma.sessionSet.count).toHaveBeenNthCalledWith(2, {
|
||||
where: {
|
||||
exercise: { sessionId: 's1', removed: false },
|
||||
exerciseId: 'se1',
|
||||
planSetId: null,
|
||||
reps: null,
|
||||
removed: false,
|
||||
|
||||
Reference in New Issue
Block a user