mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Popups
synced 2024-11-23 23:24:39 +00:00
Send disabled event from settings windows
Changes: - introduced new event 'disabled', sent from settings popup - added unit tests for 'disabled' event handling Bug: T167365 Change-Id: I048b38122b8843199c86fd1ed9ec2ff21767e114
This commit is contained in:
parent
4f9ad4d0a7
commit
7e2c79ae0d
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.
|
@ -157,11 +157,11 @@ module.exports = function ( state, action ) {
|
|||
!state.interaction &&
|
||||
action.type !== actionTypes.BOOT &&
|
||||
action.type !== actionTypes.LINK_DWELL &&
|
||||
action.type !== actionTypes.EVENT_LOGGED
|
||||
action.type !== actionTypes.EVENT_LOGGED &&
|
||||
action.type !== actionTypes.SETTINGS_CHANGE
|
||||
) {
|
||||
return state;
|
||||
}
|
||||
|
||||
switch ( action.type ) {
|
||||
case actionTypes.BOOT:
|
||||
return nextState( state, {
|
||||
|
@ -188,7 +188,6 @@ module.exports = function ( state, action ) {
|
|||
) {
|
||||
newState.interaction = undefined;
|
||||
}
|
||||
|
||||
return newState;
|
||||
|
||||
case actionTypes.FETCH_COMPLETE:
|
||||
|
@ -285,6 +284,16 @@ module.exports = function ( state, action ) {
|
|||
} )
|
||||
} );
|
||||
|
||||
case actionTypes.SETTINGS_CHANGE:
|
||||
if ( action.wasEnabled && !action.enabled ) {
|
||||
return nextState( state, {
|
||||
event: {
|
||||
action: 'disabled'
|
||||
}
|
||||
} );
|
||||
} else {
|
||||
return state;
|
||||
}
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
|
|
|
@ -634,6 +634,47 @@ QUnit.test( 'SETTINGS_SHOW should enqueue a "tapped settings cog" event', functi
|
|||
);
|
||||
} );
|
||||
|
||||
QUnit.test( 'SETTINGS_CHANGE should enqueue disabled event', function ( assert ) {
|
||||
var state = eventLogging( undefined, {
|
||||
type: 'SETTINGS_CHANGE',
|
||||
wasEnabled: false,
|
||||
enabled: false
|
||||
} );
|
||||
|
||||
assert.equal(
|
||||
state.event,
|
||||
undefined,
|
||||
'It shouldn\'t enqueue a "disabled" event when there is no change'
|
||||
);
|
||||
|
||||
state = eventLogging( state, {
|
||||
type: 'SETTINGS_CHANGE',
|
||||
wasEnabled: true,
|
||||
enabled: false
|
||||
} );
|
||||
|
||||
assert.deepEqual(
|
||||
state.event,
|
||||
{
|
||||
action: 'disabled'
|
||||
},
|
||||
'It should enqueue a "disabled" event when the previews has been disabled'
|
||||
);
|
||||
|
||||
delete state.event;
|
||||
state = eventLogging( state, {
|
||||
type: 'SETTINGS_CHANGE',
|
||||
wasEnabled: false,
|
||||
enabled: true
|
||||
} );
|
||||
|
||||
assert.equal(
|
||||
state.event,
|
||||
undefined,
|
||||
'It shouldn\'t enqueue a "disabled" event when page previews has been enabled'
|
||||
);
|
||||
} );
|
||||
|
||||
QUnit.test( 'ABANDON_END should enqueue an event', function ( assert ) {
|
||||
var dwelledState,
|
||||
token = '0987654321',
|
||||
|
|
Loading…
Reference in a new issue