jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/355865 )

Change subject: Add test for HTML in certain iOS announcement fields
......................................................................


Add test for HTML in certain iOS announcement fields

The iOS app doesn't support HTML in certain announcement fields.

Not testing for this caused some HTML to accidentally appear
uninterpreted in the latest iOS announcement. This was
hotfixed in I5b26be8106c728e8310616db9a2e6d90c56fc774

Bug: T166356
Change-Id: I34b48f52f53d92168264011b7bf452e26c12db8e
---
M routes/announcements.js
M test/features/announcements/announcements.js
2 files changed, 30 insertions(+), 1 deletion(-)

Approvals:
  BearND: Looks good to me, approved
  jenkins-bot: Verified
  Mholloway: Looks good to me, but someone else must approve



diff --git a/routes/announcements.js b/routes/announcements.js
index 07f2fb7..83a9f0e 100644
--- a/routes/announcements.js
+++ b/routes/announcements.js
@@ -9,7 +9,7 @@
 const router = sUtil.router();
 
 function getEnwikiAnnouncements() {
-    // Notes: for iOS text: HTML is not supported.
+    // Notes: for iOS 'text' and 'action.title': HTML is not supported.
     // iOS uses image_url instead of the image Android uses.
     return [
         {
diff --git a/test/features/announcements/announcements.js 
b/test/features/announcements/announcements.js
index 483a2a5..49f8365 100644
--- a/test/features/announcements/announcements.js
+++ b/test/features/announcements/announcements.js
@@ -1,5 +1,6 @@
 'use strict';
 
+const domino = require('domino');
 const preq   = require('preq');
 const assert = require('../../utils/assert.js');
 const server = require('../../utils/server.js');
@@ -51,4 +52,32 @@
                 assert.ok(res.body.announce.length === 0);
             });
     });
+
+    it('should not deliver HTML in certain iOS announcements fields', () => {
+        const doc = domino.createDocument();
+        return preq.get({ uri: 
`${server.config.uri}en.wikipedia.org/v1/feed/announcements` })
+            .then((res) => {
+                assert.status(res, 200);
+                res.body.announce
+                  .filter(announcement => 
announcement.platforms.includes('iOSApp'))
+                  .map((iOSAnnouncement) => {
+                      // destructure 'id', 'text' and 'action.title' from the 
iOS announcement
+                      const { id, text, action:{ title } } = iOSAnnouncement;
+                      return { id, fieldsToCheck: { text, title } };
+                  }).forEach((item) => {
+                      for (const textOnlyFieldName of 
Object.keys(item.fieldsToCheck)) {
+                          const textToCheck = 
item.fieldsToCheck[textOnlyFieldName];
+                          const element = doc.createElement('div');
+                          element.innerHTML = textToCheck;
+                          // Comparing innerHTML and textContent lengths 
catches even non-tag html,
+                          // such as ' ';
+                          assert.equal(
+                            element.innerHTML.length, 
element.textContent.length,
+                              `iOS does not support HTML in the 
"${textOnlyFieldName}" field` +
+                              ` - this was encountered in the "${item.id}" 
announcement`
+                          );
+                      }
+                  });
+            });
+    });
 });

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

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

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

Reply via email to