Skip to content

Commit 10c854b

Browse files
committed
Fix lock evidence assertions in race-condition tests
1 parent d3e5902 commit 10c854b

1 file changed

Lines changed: 6 additions & 7 deletions

File tree

packages/react-on-rails-pro-node-renderer/tests/uploadRaceCondition.test.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,13 @@ jest.mock('../src/shared/locks', () => {
7979
lock: async (...args: any[]) => {
8080
const filename = args[0] as string;
8181
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call
82-
const result = await mockActualLocks.lock(...args);
82+
const result = (await mockActualLocks.lock(...args)) as { wasLockAcquired: boolean };
8383
// Record which bundle acquired the lock (use last path segment as key)
8484
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call
8585
const bundleKey = mockPath.basename(mockPath.dirname(filename)) as string;
86-
mockEventLog.push({ label: `${bundleKey}:lock-acquired`, timestamp: Date.now() });
86+
if (result.wasLockAcquired) {
87+
mockEventLog.push({ label: `${bundleKey}:lock-acquired`, timestamp: Date.now() });
88+
}
8789
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
8890
return result;
8991
},
@@ -254,11 +256,8 @@ describe('concurrent upload isolation (issue #2449)', () => {
254256
const bothCompleted =
255257
releaseA.timestamp >= acquireA.timestamp && releaseB.timestamp >= acquireB.timestamp;
256258
expect(bothCompleted).toBe(true);
257-
// If overlap was observed, that is strong concurrent evidence
258-
if (aOverlapsB) {
259-
// Overlap confirmed — lock regions interleaved in time
260-
expect(aOverlapsB).toBe(true);
261-
}
259+
// Overlap confirmed — lock regions interleaved in time
260+
expect(aOverlapsB).toBe(true);
262261
});
263262

264263
test('concurrent requests with multiple assets each deliver all correct assets', async () => {

0 commit comments

Comments
 (0)