Skip to content

test: add integration tests for standings#7647

Open
Rathoz wants to merge 2 commits into
mainfrom
standings-tests-ai
Open

test: add integration tests for standings#7647
Rathoz wants to merge 2 commits into
mainfrom
standings-tests-ai

Conversation

@Rathoz

@Rathoz Rathoz commented Jun 12, 2026

Copy link
Copy Markdown
Collaborator

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.luaStandingsParser.parse: points accumulation, starting points, tie resolution (shared placements vs. manual tiebreaker), slot indexes, placement changes, bg statuses, definite status only on finished standings, nc status, standingsindex variable increment, stored tiebreaker metadata
  • standings_tiebreaker_spec.lua — factory normalization/contexts plus points, manual, matchdiff, buchholz (unfinished matches excluded), gamediff (walkovers excluded) and rounddiff (notplayed/no-winner games excluded), including display() output
  • standings_table_merge_spec.luaStandingsTable.mergeOpponentsData: manual data priority, imported-only data surviving the merge, add/drop of imported-only opponents
  • standings_import_spec.luaStandingsParseLpdb.importFromMatches against stubbed match2 records: per-round scoreboards, cross-round match accumulation, nc for unplayed rounds, draws, unfinished matches, matches assigned to multiple rounds, TBD dropping, both score-mapper shapes
  • standings_model_spec.lua — full round trip: parse → StandingsStorage.run(saveVars)Standings.getStandingsTable → model fields → rendered FFA and Swiss widget HTML, plus GoldenTest snapshots (standings_ffa, standings_swiss) for the visual snapshot workflow

Assertions 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=ci from lua/: full suite passes (605 successes, 0 failures), including the 29 new tests
  • luacheck with lua/.luacheckrc: 0 warnings / 0 errors on the new files
  • Test-only change: no modules touched, so no LPDB or page-variable impact on any wiki

🤖 Generated with Claude Code

Copilot AI review requested due to automatic review settings June 12, 2026 13:54
@Rathoz Rathoz requested review from a team as code owners June 12, 2026 13:54

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 thread lua/spec/standings_parser_spec.lua
Comment thread lua/spec/standings_model_spec.lua
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
Comment thread lua/spec/standings_model_spec.lua
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants