Don't log editCountBucket when user is logged out

Bug: T156893
Change-Id: I3cdfbe0c9872407b900f0676396b0bc3102a43fd
This commit is contained in:
Sam Smith 2017-02-06 11:57:00 +00:00
parent 83821e105c
commit 75aaf7a23e
2 changed files with 26 additions and 4 deletions

View file

@ -8,7 +8,7 @@
* @return {Object}
*/
function getBaseData( bootAction ) {
return {
var result = {
pageTitleSource: bootAction.page.title,
namespaceIdSource: bootAction.page.namespaceID,
pageIdSource: bootAction.page.id,
@ -16,10 +16,15 @@
popupEnabled: bootAction.isEnabled,
pageToken: bootAction.pageToken,
sessionToken: bootAction.sessionToken,
editCountBucket: popups.counts.getEditCountBucket( bootAction.user.editCount ),
previewCountBucket: popups.counts.getPreviewCountBucket( bootAction.user.previewCount ),
hovercardsSuppressedByGadget: bootAction.isNavPopupsEnabled
};
if ( !bootAction.user.isAnon ) {
result.editCountBucket = popups.counts.getEditCountBucket( bootAction.user.editCount );
}
return result;
}
/**

View file

@ -41,13 +41,16 @@
}
},
expectedEditCountBucket,
expectedPreviewCountBucket;
expectedPreviewCountBucket,
state;
expectedEditCountBucket = counts.getEditCountBucket( action.user.editCount );
expectedPreviewCountBucket = counts.getPreviewCountBucket( action.user.previewCount );
state = mw.popups.reducers.eventLogging( this.initialState, action );
assert.deepEqual(
mw.popups.reducers.eventLogging( this.initialState, action ),
state,
{
previewCount: action.user.previewCount,
baseData: {
@ -68,6 +71,20 @@
interaction: undefined
}
);
// ---
// And when the user is logged out...
action.user.isAnon = true;
state = mw.popups.reducers.eventLogging( this.initialState, action );
assert.strictEqual( state.baseData.isAnon, true );
assert.strictEqual(
state.baseData.editCountBucket,
undefined,
'It shouldn\'t add the editCountBucket property when the user is logged out.'
);
} );
QUnit.test( 'EVENT_LOGGED', function ( assert ) {