diff --git a/tests/unit/exclusive-connection-leases.test.ts b/tests/unit/exclusive-connection-leases.test.ts index a289ce99a2..fcfceb71c7 100644 --- a/tests/unit/exclusive-connection-leases.test.ts +++ b/tests/unit/exclusive-connection-leases.test.ts @@ -61,6 +61,19 @@ test("uses the live next-free migration slot without runner compatibility specia }); test("enforces global active owner and connection uniqueness", () => { + // Establish the OWNER_A/conn-a lease this test reuses, rather than depending + // on a lease left behind by an earlier test in the file. The DB instance is + // shared across tests (reset only in test.after), so relying on prior state + // makes this test order-dependent: run in isolation the re-acquire below + // returns ACQUIRED instead of REUSED. + leases.acquireExclusiveConnectionLease({ + leaseOwnerId: OWNER_A, + apiKeyId: "key-a", + provider: "codex", + connectionId: "conn-a", + now: at(0), + }); + const ownerA = leases.acquireExclusiveConnectionLease({ leaseOwnerId: OWNER_A, apiKeyId: "key-a",