| ... | @@ -27,7 +27,7 @@ import * as Option from "effect/Option"; | ... | @@ -27,7 +27,7 @@ import * as Option from "effect/Option"; |
| 27 | import * as Queue from "effect/Queue"; | 27 | import * as Queue from "effect/Queue"; |
| 28 | import * as Stream from "effect/Stream"; | 28 | import * as Stream from "effect/Stream"; |
| 29 | import { TestClock } from "effect/testing"; | 29 | import { TestClock } from "effect/testing"; |
| 30 | import { describe, expect, it } from "vite-plus/test"; | 30 | import { describe, expect, it, vi } from "vite-plus/test"; |
| 31 | | 31 | |
| 32 | import { PersistenceSqlError } from "../../persistence/Errors.ts"; | 32 | import { PersistenceSqlError } from "../../persistence/Errors.ts"; |
| 33 | import { OrchestrationCommandReceiptRepositoryLive } from "../../persistence/Layers/OrchestrationCommandReceipts.ts"; | 33 | import { OrchestrationCommandReceiptRepositoryLive } from "../../persistence/Layers/OrchestrationCommandReceipts.ts"; |
| ... | @@ -1039,6 +1039,8 @@ describe("OrchestrationEngine", () => { | ... | @@ -1039,6 +1039,8 @@ describe("OrchestrationEngine", () => { |
| 1039 | }, | 1039 | }, |
| 1040 | }), | 1040 | }), |
| 1041 | }); | 1041 | }); |
| | 1042 | // Same-tick links must replace the old PR, not rely on timestamp ordering. |
| | 1043 | const clock = vi.spyOn(Date, "now").mockReturnValue(Date.parse(now())); |
| 1042 | try { | 1044 | try { |
| 1043 | const projectId = ProjectId.make("pr-race-project"); | 1045 | const projectId = ProjectId.make("pr-race-project"); |
| 1044 | const threadId = ThreadId.make("pr-race-thread"); | 1046 | const threadId = ThreadId.make("pr-race-thread"); |
| ... | @@ -1141,6 +1143,9 @@ describe("OrchestrationEngine", () => { | ... | @@ -1141,6 +1143,9 @@ describe("OrchestrationEngine", () => { |
| 1141 | if (change === "delete") return; | 1143 | if (change === "delete") return; |
| 1142 | const current = (await system.readModel()).threads[0]; | 1144 | const current = (await system.readModel()).threads[0]; |
| 1143 | expect(current?.branchPullRequest ?? null).toBeNull(); | 1145 | expect(current?.branchPullRequest ?? null).toBeNull(); |
| | 1146 | expect(current?.pullRequests.map((link) => link.number)).toEqual( |
| | 1147 | change === "unlink" ? [] : change === "relink" ? [3] : [1], |
| | 1148 | ); |
| 1144 | expect(current?.linkedPullRequest ?? null).toEqual( | 1149 | expect(current?.linkedPullRequest ?? null).toEqual( |
| 1145 | change === "unlink" | 1150 | change === "unlink" |
| 1146 | ? null | 1151 | ? null |
| ... | @@ -1149,6 +1154,7 @@ describe("OrchestrationEngine", () => { | ... | @@ -1149,6 +1154,7 @@ describe("OrchestrationEngine", () => { |
| 1149 | : previous, | 1154 | : previous, |
| 1150 | ); | 1155 | ); |
| 1151 | } finally { | 1156 | } finally { |
| | 1157 | clock.mockRestore(); |
| 1152 | await system.dispose(); | 1158 | await system.dispose(); |
| 1153 | } | 1159 | } |
| 1154 | }, | 1160 | }, |