mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Popups
synced 2024-09-23 18:29:35 +00:00
reducers: Don't destroy interaction on LINK_CLICK
I09d8776 introduced a bug in the eventLogging reducer where reducing LINK_CLICK would remove any accumulated interaction state but not close the interaction. Update the associated tests so that they correctly test the reduction of this action. Bug: T162924 Change-Id: Ia03e719c228ee96f279c1fa89252dc6b6371a8e9
This commit is contained in:
parent
bb43c9c2e6
commit
2c171d7f25
BIN
resources/dist/index.js
vendored
BIN
resources/dist/index.js
vendored
Binary file not shown.
BIN
resources/dist/index.js.map
vendored
BIN
resources/dist/index.js.map
vendored
Binary file not shown.
|
@ -201,9 +201,9 @@ module.exports = function ( state, action ) {
|
|||
|
||||
case actionTypes.LINK_CLICK:
|
||||
return nextState( state, {
|
||||
interaction: {
|
||||
interaction: nextState( state.interaction, {
|
||||
finalized: true
|
||||
},
|
||||
} ),
|
||||
event: {
|
||||
action: 'opened',
|
||||
linkInteractionToken: state.interaction.token,
|
||||
|
|
|
@ -285,37 +285,43 @@ QUnit.test(
|
|||
);
|
||||
|
||||
QUnit.test( 'LINK_CLICK should enqueue an "opened" event', function ( assert ) {
|
||||
var state,
|
||||
var token = '0987654321',
|
||||
state,
|
||||
expectedState,
|
||||
now = Date.now();
|
||||
|
||||
state = {
|
||||
interaction: undefined
|
||||
};
|
||||
|
||||
state = eventLogging( state, {
|
||||
expectedState = state = eventLogging( state, {
|
||||
type: 'LINK_DWELL',
|
||||
token: '0987654321',
|
||||
el: this.link,
|
||||
token: token,
|
||||
timestamp: now
|
||||
} );
|
||||
|
||||
state = eventLogging( state, {
|
||||
type: 'LINK_CLICK',
|
||||
timestamp: now + 250.25
|
||||
el: this.link,
|
||||
timestamp: now + 250
|
||||
} );
|
||||
|
||||
assert.deepEqual(
|
||||
state.event,
|
||||
{
|
||||
action: 'opened',
|
||||
linkInteractionToken: '0987654321',
|
||||
linkInteractionToken: token,
|
||||
totalInteractionTime: 250
|
||||
},
|
||||
'The event is enqueued and the totalInteractionTime property is an integer.'
|
||||
);
|
||||
|
||||
assert.strictEqual(
|
||||
state.interaction.finalized,
|
||||
true,
|
||||
expectedState.interaction.finalized = true;
|
||||
|
||||
assert.deepEqual(
|
||||
state.interaction,
|
||||
expectedState.interaction,
|
||||
'It should finalize the interaction.'
|
||||
);
|
||||
} );
|
||||
|
@ -612,13 +618,19 @@ QUnit.test( 'ABANDON_END doesn\'t enqueue an event under certain conditions', fu
|
|||
timestamp: now + 500
|
||||
} );
|
||||
|
||||
state = eventLogging( state, {
|
||||
type: 'EVENT_LOGGED'
|
||||
} );
|
||||
|
||||
state = eventLogging( state, {
|
||||
type: 'ABANDON_START',
|
||||
token: token,
|
||||
timestamp: now + 700
|
||||
} );
|
||||
|
||||
state = eventLogging( state, {
|
||||
type: 'ABANDON_END',
|
||||
token: token,
|
||||
timestamp: now + 1000 // ABANDON_END_DELAY is 300 ms.
|
||||
} );
|
||||
|
||||
|
|
Loading…
Reference in a new issue