Jdlrobson has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/207008

Change subject: Correct API inconsistency (module name and response)
......................................................................

Correct API inconsistency (module name and response)

* The module name does not reflect the RL module
* The API currently returns '' rather than true for watchlist status

Bug: T97268
Change-Id: Id7dc98868c53aea9b7a678a66e51fc1afe7c243d
---
M includes/Gather.hooks.php
M resources/ext.gather.api/CollectionsApi.js
M resources/ext.gather.collection.delete/CollectionDeleteOverlay.js
M resources/ext.gather.collection.editor/CollectionEditOverlay.js
M resources/ext.gather.moderation/init.js
M resources/ext.gather.page.search/CollectionPageList.js
M resources/ext.gather.routes/routes.js
M resources/ext.gather.special/init.js
M resources/ext.gather.watchstar/CollectionsContentOverlay.js
A tests/qunit/ext.gather.api/test_CollectionsApi.js
M tests/qunit/ext.gather.watchstar/test_CollectionsContentOverlay.js
11 files changed, 49 insertions(+), 10 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Gather 
refs/changes/08/207008/1

diff --git a/includes/Gather.hooks.php b/includes/Gather.hooks.php
index 0248188..472a23c 100644
--- a/includes/Gather.hooks.php
+++ b/includes/Gather.hooks.php
@@ -209,6 +209,12 @@
                        'targets' => array( 'desktop', 'mobile' ),
                );
 
+               $modules['qunit']['ext.gather.api.tests'] = $boilerplate + 
array(
+                       'scripts' => array(
+                               'ext.gather.api/test_CollectionsApi.js',
+                       ),
+                       'dependencies' => array( 'ext.gather.api' ),
+               );
                $modules['qunit']['ext.gather.watchstar.tests'] = $boilerplate 
+ array(
                        'scripts' => array(
                                
'ext.gather.watchstar/test_CollectionsContentOverlay.js',
diff --git a/resources/ext.gather.api/CollectionsApi.js 
b/resources/ext.gather.api/CollectionsApi.js
index 8ff4146..85a4849 100644
--- a/resources/ext.gather.api/CollectionsApi.js
+++ b/resources/ext.gather.api/CollectionsApi.js
@@ -143,7 +143,7 @@
                 */
                _mapCollection: function ( list ) {
                        // FIXME: API should handle all these inconsistencies.
-                       list.isWatchlist = list.watchlist;
+                       list.isWatchlist = list.watchlist !== undefined;
                        list.titleInCollection = list.title;
                        list.title = list.label;
                        list.owner = list.owner;
@@ -252,6 +252,6 @@
                }
        } );
 
-       M.define( 'ext.gather.watchstar/CollectionsApi', CollectionsApi );
+       M.define( 'ext.gather.api/CollectionsApi', CollectionsApi );
 
 }( mw.mobileFrontend, jQuery ) );
diff --git a/resources/ext.gather.collection.delete/CollectionDeleteOverlay.js 
b/resources/ext.gather.collection.delete/CollectionDeleteOverlay.js
index 28e8f2c..2561e60 100644
--- a/resources/ext.gather.collection.delete/CollectionDeleteOverlay.js
+++ b/resources/ext.gather.collection.delete/CollectionDeleteOverlay.js
@@ -5,7 +5,7 @@
                schema = new SchemaGather(),
                toast = M.require( 'toast' ),
                futureToasts = M.require( 'ext.gather.alerts/futureToasts' ),
