fix: resolve all test failures after vitest 2.x upgrade

- Attach rejects handler before advancing timers (vitest 2.x strict mode)
- Fix FK constraint cleanup order in test setup
- Fix 7-char prefix matching test data
- Add INSERT OR IGNORE for deposit concurrency safety
- Add secondary ORDER BY for deterministic transaction ordering
- Update summary-service test assertions to match current prompt

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
kappa
2026-02-07 19:41:11 +09:00
parent fa7d8b2d1a
commit bd25316fd3
7 changed files with 253 additions and 194 deletions

View File

@@ -117,6 +117,8 @@ describe('executeWithOptimisticLock', () => {
// Start operation with 5 max retries
const promise = executeWithOptimisticLock(mockDb, mockOperation, 5);
// Attach error handler before advancing timers (vitest 2.x strict mode)
const expectPromise = expect(promise).rejects.toThrow('처리 중 동시성 충돌이 발생했습니다');
// Advance through all retry delays
await vi.advanceTimersByTimeAsync(100); // 1st retry
@@ -125,7 +127,7 @@ describe('executeWithOptimisticLock', () => {
await vi.advanceTimersByTimeAsync(800); // 4th retry
// Wait for final rejection
await expect(promise).rejects.toThrow('처리 중 동시성 충돌이 발생했습니다');
await expectPromise;
expect(mockOperation).toHaveBeenCalledTimes(5);
});
});
@@ -136,15 +138,17 @@ describe('executeWithOptimisticLock', () => {
// Start operation (default 3 retries)
const promise = executeWithOptimisticLock(mockDb, mockOperation);
// Attach error handler before advancing timers (vitest 2.x strict mode)
const expectPromise = expect(promise).rejects.toThrow(
'처리 중 동시성 충돌이 발생했습니다. 다시 시도해주세요. (3회 재시도 실패)'
);
// Advance through all retry delays
await vi.advanceTimersByTimeAsync(100); // 1st retry
await vi.advanceTimersByTimeAsync(200); // 2nd retry
// Wait for final rejection
await expect(promise).rejects.toThrow(
'처리 중 동시성 충돌이 발생했습니다. 다시 시도해주세요. (3회 재시도 실패)'
);
await expectPromise;
expect(mockOperation).toHaveBeenCalledTimes(3);
});