2018-07-30 14:35:54 +00:00
|
|
|
( function ( M ) {
|
2019-02-07 16:34:18 +00:00
|
|
|
var
|
|
|
|
pageIssues = M.require( 'skins.minerva.scripts/pageIssues' ),
|
|
|
|
mobile = M.require( 'mobile.startup' ),
|
|
|
|
util = mobile.util,
|
2019-01-23 20:16:11 +00:00
|
|
|
insertBannersOrNotice = pageIssues.test.insertBannersOrNotice,
|
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,
|
2019-02-07 16:34:18 +00:00
|
|
|
OverlayManager = mobile.OverlayManager,
|
|
|
|
Page = mobile.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',
|
2019-01-23 20:16:11 +00:00
|
|
|
processedAmbox = insertBannersOrNotice(
|
2018-07-26 10:13:33 +00:00
|
|
|
new Page( { el: $mockContainer } ),
|
2018-09-12 21:04:18 +00:00
|
|
|
labelText, SECTION, inline, overlayManager
|
2019-02-04 16:22:09 +00:00
|
|
|
).ambox;
|
2018-07-30 14:35:54 +00:00
|
|
|
|
|
|
|
QUnit.module( 'Minerva cleanuptemplates' );
|
|
|
|
|
2019-01-23 20:16:11 +00:00
|
|
|
QUnit.test( 'insertBannersOrNotice() should add a "learn more" message', function ( assert ) {
|
2018-07-30 14:35:54 +00:00
|
|
|
assert.strictEqual( /⧼skin-minerva-issue-learn-more⧽/.test( processedAmbox.html() ), true );
|
|
|
|
} );
|
|
|
|
|
2019-01-23 20:16:11 +00:00
|
|
|
QUnit.test( 'insertBannersOrNotice() should add an icon', function ( assert ) {
|
2018-07-30 14:35:54 +00:00
|
|
|
assert.strictEqual( /mw-ui-icon/.test( processedAmbox.html() ), true );
|
|
|
|
} );
|
2019-01-23 20:16:11 +00:00
|
|
|
QUnit.test( 'clicking on the product of insertBannersOrNotice() should trigger a URL change', function ( assert ) {
|
2018-07-30 14:35:54 +00:00
|
|
|
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
|
|
|
|
]
|
|
|
|
};
|
2019-02-07 17:54:56 +00:00
|
|
|
assert.propEqual(
|
2018-08-29 09:45:04 +00:00
|
|
|
getAllIssuesSections( allIssuesOldTreatment ),
|
|
|
|
[ '0', '0', '0' ],
|
|
|
|
'section numbers correctly extracted from old treatment'
|
|
|
|
);
|
2019-02-07 17:54:56 +00:00
|
|
|
assert.propEqual(
|
2018-08-29 09:45:04 +00:00
|
|
|
getAllIssuesSections( allIssuesNewTreatment ),
|
|
|
|
[ '0', '0', '0', '1' ],
|
|
|
|
'section numbers correctly extracted from new treatment'
|
|
|
|
);
|
2019-02-07 17:54:56 +00:00
|
|
|
assert.propEqual(
|
2018-08-29 12:59:37 +00:00
|
|
|
getAllIssuesSections( multipleIssues ),
|
|
|
|
[ '0' ],
|
|
|
|
'multiple issues are packed into one entry since there is one box'
|
|
|
|
);
|
2019-02-07 17:54:56 +00:00
|
|
|
assert.propEqual(
|
2018-08-29 12:59:37 +00:00
|
|
|
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 ) );
|