test: spec-driven acceptance suite for Article Comments (issue #188, AC1–AC14) - #191
Open
devin-ai-integration[bot] wants to merge 1 commit into
Open
test: spec-driven acceptance suite for Article Comments (issue #188, AC1–AC14)#191devin-ai-integration[bot] wants to merge 1 commit into
devin-ai-integration[bot] wants to merge 1 commit into
Conversation
Add REST API-tier and read-model/service-tier tests covering AC1-AC14 of the Article Comments feature spec. New tests only; no production code or existing tests modified.
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:
|
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 a spec-driven automated test suite covering every acceptance criterion (AC1–AC14) of the Article Comments feature spec (#188). Tests only — no production code and no existing tests were modified. Two new files, split by tier so each AC is validated at the lowest faithful level:
src/test/java/io/spring/api/CommentsApiAcceptanceTest.java— REST API tier (@WebMvcTest(CommentsApi.class)+WebSecurityConfig, REST-Assured MockMvc), covering the create/list/delete endpoints and their auth/validation contracts (401/403/404/422, author-profile shape, creation-order, removal).src/test/java/io/spring/application/comment/CommentReadModelTest.java— read-model/service tier (CommentQueryServiceoverDbTestBaseH2), covering the real follow-state and per-comment author-profile/timestamp behavior that a mocked query service can't validate.Existing coverage in
CommentsApiTestandCommentQueryServiceTestis reused (not duplicated); the matrix below references those existing tests where they already cover an AC, and the new tests fill the gaps.Spec note (finding, not a change)
AC1 states the create endpoint returns
200, butCommentsApi.createCommentreturns201 Created(matching the existingCommentsApiTest.should_create_comment_success). Per the playbook I did not modify production code; the tests assert the actual201and this discrepancy is surfaced here for the spec owner to reconcile.Traceability matrix (AC → covering test)
comment.bodymatches inputCommentsApiAcceptanceTest.createComment_returnsAuthorProfile; existingCommentsApiTest.should_create_comment_successcomment.author(username, bio, image, following)CommentsApiAcceptanceTest.createComment_returnsAuthorProfileCommentsApiTest.should_get_422_with_empty_body(empty);CommentsApiAcceptanceTest.createComment_blankBody_returns422(blank)CommentsApiAcceptanceTest.createComment_unauthenticated_returns401CommentsApiAcceptanceTest.createComment_missingArticle_returns404commentsarray in creation orderCommentsApiAcceptanceTest.listComments_preservesCreationOrder; existingCommentsApiTest.should_get_comments_of_article_successauthor.followingreflects follow stateCommentReadModelTest.followingReflectsViewerFollowStatefollowing=falseCommentsApiAcceptanceTest.listComments_anonymous_followingFalse;CommentReadModelTest.anonymousViewerSeesFollowingFalseCommentsApiAcceptanceTest.listComments_missingArticle_returns404CommentsApiAcceptanceTest.deleteComment_byAuthor_returns204AndRemoves(assertscommentRepository.remove); existingCommentsApiTest.should_delete_comment_successCommentsApiTest.should_get_403_if_not_author_of_article_or_author_of_comment_when_delete_commentCommentsApiAcceptanceTest.deleteComment_unauthenticated_returns401CommentsApiAcceptanceTest.deleteComment_missingComment_returns404CommentReadModelTest.readModelReturnsAuthorProfileAndTimestampPerComment* See spec note above re: AC1 (201 vs 200).
Run command
./gradlew clean test spotlessCheck -x jacocoTestCoverageVerificationThis mirrors the repo's CI gate (
.github/workflows/gradle.ymlruns./gradlew clean test -x jacocoTestCoverageVerification). Result: BUILD SUCCESSFUL, 81 tests, 0 failed (was 68); Spotless clean.Coverage before → after
Repo-wide
jacocoTestCoverageVerification(80% instruction rule) is excluded from the CI gate and fails pre-existing onmain(~34% line); this PR does not change that rule or the build config. Coverage on the classes touched by the spec:io.spring.api.CommentsApiio.spring.application.CommentQueryServiceCommentsApiline coverage was already saturated by existing tests; the new API tests add the missing behavioral assertions (401/404 paths, blank body, author-profile shape, ordering, removal verification, anonymous follow state).CommentQueryServicebranch coverage improves via the real follow-state / anonymous paths (its remaining uncovered lines are the out-of-scopefindByArticleIdWithCursorcursor method).Assumptions
201(see spec note).findByArticleIdSQL has no explicitORDER BY; comments are returned in natural insertion order).Closes #188
Link to Devin session: https://partner-workshops.devinenterprise.com/sessions/7569f8f87acf4e4085811288d43960d4
Requested by: @mbatchelor81