Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lua/snapshot.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const PIXELMATCH_OPTIONS = { threshold: 0.1 };
args: ['--disable-web-security']
});
const page = await browser.newPage({ viewport: VIEWPORT });
await page.goto(`file://${htmlPath}`);
await page.goto(`file://${htmlPath}`, {waitUntil: "networkidle"});
const newScreenshotBuffer = await page.screenshot({ animations: 'disabled' });
await browser.close();

Expand Down
6 changes: 4 additions & 2 deletions lua/spec/helpers/test_helper.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ function allwikis(name, funcToRun, wikiArgs) error('SOMETHING WENT WRONG') end

--- @param testname string
--- @param actual string
function GoldenTest(testname, actual) error('SOMETHING WENT WRONG') end
--- @param extraHTML string?
function GoldenTest(testname, actual, extraHTML) error('SOMETHING WENT WRONG') end

return function(busted, helper, options)
-- Copy from commons/lua.lua
Expand Down Expand Up @@ -145,13 +146,14 @@ return function(busted, helper, options)
return text
end

local function GoldenTest(testName, actual)
local function GoldenTest(testName, actual, extraHTML)
-- Currently we're only running snapshots tests while updating them too
if os.getenv('UPDATE_SNAPSHOTS') ~= 'true' then
return
end

local generatedHtml = simpleMediaWikiParser(tostring(actual))
.. (extraHTML or '')

local template = readFile('spec/helpers/template.html')
assert(template, 'Could not read template.html')
Expand Down
Binary file modified lua/spec/snapshots/team_participant.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
95 changes: 58 additions & 37 deletions lua/spec/team_participant_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,46 +8,67 @@ insulate('Team Participant', function()

local TeamParticipantsController = require('Module:TeamParticipants/Controller')

GoldenTest('team_participant', tostring(TeamParticipantsController.fromTemplate{
{
'Team Liquid',
players = {
{'alexis'},
{'dodonut'},
{'meL'},
{'Noia'},
{'sarah'},
{'effys', role = 'Head Coach', type = 'staff'},
{'Veer', role = 'Coach', type = 'staff'},
GoldenTest('team_participant',
tostring(TeamParticipantsController.fromTemplate{
{
'Team Liquid',
players = {
{'alexis'},
{'dodonut'},
{'meL'},
{'Noia'},
{'sarah'},
{'effys', role = 'Head Coach', type = 'staff'},
{'Veer', role = 'Coach', type = 'staff'},
},
qualification = {
method = 'qual',
url = 'https://google.com',
text = 'FooBar',
},
notes = {
{'SOME TEXT HERE'},
}
},
qualification = {
method = 'qual',
url = 'https://google.com',
text = 'FooBar',
{
'bds',
qualification = {
method = 'invite',
text = 'Invited',
},
players = {
{'ElectricalBoy'},
{'hjpalpha'},
{'Eetu'},
{'SyntacticSugar'},
{'SyntacticSalt'},
{'Rathoz', role = 'Coach', type = 'staff'},
},
notes = {
{'Best Team in the World!', highlighted = true},
}
},
notes = {
{'SOME TEXT HERE'},
}
},
{
'bds',
qualification = {
method = 'invite',
text = 'Invited',
{
'mouz',
qualification = {
method = 'invite',
page = 'Testpage',
text = 'Invited',
},
players = {},
},
players = {
{'ElectricalBoy'},
{'hjpalpha'},
{'Eetu'},
{'SyntacticSugar'},
{'SyntacticSalt'},
{'Rathoz', role = 'Coach', type = 'staff'},
},
notes = {
{'Best Team in the World!', highlighted = true},
}
},
}))
}),
[[<script>
$(document).ready(function() {
var timer = setInterval(function(){
if (window.liquipedia?.switchButtons?.switchGroups) {
liquipedia.switchButtons.switchGroups["team-cards-show-rosters"].nodes[0].click();
clearInterval(timer);
}
}, 50)
});
</script>]]
)

LpdbQuery:revert()
LpdbPlacementStore:revert()
Expand Down