mirror of
https://gerrit.wikimedia.org/r/mediawiki/skins/MinervaNeue
synced 2024-12-18 16:51:05 +00:00
c0f08790ea
Note: this agitates T230232 again - when merging this please make sure a merge for I929090848f3e04647a97f4979ec78682623fa070 is pending. In various places we try to override the default mw-ui-icon behaviours The hacks need to be removed as part of addressing the core problem. Changes: * Wherever we use mw-ui-icon-before in PHP - wrap the label with a span so that label font-size is altered where needed - not the icon * Where a small icon is needed us isSmall parameter for the Icon component * Apply font-size to labels of mw-ui-icon-before elements * The browser tests need a slight update to access the span element inside a menu item - in the case of the logout button the label is always hidden, so we need to check the visibility of the parent element (secondary_action) Bug: T229440 Depends-On: I3f803ec4c9068b30aa93b803391aa4d65d8310ff Change-Id: I07e4ae233979636b739f1117dd7703571e0a9366
190 lines
5.4 KiB
JavaScript
190 lines
5.4 KiB
JavaScript
( function () {
|
|
var icon = {},
|
|
pageIssuesParser = require( '../../../../resources/skins.minerva.scripts/page-issues/parser.js' ),
|
|
extractMessage = pageIssuesParser.extract;
|
|
|
|
QUnit.module( 'Minerva pageIssuesParser' );
|
|
|
|
/**
|
|
* @param {string} className
|
|
* @return {Element}
|
|
*/
|
|
function newBox( className ) {
|
|
var box = document.createElement( 'div' );
|
|
box.className = className;
|
|
return box;
|
|
}
|
|
|
|
QUnit.test( 'extractMessage', function () {
|
|
[
|
|
[
|
|
$( '<div />' ).html(
|
|
'<div class="mbox-text">Smelly</div>'
|
|
).appendTo( '<div class="mw-collapsible-content" />' ),
|
|
{
|
|
issue: {
|
|
severity: 'DEFAULT',
|
|
grouped: true,
|
|
icon: icon
|
|
},
|
|
text: '<p>Smelly</p>'
|
|
},
|
|
'When the box is a child of mw-collapsible-content it grouped'
|
|
],
|
|
[
|
|
$( '<div />' ).html(
|
|
'<div class="mbox-text">Dirty</div>'
|
|
),
|
|
{
|
|
issue: {
|
|
severity: 'DEFAULT',
|
|
grouped: false,
|
|
icon: icon
|
|
},
|
|
text: '<p>Dirty</p>'
|
|
},
|
|
'When the box is not child of mw-collapsible-content it !grouped'
|
|
]
|
|
].forEach( function ( test ) {
|
|
sinon.assert.match( // eslint-disable-line no-undef
|
|
extractMessage( test[ 0 ] ),
|
|
test[ 1 ],
|
|
test[ 2 ]
|
|
);
|
|
} );
|
|
} );
|
|
|
|
QUnit.test( 'parseSeverity', function ( assert ) {
|
|
var tests = [
|
|
[ '', 'DEFAULT', 'empty' ],
|
|
[ 'foo', 'DEFAULT', 'unknown' ],
|
|
[ 'ambox-style', 'LOW', 'style' ],
|
|
[ 'ambox-content', 'MEDIUM', 'content' ],
|
|
[ 'ambox-speedy', 'HIGH', 'speedy' ],
|
|
[ 'ambox-delete', 'HIGH', 'delete' ],
|
|
// Move has an "unknown" severity and falls into DEFAULT.
|
|
[ 'ambox-move', 'DEFAULT', 'move' ],
|
|
// Point of view uses ambox-content to identify correct severity.
|
|
[ 'ambox-content ambox-POV', 'MEDIUM', 'point of view' ]
|
|
// Mixed severities such as 'ambox-style ambox-content' are not prioritized.
|
|
];
|
|
tests.forEach( function ( params, i ) {
|
|
var
|
|
className = params[ 0 ],
|
|
expect = params[ 1 ],
|
|
test = params[ 2 ],
|
|
box = newBox( className );
|
|
assert.strictEqual(
|
|
pageIssuesParser.test.parseSeverity( box ),
|
|
expect,
|
|
'Result should be the correct severity; case ' + i + ': ' + test + '.'
|
|
);
|
|
} );
|
|
} );
|
|
|
|
QUnit.test( 'parseType', function ( assert ) {
|
|
var tests = [
|
|
[ '', 'DEFAULT', 'issue-generic', 'empty' ],
|
|
[ 'foo', 'DEFAULT', 'issue-generic', 'unknown' ],
|
|
[ 'ambox-move', 'DEFAULT', 'issue-type-move', 'move' ],
|
|
[ 'ambox-POV', 'MEDIUM', 'issue-type-point-of-view', 'point of view' ],
|
|
[ '', 'DEFAULT', 'issue-generic', 'Default severity' ],
|
|
[ '', 'LOW', 'issue-severity-low', 'Low severity' ],
|
|
[ '', 'MEDIUM', 'issue-severity-medium', 'Medium severity' ],
|
|
[ '', 'HIGH', 'issue-generic', 'HIGH severity' ]
|
|
];
|
|
tests.forEach( function ( params, i ) {
|
|
var
|
|
className = params[ 0 ],
|
|
severity = params[ 1 ],
|
|
expect = {
|
|
name: params[ 2 ],
|
|
severity: severity
|
|
},
|
|
test = params[ 3 ],
|
|
box = newBox( className );
|
|
assert.propEqual(
|
|
pageIssuesParser.test.parseType( box, severity ),
|
|
expect,
|
|
'Result should be the correct icon type; case ' + i + ': ' + test + '.'
|
|
);
|
|
} );
|
|
} );
|
|
|
|
QUnit.test( 'parseGroup', function ( assert ) {
|
|
var tests = [
|
|
[ undefined, false, 'orphaned' ],
|
|
[ '', false, 'ungrouped' ],
|
|
[ 'mw-collapsible-content', true, 'grouped' ]
|
|
];
|
|
tests.forEach( function ( params, i ) {
|
|
var
|
|
parentClassName = params[ 0 ],
|
|
expect = params[ 1 ],
|
|
test = params[ 2 ],
|
|
parent,
|
|
box = newBox( '' );
|
|
if ( parentClassName !== undefined ) {
|
|
parent = document.createElement( 'div' );
|
|
parent.className = parentClassName;
|
|
parent.appendChild( box );
|
|
}
|
|
assert.strictEqual(
|
|
pageIssuesParser.test.parseGroup( box ),
|
|
expect,
|
|
'Result should be the correct grouping; case ' + i + ': ' + test + '.'
|
|
);
|
|
} );
|
|
} );
|
|
|
|
QUnit.test( 'iconName', function ( assert ) {
|
|
var tests = [
|
|
[ '', 'DEFAULT', 'issue-generic-defaultColor' ],
|
|
[ '', 'LOW', 'issue-severity-low-lowColor' ],
|
|
[ '', 'MEDIUM', 'issue-severity-medium-mediumColor' ],
|
|
[ '', 'HIGH', 'issue-generic-highColor' ],
|
|
[ 'ambox-move', 'DEFAULT', 'issue-type-move-defaultColor' ],
|
|
[ 'ambox-POV', 'MEDIUM', 'issue-type-point-of-view-mediumColor' ],
|
|
// ResourceLoader only supplies color variants for the generic type. Ensure impossible
|
|
// combinations are forbidden.
|
|
[ 'ambox-style ambox-POV', 'LOW', 'issue-type-point-of-view-mediumColor' ],
|
|
[ 'ambox-content ambox-move', 'MEDIUM', 'issue-type-move-defaultColor' ]
|
|
];
|
|
tests.forEach( function ( params, i ) {
|
|
var
|
|
className = params[ 0 ],
|
|
severity = params[ 1 ],
|
|
expect = params[ 2 ],
|
|
box = newBox( className );
|
|
assert.strictEqual(
|
|
pageIssuesParser.iconName( box, severity ),
|
|
expect,
|
|
'Result should be the correct ResourceLoader icon name; case ' + i + ': ' + severity + '.'
|
|
);
|
|
} );
|
|
} );
|
|
|
|
QUnit.test( 'maxSeverity', function ( assert ) {
|
|
var tests = [
|
|
[ [], 'DEFAULT' ],
|
|
[ [ 'DEFAULT' ], 'DEFAULT' ],
|
|
[ [ 'DEFAULT', 'LOW' ], 'LOW' ],
|
|
[ [ 'DEFAULT', 'LOW', 'MEDIUM' ], 'MEDIUM' ],
|
|
[ [ 'DEFAULT', 'LOW', 'MEDIUM', 'HIGH' ], 'HIGH' ],
|
|
[ [ 'HIGH', 'DEFAULT', 'LOW', 'MEDIUM' ], 'HIGH' ],
|
|
[ [ 'DEFAULT', 'HIGH', 'LOW', 'MEDIUM' ], 'HIGH' ]
|
|
];
|
|
tests.forEach( function ( params, i ) {
|
|
var severities = params[ 0 ],
|
|
expect = params[ 1 ];
|
|
|
|
assert.strictEqual(
|
|
pageIssuesParser.maxSeverity( severities ),
|
|
expect,
|
|
'Result should be the highest severity in the array; case ' + i + '.'
|
|
);
|
|
} );
|
|
} );
|
|
|
|
}() );
|