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.
This commit is contained in:
Waleed
2026-08-18 08:03:37 -07:00
committed by GitHub
parent 34aac38112
commit c86c084a51
@@ -3,7 +3,7 @@
*/
import { dbChainMockFns, queueTableRows, resetDbChainMock, schemaMock } from '@sim/testing'
import { inArray } from 'drizzle-orm'
import { beforeEach, describe, expect, it, vi } from 'vitest'
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
const { adapter } = vi.hoisted(() => ({
adapter: {
@@ -41,6 +41,23 @@ import { sendEmail } from '@/lib/messaging/email/mailer'
const MAX_CONNECTION_SUMMARIES = CREDENTIAL_GROUP_PROVIDER_IDS.length * 3
/**
* The invitation fixtures below are dated relative to a fixed point in the enrollment
* window, and the code under test compares them against the wall clock. Pinning the
* clock keeps those literals meaningful and keeps the suite deterministic — dating the
* expiry to a real future instant only moves the failure, it does not remove it.
*/
const NOW = new Date('2026-08-11T12:10:00.000Z')
beforeEach(() => {
vi.useFakeTimers({ shouldAdvanceTime: true })
vi.setSystemTime(NOW)
})
afterEach(() => {
vi.useRealTimers()
})
const ENROLLMENT = {
id: 'enrollment-1',
credentialGroupId: 'group-1',