From 5407e446b88bf1e505843af07f09de293fcb5600 Mon Sep 17 00:00:00 2001 From: Rikard Blixt <rikardblixt@gmail.com> Date: Tue, 3 Dec 2024 11:46:43 +0100 Subject: [PATCH] test(match2): brkts/wikispec always uses commons (#5161) * 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 <75081997+hjpalpha@users.noreply.github.com> --------- Co-authored-by: hjpalpha <75081997+hjpalpha@users.noreply.github.com> --- .../infobox/wikis/rocketleague/infobox_league_custom.lua | 6 +++++- definitions/mw.lua | 1 + spec/golden_masters/match2_matchlist_smoke_starcraft2.txt | 2 +- spec/match2_spec.lua | 6 +++--- spec/test_helper.lua | 3 +++ 5 files changed, 13 insertions(+), 5 deletions(-) diff --git a/components/infobox/wikis/rocketleague/infobox_league_custom.lua b/components/infobox/wikis/rocketleague/infobox_league_custom.lua index f1a7c3e0074..62f5acf1ce6 100644 --- a/components/infobox/wikis/rocketleague/infobox_league_custom.lua +++ b/components/infobox/wikis/rocketleague/infobox_league_custom.lua @@ -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 diff --git a/definitions/mw.lua b/definitions/mw.lua index 1d02a7e5c92..df457dc2d0c 100644 --- a/definitions/mw.lua +++ b/definitions/mw.lua @@ -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') diff --git a/spec/golden_masters/match2_matchlist_smoke_starcraft2.txt b/spec/golden_masters/match2_matchlist_smoke_starcraft2.txt index 938a11ce137..a8ae0401ddd 100644 --- a/spec/golden_masters/match2_matchlist_smoke_starcraft2.txt +++ b/spec/golden_masters/match2_matchlist_smoke_starcraft2.txt @@ -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> \ No newline at end of file +<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> \ No newline at end of file diff --git a/spec/match2_spec.lua b/spec/match2_spec.lua index b2da7a37253..41a7b862fdd 100644 --- a/spec/match2_spec.lua +++ b/spec/match2_spec.lua @@ -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 @@ -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 () @@ -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) diff --git a/spec/test_helper.lua b/spec/test_helper.lua index f4a03eac99e..464e38b69c4 100644 --- a/spec/test_helper.lua +++ b/spec/test_helper.lua @@ -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)