-               CollectionsApi = M.require( 
'ext.gather.watchstar/CollectionsApi' ),
+               CollectionsApi = M.require( 'ext.gather.api/CollectionsApi' ),
                ConfirmationOverlay = M.require( 
'ext.gather.confirm/ConfirmationOverlay' );
 
        /**
diff --git a/resources/ext.gather.collection.editor/CollectionEditOverlay.js 
b/resources/ext.gather.collection.editor/CollectionEditOverlay.js
index a38a26a..23cc312 100644
--- a/resources/ext.gather.collection.editor/CollectionEditOverlay.js
+++ b/resources/ext.gather.collection.editor/CollectionEditOverlay.js
@@ -2,7 +2,7 @@
 
        var CollectionEditOverlay,
                toast = M.require( 'toast' ),
-               CollectionsApi = M.require( 
'ext.gather.watchstar/CollectionsApi' ),
+               CollectionsApi = M.require( 'ext.gather.api/CollectionsApi' ),
                CollectionSearchPanel = M.require( 
'ext.gather.page.search/CollectionSearchPanel' ),
                Overlay = M.require( 'Overlay' ),
                Icon = M.require( 'Icon' ),
diff --git a/resources/ext.gather.moderation/init.js 
b/resources/ext.gather.moderation/init.js
index 1744c05..ca9728f 100644
--- a/resources/ext.gather.moderation/init.js
+++ b/resources/ext.gather.moderation/init.js
@@ -1,5 +1,5 @@
 ( function ( M, $ ) {
-       var CollectionsApi = M.require( 'ext.gather.watchstar/CollectionsApi' ),
+       var CollectionsApi = M.require( 'ext.gather.api/CollectionsApi' ),
                toast = M.require( 'toast' ),
                Icon = M.require( 'Icon' ),
                api = new CollectionsApi();
diff --git a/resources/ext.gather.page.search/CollectionPageList.js 
b/resources/ext.gather.page.search/CollectionPageList.js
index f7f36a3..1b297d1 100644
--- a/resources/ext.gather.page.search/CollectionPageList.js
+++ b/resources/ext.gather.page.search/CollectionPageList.js
@@ -2,7 +2,7 @@
 
        var PageList = M.require( 'modules/PageList' ),
                Page = M.require( 'Page' ),
-               CollectionsApi = M.require( 
'ext.gather.watchstar/CollectionsApi' ),
+               CollectionsApi = M.require( 'ext.gather.api/CollectionsApi' ),
                View = M.require( 'View' ),
                Icon = M.require( 'Icon' ),
                CollectionPageList;
diff --git a/resources/ext.gather.routes/routes.js 
b/resources/ext.gather.routes/routes.js
index 24e1d9b..e02e7be 100644
--- a/resources/ext.gather.routes/routes.js
+++ b/resources/ext.gather.routes/routes.js
@@ -1,6 +1,6 @@
 ( function ( M, $ ) {
 
-       var CollectionsApi = M.require( 'ext.gather.watchstar/CollectionsApi' ),
+       var CollectionsApi = M.require( 'ext.gather.api/CollectionsApi' ),
                toast = M.require( 'toast' ),
                overlayManager = M.require( 'overlayManager' );
 
diff --git a/resources/ext.gather.special/init.js 
b/resources/ext.gather.special/init.js
index 2e2de29..908ae9f 100644
--- a/resources/ext.gather.special/init.js
+++ b/resources/ext.gather.special/init.js
@@ -1,6 +1,6 @@
 ( function ( M, $ ) {
 
-       var CollectionsApi = M.require( 'ext.gather.watchstar/CollectionsApi' ),
+       var CollectionsApi = M.require( 'ext.gather.api/CollectionsApi' ),
                CollectionFlagOverlay = M.require( 
'ext.gather.flag/CollectionFlagOverlay' ),
                Icon = M.require( 'Icon' ),
                api = new CollectionsApi();
diff --git a/resources/ext.gather.watchstar/CollectionsContentOverlay.js 
b/resources/ext.gather.watchstar/CollectionsContentOverlay.js
index 7f05eff..fbed853 100644
--- a/resources/ext.gather.watchstar/CollectionsContentOverlay.js
+++ b/resources/ext.gather.watchstar/CollectionsContentOverlay.js
@@ -6,7 +6,7 @@
                toast = M.require( 'toast' ),
                user = M.require( 'user' ),
                Icon = M.require( 'Icon' ),
-               CollectionsApi = M.require( 
'ext.gather.watchstar/CollectionsApi' ),
+               CollectionsApi = M.require( 'ext.gather.api/CollectionsApi' ),
                CollectionsContentOverlayBase = M.require( 
'ext.gather.collection.base/CollectionsContentOverlayBase' ),
                ButtonWithSpinner = M.require( 'ButtonWithSpinner' );
 
diff --git a/tests/qunit/ext.gather.api/test_CollectionsApi.js 
b/tests/qunit/ext.gather.api/test_CollectionsApi.js
new file mode 100644
index 0000000..50aa388
--- /dev/null
+++ b/tests/qunit/ext.gather.api/test_CollectionsApi.js
@@ -0,0 +1,33 @@
+// var state = mw.config.get( 'wgGatherCollections' )
+// iterate through
+// check id against just watched collection id
+// update state
+// mw.config.set( 'wgGatherCollections', state );
+( function ( M, $ ) {
+       var CollectionsApi = M.require( 'ext.gather.api/CollectionsApi' );
+       QUnit.module( 'Gather', {
+               setup: function () {
+                       var d = $.Deferred().resolve( {
+                               query: {
+                                       lists: [
+                                               {
+                                                       id: 0,
+                                                       title: 'Watchlist',
+                                                       watchlist: ''
+                                               }
+                                       ]
+                               }
+                       } );
+                       this.sandbox.stub( CollectionsApi.prototype, 'get' 
).returns( d );
+               }
+       } );
+
+       QUnit.asyncTest( 'Watchlist in api request', 1, function ( assert ) {
+               var api = new CollectionsApi();
+               api.getCollection( 0 ).done( function ( collection ) {
+                       assert.strictEqual( collection.isWatchlist, true,
+                                       'Check it is a boolean and not an empty 
string.' );
+               } );
+       } );
+
+}( mw.mobileFrontend, jQuery ) );
diff --git a/tests/qunit/ext.gather.watchstar/test_CollectionsContentOverlay.js 
b/tests/qunit/ext.gather.watchstar/test_CollectionsContentOverlay.js
index 53437bd..7f8fe9d 100644
--- a/tests/qunit/ext.gather.watchstar/test_CollectionsContentOverlay.js
+++ b/tests/qunit/ext.gather.watchstar/test_CollectionsContentOverlay.js
@@ -4,7 +4,7 @@
 // update state
 // mw.config.set( 'wgGatherCollections', state );
 ( function ( M, $ ) {
-       var CollectionsApi = M.require( 'ext.gather.watchstar/CollectionsApi' ),
+       var CollectionsApi = M.require( 'ext.gather.api/CollectionsApi' ),
                CollectionsContentOverlay = M.require( 
'ext.gather.watchstar/CollectionsContentOverlay' );
 
        QUnit.module( 'Gather', {

-- 
To view, visit https://gerrit.wikimedia.org/r/207008
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Id7dc98868c53aea9b7a678a66e51fc1afe7c243d
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Gather
Gerrit-Branch: master
Gerrit-Owner: Jdlrobson <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to