Skip to content

Add comment unit tests and Cypress API tests - #121

Open
devin-ai-integration[bot] wants to merge 1 commit into
developfrom
devin/1777361280-add-comment-tests
Open

devin-ai-integration[bot] wants to merge 1 commit into
developfrom
devin/1777361280-add-comment-tests

Conversation

@devin-ai-integration

@devin-ai-integration devin-ai-integration Bot commented Apr 28, 2026

Copy link
Copy Markdown

Summary

Adds comprehensive test coverage for the comments feature across two independent workstreams:

Workstream A — Unit tests (src/__tests__/comments.test.ts):

  • Test createComments (plural) with notification side effects: verifies that calling createComments with a third-party user (not sender/receiver) creates the comment and generates notifications for both the transaction's sender and receiver
  • Comment object shape assertions: validates the returned comment has all expected Comment interface properties (id, uuid, content, userId, transactionId, createdAt, modifiedAt)
  • Test getCommentsByTransactionId returns an empty array for a transaction with no comments

Workstream B — Cypress API tests (cypress/tests/api/api-comments.spec.ts):

  • Unauthenticated request tests (401): GET and POST without login return 401
  • Invalid transactionId validation (422) on GET: non-shortid 1234 triggers validation error
  • Missing content body validation (422) on POST: empty body triggers validation error
  • Invalid transactionId validation (422) on POST: non-shortid triggers validation error
  • Response body shape validation on GET: asserts comment objects have all expected properties
  • POST persistence verification: follow-up GET confirms the created comment was persisted

Review & Testing Checklist for Human

  • Verify the unit tests pass locally: npx vitest run src/__tests__/comments.test.ts
  • Verify the Cypress API tests pass locally: npx cypress run --spec cypress/tests/api/api-comments.spec.ts (requires app running)
  • Confirm the unauthenticated tests (401) correctly clear cookies before making requests — cy.clearCookies() runs after the beforeEach login

Notes

  • All 4 unit tests pass locally via vitest
  • Cypress API tests require the app server to be running — CI will validate these
  • The createComments test exercises the branch at backend/database.ts:675 where userId !== senderId || userId !== receiverId

Link to Devin session: https://app.devin.ai/sessions/042dcfa0177c41e5bcda348450583fed
Requested by: @scottyandrade99


Open in Devin Review

Workstream A (unit tests):
- Test createComments with notification side effects for sender/receiver
- Add comment object shape assertions (id, uuid, content, userId, etc.)
- Test getCommentsByTransactionId returns empty array for no comments

Workstream B (API tests):
- Add unauthenticated request tests (401) for GET and POST
- Add invalid transactionId validation test (422) for GET
- Add missing content body validation test (422) for POST
- Add invalid transactionId validation test (422) for POST
- Enhance GET test with response body shape validation
- Enhance POST test with persistence verification via follow-up GET

Co-Authored-By: Scotty Andrade <scotty.andrade@cognition.ai>
@devin-ai-integration

Copy link
Copy Markdown
Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@staging-devin-ai-integration

Copy link
Copy Markdown

Devin Review

Status Commit
⚪ Not started

Open in Devin Review (Staging)

💡 Connect your GitHub account to enable automatic code reviews.

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 3 additional findings.

Open in Devin Review

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