mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Popups
synced 2024-12-11 15:27:04 +00:00
3f2752b039
Action changes: * Include whether the user is logged in/out and information about the current page in the BOOT action. * Add the EVENT_LOGGED action, which represents the eventLoggined change listener logging the queued event. Reducer changes: * Move all tokens and timing information from the preview reducer to the eventLogging reducer. * Make the eventLogging reducer reset the state. Changes: * Add the mw.popups.createSchema function, which constructs an instance of the mw.eventLog.Schema object that can be used to log Popups events. * Add the eventLogging change listener, which logs the queued event. * Add hand-crafted, artisanal documentation. Bug: T152225 Change-Id: I8a3f58358b211cc55417dcda7e796fe538e3d910
66 lines
1.2 KiB
JavaScript
66 lines
1.2 KiB
JavaScript
( function ( mw ) {
|
|
|
|
QUnit.module( 'ext.popups/reducers#eventLogging', {
|
|
setup: function () {
|
|
this.initialState = mw.popups.reducers.eventLogging( undefined, {
|
|
type: '@@INIT'
|
|
} );
|
|
}
|
|
} );
|
|
|
|
QUnit.test( 'BOOT', function ( assert ) {
|
|
var action = {
|
|
type: 'BOOT',
|
|
isUserInCondition: true,
|
|
sessionToken: '0123456789',
|
|
pageToken: '9876543210',
|
|
page: {
|
|
title: 'Foo',
|
|
namespaceID: 1,
|
|
id: 2
|
|
},
|
|
isUserAnon: true
|
|
};
|
|
|
|
assert.deepEqual(
|
|
mw.popups.reducers.eventLogging( this.initialState, action ),
|
|
{
|
|
baseData: {
|
|
pageTitleSource: action.page.title,
|
|
namespaceIdSource: action.page.namespaceID,
|
|
pageIdSource: action.page.id,
|
|
isAnon: action.isUserAnon,
|
|
popupEnabled: action.isUserInCondition,
|
|
pageToken: action.pageToken,
|
|
sessionToken: action.sessionToken
|
|
},
|
|
event: {
|
|
action: 'pageLoaded'
|
|
}
|
|
}
|
|
);
|
|
} );
|
|
|
|
QUnit.test( 'EVENT_LOGGED', function ( assert ) {
|
|
var state,
|
|
action;
|
|
|
|
state = {
|
|
event: {}
|
|
};
|
|
|
|
action = {
|
|
type: 'EVENT_LOGGED'
|
|
};
|
|
|
|
assert.deepEqual(
|
|
mw.popups.reducers.eventLogging( state, action ),
|
|
{
|
|
event: undefined
|
|
},
|
|
'It dequeues any event queued for logging.'
|
|
);
|
|
} );
|
|
|
|
}( mediaWiki ) );
|