2015-05-04 19:24:37 +00:00
|
|
|
( function ( $, mw ) {
|
2014-08-05 22:18:38 +00:00
|
|
|
QUnit.module( 'ext.echo.overlay', {
|
2015-05-04 19:24:37 +00:00
|
|
|
setup: function () {
|
2016-02-29 23:18:06 +00:00
|
|
|
var ApiStub;
|
|
|
|
|
2015-08-13 00:54:16 +00:00
|
|
|
this.$badge = $( '<a class="mw-echo-notifications-badge mw-echo-unseen-notifications">1</a>' );
|
2014-08-06 19:29:17 +00:00
|
|
|
this.sandbox.stub( mw.echo, 'getBadge' ).returns( this.$badge );
|
|
|
|
// Kill any existing overlays to avoid clashing with other tests
|
|
|
|
$( '.mw-echo-overlay' ).remove();
|
|
|
|
|
2016-02-29 23:18:06 +00:00
|
|
|
ApiStub = function ( mode, numberUnreadMessages ) {
|
2014-08-06 19:29:17 +00:00
|
|
|
this.mode = mode;
|
2014-08-13 00:35:08 +00:00
|
|
|
this.numberUnreadMessages = numberUnreadMessages || 7;
|
2014-08-06 19:29:17 +00:00
|
|
|
};
|
2014-08-05 22:18:38 +00:00
|
|
|
ApiStub.prototype = {
|
2015-05-04 19:24:37 +00:00
|
|
|
post: function ( data ) {
|
2015-04-29 12:08:30 +00:00
|
|
|
switch ( data.action ) {
|
|
|
|
case 'echomarkread':
|
|
|
|
data = this.getNewNotificationCountData( data, this.mode === 'with-new-messages' );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'echomarkseen':
|
|
|
|
data = { query: { echomarkseen: { result: 'success', timestamp: '20140509000000' } } };
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
throw 'Unrecognized post action: ' + data.action;
|
|
|
|
}
|
|
|
|
|
|
|
|
return $.Deferred().resolve( data );
|
2014-08-06 19:29:17 +00:00
|
|
|
},
|
2015-06-08 00:24:09 +00:00
|
|
|
postWithToken: function ( type, data ) {
|
|
|
|
return this.post( data );
|
|
|
|
},
|
2015-05-04 19:24:37 +00:00
|
|
|
get: function () {
|
2014-08-12 01:54:34 +00:00
|
|
|
var i, id,
|
2015-05-04 19:24:37 +00:00
|
|
|
index = [],
|
|
|
|
listObj = {},
|
2014-08-12 01:54:34 +00:00
|
|
|
data = this.getData();
|
2014-09-09 14:41:59 +00:00
|
|
|
// a response which contains 0 unread messages and 1 unread alert
|
2014-09-05 23:52:42 +00:00
|
|
|
if ( this.mode === 'no-new-messages' ) {
|
2014-08-06 19:29:17 +00:00
|
|
|
data.query.notifications.message = {
|
|
|
|
index: [ 100 ],
|
|
|
|
list: {
|
|
|
|
100: {
|
|
|
|
'*': 'Jon sent you a message on the Flow board Talk:XYZ',
|
|
|
|
read: '20140805211446',
|
|
|
|
category: 'message',
|
|
|
|
id: 100,
|
2015-04-29 12:08:30 +00:00
|
|
|
timestamp: {
|
|
|
|
date: '8 May',
|
|
|
|
mw: '20140508211436',
|
|
|
|
unix: '1407273276',
|
|
|
|
utcunix: '1407273276'
|
|
|
|
},
|
2014-08-06 19:29:17 +00:00
|
|
|
type: 'message'
|
|
|
|
}
|
2014-08-13 00:35:08 +00:00
|
|
|
},
|
|
|
|
rawcount: 0,
|
|
|
|
count: '0'
|
2014-08-06 19:29:17 +00:00
|
|
|
};
|
2014-09-09 14:41:59 +00:00
|
|
|
// a response which contains 8 unread messages and 1 unread alert
|
2014-09-05 23:52:42 +00:00
|
|
|
} else if ( this.mode === 'with-new-messages' ) {
|
2014-08-12 01:54:34 +00:00
|
|
|
for ( i = 0; i < 7; i++ ) {
|
|
|
|
id = 500 + i;
|
|
|
|
index.push( id );
|
2015-10-01 13:48:52 +00:00
|
|
|
listObj[ id ] = {
|
2015-04-29 12:08:30 +00:00
|
|
|
'*': '!',
|
|
|
|
category: 'message',
|
|
|
|
id: id,
|
|
|
|
timestamp: {
|
|
|
|
date: '8 May',
|
|
|
|
mw: '20140508211436',
|
|
|
|
unix: '1407273276',
|
|
|
|
utcunix: '1407273276'
|
|
|
|
},
|
|
|
|
type: 'message'
|
|
|
|
};
|
2014-08-12 01:54:34 +00:00
|
|
|
}
|
|
|
|
data.query.notifications.message = {
|
|
|
|
index: index,
|
2014-08-13 00:35:08 +00:00
|
|
|
list: listObj,
|
|
|
|
rawcount: this.numberUnreadMessages,
|
2015-05-04 19:24:37 +00:00
|
|
|
count: String( this.numberUnreadMessages )
|
2014-08-12 01:54:34 +00:00
|
|
|
};
|
2014-08-13 00:35:08 +00:00
|
|
|
// Total number is number of messages + number of alerts (1)
|
|
|
|
data.query.notifications.count = this.numberUnreadMessages + 1;
|
|
|
|
data.query.notifications.rawcount = this.numberUnreadMessages + 1;
|
2014-08-06 19:29:17 +00:00
|
|
|
}
|
|
|
|
return $.Deferred().resolve( data );
|
|
|
|
},
|
2015-05-04 19:24:37 +00:00
|
|
|
getNewNotificationCountData: function ( data, hasNewMessages ) {
|
2014-08-06 19:29:17 +00:00
|
|
|
var alertCount, messageCount,
|
|
|
|
rawCount = 0,
|
|
|
|
count = 0;
|
|
|
|
|
|
|
|
messageCount = {
|
|
|
|
count: '0',
|
|
|
|
rawcount: 0
|
|
|
|
};
|
2014-09-09 17:20:23 +00:00
|
|
|
alertCount = {
|
|
|
|
count: '0',
|
|
|
|
rawcount: 0
|
|
|
|
};
|
2014-08-06 19:29:17 +00:00
|
|
|
if ( data.list === '100' ) {
|
|
|
|
alertCount = {
|
2014-09-09 17:20:23 +00:00
|
|
|
count: '0',
|
|
|
|
rawcount: 0
|
2014-08-06 19:29:17 +00:00
|
|
|
};
|
|
|
|
count = 1;
|
|
|
|
rawCount = 1;
|
2014-09-09 17:20:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( hasNewMessages && data.sections === 'alert' ) {
|
2014-08-12 17:17:19 +00:00
|
|
|
messageCount = {
|
2014-09-09 17:20:23 +00:00
|
|
|
count: '7',
|
|
|
|
rawcount: 7
|
2014-08-12 17:17:19 +00:00
|
|
|
};
|
|
|
|
rawCount = 7;
|
|
|
|
count = 7;
|
2014-09-09 17:20:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( data.list === 500 ) {
|
|
|
|
messageCount = {
|
|
|
|
count: '6',
|
|
|
|
rawcount: 6
|
2014-08-06 19:29:17 +00:00
|
|
|
};
|
2014-09-09 17:20:23 +00:00
|
|
|
rawCount = 6;
|
|
|
|
count = 6;
|
2014-08-06 19:29:17 +00:00
|
|
|
}
|
2014-09-09 17:20:23 +00:00
|
|
|
|
2014-08-06 19:29:17 +00:00
|
|
|
data = {
|
2014-08-05 22:18:38 +00:00
|
|
|
query: {
|
|
|
|
echomarkread: {
|
2014-08-06 19:29:17 +00:00
|
|
|
alert: alertCount,
|
|
|
|
message: messageCount,
|
|
|
|
rawcount: rawCount,
|
|
|
|
count: count
|
2014-08-05 22:18:38 +00:00
|
|
|
}
|
|
|
|
}
|
2014-08-06 19:29:17 +00:00
|
|
|
};
|
|
|
|
return data;
|
2014-08-05 22:18:38 +00:00
|
|
|
},
|
2015-05-04 19:24:37 +00:00
|
|
|
getData: function () {
|
2014-08-06 19:29:17 +00:00
|
|
|
return {
|
2014-08-05 22:18:38 +00:00
|
|
|
query: {
|
|
|
|
notifications: {
|
|
|
|
count: '1',
|
|
|
|
rawcount: 1,
|
2014-08-06 19:29:17 +00:00
|
|
|
message: {
|
2014-08-13 00:35:08 +00:00
|
|
|
rawcount: 0,
|
|
|
|
count: '0',
|
2014-08-06 19:29:17 +00:00
|
|
|
index: [],
|
|
|
|
list: {}
|
|
|
|
},
|
|
|
|
alert: {
|
2014-08-13 00:35:08 +00:00
|
|
|
rawcount: 1,
|
|
|
|
count: '1',
|
2014-08-06 19:29:17 +00:00
|
|
|
index: [ 70, 71 ],
|
|
|
|
list: {
|
|
|
|
70: {
|
|
|
|
'*': 'Jon mentioned you.',
|
|
|
|
agent: { id: 212, name: 'Jon' },
|
|
|
|
category: 'mention',
|
|
|
|
id: 70,
|
|
|
|
read: '20140805211446',
|
|
|
|
timestamp: {
|
2015-04-29 12:08:30 +00:00
|
|
|
date: '8 May',
|
|
|
|
mw: '20140508211436',
|
|
|
|
unix: '1407273276',
|
|
|
|
utcunix: '1407273276'
|
2014-08-06 19:29:17 +00:00
|
|
|
},
|
|
|
|
title: {
|
|
|
|
full: 'Spiders'
|
|
|
|
},
|
|
|
|
type: 'mention'
|
2014-08-05 22:18:38 +00:00
|
|
|
},
|
2014-08-06 19:29:17 +00:00
|
|
|
71: {
|
|
|
|
'*': 'X talked to you.',
|
|
|
|
category: 'edit-user-talk',
|
|
|
|
id: 71,
|
2015-04-29 12:08:30 +00:00
|
|
|
timestamp: {
|
|
|
|
date: '8 May',
|
|
|
|
mw: '20140508211436',
|
|
|
|
unix: '1407273276',
|
|
|
|
utcunix: '1407273276'
|
|
|
|
},
|
2014-08-06 19:29:17 +00:00
|
|
|
type: 'edit-user-talk'
|
|
|
|
}
|
2014-08-05 22:18:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-08-06 19:29:17 +00:00
|
|
|
};
|
2014-08-05 22:18:38 +00:00
|
|
|
}
|
|
|
|
};
|
2014-08-06 19:29:17 +00:00
|
|
|
this.ApiStub = ApiStub;
|
2014-08-05 22:18:38 +00:00
|
|
|
}
|
|
|
|
} );
|
|
|
|
|
2015-05-04 19:24:37 +00:00
|
|
|
QUnit.test( 'mw.echo.overlay.buildOverlay', 7, function ( assert ) {
|
2014-08-05 22:18:38 +00:00
|
|
|
var $overlay;
|
2014-08-06 19:29:17 +00:00
|
|
|
this.sandbox.stub( mw.echo.overlay, 'api', new this.ApiStub() );
|
2015-05-04 19:24:37 +00:00
|
|
|
mw.echo.overlay.buildOverlay( function ( $o ) {
|
2014-08-05 22:18:38 +00:00
|
|
|
$overlay = $o;
|
|
|
|
} );
|
2014-08-06 19:29:17 +00:00
|
|
|
assert.strictEqual( $overlay.find( '.mw-echo-overlay-title ul li' ).length, 1, 'Only one tab in header' );
|
2014-08-12 01:54:34 +00:00
|
|
|
assert.strictEqual( $overlay.find( '.mw-echo-notifications' ).length, 1, 'Overlay contains a list of notifications.' );
|
|
|
|
assert.strictEqual( $overlay.find( '.mw-echo-notifications li' ).length, 2, 'There are two notifications.' );
|
2014-08-05 22:18:38 +00:00
|
|
|
assert.strictEqual( $overlay.find( '.mw-echo-unread' ).length, 1, 'There is one unread notification.' );
|
2014-08-14 21:31:13 +00:00
|
|
|
assert.strictEqual( $overlay.find( '.mw-echo-overlay-footer a' ).length, 2,
|
2014-08-05 22:18:38 +00:00
|
|
|
'There is a footer with 2 links to preferences and all notifications.' );
|
2014-08-06 19:29:17 +00:00
|
|
|
assert.strictEqual( this.$badge.text(),
|
|
|
|
'0', 'The alerts are marked as read once opened.' );
|
2015-08-13 00:54:16 +00:00
|
|
|
assert.strictEqual( this.$badge.hasClass( 'mw-echo-unseen-notifications' ),
|
2014-08-06 19:29:17 +00:00
|
|
|
false, 'The badge no longer indicates new messages.' );
|
|
|
|
} );
|
|
|
|
|
2015-05-04 19:24:37 +00:00
|
|
|
QUnit.test( 'mw.echo.overlay.buildOverlay with messages', 5, function ( assert ) {
|
2014-09-09 17:20:23 +00:00
|
|
|
var $overlay;
|
|
|
|
this.sandbox.stub( mw.echo.overlay, 'api', new this.ApiStub( 'no-new-messages' ) );
|
2015-05-04 19:24:37 +00:00
|
|
|
mw.echo.overlay.buildOverlay( function ( $o ) {
|
2014-09-09 17:20:23 +00:00
|
|
|
$overlay = $o;
|
|
|
|
} );
|
|
|
|
assert.strictEqual( $overlay.find( '.mw-echo-overlay-title ul li' ).length, 2, 'There are two tabs in header' );
|
|
|
|
assert.strictEqual( $overlay.find( '.mw-echo-notifications' ).length, 2, 'Overlay contains 2 lists of notifications.' );
|
2014-09-09 14:41:59 +00:00
|
|
|
assert.strictEqual( $overlay.find( '.mw-echo-overlay-title a' ).eq( 0 ).hasClass( 'mw-ui-quiet' ),
|
2014-09-09 17:20:23 +00:00
|
|
|
true, 'First tab is the selected tab upon opening.' );
|
|
|
|
assert.strictEqual( this.$badge.text(),
|
|
|
|
'0', 'The label updates to 0 as alerts tab is default and now alerts have been read.' );
|
2015-08-13 00:54:16 +00:00
|
|
|
assert.strictEqual( this.$badge.hasClass( 'mw-echo-unseen-notifications' ),
|
2014-09-09 17:20:23 +00:00
|
|
|
false, 'The notification button class is updated with the default switch to alert tab.' );
|
|
|
|
} );
|
|
|
|
|
2015-05-04 19:24:37 +00:00
|
|
|
QUnit.test( 'Switch tabs on overlay. 1 unread alert, no unread messages.', 7, function ( assert ) {
|
2014-08-06 19:29:17 +00:00
|
|
|
var $overlay, $tabs;
|
|
|
|
|
2014-09-05 23:52:42 +00:00
|
|
|
this.sandbox.stub( mw.echo.overlay, 'api', new this.ApiStub( 'no-new-messages' ) );
|
2015-05-04 19:24:37 +00:00
|
|
|
mw.echo.overlay.buildOverlay( function ( $o ) {
|
2014-08-06 19:29:17 +00:00
|
|
|
$overlay = $o;
|
2014-09-09 14:41:59 +00:00
|
|
|
// switch to 1st tab (alerts)
|
2014-09-09 17:20:23 +00:00
|
|
|
$overlay.find( '.mw-echo-overlay-title li a' ).eq( 0 ).trigger( 'click' );
|
2014-08-06 19:29:17 +00:00
|
|
|
} );
|
|
|
|
|
2014-09-09 17:20:23 +00:00
|
|
|
$tabs = $overlay.find( '.mw-echo-overlay-title li a' );
|
2014-08-06 19:29:17 +00:00
|
|
|
|
2014-09-09 17:20:23 +00:00
|
|
|
assert.strictEqual( $tabs.eq( 0 ).hasClass( 'mw-ui-quiet' ),
|
|
|
|
true, 'First tab is now the selected tab.' );
|
2014-09-09 14:41:59 +00:00
|
|
|
assert.strictEqual( $tabs.eq( 1 ).hasClass( 'mw-ui-quiet' ),
|
|
|
|
false, 'Second tab is not the selected tab.' );
|
2014-08-06 19:29:17 +00:00
|
|
|
assert.strictEqual( this.$badge.text(),
|
|
|
|
'0', 'The label is now set to 0.' );
|
2015-08-13 00:54:16 +00:00
|
|
|
assert.strictEqual( this.$badge.hasClass( 'mw-echo-unseen-notifications' ),
|
2014-08-06 19:29:17 +00:00
|
|
|
false, 'There are now zero unread notifications.' );
|
2014-09-09 17:20:23 +00:00
|
|
|
|
2014-09-09 14:41:59 +00:00
|
|
|
assert.strictEqual( $tabs.eq( 0 ).text(), 'Alerts (0)', 'Check the label has a count in it.' );
|
|
|
|
assert.strictEqual( $tabs.eq( 1 ).text(), 'Messages (0)', 'Check the label has an updated count in it.' );
|
2014-09-09 17:20:23 +00:00
|
|
|
assert.strictEqual( $tabs.eq( 1 ).hasClass( 'mw-ui-active' ),
|
|
|
|
true, 'Second tab has active class .as it is the only clickable tab' );
|
2014-08-05 22:18:38 +00:00
|
|
|
} );
|
|
|
|
|
2015-05-04 19:24:37 +00:00
|
|
|
QUnit.test( 'Unread message behaviour', 5, function ( assert ) {
|
2014-08-12 01:54:34 +00:00
|
|
|
var $overlay;
|
|
|
|
|
2014-09-05 23:52:42 +00:00
|
|
|
this.sandbox.stub( mw.echo.overlay, 'api', new this.ApiStub( 'with-new-messages' ) );
|
2015-05-04 19:24:37 +00:00
|
|
|
mw.echo.overlay.buildOverlay( function ( $o ) {
|
2014-08-12 01:54:34 +00:00
|
|
|
$overlay = $o;
|
|
|
|
} );
|
|
|
|
|
|
|
|
// Test initial state
|
2014-09-09 14:41:59 +00:00
|
|
|
assert.strictEqual( $overlay.find( '.mw-echo-overlay-title li a' ).eq( 1 ).text(), 'Messages (7)',
|
2014-08-12 01:54:34 +00:00
|
|
|
'Check the label has a count in it and it is not automatically reset when tab is open.' );
|
|
|
|
assert.strictEqual( $overlay.find( '.mw-echo-unread' ).length, 8, 'There are 8 unread notifications.' );
|
|
|
|
|
|
|
|
// Click mark as read
|
2014-08-12 17:17:19 +00:00
|
|
|
$overlay.find( '.mw-echo-notifications > button' ).eq( 0 ).trigger( 'click' );
|
2014-09-09 14:41:59 +00:00
|
|
|
assert.strictEqual( $overlay.find( '.mw-echo-overlay-title li a' ).eq( 1 ).text(), 'Messages (0)',
|
2014-08-12 01:54:34 +00:00
|
|
|
'Check all the notifications (even those outside overlay) have been marked as read.' );
|
2014-09-09 14:41:59 +00:00
|
|
|
assert.strictEqual( $overlay.find( '.mw-echo-notifications ' ).eq( 1 ).find( '.mw-echo-unread' ).length,
|
2014-08-12 01:54:34 +00:00
|
|
|
0, 'There are now no unread notifications in this tab.' );
|
2014-08-12 17:17:19 +00:00
|
|
|
assert.strictEqual( $overlay.find( '.mw-echo-notifications > button' ).length, 0,
|
2014-08-12 01:54:34 +00:00
|
|
|
'There are no notifications now so no need for button.' );
|
|
|
|
} );
|
|
|
|
|
2015-05-04 19:24:37 +00:00
|
|
|
QUnit.test( 'Mark as read.', 8, function ( assert ) {
|
2014-09-09 17:20:23 +00:00
|
|
|
var $overlay;
|
|
|
|
this.$badge.text( '8' );
|
|
|
|
this.sandbox.stub( mw.echo.overlay, 'api', new this.ApiStub( 'with-new-messages' ) );
|
2015-05-04 19:24:37 +00:00
|
|
|
mw.echo.overlay.buildOverlay( function ( $o ) {
|
2014-09-09 17:20:23 +00:00
|
|
|
$overlay = $o;
|
|
|
|
} );
|
|
|
|
|
|
|
|
// Test initial state
|
2014-09-09 14:41:59 +00:00
|
|
|
assert.strictEqual( $overlay.find( '.mw-echo-overlay-title li a' ).eq( 1 ).text(), 'Messages (7)',
|
2014-09-09 17:20:23 +00:00
|
|
|
'Check the label has a count in it and it is not automatically reset when tab is open.' );
|
|
|
|
assert.strictEqual( $overlay.find( '.mw-echo-unread' ).length, 8,
|
|
|
|
'There are 7 unread message notifications and although the alert is marked as read on server is displays as unread in overlay.' );
|
|
|
|
assert.strictEqual( this.$badge.text(), '7', '7 unread notifications in badge (alerts get marked automatically).' );
|
|
|
|
assert.strictEqual( $overlay.find( '.mw-echo-notifications li button' ).length, 7,
|
|
|
|
'There are 7 mark as read button.' );
|
|
|
|
|
|
|
|
// Click first mark as read
|
|
|
|
$overlay.find( '.mw-echo-notifications li button' ).eq( 0 ).trigger( 'click' );
|
|
|
|
|
2014-09-09 14:41:59 +00:00
|
|
|
assert.strictEqual( $overlay.find( '.mw-echo-overlay-title li a' ).eq( 1 ).text(), 'Messages (6)',
|
2014-09-09 17:20:23 +00:00
|
|
|
'Check the notification was marked as read.' );
|
|
|
|
assert.strictEqual( $overlay.find( '.mw-echo-unread' ).length, 7,
|
|
|
|
'There are now 6 unread message notifications in UI and 1 unread alert.' );
|
|
|
|
assert.strictEqual( $overlay.find( '.mw-echo-notifications li button' ).length, 6,
|
|
|
|
'There are now 6 mark as read buttons.' );
|
|
|
|
assert.strictEqual( this.$badge.text(), '6', 'Now 6 unread notifications.' );
|
|
|
|
} );
|
|
|
|
|
2015-05-04 19:24:37 +00:00
|
|
|
QUnit.test( 'Tabs when there is overflow.', 2, function ( assert ) {
|
2014-08-13 00:35:08 +00:00
|
|
|
var $overlay;
|
2014-09-05 23:52:42 +00:00
|
|
|
this.sandbox.stub( mw.echo.overlay, 'api', new this.ApiStub( 'with-new-messages', 50 ) );
|
2015-05-04 19:24:37 +00:00
|
|
|
mw.echo.overlay.buildOverlay( function ( $o ) {
|
2014-08-13 00:35:08 +00:00
|
|
|
$overlay = $o;
|
|
|
|
} );
|
|
|
|
|
|
|
|
// Test initial state
|
2014-09-09 14:41:59 +00:00
|
|
|
assert.strictEqual( $overlay.find( '.mw-echo-overlay-title li a' ).eq( 1 ).text(), 'Messages (50)',
|
2014-08-13 00:35:08 +00:00
|
|
|
'Check the label has a count in it and reflects the total unread and not the shown unread' );
|
|
|
|
assert.strictEqual( $overlay.find( '.mw-echo-unread' ).length, 8, 'There are 8 unread notifications.' );
|
|
|
|
} );
|
2014-08-13 17:07:32 +00:00
|
|
|
|
2015-05-04 19:24:37 +00:00
|
|
|
QUnit.test( 'Switching tabs visibility', 4, function ( assert ) {
|
2014-08-13 17:07:32 +00:00
|
|
|
var $overlay;
|
|
|
|
|
2014-09-05 23:52:42 +00:00
|
|
|
this.sandbox.stub( mw.echo.overlay, 'api', new this.ApiStub( 'with-new-messages' ) );
|
2015-05-04 19:24:37 +00:00
|
|
|
mw.echo.overlay.buildOverlay( function ( $o ) {
|
2014-08-13 17:07:32 +00:00
|
|
|
// put in dom so we can do visibility tests
|
|
|
|
$overlay = $o.appendTo( '#qunit-fixture' );
|
|
|
|
} );
|
|
|
|
|
|
|
|
// Test initial state
|
|
|
|
assert.strictEqual( $overlay.find( '.mw-echo-notifications' ).eq( 0 ).is( ':visible' ),
|
2014-09-09 14:41:59 +00:00
|
|
|
true, 'First tab (alerts) starts visible.' );
|
2014-08-13 17:07:32 +00:00
|
|
|
assert.strictEqual( $overlay.find( '.mw-echo-notifications' ).eq( 1 ).is( ':visible' ),
|
2014-09-09 14:41:59 +00:00
|
|
|
false, 'Second tab (messages) starts hidden.' );
|
2014-08-13 17:07:32 +00:00
|
|
|
|
2014-09-09 17:20:23 +00:00
|
|
|
// Switch to second tab
|
2014-09-09 14:41:59 +00:00
|
|
|
$overlay.find( '.mw-echo-overlay-title li a' ).eq( 1 ).trigger( 'click' );
|
2014-08-13 17:07:32 +00:00
|
|
|
|
|
|
|
// check new tab visibility
|
|
|
|
assert.strictEqual( $overlay.find( '.mw-echo-notifications' ).eq( 0 ).is( ':visible' ),
|
2014-09-09 14:41:59 +00:00
|
|
|
false, 'First tab is now hidden.' );
|
2014-08-13 17:07:32 +00:00
|
|
|
assert.strictEqual( $overlay.find( '.mw-echo-notifications' ).eq( 1 ).is( ':visible' ),
|
2014-09-09 14:41:59 +00:00
|
|
|
true, 'Second tab is now visible.' );
|
2014-08-13 17:07:32 +00:00
|
|
|
} );
|
2014-08-05 22:18:38 +00:00
|
|
|
}( jQuery, mediaWiki ) );
|