Add comprehensive GraphQL test suite #172
Open
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.
Add comprehensive GraphQL test suite
Summary
This PR adds a comprehensive test suite for GraphQL operations using Netflix DGS testing utilities. The tests cover all major GraphQL queries and mutations in the application.
Test files added (11 files, ~1850 lines):
ArticleDatafetcherTest- Article queries, pagination, filtering by author/tag/favoritedArticleMutationTest- Article create, update, delete, favorite/unfavoriteCommentDatafetcherTest- Comment queries with cursor-based paginationCommentMutationTest- Comment add/delete operationsMeDatafetcherTest- User query configuration (note: some tests skipped due to Authorization header requirement)ProfileDatafetcherTest- Profile queriesRelationMutationTest- Follow/unfollow user operationsTagDatafetcherTest- Tag listing queriesUserMutationTest- User registration, login, updateGraphQLCustomizeExceptionHandlerTest- Exception handling for validation errorsTestSecurityConfig- Security configuration for test contextTesting approach:
@SpringBootTestwith DGS auto-configuration@MockBean@BeforeEachto handle SecurityContext requirementsReview & Testing Checklist for Human
MeDatafetchertests - these require Authorization header which is difficult to provide in DGS test contextatLeastOnce()verification is acceptable (used instead of strict verification due to DGS executor behavior)./gradlew test -x spotlessJavalocally to confirm all 132 tests passRecommended test plan:
Notes
actions/cache: v2in GitHub Actions workflow (unrelated to this PR)Requested by: Roshan Fernando (@rdf004)
Devin Session: https://app.devin.ai/sessions/e1c4f0c64b794fe3abab95d46bbf5838