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:
parent
cc4eefcb86
commit
a8cc7eca5e
8 changed files with 269 additions and 122 deletions
|
|
@ -568,51 +568,71 @@ describe("circuit structure project-command repository", () => {
|
|||
const store = new CircuitStructureProjectCommandRepository(
|
||||
fixture.context.db
|
||||
);
|
||||
const invalidSnapshots = [
|
||||
createCircuitSnapshot(fixture, {
|
||||
id: "foreign-list",
|
||||
circuitListId: fixture.foreignCircuitListId,
|
||||
sectionId: fixture.foreignSectionId,
|
||||
}),
|
||||
createCircuitSnapshot(fixture, {
|
||||
id: "foreign-section",
|
||||
sectionId: fixture.foreignSectionId,
|
||||
}),
|
||||
createCircuitSnapshot(fixture, {
|
||||
id: "duplicate-bmk",
|
||||
equipmentIdentifier: "-1F1",
|
||||
}),
|
||||
createCircuitSnapshot(fixture, {
|
||||
id: "duplicate-row",
|
||||
deviceRows: [
|
||||
createRow("duplicate-row", "row-existing-1", 10),
|
||||
],
|
||||
}),
|
||||
createCircuitSnapshot(fixture, {
|
||||
id: "foreign-device",
|
||||
deviceRows: [
|
||||
createRow("foreign-device", "row-foreign-device", 10, {
|
||||
linkedProjectDeviceId: "device-foreign",
|
||||
}),
|
||||
],
|
||||
}),
|
||||
createCircuitSnapshot(fixture, {
|
||||
id: "foreign-room",
|
||||
deviceRows: [
|
||||
createRow("foreign-room", "row-foreign-room", 10, {
|
||||
roomId: "room-foreign",
|
||||
}),
|
||||
],
|
||||
}),
|
||||
const invalidSnapshots: Array<[CircuitSnapshot, RegExp]> = [
|
||||
[
|
||||
createCircuitSnapshot(fixture, {
|
||||
id: "foreign-list",
|
||||
circuitListId: fixture.foreignCircuitListId,
|
||||
sectionId: fixture.foreignSectionId,
|
||||
}),
|
||||
/Circuit list does not belong to project/,
|
||||
],
|
||||
[
|
||||
createCircuitSnapshot(fixture, {
|
||||
id: "foreign-section",
|
||||
sectionId: fixture.foreignSectionId,
|
||||
}),
|
||||
/Section does not belong to circuit list/,
|
||||
],
|
||||
[
|
||||
createCircuitSnapshot(fixture, {
|
||||
id: "duplicate-bmk",
|
||||
equipmentIdentifier: "-1F1",
|
||||
}),
|
||||
/Duplicate equipmentIdentifier in circuit list/,
|
||||
],
|
||||
[
|
||||
createCircuitSnapshot(fixture, {
|
||||
id: "duplicate-row",
|
||||
deviceRows: [
|
||||
createRow("duplicate-row", "row-existing-1", 10),
|
||||
],
|
||||
}),
|
||||
/Circuit device-row id already exists/,
|
||||
],
|
||||
[
|
||||
createCircuitSnapshot(fixture, {
|
||||
id: "foreign-device",
|
||||
deviceRows: [
|
||||
createRow("foreign-device", "row-foreign-device", 10, {
|
||||
linkedProjectDeviceId: "device-foreign",
|
||||
}),
|
||||
],
|
||||
}),
|
||||
/Invalid linked project device id/,
|
||||
],
|
||||
[
|
||||
createCircuitSnapshot(fixture, {
|
||||
id: "foreign-room",
|
||||
deviceRows: [
|
||||
createRow("foreign-room", "row-foreign-room", 10, {
|
||||
roomId: "room-foreign",
|
||||
}),
|
||||
],
|
||||
}),
|
||||
/Invalid room id/,
|
||||
],
|
||||
];
|
||||
for (const snapshot of invalidSnapshots) {
|
||||
assert.throws(() =>
|
||||
store.execute({
|
||||
projectId: "project-1",
|
||||
expectedRevision: 0,
|
||||
source: "user",
|
||||
command: createCircuitInsertProjectCommand(snapshot),
|
||||
})
|
||||
for (const [snapshot, expectedError] of invalidSnapshots) {
|
||||
assert.throws(
|
||||
() =>
|
||||
store.execute({
|
||||
projectId: "project-1",
|
||||
expectedRevision: 0,
|
||||
source: "user",
|
||||
command: createCircuitInsertProjectCommand(snapshot),
|
||||
}),
|
||||
expectedError
|
||||
);
|
||||
}
|
||||
assert.equal(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue