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 RuleBody {
|
||||
id: string;
|
||||
@@ -22,6 +23,7 @@ describe('Follow-up controls (e2e)', () => {
|
||||
const suffix = `${Date.now()}-${Math.round(Math.random() * 1e6)}`;
|
||||
let token: string;
|
||||
let apiaryId: string;
|
||||
const colonyIds: string[] = [];
|
||||
|
||||
const server = () => app.getHttpServer();
|
||||
const auth = () => ({ Authorization: `Bearer ${token}` });
|
||||
@@ -39,17 +41,21 @@ describe('Follow-up controls (e2e)', () => {
|
||||
}
|
||||
|
||||
async function newColony(code: string) {
|
||||
return prisma.colony.create({
|
||||
const colony = await prisma.colony.create({
|
||||
data: {
|
||||
code: `${code}-${suffix}`,
|
||||
apiaryId,
|
||||
colonyType: 'PRODUCTION_COLONY',
|
||||
},
|
||||
});
|
||||
colonyIds.push(colony.id);
|
||||
return colony;
|
||||
}
|
||||
|
||||
function treat(colonyId: string, body: Record<string, unknown> = {}) {
|
||||
return request(server())
|
||||
// The follow-up check comes from the TreatmentRecorded handler, not from
|
||||
// the request: the helper drains the events of this treatment.
|
||||
async function treat(colonyId: string, body: Record<string, unknown> = {}) {
|
||||
const response = await request(server())
|
||||
.post('/api/v1/treatments')
|
||||
.set(auth())
|
||||
.send({
|
||||
@@ -59,6 +65,7 @@ describe('Follow-up controls (e2e)', () => {
|
||||
...body,
|
||||
})
|
||||
.expect(201);
|
||||
await drainDomainEvents(app, [(response.body as { id: string }).id]);
|
||||
}
|
||||
|
||||
beforeAll(async () => {
|
||||
@@ -88,6 +95,36 @@ describe('Follow-up controls (e2e)', () => {
|
||||
},
|
||||
data: { active: false, config: {} },
|
||||
});
|
||||
// Follow-up tasks are written without a user: remove their audit entry
|
||||
// and TaskCreated (deliveries go with the event, ON DELETE CASCADE).
|
||||
const followUpTaskIds = (
|
||||
await prisma.task.findMany({
|
||||
where: { relatedId: { in: colonyIds } },
|
||||
select: { id: true },
|
||||
})
|
||||
).map((task) => task.id);
|
||||
await prisma.auditLog.deleteMany({
|
||||
where: { entityType: 'Task', entityId: { in: followUpTaskIds } },
|
||||
});
|
||||
const measureIds = [
|
||||
...(await prisma.treatment.findMany({
|
||||
where: { colonyId: { in: colonyIds } },
|
||||
select: { id: true },
|
||||
})),
|
||||
...(await prisma.feeding.findMany({
|
||||
where: { colonyId: { in: colonyIds } },
|
||||
select: { id: true },
|
||||
})),
|
||||
].map((measure) => measure.id);
|
||||
await prisma.domainEvent.deleteMany({
|
||||
where: { aggregateId: { in: measureIds } },
|
||||
});
|
||||
await prisma.auditLog.deleteMany({
|
||||
where: { entityId: { in: measureIds } },
|
||||
});
|
||||
await prisma.domainEvent.deleteMany({
|
||||
where: { aggregateType: 'Task', aggregateId: { in: followUpTaskIds } },
|
||||
});
|
||||
await app.close();
|
||||
});
|
||||
|
||||
@@ -150,7 +187,7 @@ describe('Follow-up controls (e2e)', () => {
|
||||
.expect(200);
|
||||
|
||||
const colony = await newColony('FEED');
|
||||
await request(server())
|
||||
const response = await request(server())
|
||||
.post('/api/v1/feedings')
|
||||
.set(auth())
|
||||
.send({
|
||||
@@ -161,6 +198,11 @@ describe('Follow-up controls (e2e)', () => {
|
||||
unit: 'l',
|
||||
})
|
||||
.expect(201);
|
||||
// Not before the FeedingRecorded handler ran.
|
||||
expect(await prisma.task.count({ where: { relatedId: colony.id } })).toBe(
|
||||
0,
|
||||
);
|
||||
await drainDomainEvents(app, [(response.body as { id: string }).id]);
|
||||
|
||||
const task = await prisma.task.findFirstOrThrow({
|
||||
where: {
|
||||
|
||||
Reference in new issue
Block a user