Skip to content

Commit c86c084

Browse files
authored
fix(credential-groups): pin the clock in the enrollment tests (#6812)
`invitationExpiresAt` was dated 2026-08-18T12:00:00Z, and the code under test compares it against the wall clock. The suite passed until that instant and has failed for everyone since -- the same commit passed CI at 07:21Z and failed at 14:55Z with no code change between the runs. Pin the clock to a point inside the invitation window instead. Every existing date literal keeps its meaning and the suite stops depending on when it runs. Re-dating the fixture to a later instant would only move the failure.
1 parent 34aac38 commit c86c084

1 file changed

Lines changed: 18 additions & 1 deletion

File tree

apps/sim/lib/credential-groups/enrollments.test.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*/
44
import { dbChainMockFns, queueTableRows, resetDbChainMock, schemaMock } from '@sim/testing'
55
import { inArray } from 'drizzle-orm'
6-
import { beforeEach, describe, expect, it, vi } from 'vitest'
6+
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
77

88
const { adapter } = vi.hoisted(() => ({
99
adapter: {
@@ -41,6 +41,23 @@ import { sendEmail } from '@/lib/messaging/email/mailer'
4141

4242
const MAX_CONNECTION_SUMMARIES = CREDENTIAL_GROUP_PROVIDER_IDS.length * 3
4343

44+
/**
45+
* The invitation fixtures below are dated relative to a fixed point in the enrollment
46+
* window, and the code under test compares them against the wall clock. Pinning the
47+
* clock keeps those literals meaningful and keeps the suite deterministic — dating the
48+
* expiry to a real future instant only moves the failure, it does not remove it.
49+
*/
50+
const NOW = new Date('2026-08-11T12:10:00.000Z')
51+
52+
beforeEach(() => {
53+
vi.useFakeTimers({ shouldAdvanceTime: true })
54+
vi.setSystemTime(NOW)
55+
})
56+
57+
afterEach(() => {
58+
vi.useRealTimers()
59+
})
60+
4461
const ENROLLMENT = {
4562
id: 'enrollment-1',
4663
credentialGroupId: 'group-1',

0 commit comments

Comments
 (0)