mirror of
https://gerrit.wikimedia.org/r/mediawiki/skins/MinervaNeue
synced 2024-11-17 19:21:39 +00:00
f67c410859
Uses `mw.trackSubscribe` to create an intermediary data handler named `wikimedia.PageIssuesAB` which extends event-logging data before passing it to the eventLogging through `wikimedia.event.PageIssues`. Event hooks are placed where appropriate and the `CleanupOverlay` class is extended to capture events from within the page issues modal. Additional changes: * Merge two identical on click event handlers for .edit-page, .edit-link elements * change pageIssueParser.maxSeverity to accept an array of severity levels instead of an array of pageIssues objects Depends-On: Ic84e4a3286220407863167e0f57cef1b13a72964 Bug: T191532 Change-Id: I67fb6e448f6ecc97c89c1187e491ee05f7a312ef
44 lines
1.6 KiB
JavaScript
44 lines
1.6 KiB
JavaScript
( function ( M ) {
|
|
var createBanner = M.require( 'skins.minerva.scripts/cleanuptemplates' ).test.createBanner,
|
|
OverlayManager = M.require( 'mobile.startup/OverlayManager' ),
|
|
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',
|
|
section = 0,
|
|
inline = true,
|
|
processedAmbox = createBanner( $mockContainer, labelText, section, inline, overlayManager );
|
|
|
|
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();
|
|
assert.strictEqual( window.location.hash, '#/issues/0' );
|
|
} );
|
|
|
|
// NOTE: Only for PageIssues AB
|
|
QUnit.test( 'clicking on the product of createBanner() should trigger a custom event', function ( assert ) {
|
|
var mockAction = {
|
|
action: 'issueClicked',
|
|
issueSeverity: [ 'MEDIUM' ]
|
|
};
|
|
mw.trackSubscribe( 'minerva.PageIssuesAB', function ( topic, data ) {
|
|
assert.equal( JSON.toString( mockAction ), JSON.toString( data ) );
|
|
} );
|
|
} );
|
|
}( mw.mobileFrontend ) );
|