mirror of
https://gerrit.wikimedia.org/r/mediawiki/skins/MinervaNeue
synced 2024-12-28 05:23:05 +00:00
4ca4febd89
Resubmission of Ib68f45d93a (548e94da98
), which caused an error due
to `require('../../`)` not working outside the module base directory.
This is fixed with regression test in T373065.
Further confirmed in this repo by viewing
`/wiki/Special:CreateAccount?campaign=loginCTA&useskin=minerva`
with this patch applied. Without the T373065 fix, the console warns:
> Error: Cannot require undefined file …/ToggleList.js
-------
Support for private require() in tests is available since MW 1.41:
https://mediawiki.org/wiki/RL/PKG#Private_export_and_import
https://mediawiki.org/wiki/RL/PKG#Virtual_files_in_traditional_modules
This fixes a confusing assertion in page-issues/index.test.js,
where for "insertBannersOrNotice()" it was asserting that the HTML
contain "⧼skin-minerva-issue-learn-more⧽", where the ⧼ character
indicates the message is not found (i.e. an error).
The test had to be written this way in order to pass, because
the skins.minerva.scripts module was not actually loaded, and thus
its templates and messages are not present either. This lack was
filled in by index.js for mw.templates, but not mw.messages.
By adopting private require(), these workarounds can all be removed.
== Motivation ==
In change I3a4024ccf90e505581, I'm working on improving the testrunner
config to enforce uselang=qqx on all tests. This is passing except
for GrowthExperiments and Minerva, both of which have the above
workarounds in place that caused a message to be undefined, and then
kept in the assertion expectation. When using uselang=qqx, values are
returned as (key) instead of ⧼key⧽, which exposes these message
existence errors.
By removing this workaround, the test will simply import the module
in the test as normal, thus the messages will exist, and thus it
will expect (key), and thus it will continue to pass even after
enforcing uselang=qqx.
Bug: T373482
Depends-On: I777f2c12e845a738edeac00e19818d4c939a1ef1
Change-Id: I6348e5ae00776c2c01d91fa90a431b6ffe3da25d
36 lines
1.3 KiB
JavaScript
36 lines
1.3 KiB
JavaScript
QUnit.module( 'Minerva pageIssues', () => {
|
|
const mobile = require( 'mobile.startup' );
|
|
const pageIssues = require( 'skins.minerva.scripts/page-issues/index.js' );
|
|
const insertBannersOrNotice = pageIssues.test.insertBannersOrNotice;
|
|
const PageHTMLParser = mobile.PageHTMLParser;
|
|
const overlayManager = mobile.getOverlayManager();
|
|
const $mockContainer = $(
|
|
'<div id="bodyContent">' +
|
|
'<table class="ambox ambox-content">' +
|
|
'<tbody class="mbox-text">' +
|
|
'<tr><td><span class="mbox-text-span"> ambox text span </span></td></tr>' +
|
|
'</tbody>' +
|
|
'</table>' +
|
|
'</div>'
|
|
);
|
|
const labelText = 'label text';
|
|
const inline = true;
|
|
const SECTION = '0';
|
|
const processedAmbox = insertBannersOrNotice(
|
|
new PageHTMLParser( $mockContainer ),
|
|
labelText, SECTION, inline, overlayManager
|
|
).ambox;
|
|
|
|
QUnit.test( 'insertBannersOrNotice() should add a "learn more" message', ( assert ) => {
|
|
assert.true( /(skin-minerva-issue-learn-more)/.test( processedAmbox.html() ) );
|
|
} );
|
|
|
|
QUnit.test( 'insertBannersOrNotice() should add an icon', ( assert ) => {
|
|
assert.true( /(minerva-icon)/.test( processedAmbox.html() ) );
|
|
} );
|
|
QUnit.test( 'clicking on the product of insertBannersOrNotice() should trigger a URL change', ( assert ) => {
|
|
processedAmbox.click();
|
|
assert.strictEqual( window.location.hash, '#/issues/' + SECTION );
|
|
} );
|
|
} );
|