Skip to content

fix(credential-groups): pin the clock in the enrollment tests - #6812

Merged
waleedlatif1 merged 1 commit into
stagingfrom
fix/enrollment-test-time-bomb
Aug 18, 2026
Merged

fix(credential-groups): pin the clock in the enrollment tests#6812
waleedlatif1 merged 1 commit into
stagingfrom
fix/enrollment-test-time-bomb

Conversation

@waleedlatif1

Copy link
Copy Markdown
Collaborator

Summary

apps/sim/lib/credential-groups/enrollments.test.ts had a time bomb that has now gone off. It blocks CI on every branch, not just this one.

ENROLLMENT.invitationExpiresAt was hardcoded to 2026-08-18T12:00:00.000Z, and completeCredentialGroupEnrollment compares it against the wall clock. Before that instant the invitation was valid and the suite passed; after it, the invitation is expired, the function returns null, and two tests fail.

The evidence is a single unchanged commit running twice:

Run Time enrollments.test.ts
First 2026-08-18T07:21Z 11 passed
Re-run 2026-08-18T14:55Z 11 tests, 2 failed

Same SHA, same base, no code change between them — only the clock moved past 12:00Z.

Confirmed locally: on clean origin/staging the two tests fail deterministically; re-dating the fixture to 2027 makes all 11 pass.

Fix

Pin the clock to a point inside the invitation window rather than re-dating the fixture:

const NOW = new Date('2026-08-11T12:10:00.000Z')
beforeEach(() => {
  vi.useFakeTimers({ shouldAdvanceTime: true })
  vi.setSystemTime(NOW)
})
afterEach(() => { vi.useRealTimers() })

Every existing date literal keeps its meaning, and the suite stops depending on when it runs. Bumping the date to a later instant would only re-arm the same failure.

Type of Change

  • Bug fix (broken CI)

Testing

lib/credential-groups — 63 tests across 13 files pass. type-check clean, lint clean. Verified the cause by moving the fixture date forward and back.

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

`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.
@vercel

vercel Bot commented Aug 18, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Aug 18, 2026 2:58pm

Request Review

@cursor

cursor Bot commented Aug 18, 2026

Copy link
Copy Markdown

PR Summary

Low Risk
Test-only change with no production code paths affected.

Overview
Fixes flaky CI in enrollments.test.ts where completeCredentialGroupEnrollment treats invitations as expired once the real clock passes ENROLLMENT.invitationExpiresAt (2026-08-18T12:00:00.000Z).

The suite now pins time with Vitest fake timers: a fixed NOW inside the invitation window, beforeEach sets system time and afterEach restores real timers. Existing fixture dates stay unchanged; only test execution time is controlled.

Reviewed by Cursor Bugbot for commit 1aa8014. Configure here.

@greptile-apps

greptile-apps Bot commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

Pins the enrollment test suite’s system clock within the invitation-validity window and restores real timers after each test, removing dependence on the wall clock.

  • Adds a fixed reference time for date-sensitive enrollment fixtures.
  • Enables advancing fake timers before each test.
  • Restores real timers during test cleanup.

Confidence Score: 5/5

The PR appears safe to merge; the fixed clock removes the expired-fixture failure without introducing a reachable test regression.

The affected tests perform date comparisons but do not rely on real timer scheduling, and each test restores real timers during cleanup.

Important Files Changed

Filename Overview
apps/sim/lib/credential-groups/enrollments.test.ts Adds deterministic clock setup and cleanup without disrupting the file’s existing timer or date-sensitive behavior.

Reviews (1): Last reviewed commit: "fix(credential-groups): pin the clock in..." | Re-trigger Greptile

@waleedlatif1
waleedlatif1 merged commit c86c084 into staging Aug 18, 2026
23 checks passed
@waleedlatif1
waleedlatif1 deleted the fix/enrollment-test-time-bomb branch August 18, 2026 15:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant