feat: platform backbone and field capture complete (checkpoint)
Platform backbone (plan 2026-10-13-plattform-rueckgrat), all tasks reviewed: - webhooks with delivery table, retries and stable delivery id - calendar handlers; a finished task removes its Outlook event - tasks, automations, inspections, varroa, treatments, feedings, harvests, colonies, wintering, stock and bottling record domain events in the same transaction; legacy post-commit calls removed - row locks through one helper (lockRowForUpdate, lockRowsForShare, lockRowsForUpdate) - job framework with JobRun, cli exit codes, cleanup, task templates, daily evaluation, hourly app-backup and the rekey job - system API and page "Verwaltung > System" with retry - @nestjs/schedule removed, guard tests against in-process schedulers Field capture T3 (plan 2026-10-13-t3-erfassung-am-stand), all tasks reviewed: - inspection photo offline without metadata - bulk capture for treatments, feedings and varroa (backend + frontend) - offline stand mode with service worker, offline pages and packs - offline session, cold start and logout on shared devices Docs: ARCHITECTURE.md assumptions and sections updated, TASKS.md. Gates: backend lint, typecheck, 1770 unit, 420 e2e, build, no schema drift; frontend lint, typecheck, 913 tests, build. Not rolled out. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
This commit is contained in:
1 parent
c01a38835a
commit
cdd30cf3ee
288 files changed
+39165
-2853
No files matched your search
@@ -5,6 +5,7 @@ import { App } from 'supertest/types';
|
||||
import { PrismaService } from '../src/prisma/prisma.service';
|
||||
import { createTestApp } from './utils/create-test-app';
|
||||
import { login } from './utils/api';
|
||||
import { drainDomainEvents } from './utils/domain-events';
|
||||
|
||||
interface InspectionBody {
|
||||
id: string;
|
||||
@@ -74,8 +75,27 @@ describe('Inspections (e2e)', () => {
|
||||
|
||||
afterAll(async () => {
|
||||
if (taskId) {
|
||||
await prisma.domainEvent.deleteMany({
|
||||
where: { aggregateType: 'Task', aggregateId: taskId },
|
||||
});
|
||||
await prisma.task.delete({ where: { id: taskId } });
|
||||
}
|
||||
const inspectionIds = (
|
||||
await prisma.inspection.findMany({
|
||||
where: { colonyId },
|
||||
select: { id: true },
|
||||
})
|
||||
).map((inspection) => inspection.id);
|
||||
// Deliveries go with their event (ON DELETE CASCADE).
|
||||
await prisma.domainEvent.deleteMany({
|
||||
where: {
|
||||
aggregateType: 'Inspection',
|
||||
aggregateId: { in: inspectionIds },
|
||||
},
|
||||
});
|
||||
await prisma.calendarSyncOutboxEntry.deleteMany({
|
||||
where: { sourceType: 'INSPECTION', sourceId: { in: inspectionIds } },
|
||||
});
|
||||
await prisma.inspection.deleteMany({ where: { colonyId } });
|
||||
await prisma.colony.deleteMany({ where: { id: colonyId } });
|
||||
await prisma.apiary.deleteMany({ where: { id: apiaryId } });
|
||||
@@ -122,6 +142,61 @@ describe('Inspections (e2e)', () => {
|
||||
},
|
||||
});
|
||||
expect(auditEntry).not.toBeNull();
|
||||
|
||||
// Committed with the inspection; rules, calendar and webhook follow
|
||||
// from it once the handlers run - nothing of that in the request.
|
||||
const events = await prisma.domainEvent.findMany({
|
||||
where: { aggregateType: 'Inspection', aggregateId: inspectionId },
|
||||
});
|
||||
expect(events).toEqual([
|
||||
expect.objectContaining({
|
||||
type: 'InspectionRecorded',
|
||||
actorUserId: staffId,
|
||||
payload: { colonyId },
|
||||
status: 'PENDING',
|
||||
}),
|
||||
]);
|
||||
});
|
||||
|
||||
it('records InspectionCorrected for an edit, whose only follow-up is the calendar', async () => {
|
||||
await drainDomainEvents(app, [inspectionId]);
|
||||
|
||||
await request(app.getHttpServer())
|
||||
.patch(`/api/v1/inspections/${inspectionId}`)
|
||||
.set('Authorization', `Bearer ${staffToken}`)
|
||||
.send({ notes: 'Nachtrag: Weiselzelle gesehen' })
|
||||
.expect(200);
|
||||
|
||||
await expect(
|
||||
prisma.auditLog.count({
|
||||
where: {
|
||||
entityType: 'Inspection',
|
||||
entityId: inspectionId,
|
||||
action: 'UPDATE',
|
||||
userId: staffId,
|
||||
},
|
||||
}),
|
||||
).resolves.toBe(1);
|
||||
const correction = await prisma.domainEvent.findFirstOrThrow({
|
||||
where: { aggregateId: inspectionId, type: 'InspectionCorrected' },
|
||||
});
|
||||
expect(correction).toMatchObject({
|
||||
aggregateType: 'Inspection',
|
||||
actorUserId: staffId,
|
||||
payload: { colonyId },
|
||||
});
|
||||
|
||||
await drainDomainEvents(app, [inspectionId]);
|
||||
// A correction evaluates no automation rule and sends no webhook.
|
||||
const deliveries = await prisma.domainEventDelivery.findMany({
|
||||
where: { eventId: correction.id },
|
||||
});
|
||||
expect(deliveries).toEqual([
|
||||
expect.objectContaining({
|
||||
handler: 'calendar-sync.inspection',
|
||||
status: 'DONE',
|
||||
}),
|
||||
]);
|
||||
});
|
||||
|
||||
it('lists inspections for the colony', async () => {
|
||||
@@ -142,6 +217,28 @@ describe('Inspections (e2e)', () => {
|
||||
const task = response.body as TaskBody;
|
||||
taskId = task.id;
|
||||
expect(task.sourceInspectionId).toBe(inspectionId);
|
||||
|
||||
// The same trail as a task from the task page.
|
||||
await expect(
|
||||
prisma.auditLog.count({
|
||||
where: {
|
||||
entityType: 'Task',
|
||||
entityId: taskId,
|
||||
action: 'CREATE',
|
||||
userId: staffId,
|
||||
},
|
||||
}),
|
||||
).resolves.toBe(1);
|
||||
const events = await prisma.domainEvent.findMany({
|
||||
where: { aggregateType: 'Task', aggregateId: taskId },
|
||||
});
|
||||
expect(events).toEqual([
|
||||
expect.objectContaining({
|
||||
type: 'TaskCreated',
|
||||
actorUserId: staffId,
|
||||
payload: { relatedType: 'COLONY', relatedId: colonyId, dueDate: null },
|
||||
}),
|
||||
]);
|
||||
});
|
||||
|
||||
it('stores, clears and validates broodFrames', async () => {
|
||||
|
||||
Reference in new issue
Block a user