test: cover list endpoints and fix match display name casing - #6
Conversation
Adds the first tests for getEvents, getEventMatches, and getEventTeamsBasic, the three list endpoints that had no test coverage. getEvents and getEventMatches verify the request URL and the sort order (week then name, and comp level then match number). getEventTeamsBasic verifies parsing plus the best-effort empty-list fallback for both a non-transient HTTP error (403) and a malformed response body. Also fixes StatboticsMatch.displayName, which special-cased qm, sf, and f but left ef and qf to fall through to the default branch, producing lower-case 'ef2' and 'qf3' while siblings rendered as 'EF2' / 'QF3' / 'SF1' / 'F1'. All known FRC comp levels now render with their conventional two-letter abbreviation, and unknown levels upper-case themselves so a future level never silently renders lower case. Verification (Dart 3.12.2): dart format --output=none --set-exit-if-changed . -> clean dart analyze --fatal-infos -> no issues dart test -> 21 passed (was 13) On behalf of @Project516
|
Important Review skippedNo new commits to review since the last review. ⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
📝 WalkthroughWalkthroughThe change updates ChangesStatbotics client behavior
Estimated code review effort: 3 (Moderate) | ~20 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
cc @Project516 |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@test/statbotics_client_test.dart`:
- Around line 248-276: Update the test fixture used by getEvents(2026) to
include at least one event from a different year, then assert that the returned
results exclude that event while preserving the existing 2026 sorting
assertions.
- Around line 311-317: Update the match sort fixture using _matchJson to include
an ef match, and extend the expected ordering assertions so ef appears after qm
and before qf matches, preserving the documented qm < ef < qf < sf < f order.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 615643bf-0656-4e4d-9047-0bb2a1a69edb
📒 Files selected for processing (2)
lib/src/statbotics_models.darttest/statbotics_client_test.dart
|
@coderabbitai review |
|
What
Adds the first tests for the three list endpoints that had zero coverage, and fixes a display-name casing bug those tests surfaced.
Test coverage
getEvents,getEventMatches, andgetEventTeamsBasicwere the onlyStatboticsClientmethods with no tests. This adds:getEvents(year): verifies the request hits/v3/events?year=2026&limit=500and that results come back sorted by week then name, including a null-week event sorting after every numbered week. The year is a server-side query parameter, not a client-side filter, so the test asserts the URL and the ordering, nothing more.getEventsreturns empty on 404.getEventMatches(eventKey): verifies the request hits/v3/matches?event=...&limit=200and that results sort by comp level (qm<ef<qf<sf<f) then match number, using a deliberately jumbled input that includes anefmatch.getEventMatchesreturns empty on 404.getEventTeamsBasic(eventKey): verifies the request URL and that the basic team list parses intoStatboticsTeamBasic.getEventTeamsBasicreturns an empty list when the endpoint fails (the documented best-effort behavior), covering both a non-transient HTTP error (403) and a malformed response body that throws duringjsonDecode.StatboticsMatch.displayNameformats every comp level consistently.Bug fix
StatboticsMatch.displayNamespecial-casedqm,sf, andfbut leftefandqfto fall through to the default branch. That branch built'$compLevel$matchNumber', so:qmQ12Q12efef2EF2qfqf3QF3sfSF1SF1fF2F2Sibling levels rendered inconsistently (
SF1upper-case next toqf3lower-case). All known FRC comp levels now use their conventional two-letter abbreviation, and the default branch upper-cases the level so a future level never silently renders lower case.The
levelOrdermap ingetEventMatchesalready treatsefandqfas first-class levels, so they should not be special-cased away in the display name either.Review notes
Taken over from the bot. Two CodeRabbit findings on the original push:
getEventstest was named "filters by year" when the client does no client-side filtering. Renamed rather than adding an assertion for behavior that does not exist. Feeding an off-year event and asserting it is dropped would have failed.ef, the one level whose ordering is easiest to get wrong. Added, and the expected ordering now pins all five levels.Verification
Ran locally against
dart:stable, mirroring the CI workflow:One focused change. No new dependencies; no public API change beyond the
displayNamecasing fix.Summary by CodeRabbit
Bug Fixes
EFandQFmatches.Tests