Tighten rejection tests to their expected errors

Every assert.throws now names the error it expects, so a broken fixture
or an unrelated failure can no longer satisfy a rejection test. Zod
rejections are matched by issue path and code via tests/support/zod-assertions.ts.

Restore snapshot coverage lost with the release baseline: invalid board
floor, room floor and circuit section references and a reserve state
that contradicts the device rows are rejected again under test.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Julian Appel 2026-10-29 12:27:46 +01:00
parent cc4eefcb86
commit a8cc7eca5e
8 changed files with 269 additions and 122 deletions

View file

@ -410,25 +410,39 @@ describe("circuit device-row structure project-command repository", () => {
try {
const store =
new CircuitDeviceRowStructureProjectCommandRepository(context.db);
for (const snapshot of [
createInsertSnapshot({ circuitId: "circuit-foreign" }),
createInsertSnapshot({
id: "row-foreign-device",
linkedProjectDeviceId: "device-foreign",
}),
createInsertSnapshot({
id: "row-foreign-room",
roomId: "room-foreign",
}),
createInsertSnapshot({ id: "row-1" }),
]) {
assert.throws(() =>
store.execute({
projectId: "project-1",
expectedRevision: 0,
source: "user",
command: createCircuitDeviceRowInsertProjectCommand(snapshot),
})
for (const [snapshot, expectedError] of [
[
createInsertSnapshot({ circuitId: "circuit-foreign" }),
/Circuit does not belong to project/,
],
[
createInsertSnapshot({
id: "row-foreign-device",
linkedProjectDeviceId: "device-foreign",
}),
/Invalid linked project device id/,
],
[
createInsertSnapshot({
id: "row-foreign-room",
roomId: "room-foreign",
}),
/Invalid room id/,
],
[
createInsertSnapshot({ id: "row-1" }),
/Circuit device-row id already exists/,
],
] as const) {
assert.throws(
() =>
store.execute({
projectId: "project-1",
expectedRevision: 0,
source: "user",
command: createCircuitDeviceRowInsertProjectCommand(snapshot),
}),
expectedError
);
}
assert.equal(context.db.select().from(projectRevisions).all().length, 0);