Skip to content

test: cover list endpoints and fix match display name casing - #6

Merged
Project516 merged 2 commits into
Project516:mainfrom
cappy-dev:test/cover-list-endpoints-and-fix-displayname
Aug 6, 2026
Merged

test: cover list endpoints and fix match display name casing#6
Project516 merged 2 commits into
Project516:mainfrom
cappy-dev:test/cover-list-endpoints-and-fix-displayname

Conversation

@cappy-dev

@cappy-dev cappy-dev commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

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, and getEventTeamsBasic were the only StatboticsClient methods with no tests. This adds:

  • getEvents(year): verifies the request hits /v3/events?year=2026&limit=500 and 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.
  • getEvents returns empty on 404.
  • getEventMatches(eventKey): verifies the request hits /v3/matches?event=...&limit=200 and that results sort by comp level (qm < ef < qf < sf < f) then match number, using a deliberately jumbled input that includes an ef match.
  • getEventMatches returns empty on 404.
  • getEventTeamsBasic(eventKey): verifies the request URL and that the basic team list parses into StatboticsTeamBasic.
  • getEventTeamsBasic returns 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 during jsonDecode.
  • StatboticsMatch.displayName formats every comp level consistently.

Bug fix

StatboticsMatch.displayName special-cased qm, sf, and f but left ef and qf to fall through to the default branch. That branch built '$compLevel$matchNumber', so:

comp level Before After
qm Q12 Q12
ef ef2 EF2
qf qf3 QF3
sf SF1 SF1
f F2 F2

Sibling levels rendered inconsistently (SF1 upper-case next to qf3 lower-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 levelOrder map in getEventMatches already treats ef and qf as 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:

  • The getEvents test 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.
  • The sort fixture skipped 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:

dart format --output=none --set-exit-if-changed .  -> clean
dart analyze --fatal-infos                        -> No issues found
dart test                                         -> All tests passed (21, up from 13)

One focused change. No new dependencies; no public API change beyond the displayName casing fix.

Summary by CodeRabbit

  • Bug Fixes

    • Competition-level match names now consistently use uppercase formatting, including EF and QF matches.
    • Unknown competition levels are normalized to uppercase before the match number is displayed.
  • Tests

    • Expanded coverage for match parsing, sorting, event and match filtering, team retrieval, malformed responses, 404 errors, and non-transient failures.

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
@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown

Review Change Stack

Important

Review skipped

No new commits to review since the last review.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: fa1495e0-81a6-496d-a1de-d3b5b6ca3649

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

The change updates StatboticsMatch.displayName formatting and adds client tests for match construction, event and match retrieval, team parsing, sorting, 404 handling, malformed responses, and non-transient failures.

Changes

Statbotics client behavior

Layer / File(s) Summary
Match display-name formatting and fixtures
lib/src/statbotics_models.dart, test/statbotics_client_test.dart
ef and qf display names now use uppercase prefixes. Unknown competition levels are uppercased. Tests cover match formatting and qualification detection.
Event and match retrieval
test/statbotics_client_test.dart
Tests cover event requests, year filtering, sorting, 404 responses, match sorting, alliance parsing, and qualification detection.
Team parsing and HTTP error handling
test/statbotics_client_test.dart
Tests cover team nickname parsing, malformed responses, non-transient failures, and immediate 403 handling.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Poem

A rabbit checks each match with care,
EF and QF now shine so clear.
Events sort, teams parse, errors stay,
Tests hop through the client all day.
Thump, thump—clean results appear!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes both the added endpoint tests and the match display name casing fix.

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@cappy-dev

Copy link
Copy Markdown
Contributor Author

cc @Project516

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between d63de33 and 25f385f.

📒 Files selected for processing (2)
  • lib/src/statbotics_models.dart
  • test/statbotics_client_test.dart

Comment thread test/statbotics_client_test.dart
Comment thread test/statbotics_client_test.dart
@Project516
Project516 merged commit c3035d3 into Project516:main Aug 6, 2026
1 of 2 checks passed
@Project516

Copy link
Copy Markdown
Owner

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown
⚠️ Action not completed

Already reviewed.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

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.

2 participants