Add error handling and validation tests for Comments API - #126
Open
devin-ai-integration[bot] wants to merge 2 commits into
Open
devin-ai-integration[bot] wants to merge 2 commits into
devin-ai-integration[bot] wants to merge 2 commits into
Conversation
- Add Unauthenticated context: GET and POST without auth return 401 - Add malformed transactionId tests (422) for both GET and POST - Add invalid POST body tests (422): empty body, non-string content, unknown field - Restructure beforeEach so login only runs for authenticated contexts - Use failOnStatusCode: false on all error tests Co-Authored-By: Ahmad Raza <ahmad.raza@cognition.ai>
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
araza-cog
reviewed
May 20, 2026
| }); | ||
| }); | ||
|
|
||
| it("errors with malformed transactionId", function () { |
There was a problem hiding this comment.
can you add a comment here explaining the change
…tor error field Co-Authored-By: Ahmad Raza <ahmad.raza@cognition.ai>
Author
Test ResultsRan New error handling tests (7 tests)
Regression: existing happy-path tests (2 tests)
Cypress CLI outputNote: Initial run caught a bug in the test — |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds 8 new test cases to
cypress/tests/api/api-comments.spec.tscovering error handling and validation for the Comments API:Unauthenticated access (401):
/comments/:transactionIdwithout auth → 401 +{ error: "Unauthorized" }/comments/:transactionIdwithout auth → 401Invalid transactionId (422):
Invalid POST body (422):
{}→ 422, errors referencecontentfield (param === "content"){ content: 12345 }→ 422{ notACommentField: "foo" }→ 422Structural change: Moved
cy.loginByApi()from the top-levelbeforeEachinto per-contextbeforeEachblocks so theUnauthenticatedcontext can run without login. Thedb:seedandtransactionIdlookup remain in the top-levelbeforeEach.All new tests use
failOnStatusCode: falseand follow the patterns fromapi-transactions.spec.tsandapi-notifications.spec.ts.Review & Testing Checklist for Human
Unauthenticatedcontext has nobeforeEachcallingloginByApi)beforeEachrestructuringnpx cypress run --spec 'cypress/tests/api/api-comments.spec.ts'Notes
beforeEachrestructuring only moves the login call —db:seedand comment lookup remain shared across all contextsensureAuthenticated(401),validateMiddleware(422), andshortIdValidation(422)param(notpath) as the field name key in error objectsLink to Devin session: https://app.devin.ai/sessions/9750ca3b5695429782d9bc38110acce0
Requested by: @araza-cog
Devin Review