2018-07-30 14:35:54 +00:00
|
|
|
( function ( M ) {
|
2018-08-29 09:45:04 +00:00
|
|
|
var pageIssues = M.require( 'skins.minerva.scripts/pageIssues' ),
|
2018-08-29 12:59:37 +00:00
|
|
|
util = M.require( 'mobile.startup/util' ),
|
2018-08-29 09:45:04 +00:00
|
|
|
createBanner = pageIssues.test.createBanner,
|
2018-10-16 22:46:28 +00:00
|
|
|
icon = {},
|
2018-08-29 09:45:04 +00:00
|
|
|
MEDIUM_ISSUE = {
|
2018-10-16 22:46:28 +00:00
|
|
|
issue: {
|
|
|
|
severity: 'MEDIUM',
|
|
|
|
icon: icon
|
|
|
|
},
|
|
|
|
iconString: 'i',
|
2018-08-29 09:45:04 +00:00
|
|
|
text: 't'
|
|
|
|
},
|
|
|
|
LOW_ISSUE = {
|
2018-10-16 22:46:28 +00:00
|
|
|
issue: {
|
|
|
|
severity: 'LOW',
|
|
|
|
icon: icon
|
|
|
|
},
|
|
|
|
iconString: 'i',
|
2018-08-29 09:45:04 +00:00
|
|
|
text: 't'
|
|
|
|
},
|
|
|
|
HIGH_ISSUE = {
|
2018-10-16 22:46:28 +00:00
|
|
|
issue: {
|
|
|
|
severity: 'HIGH',
|
|
|
|
icon: icon
|
|
|
|
},
|
|
|
|
iconString: 'i',
|
2018-08-29 09:45:04 +00:00
|
|
|
text: 't'
|
|
|
|
},
|
|
|
|
getAllIssuesSections = pageIssues.test.getAllIssuesSections,
|
2018-07-30 14:35:54 +00:00
|
|
|
OverlayManager = M.require( 'mobile.startup/OverlayManager' ),
|
2018-07-26 10:13:33 +00:00
|
|
|
Page = M.require( 'mobile.startup/Page' ),
|
2018-07-30 14:35:54 +00:00
|
|
|
overlayManager = new OverlayManager( require( 'mediawiki.router' ) ),
|
|
|
|
$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>'
|
|
|
|
),
|
|
|
|
labelText = 'label text',
|
|
|
|
inline = true,
|
2018-09-12 21:04:18 +00:00
|
|
|
SECTION = '0',
|
2018-07-26 10:13:33 +00:00
|
|
|
processedAmbox = createBanner(
|
|
|
|
new Page( { el: $mockContainer } ),
|
2018-09-12 21:04:18 +00:00
|
|
|
labelText, SECTION, inline, overlayManager
|
2018-07-26 10:13:33 +00:00
|
|
|
);
|
2018-07-30 14:35:54 +00:00
|
|
|
|
|
|
|
QUnit.module( 'Minerva cleanuptemplates' );
|
|
|
|
|
|
|
|
QUnit.test( 'createBanner() should add a "learn more" message', function ( assert ) {
|
|
|
|
assert.strictEqual( /⧼skin-minerva-issue-learn-more⧽/.test( processedAmbox.html() ), true );
|
|
|
|
} );
|
|
|
|
|
|
|
|
QUnit.test( 'createBanner() should add an icon', function ( assert ) {
|
|
|
|
assert.strictEqual( /mw-ui-icon/.test( processedAmbox.html() ), true );
|
|
|
|
} );
|
|
|
|
QUnit.test( 'clicking on the product of createBanner() should trigger a URL change', function ( assert ) {
|
|
|
|
processedAmbox.click();
|
2018-09-12 21:04:18 +00:00
|
|
|
assert.strictEqual( window.location.hash, '#/issues/' + SECTION );
|
2018-07-30 14:35:54 +00:00
|
|
|
} );
|
|
|
|
|
2018-08-29 09:45:04 +00:00
|
|
|
QUnit.test( 'getAllIssuesSections', function ( assert ) {
|
2018-08-29 12:59:37 +00:00
|
|
|
var multipleIssuesWithDeletion,
|
|
|
|
multipleIssues, allIssuesOldTreatment, allIssuesNewTreatment;
|
2018-08-29 09:45:04 +00:00
|
|
|
allIssuesOldTreatment = {
|
|
|
|
0: [
|
|
|
|
MEDIUM_ISSUE,
|
|
|
|
LOW_ISSUE,
|
|
|
|
MEDIUM_ISSUE
|
|
|
|
]
|
|
|
|
};
|
2018-08-29 12:59:37 +00:00
|
|
|
multipleIssues = {
|
|
|
|
0: [
|
2018-10-16 22:46:28 +00:00
|
|
|
util.extend( {}, MEDIUM_ISSUE, { grouped: true } ),
|
|
|
|
util.extend( {}, LOW_ISSUE, { grouped: true } ),
|
|
|
|
util.extend( {}, MEDIUM_ISSUE, { grouped: true } )
|
2018-08-29 12:59:37 +00:00
|
|
|
]
|
|
|
|
};
|
|
|
|
multipleIssuesWithDeletion = {
|
|
|
|
0: [
|
|
|
|
HIGH_ISSUE,
|
2018-10-16 22:46:28 +00:00
|
|
|
util.extend( {}, MEDIUM_ISSUE, { grouped: true } ),
|
|
|
|
util.extend( {}, LOW_ISSUE, { grouped: true } ),
|
|
|
|
util.extend( {}, MEDIUM_ISSUE, { grouped: true } )
|
2018-08-29 12:59:37 +00:00
|
|
|
]
|
|
|
|
};
|
2018-08-29 09:45:04 +00:00
|
|
|
allIssuesNewTreatment = {
|
|
|
|
0: [
|
|
|
|
HIGH_ISSUE,
|
|
|
|
LOW_ISSUE,
|
|
|
|
MEDIUM_ISSUE
|
|
|
|
],
|
|
|
|
1: [
|
|
|
|
MEDIUM_ISSUE
|
|
|
|
]
|
|
|
|
};
|
|
|
|
assert.deepEqual(
|
|
|
|
getAllIssuesSections( allIssuesOldTreatment ),
|
|
|
|
[ '0', '0', '0' ],
|
|
|
|
'section numbers correctly extracted from old treatment'
|
|
|
|
);
|
|
|
|
assert.deepEqual(
|
|
|
|
getAllIssuesSections( allIssuesNewTreatment ),
|
|
|
|
[ '0', '0', '0', '1' ],
|
|
|
|
'section numbers correctly extracted from new treatment'
|
|
|
|
);
|
2018-08-29 12:59:37 +00:00
|
|
|
assert.deepEqual(
|
|
|
|
getAllIssuesSections( multipleIssues ),
|
|
|
|
[ '0' ],
|
|
|
|
'multiple issues are packed into one entry since there is one box'
|
|
|
|
);
|
|
|
|
assert.deepEqual(
|
|
|
|
getAllIssuesSections( multipleIssuesWithDeletion ),
|
|
|
|
[ '0', '0' ],
|
|
|
|
'while multiple issues are grouped, non-multiple issues are still reported'
|
|
|
|
);
|
2018-08-29 09:45:04 +00:00
|
|
|
} );
|
2018-07-30 14:35:54 +00:00
|
|
|
}( mw.mobileFrontend ) );
|