Phuedx has uploaded a new change for review. (
https://gerrit.wikimedia.org/r/331338 )
Change subject: actions: Add token to LINK_ABANDON_*
......................................................................
actions: Add token to LINK_ABANDON_*
Change-Id: I7f6187f6c0249c112a08163a343d35ee75cf85e8
---
M resources/ext.popups/actions.js
M tests/qunit/ext.popups/actions.test.js
2 files changed, 25 insertions(+), 8 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Popups
refs/changes/38/331338/1
diff --git a/resources/ext.popups/actions.js b/resources/ext.popups/actions.js
index c575592..996eadb 100644
--- a/resources/ext.popups/actions.js
+++ b/resources/ext.popups/actions.js
@@ -176,17 +176,21 @@
* @return {Object}
*/
actions.linkAbandon = function ( el ) {
- return function ( dispatch ) {
+ return function ( dispatch, getState ) {
+ var token = getState().preview.activeToken;
+
dispatch( timedAction( {
type: types.LINK_ABANDON_START,
- el: el
+ el: el,
+ token: token
} ) );
mw.popups.wait( ABANDON_END_DELAY )
.then( function () {
dispatch( {
type: types.LINK_ABANDON_END,
- el: el
+ el: el,
+ token: token
} );
} );
};
diff --git a/tests/qunit/ext.popups/actions.test.js
b/tests/qunit/ext.popups/actions.test.js
index d1b5a1a..8519adf 100644
--- a/tests/qunit/ext.popups/actions.test.js
+++ b/tests/qunit/ext.popups/actions.test.js
@@ -204,16 +204,25 @@
QUnit.test( 'it should dispatch start and end actions', function (
assert ) {
var that = this,
dispatch = that.sandbox.spy(),
+ token = '0123456789',
+ getState = function () {
+ return {
+ preview: {
+ activeToken: token
+ }
+ };
+ },
done = assert.async();
this.sandbox.stub( mw, 'now' ).returns( new Date() );
- mw.popups.actions.linkAbandon( that.el )( dispatch );
+ mw.popups.actions.linkAbandon( that.el )( dispatch, getState );
assert.ok( dispatch.calledWith( {
type: 'LINK_ABANDON_START',
el: that.el,
- timestamp: mw.now()
+ timestamp: mw.now(),
+ token: token
} ) );
// ---
@@ -224,10 +233,14 @@
);
that.waitPromise.then( function () {
- assert.ok( dispatch.calledWith( {
+ assert.ok(
+ dispatch.calledWith( {
type: 'LINK_ABANDON_END',
- el: that.el
- } ) );
+ el: that.el,
+ token: token
+ } ),
+ 'LINK_ABANDON_* share the same token.'
+ );
done();
} );
--
To view, visit https://gerrit.wikimedia.org/r/331338
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I7f6187f6c0249c112a08163a343d35ee75cf85e8
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Popups
Gerrit-Branch: mpga
Gerrit-Owner: Phuedx <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits