Use getPageviewToken api

Currently the Popups schema is disabled but if we were to re-enable
it, the page tokens would now be consistent with the ReadingDepth
schema

The getToken function is kept to allow generation of the
pageInteractionToken's relating to a link interaction, for which
there is no centralised API.

Additional changes:
* I've updated various tests to use the central mw.user stub to make
clearer where tokens come from.

Bug: T203013
Change-Id: If746bea5aeed2b4c192a9b8a02feb1fe06480633
This commit is contained in:
jdlrobson 2018-08-21 16:43:33 -07:00 committed by Jdlrobson
parent 14df0a587c
commit 53d1a2c329
7 changed files with 7 additions and 11 deletions

Binary file not shown.

Binary file not shown.

View file

@ -59,7 +59,6 @@ function timedAction( baseAction ) {
* @param {boolean} isEnabled See `isEnabled.js`
* @param {mw.user} user
* @param {ext.popups.UserSettings} userSettings
* @param {Function} generateToken
* @param {mw.Map} config The config of the MediaWiki client-side application,
* i.e. `mw.config`
* @param {string} url url
@ -69,7 +68,6 @@ export function boot(
isEnabled,
user,
userSettings,
generateToken,
config,
url
) {
@ -81,7 +79,7 @@ export function boot(
isEnabled,
isNavPopupsEnabled: config.get( 'wgPopupsConflictsWithNavPopupGadget' ),
sessionToken: user.sessionId(),
pageToken: generateToken(),
pageToken: user.getPageviewToken(),
page: {
url,
title: config.get( 'wgTitle' ),

View file

@ -208,7 +208,6 @@ function registerChangeListeners(
isEnabled,
mw.user,
userSettings,
generateToken,
mw.config,
window.location.href
);

View file

@ -7,7 +7,7 @@ const mw = mediaWiki,
REFERRER = 'https://en.wikipedia.org/wiki/Kitten';
function generateToken() {
return '9876543210';
return 'ABC';
}
QUnit.module( 'ext.popups/actions' );
@ -34,7 +34,6 @@ QUnit.test( '#boot', ( assert ) => {
false,
stubUser,
stubUserSettings,
generateToken,
config,
REFERRER
);
@ -129,7 +128,7 @@ QUnit.test( '#linkDwell', function ( assert ) {
type: actionTypes.LINK_DWELL,
el: this.el,
event,
token: '9876543210',
token: 'ABC',
timestamp: mw.now(),
title: 'Foo',
namespaceId: 1,

View file

@ -87,12 +87,9 @@ QUnit.module( 'ext.popups preview @integration', {
/* isEnabled: */
constant( true ),
/* user */
{ sessionId: constant( 'sessiontoken' ),
isAnon: constant( true ) },
stubs.createStubUser( true ),
/* userSettings: */
{ getPreviewCount: constant( 1 ) },
/* generateToken: */
constant( 'pagetoken' ),
/* config: */
{ get: identity }
);

View file

@ -7,6 +7,9 @@
*/
export function createStubUser( isAnon ) {
return {
getPageviewToken() {
return '9876543210';
},
isAnon() {
return isAnon;
},