fix(backend): Status-Guard fuer Move/Split/Merge auf inaktiven Voelkern
Beim Live-Test im Browser gefunden: move/split/merge liessen sich auch auf einem bereits DISSOLVED/MERGED-Volk aufrufen und wuerden dort klaglos durchlaufen - ein Datenintegritaetsproblem, kein reines UI-Detail. assertActive() wirft jetzt ConflictException (409), wenn das betroffene Volk (bzw. bei merge: Ziel- und alle zu vereinigenden Voelker) nicht ACTIVE ist. Neuer Unit-Test + neuer e2e-Test (dissolve, danach move -> 409).
This commit is contained in:
1 parent
d3f321f1b5
commit
a71b31df38
3 files changed
+34
-2
No files matched your search
@@ -1,4 +1,4 @@
|
||||
import { NotFoundException } from '@nestjs/common';
|
||||
import { ConflictException, NotFoundException } from '@nestjs/common';
|
||||
import { ColoniesService } from './colonies.service';
|
||||
import { PrismaService } from '../prisma/prisma.service';
|
||||
import { AuditLogService } from '../audit/audit-log.service';
|
||||
@@ -143,6 +143,16 @@ describe('ColoniesService', () => {
|
||||
expect(lineageArg.data.toColonyId).toBe('colony-1');
|
||||
});
|
||||
|
||||
it('move rejects a non-active colony', async () => {
|
||||
prisma.colony.findUnique.mockResolvedValue({
|
||||
...parentColony,
|
||||
status: 'DISSOLVED',
|
||||
});
|
||||
await expect(
|
||||
service.move('colony-1', { apiaryId: 'apiary-2' }, 'user-1'),
|
||||
).rejects.toBeInstanceOf(ConflictException);
|
||||
});
|
||||
|
||||
it('dissolve sets status DISSOLVED and records DEACTIVATE', async () => {
|
||||
prisma.colony.findUnique.mockResolvedValue(parentColony);
|
||||
prisma.colony.update.mockResolvedValue({
|
||||
|
||||
Reference in new issue
Block a user