Skip to content

Commit

Permalink
test(match2): brkts/wikispec always uses commons (#5161)
Browse files Browse the repository at this point in the history
* fix test handling

* actual fix the issue in the test

* make moduleExists work in busted

* fix rl

* fix sc2

* Update components/infobox/wikis/rocketleague/infobox_league_custom.lua

Co-authored-by: hjpalpha <[email protected]>

---------

Co-authored-by: hjpalpha <[email protected]>
  • Loading branch information
Rathoz and hjpalpha authored Dec 3, 2024
1 parent 08fd0c1 commit 5407e44
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,11 @@ end
---@param args table
---@return table
function CustomLeague:getWikiCategories(args)
return {Game.name{game = args.game} .. ' Competitions'}
local gameName = Game.name{game = args.game}
if not gameName then
return {'Competitions'}
end
return {gameName .. ' Competitions'}
end

---@param args table
Expand Down
1 change: 1 addition & 0 deletions definitions/mw.lua
Original file line number Diff line number Diff line change
Expand Up @@ -948,6 +948,7 @@ function mw.ustring.upper(s) return string.upper(s) end

mw.uri = {}
function mw.uri.localUrl(s, s2) return '' end
function mw.uri.fullUrl(s, s2) return 'https://liquipedia.net/' end

mw.ext = {}
mw.ext.LiquipediaDB = require('definitions.liquipedia_db')
Expand Down
2 changes: 1 addition & 1 deletion spec/golden_masters/match2_matchlist_smoke_starcraft2.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<div class="brkts-matchlist brkts-matchlist-collapsible" style="width:300px"><div class="brkts-matchlist-title" style="overflow-wrap:break-word;white-space:normal">Match List</div><div class="brkts-matchlist-match brkts-match-has-details brkts-match-popup-wrapper"><div class="brkts-matchlist-cell brkts-matchlist-opponent brkts-matchlist-slot-winner brkts-opponent-hover" aria-label="abc"><div class="block-players-wrapper brkts-matchlist-cell-content"><div class="block-player starcraft-block-player flipped"><span class="name" style="overflow:hidden;text-overflow:ellipsis;white-space:pre">A</span></div></div></div><div class="brkts-matchlist-cell brkts-matchlist-score brkts-matchlist-slot-bold brkts-opponent-hover" aria-label="abc"><div class="brkts-matchlist-cell-content">3</div></div><div class="brkts-match-info-icon"></div><div class="brkts-matchlist-cell brkts-matchlist-score brkts-opponent-hover" aria-label="B"><div class="brkts-matchlist-cell-content">2</div></div><div class="brkts-matchlist-cell brkts-matchlist-opponent brkts-opponent-hover" aria-label="B"><div class="block-players-wrapper brkts-matchlist-cell-content"><div class="block-player starcraft-block-player"><span class="name" style="overflow:hidden;text-overflow:ellipsis;white-space:pre">B</span></div></div></div><div class="brkts-popup brkts-popup-sc brkts-match-info-popup"><div class="brkts-popup-header-dev" style="justify-content:center"><div class="brkts-popup-header-opponent brkts-popup-header-opponent-left"><div class="block-players-wrapper"><div class="block-player starcraft-block-player flipped"><span class="name" style="overflow:hidden;text-overflow:ellipsis;white-space:pre">[[abc|A]]</span></div></div><div class="brkts-popup-header-opponent-score-left"><b>3</b></div></div><div class="brkts-popup-header-opponent brkts-popup-header-opponent-right"><div class="brkts-popup-header-opponent-score-right">2</div><div class="block-players-wrapper"><div class="block-player starcraft-block-player"><span class="name" style="overflow:hidden;text-overflow:ellipsis;white-space:pre">[[B|B]]</span></div></div></div></div><div class="brkts-popup-break"></div><div class="brkts-popup-body"></div><div class="brkts-popup-break"></div><div class="brkts-popup-comment" style="font-size:85%;white-space:normal">A Match Comment<div class="brkts-popup-break"></div></div><div class="brkts-popup-break"></div></div></div></div>
<div class="brkts-matchlist brkts-matchlist-collapsible" style="width:300px"><div class="brkts-matchlist-title" style="overflow-wrap:break-word;white-space:normal">Match List</div><div class="brkts-matchlist-match brkts-match-has-details brkts-match-popup-wrapper"><div class="brkts-matchlist-cell brkts-matchlist-opponent brkts-matchlist-slot-winner brkts-opponent-hover" aria-label="abc"><div class="block-player starcraft-block-player flipped brkts-matchlist-cell-content"><span class="name" style="overflow:hidden;text-overflow:ellipsis;white-space:pre">A</span></div></div><div class="brkts-matchlist-cell brkts-matchlist-score brkts-matchlist-slot-bold brkts-opponent-hover" aria-label="abc"><div class="brkts-matchlist-cell-content">3</div></div><div class="brkts-match-info-icon"></div><div class="brkts-matchlist-cell brkts-matchlist-score brkts-opponent-hover" aria-label="B"><div class="brkts-matchlist-cell-content">2</div></div><div class="brkts-matchlist-cell brkts-matchlist-opponent brkts-opponent-hover" aria-label="B"><div class="block-player starcraft-block-player brkts-matchlist-cell-content"><span class="name" style="overflow:hidden;text-overflow:ellipsis;white-space:pre">B</span></div></div><div class="brkts-popup brkts-popup-sc brkts-match-info-popup"><div class="brkts-popup-header-dev" style="justify-content:center"><div class="brkts-popup-header-opponent brkts-popup-header-opponent-left"><div class="block-player starcraft-block-player flipped"><span class="name" style="overflow:hidden;text-overflow:ellipsis;white-space:pre">[[abc|A]]</span></div><div class="brkts-popup-header-opponent-score-left"><b>3</b></div></div><div class="brkts-popup-header-opponent brkts-popup-header-opponent-right"><div class="brkts-popup-header-opponent-score-right">2</div><div class="block-player starcraft-block-player"><span class="name" style="overflow:hidden;text-overflow:ellipsis;white-space:pre">[[B|B]]</span></div></div></div><div class="brkts-popup-break"></div><div class="brkts-popup-body"></div><div class="brkts-popup-break"></div><div class="brkts-popup-comment" style="font-size:85%;white-space:normal">A Match Comment<div class="brkts-popup-break"></div></div><div class="brkts-popup-break"></div><div class="brkts-popup-footer"><div class="brkts-popup-spaced vodlink">[[File:Match Info Stats.png|link=https://liquipedia.net/?pfRunQueryFormName=Match+history&Head_to_head_query%5Bplayer%5D=abc&Head_to_head_query%5Bopponent%5D=B&wpRunQuery=Run+query|32px|Head-to-head statistics|alt=https://liquipedia.net/?pfRunQueryFormName=Match+history&Head_to_head_query%5Bplayer%5D=abc&Head_to_head_query%5Bopponent%5D=B&wpRunQuery=Run+query]]</div></div></div></div></div>
6 changes: 3 additions & 3 deletions spec/match2_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
describe('match2', function()
local tournamentData = require('test_assets.tournaments').dummy
insulate('matchlist', function()
local InfoboxLeague = require('Module:Infobox/League/Custom')
local Json = require('Module:Json')

before_each(function ()
local dataSaved, dataSavedOpponent, dataSavedPlayer, dataSavedGame = {}, {}, {}, {}
-- Mock the lpdb functions
Expand Down Expand Up @@ -40,7 +38,6 @@ describe('match2', function()
end)

stub(mw.ext.LiquipediaDB, 'lpdb_tournament')
InfoboxLeague.run(tournamentData) -- Set variable for tournament context
end)

after_each(function ()
Expand All @@ -60,6 +57,9 @@ describe('match2', function()
if Info.config.match2.status == 0 then
return
end
local InfoboxLeague = require('Module:Infobox/League/Custom')
InfoboxLeague.run(tournamentData) -- Set variable for tournament context

local MatchGroup = require('Module:MatchGroup')
local Match = require('Module:Match')
local props = require('Module:Table').deepCopy(args)
Expand Down
3 changes: 3 additions & 0 deletions spec/test_helper.lua
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,9 @@ return function(busted, helper, options)
end
local stub = require('luassert.stub')
stub(require('Module:Lua'), 'requireIfExists', attemptImport)
stub(require('Module:Lua'), 'moduleExists', function(file)
return attemptImport(file) ~= nil
end)
end

busted.subscribe({'suite', 'start'}, setupForTesting)
Expand Down

0 comments on commit 5407e44

Please sign in to comment.