Skip to content

test(core): add unit tests for createPermitDeadline - #337

Open
Sudhakar7J wants to merge 3 commits into
dmae97:mainfrom
Sudhakar7J:test/permit-deadline
Open

Sudhakar7J wants to merge 3 commits into
dmae97:mainfrom
Sudhakar7J:test/permit-deadline

Conversation

@Sudhakar7J

Copy link
Copy Markdown

Summary

Adds unit tests for createPermitDeadline in packages/coding-agent/src/core/permit-deadline.ts, which currently has no dedicated test coverage. The function takes an injectable clock, making it straightforward to test without real waiting.

Changes

  • packages/coding-agent/test/permit-deadline.test.ts (new): 6 tests covering:
    • RangeError for non-positive/non-finite durations
    • RangeError for non-finite clock values at start
    • expired() follows the injected clock
    • onExpire runs exactly once on expiry (fake timers)
    • re-arming instead of expiring when the clock lags (event-loop lag)
    • cancel() prevents onExpire from running

Testing

cd packages/coding-agent && npx vitest --run test/permit-deadline.test.ts

Result: 1 test file, 6 tests passed.

Related

Checklist

  • Follows project CONTRIBUTING.md
  • Tests added for the change
  • No unrelated changes

dmae97 commented Nov 6, 2026

Copy link
Copy Markdown
Owner

The latest CI attempt for a4a6335 is now failing at npm run check, before the Test step. Both errors are in the new test file: lint/style/useConst at line 72 (t is never reassigned in the re-arm test), and Biome formatting around the three-argument createPermitDeadline call at line 30. Please apply the repository formatter and change that one declaration to const (or advance the clock and assert eventual expiry if that is the intended test), then rerun CI. The provider-adopt and spec066 messages in the same log are informational, not the two failing diagnostics.

Build and secret scan passed; the full Test step was skipped. This finding is based on the current diff and CI log, not a local test run.

@dmae97 dmae97 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding these. All 6 tests pass locally, and the behavior they check matches createPermitDeadline.

CI is failing at the Check step (build-check-test) because of two Biome errors:

  • lint/style/useConst at line 72: let t = 0 is never reassigned, so it should be const;
  • formatting at about line 30: () => createPermitDeadline(100, () => {}, () => value) needs to be split across lines.

Running npx biome check --write packages/coding-agent/test/permit-deadline.test.ts fixes both.

Optional: the function's doc comment also promises that delays longer than the 32-bit timer limit (2_147_483_647 ms) are split into chunks, and no test covers that yet. A fake-timer test for it would be a nice addition.

dmae97 commented Nov 6, 2026

Copy link
Copy Markdown
Owner

Rechecked 9cf20c9: the re-arm test now uses const, and the three-argument createPermitDeadline call has the requested multiline formatting. Both previously reported diagnostics are addressed in the source diff. This is a source review, not an independent Biome or Vitest run.

The new CI run 42204086001 is action_required, with zero jobs and no check runs for this head. It still needs workflow approval and successful repository gates before merge. The branch also remains based on fcfdf5f, 45 commits behind current main (da81013), so please refresh the branch and verify the combined tree rather than relying on the old run.

@Sudhakar7J
Sudhakar7J force-pushed the test/permit-deadline branch from 9cf20c9 to efbbbaf Compare November 6, 2026 19:55

dmae97 commented Nov 6, 2026

Copy link
Copy Markdown
Owner

Rechecked efbbbaf8: the branch is now rebased onto current main (da81013a, zero commits behind), so the stale-base concern in my earlier comment is resolved. The diff remains test-only and now includes the optional >32-bit timer-delay case, bringing the file to seven tests. The earlier formatting and const fixes are still present. I found no new source-level blocker; I have not independently run these tests.

The remaining validation blocker is CI run 42283918523: action_required, with zero jobs and zero check runs on this head. A maintainer needs to approve the workflow and let the repository gates complete successfully before merge. The existing changes-requested review also remains recorded; this comment is not merge approval.

This branch has not been deployed

No deployments
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.

test: add unit tests for createPermitDeadline in core/permit-deadline.ts

2 participants