Skip to content

test: expand test coverage of the graphql endpoints - #161

Merged
Dejmenek merged 12 commits into
mainfrom
test/137-expand-test-coverage-for-the-implementation-first-graphql-migration
Sep 24, 2026
Merged

Dejmenek merged 12 commits into
mainfrom
test/137-expand-test-coverage-for-the-implementation-first-graphql-migration

Conversation

@Dejmenek

Copy link
Copy Markdown
Owner

Summary

Introduces comprehensive integration and unit tests for GraphQL endpoints, focusing on authentication, query efficiency, and data privacy. Improves test utilities and ensures internal fields are not exposed.

Changes

  • Added new test files (JwtValidationTests.cs, BatchingTests.cs, ParticipantQueryTests.cs, SlotNumberAssignmentTests.cs, ApplicationUserSchemaTests.cs) targeting authentication, batching, and participant/tournament queries.
  • Implemented QueryCommandRecorder and integrated it into the test web app factory to verify database query batching.
  • Added JwtTestTokenFactory for generating various JWT tokens to test authentication error handling.
  • Updated GraphQL query examples and extended test coverage for filtering, sorting, and privacy scenarios.
  • Modified main project to expose internal members to tests and restricted ApplicationUser GraphQL type to allow-listed fields only.

Added JwtValidationTests for parameterized JWT auth tests in GraphQL, covering expired, tampered, malformed, and missing-claim tokens. Introduced JwtTestTokenFactory to generate test tokens with specific properties. Ensured protected operations return correct errors
Added tests to verify that querying matches by round returns only matches from the specified round and that querying a non-existent round returns an empty result set.
Added ParticipantQueryTests covering:
- Sorting by slot number (asc/desc)
- Filtering by min slot number
- Filtering by participant ID
Added SlotNumberAssignmentTests to verify unique, strictly increasing slot numbers for tournament participants. Tests cover sequential adds, joins, interleaved operations, and race conditions to ensure no gaps or duplicates in slot assignments.
Added tests to verify participant email visibility in tournament queries for anonymous users, unrelated users, and private email owners, ensuring correct privacy handling in all scenarios.
Added tests to verify filtering played tournaments by name, filtering won matches by round, and sorting played tournaments by name in descending order.
Expanded TournamentQueries and UserQueries with new GraphQL query constants for advanced filtering, sorting, and data retrieval. Includes queries for participants by slot or ID, participants' won tournaments and matches, all matches and players in a tournament, and user-played tournaments with name filters and sorting.
Added ApplicationUserSchemaTests to verify the GraphQL ApplicationUser type. Ensured only allow-listed fields are exposed and internal identity fields are not present in the schema.
Added <InternalsVisibleTo> to allow TournamentAPI.UnitTests project to access internal types for improved unit testing coverage.
Added WonMatches of type MatchesByBracketConnection? to ApplicationUserNode in ResponseModels.cs to represent user's won matches by bracket.
@Dejmenek Dejmenek linked an issue Sep 24, 2026 that may be closed by this pull request
@Dejmenek
Dejmenek merged commit f912e62 into main Sep 24, 2026
3 checks passed
@Dejmenek
Dejmenek deleted the test/137-expand-test-coverage-for-the-implementation-first-graphql-migration branch September 24, 2026 18:01
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.

Expand test coverage for the implementation-first GraphQL migration

1 participant