Skip to content

test: cover commitmentHistory service aggregation and ordering#1095

Open
Sendi0011 wants to merge 1 commit into
Commitlabs-Org:masterfrom
Sendi0011:test/commitment-history-service
Open

test: cover commitmentHistory service aggregation and ordering#1095
Sendi0011 wants to merge 1 commit into
Commitlabs-Org:masterfrom
Sendi0011:test/commitment-history-service

Conversation

@Sendi0011

@Sendi0011 Sendi0011 commented Jun 28, 2026

Copy link
Copy Markdown

Description

  • Add service-level unit test for getCommitmentHistory at tests/lib/backend/commitmentHistory.service.test.ts
  • Mock getMockData to verify created event shape
  • Assert one event per attestation, filtered by commitmentId
  • Assert correct terminal event (early_exit / settlement) based on status, and none for ACTIVE/VIOLATED/UNKNOWN
  • Verify chronological ordering ascending by occurredAt, including out-of-order source data and interleaved terminal events
  • Cover edge cases: no attestations, active/early_exit/settled, missing createdAt (epoch fallback), missing kind (defaults to 'unknown'), undefined complianceScore/violation

Closes #759

Type of Change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

Checklist

Please review the Developer Guide before checking the items below:

  • My code follows the code style and standards of this project (strict TypeScript, components/functions/constants naming conventions).
  • I have performed a self-review of my code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have updated or added documentation where relevant (DEVELOPER_GUIDE.md, README.md, or inline files).
  • I have added unit/integration tests that prove my fix is effective or that my feature works.
  • Any new or modified logic has at least 95% test coverage (verified via pnpm run test:coverage or npm run test:coverage).
  • I have ran the project linter (pnpm lint or npm run lint) and fixed all error diagnostics.
  • I have verified that this change fits within the 96-hour campaign timeframe for contributor assignments.
  • I have attached screenshots/videos showing the before and after states for any visual or UI changes.

Visual Changes (if applicable)

Please add screenshots, screen recordings, or GIFs showcasing the user interface changes.

Join the Discussion

Need help or want to chat? Join our CommitLabs Discord server.

- Add service-level unit test for getCommitmentHistory at
  tests/lib/backend/commitmentHistory.service.test.ts
- Mock getMockData to verify created event shape
- Assert one event per attestation, filtered by commitmentId
- Assert correct terminal event (early_exit / settlement) based on status,
  and none for ACTIVE/VIOLATED/UNKNOWN
- Verify chronological ordering ascending by occurredAt, including
  out-of-order source data and interleaved terminal events
- Cover edge cases: no attestations, active/early_exit/settled,
  missing createdAt (epoch fallback), missing kind (defaults to 'unknown'),
  undefined complianceScore/violation

Closes Commitlabs-Org#759
@vercel

vercel Bot commented Jun 28, 2026

Copy link
Copy Markdown

@Sendi0011 is attempting to deploy a commit to the 1nonly's projects Team on Vercel.

A member of the Team first needs to authorize it.

@1nonlypiece

Copy link
Copy Markdown
Contributor

this one comes in massively diverged, the merge wants to delete most of the source tree and tests. looks like it's built off a very old base, can you rebase onto current master and repush? ping us in https://discord.gg/WV7tdYkJk if you want a hand

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.

Add unit tests for the commitmentHistory service event aggregation and ordering

2 participants