Plans: wznawianie planu tylko dla wlasciciela (usuniete akcje trenera)

This commit is contained in:
tisachi
2026-10-22 23:53:49 +02:00
parent 50df81dbf0
commit 83ee38dc3a
13 changed files with 54 additions and 175 deletions

View File

@@ -167,6 +167,16 @@ describe('draft-only rules', () => {
});
});
it('reopenPlan: rejects reopening a plan owned by another user with 404', async () => {
const { prisma } = mockPrisma();
prisma.trainingPlan.findUnique.mockResolvedValue({ ...draftPlan, status: 'COMPLETED' });
await expect(reopenPlan(prisma, 'p1', 'trainer1')).rejects.toMatchObject({
status: 404,
message: 'Plan not found',
});
expect(prisma.trainingPlan.update).not.toHaveBeenCalled();
});
it('reopenPlan: rejects when the owner has another active plan with 409', async () => {
const { prisma } = mockPrisma();
prisma.trainingPlan.findUnique.mockResolvedValue({ ...draftPlan, status: 'COMPLETED' });