test: add integration tests for standings#7647
Open
Rathoz wants to merge 2 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds a comprehensive integration-test baseline for Standings parsing, importing, tiebreakers, merges, and end-to-end model/widget rendering, to protect current behavior before an upcoming performance refactor.
Changes:
- Introduces integration specs for parser behavior, tiebreaker calculations, and opponent merge semantics.
- Adds LPDB match-import integration tests with stubbed match2 records to validate round accumulation and statuses.
- Adds a full “round trip” model/storage/widget rendering test with GoldenTest snapshots for FFA and Swiss widgets.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| lua/spec/standings_tiebreaker_spec.lua | Adds integration coverage for Factory normalization and key tiebreaker computations/display. |
| lua/spec/standings_table_merge_spec.lua | Adds tests locking down merge behavior between manual and imported opponent data. |
| lua/spec/standings_parser_spec.lua | Adds parser integration tests for placements/statuses/tiebreakers plus a standingsindex increment check. |
| lua/spec/standings_model_spec.lua | Adds end-to-end parse→store→load→widget rendering tests with GoldenTest snapshots. |
| lua/spec/standings_import_spec.lua | Adds integration tests for importing standings input from match2 LPDB records via a stubbed query. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+37
to
+55
| local function stubMatchQuery(records) | ||
| local recordsById = {} | ||
| for _, record in ipairs(records) do | ||
| recordsById[record.match2id] = record | ||
| end | ||
| return stub(mw.ext.LiquipediaDB, 'lpdb', function(tableName, parameters) | ||
| if tableName ~= 'match2' then | ||
| return {} | ||
| end | ||
| -- return the records the conditions ask for, mimicking the LPDB matchid filter | ||
| local found = {} | ||
| for matchId, record in pairs(recordsById) do | ||
| if parameters.conditions:find(matchId, 1, true) then | ||
| table.insert(found, record) | ||
| end | ||
| end | ||
| return found | ||
| end) | ||
| end |
This was referenced Jun 12, 2026
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 integration test coverage for the standings setup ahead of a planned performance refactor, locking down current behavior so the refactor PRs can be verified against a fixed baseline:
standings_parser_spec.lua—StandingsParser.parse: points accumulation, starting points, tie resolution (shared placements vs. manual tiebreaker), slot indexes, placement changes, bg statuses, definite status only on finished standings,ncstatus, standingsindex variable increment, stored tiebreaker metadatastandings_tiebreaker_spec.lua— factory normalization/contexts plus points, manual, matchdiff, buchholz (unfinished matches excluded), gamediff (walkovers excluded) and rounddiff (notplayed/no-winner games excluded), includingdisplay()outputstandings_table_merge_spec.lua—StandingsTable.mergeOpponentsData: manual data priority, imported-only data surviving the merge, add/drop of imported-only opponentsstandings_import_spec.lua—StandingsParseLpdb.importFromMatchesagainst stubbed match2 records: per-round scoreboards, cross-round match accumulation,ncfor unplayed rounds, draws, unfinished matches, matches assigned to multiple rounds, TBD dropping, both score-mapper shapesstandings_model_spec.lua— full round trip: parse →StandingsStorage.run(saveVars)→Standings.getStandingsTable→ model fields → rendered FFA and Swiss widget HTML, plusGoldenTestsnapshots (standings_ffa,standings_swiss) for the visual snapshot workflowAssertions are on observable content, never table identity, so the suite constrains behavior without blocking the upcoming refactor.
Note for reviewers: writing these surfaced one latent quirk that is deliberately locked in as current behavior (see the comment in
standings_parser_spec.lua): the parser shares a single cumulative match W/D/L table across all of an opponent's round entries, so earlier rounds store final totals and match-based tiebreakers see final totals in every round. A fix is planned as a separate PR; the test will be updated there.How did you test this change?
busted --run=cifromlua/: full suite passes (605 successes, 0 failures), including the 29 new testsluacheckwithlua/.luacheckrc: 0 warnings / 0 errors on the new files🤖 Generated with Claude Code