Mobrovac has submitted this change and it was merged.

Change subject: Eliminate image/video distinction in media object
......................................................................


Eliminate image/video distinction in media object

Eliminate the image/video distinction for greater flexibility in ordering
(see, e.g., T86954).

Bug: T109105
Change-Id: Ib26cb183f322ed7f7413c64f0e748162d8dbc890
---
M lib/gallery.js
M test/features/mobile-html-sections-remaining/pagecontent.js
M test/features/mobile-html-sections/pagecontent.js
3 files changed, 13 insertions(+), 8 deletions(-)

Approvals:
  Mobrovac: Looks good to me, approved



diff --git a/lib/gallery.js b/lib/gallery.js
index d0b4c45..eff254e 100644
--- a/lib/gallery.js
+++ b/lib/gallery.js
@@ -189,6 +189,13 @@
         return BBPromise.props({
             videos: detailsPromises.videos,
             images: detailsPromises.images
+        }).then(function(result) {
+            result.images = result.images || [];
+            result.videos = result.videos || [];
+            return (((result.images + result.videos).length > 0)
+                ? {"items": result.images + result.videos}
+                : {}
+            );
         });
     });
 }
diff --git a/test/features/mobile-html-sections-remaining/pagecontent.js 
b/test/features/mobile-html-sections-remaining/pagecontent.js
index dfa23a9..10df3a3 100644
--- a/test/features/mobile-html-sections-remaining/pagecontent.js
+++ b/test/features/mobile-html-sections-remaining/pagecontent.js
@@ -17,11 +17,11 @@
         return headers.checkHeaders(server.config.uri + 
'test.wikipedia.org/v1/page/mobile-html-sections-remaining/Test',
             'application/json');
     });
-    it('en Main page should have at least on image', function() {
+    it('en Main page should have at least one image', function() {
         return preq.get({ uri: server.config.uri + 
'en.wikipedia.org/v1/page/mobile-html-sections-remaining/Main_Page' })
             .then(function(res) {
                 var remaining = res.body;
-                assert.ok(remaining.media.images.length > 0, 'Expected at 
least one image');
+                assert.ok(remaining.media.items.length > 0, 'Expected at least 
one media item');
             });
     });
     it('Obama (redirect) should have at least one video, and many images', 
function() {
@@ -35,8 +35,7 @@
                 assert.ok(remaining.sections[0].text.length > 3);
                 assert.ok(remaining.sections[0].line.length > 3);
                 assert.ok(remaining.sections[0].anchor.length > 3);
-                assert.ok(remaining.media.videos.length > 0, 'Expected at 
least one video');
-                assert.ok(remaining.media.images.length > 3, 'Expected many 
images');
+                assert.ok(remaining.media.items.length > 3, 'Expected many 
media items');
             });
     });
 });
\ No newline at end of file
diff --git a/test/features/mobile-html-sections/pagecontent.js 
b/test/features/mobile-html-sections/pagecontent.js
index c2661ce..1b68255 100644
--- a/test/features/mobile-html-sections/pagecontent.js
+++ b/test/features/mobile-html-sections/pagecontent.js
@@ -55,10 +55,10 @@
                 assert.ok(lead.sections[0].text.length > 0, 'Expected text to 
be non-empty');
 
                 var remaining = res.body.remaining;
-                assert.ok(remaining.media.images.length > 0, 'Expected at 
least one image');
+                assert.ok(remaining.media.items.length > 0, 'Expected at least 
one media item');
             });
     });
-    it('Obama (redirect) should have a lead image, at least one video, and 
many images', function() {
+    it('Obama (redirect) should have a lead image and many media items', 
function() {
         return preq.get({ uri: server.config.uri + 
'en.wikipedia.org/v1/page/mobile-html-sections/Obama' })
             .then(function(res) {
                 var lead = res.body.lead;
@@ -79,8 +79,7 @@
                 assert.ok(remaining.sections[0].text.length > 3);
                 assert.ok(remaining.sections[0].line.length > 3);
                 assert.ok(remaining.sections[0].anchor.length > 3);
-                assert.ok(remaining.media.videos.length > 0, 'Expected at 
least one video');
-                assert.ok(remaining.media.images.length > 3, 'Expected many 
images');
+                assert.ok(remaining.media.items.length > 3, 'Expected many 
media items');
             });
     });
 });
\ No newline at end of file

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Ib26cb183f322ed7f7413c64f0e748162d8dbc890
Gerrit-PatchSet: 5
Gerrit-Project: mediawiki/services/mobileapps
Gerrit-Branch: master
Gerrit-Owner: Mholloway <[email protected]>
Gerrit-Reviewer: BearND <[email protected]>
Gerrit-Reviewer: Bgerstle <[email protected]>
Gerrit-Reviewer: Dbrant <[email protected]>
Gerrit-Reviewer: Fjalapeno <[email protected]>
Gerrit-Reviewer: GWicke <[email protected]>
Gerrit-Reviewer: Mholloway <[email protected]>
Gerrit-Reviewer: Mhurd <[email protected]>
Gerrit-Reviewer: Mobrovac <[email protected]>
Gerrit-Reviewer: Niedzielski <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to