diff --git a/client/recordUtil.js b/client/recordUtil.js index 28fc37c..1874d6a 100644 --- a/client/recordUtil.js +++ b/client/recordUtil.js @@ -114,6 +114,17 @@ const pickFields = (object, fields) => { }, {}) } +/** + * Converts [] parentFolderObjectIds fields to null in place. Fix #107. + * @param {Object} record + */ +const normalizeBookmark = (record) => { + if (record && record.bookmark && record.bookmark.parentFolderObjectId && + !record.bookmark.parentFolderObjectId.length) { + record.bookmark.parentFolderObjectId = null + } +} + /** * Given a SyncRecord and a browser's matching existing object, resolve * objectData to the final object that should be applied by the browser. @@ -262,6 +273,12 @@ const mergeRecords = (recordsAndObjects) => { */ module.exports.resolveRecords = (recordsAndExistingObjects) => { let resolvedRecords = [] + recordsAndExistingObjects.forEach((item) => { + if (item) { + normalizeBookmark(item[0]) + normalizeBookmark(item[1]) + } + }) const merged = mergeRecords(recordsAndExistingObjects) merged.forEach(([record, existingObject]) => { const resolved = this.resolve(record, existingObject) diff --git a/package.json b/package.json index 4961a34..2d5451c 100644 --- a/package.json +++ b/package.json @@ -68,6 +68,7 @@ "standard": { "ignore": [ "test/crypto.js", + "test/client/data/*.js", "bundles/*.js", "client/polyfill/*.js", "lib/api.proto.js", diff --git a/test/client/fixtures/resolveAndroid.js b/test/client/fixtures/resolveAndroid.js new file mode 100644 index 0000000..9af5651 --- /dev/null +++ b/test/client/fixtures/resolveAndroid.js @@ -0,0 +1,2 @@ +module.exports.data = [[{ action: 0, deviceId: [1], objectId: [180, 199, 181, 215, 249, 207, 92, 243, 63, 69, 164, 188, 146, 53, 214, 145], objectData: 'bookmark', bookmark:{ site:{ location: "https://m.facebook.com/", title: "Facebook – log in or sign up", customTitle: "", favicon: "", lastAccessedTime: 0, creationTime: 0}, isFolder: false, parentFolderObjectId: null} }, null], [{ action: 1, deviceId: [0], objectId: [102, 169, 71, 255, 160, 7, 199, 37, 174, 1, 89, 148, 37, 235, 137, 188], objectData: 'bookmark', bookmark:{ site:{ location: "https://twitter.com/brave", title: "Brave Software (@brave) | Twitter", customTitle: "", favicon: "https://abs.twimg.com/favicons/favicon.ico", lastAccessedTime: 1499182519524, creationTime: 0}, isFolder: false, parentFolderObjectId: null} }, null], [{ action: 0, deviceId: [1], objectId: [50, 155, 253, 23, 226, 251, 247, 250, 190, 65, 73, 221, 118, 109, 70, 61], objectData: 'bookmark', bookmark:{ site:{ location: "https://en.m.wikipedia.org/wiki/Main_Page", title: "Wikipedia, the free encyclopedia", customTitle: "", favicon: "", lastAccessedTime: 0, creationTime: 0}, isFolder: false, parentFolderObjectId: null} }, null], [{ action: 0, deviceId: [1], objectId: [100, 238, 226, 152, 162, 241, 78, 165, 80, 209, 69, 56, 43, 239, 246, 120], objectData: 'bookmark', bookmark:{ site:{ location: "https://www.yahoo.com/", title: "Yahoo", customTitle: "", favicon: "", lastAccessedTime: 0, creationTime: 0}, isFolder: false, parentFolderObjectId: null} }, null], [{ action: 1, deviceId: [0], objectId: [57, 70, 144, 212, 237, 131, 12, 182, 117, 184, 46, 131, 46, 82, 113, 92], objectData: 'bookmark', bookmark:{ site:{ location: "https://brave.com/", title: "Brave Software | Building a Better Web", customTitle: "", favicon: "chrome-extension://mnojpmjdmbbfmejpflffifhffcmidifd/img/newtab/defaultTopSitesIcon/brave.ico", lastAccessedTime: 1, creationTime: 0}, isFolder: false, parentFolderObjectId: null} }, null], [{ action: 0, deviceId: [2], objectId: [50, 18, 21, 48, 179, 186, 120, 100, 165, 225, 251, 230, 29, 214, 223, 181], objectData: 'bookmark', bookmark:{ site:{ location: "https://www.theguardian.com/international", title: "News, sport and opinion from the Guardian's global edition | The Guardian", customTitle: "", favicon: "", lastAccessedTime: 0, creationTime: 0}, isFolder: false, parentFolderObjectId: null} }, null], [{ action: 0, deviceId: [2], objectId: [8, 146, 83, 105, 4, 60, 9, 110, 111, 10, 161, 34, 175, 6, 41, 174], objectData: 'bookmark', bookmark:{ site:{ location: "", title: "Folder1", customTitle: "", favicon: "", lastAccessedTime: 0, creationTime: 0}, isFolder: true, parentFolderObjectId: null} }, null], [{ action: 1, deviceId: [2], objectId: [50, 18, 21, 48, 179, 186, 120, 100, 165, 225, 251, 230, 29, 214, 223, 181], objectData: 'bookmark', bookmark:{ site:{ location: "https://www.theguardian.com/international", title: "News, sport and opinion from the Guardian's global edition | The Guardian", customTitle: "", favicon: "", lastAccessedTime: 0, creationTime: 0}, isFolder: false, parentFolderObjectId: [8, 146, 83, 105, 4, 60, 9, 110, 111, 10, 161, 34, 175, 6, 41, 174]} }, null], [{ action: 0, deviceId: [2], objectId: [185, 137, 250, 90, 121, 233, 6, 219, 254, 150, 22, 101, 172, 45, 193, 26], objectData: 'bookmark', bookmark:{ site:{ location: "", title: "Folder0", customTitle: "", favicon: "", lastAccessedTime: 0, creationTime: 0}, isFolder: true, parentFolderObjectId: null} }, null], [{ action: 1, deviceId: [2], objectId: [8, 146, 83, 105, 4, 60, 9, 110, 111, 10, 161, 34, 175, 6, 41, 174], objectData: 'bookmark', bookmark:{ site:{ location: "", title: "Folder1", customTitle: "", favicon: "", lastAccessedTime: 0, creationTime: 0}, isFolder: true, parentFolderObjectId: [185, 137, 250, 90, 121, 233, 6, 219, 254, 150, 22, 101, 172, 45, 193, 26]} }, null], [{ action: 1, deviceId: [2], objectId: [8, 146, 83, 105, 4, 60, 9, 110, 111, 10, 161, 34, 175, 6, 41, 174], objectData: 'bookmark', bookmark:{ site:{ location: "", title: "Folder1", customTitle: "", favicon: "", lastAccessedTime: 0, creationTime: 0}, isFolder: true, parentFolderObjectId: null} }, null], [{ action: 0, deviceId: [2], objectId: [28, 88, 77, 105, 60, 148, 56, 216, 234, 167, 75, 220, 142, 91, 173, 37], objectData: 'bookmark', bookmark:{ site:{ location: "https://m.slashdot.org/", title: "Slashdot", customTitle: "", favicon: "", lastAccessedTime: 0, creationTime: 0}, isFolder: false, parentFolderObjectId: null} }, null], [{ action: 0, deviceId: [4], objectId: [12, 150, 93, 122, 6, 116, 243, 239, 237, 197, 68, 195, 0, 188, 183, 150], objectData: 'bookmark', bookmark:{ site:{ location: "", title: "Folder2", customTitle: "", favicon: "", lastAccessedTime: 0, creationTime: 0}, isFolder: true, parentFolderObjectId: null} }, null], [{ action: 1, deviceId: [4], objectId: [100, 238, 226, 152, 162, 241, 78, 165, 80, 209, 69, 56, 43, 239, 246, 120], objectData: 'bookmark', bookmark:{ site:{ location: "https://www.yahoo.com/", title: "Yahoo", customTitle: "", favicon: "", lastAccessedTime: 0, creationTime: 0}, isFolder: false, parentFolderObjectId: [12, 150, 93, 122, 6, 116, 243, 239, 237, 197, 68, 195, 0, 188, 183, 150]} }, null], [{ action: 0, deviceId: [4], objectId: [186, 183, 34, 202, 153, 217, 44, 45, 153, 87, 34, 117, 39, 115, 246, 80], objectData: 'bookmark', bookmark:{ site:{ location: "", title: "Folder3", customTitle: "", favicon: "", lastAccessedTime: 0, creationTime: 0}, isFolder: true, parentFolderObjectId: null} }, null], [{ action: 1, deviceId: [4], objectId: [12, 150, 93, 122, 6, 116, 243, 239, 237, 197, 68, 195, 0, 188, 183, 150], objectData: 'bookmark', bookmark:{ site:{ location: "", title: "Folder2", customTitle: "", favicon: "", lastAccessedTime: 0, creationTime: 0}, isFolder: true, parentFolderObjectId: [186, 183, 34, 202, 153, 217, 44, 45, 153, 87, 34, 117, 39, 115, 246, 80]} }, null], [{ action: 1, deviceId: [4], objectId: [12, 150, 93, 122, 6, 116, 243, 239, 237, 197, 68, 195, 0, 188, 183, 150], objectData: 'bookmark', bookmark:{ site:{ location: "", title: "Folder2", customTitle: "", favicon: "", lastAccessedTime: 0, creationTime: 0}, isFolder: true, parentFolderObjectId: null} }, null], [{ action: 2, deviceId: [4], objectId: [28, 88, 77, 105, 60, 148, 56, 216, 234, 167, 75, 220, 142, 91, 173, 37], objectData: 'bookmark', bookmark:{ site:{ location: "https://m.slashdot.org/", title: "Slashdot", customTitle: "", favicon: "", lastAccessedTime: 0, creationTime: 0}, isFolder: false, parentFolderObjectId: null} }, null], [{ action: 2, deviceId: [4], objectId: [28, 88, 77, 105, 60, 148, 56, 216, 234, 167, 75, 220, 142, 91, 173, 37], objectData: 'bookmark', bookmark:{ site:{ location: "https://m.slashdot.org/", title: "Slashdot", customTitle: "", favicon: "", lastAccessedTime: 0, creationTime: 0}, isFolder: false, parentFolderObjectId: null} }, null], [{ action: 2, deviceId: [4], objectId: [28, 88, 77, 105, 60, 148, 56, 216, 234, 167, 75, 220, 142, 91, 173, 37], objectData: 'bookmark', bookmark:{ site:{ location: "https://m.slashdot.org/", title: "Slashdot", customTitle: "", favicon: "", lastAccessedTime: 0, creationTime: 0}, isFolder: false, parentFolderObjectId: null} }, null], [{ action: 2, deviceId: [4], objectId: [28, 88, 77, 105, 60, 148, 56, 216, 234, 167, 75, 220, 142, 91, 173, 37], objectData: 'bookmark', bookmark:{ site:{ location: "https://m.slashdot.org/", title: "Slashdot", customTitle: "", favicon: "", lastAccessedTime: 0, creationTime: 0}, isFolder: false, parentFolderObjectId: null} }, null], [{ action: 2, deviceId: [4], objectId: [28, 88, 77, 105, 60, 148, 56, 216, 234, 167, 75, 220, 142, 91, 173, 37], objectData: 'bookmark', bookmark:{ site:{ location: "https://m.slashdot.org/", title: "Slashdot", customTitle: "", favicon: "", lastAccessedTime: 0, creationTime: 0}, isFolder: false, parentFolderObjectId: null} }, null], [{ action: 2, deviceId: [5], objectId: [180, 199, 181, 215, 249, 207, 92, 243, 63, 69, 164, 188, 146, 53, 214, 145], objectData: 'bookmark', bookmark:{ site:{ location: "https://m.facebook.com/", title: "Facebook – log in or sign up", customTitle: "", favicon: "", lastAccessedTime: 0, creationTime: 0}, isFolder: false, parentFolderObjectId: null} }, null], [{ action: 2, deviceId: [5], objectId: [102, 169, 71, 255, 160, 7, 199, 37, 174, 1, 89, 148, 37, 235, 137, 188], objectData: 'bookmark', bookmark:{ site:{ location: "https://twitter.com/brave", title: "Brave Software (@brave) | Twitter", customTitle: "", favicon: "https://abs.twimg.com/favicons/favicon.ico", lastAccessedTime: 1499182519524, creationTime: 0}, isFolder: false, parentFolderObjectId: null} }, null], [{ action: 2, deviceId: [5], objectId: [50, 155, 253, 23, 226, 251, 247, 250, 190, 65, 73, 221, 118, 109, 70, 61], objectData: 'bookmark', bookmark:{ site:{ location: "https://en.m.wikipedia.org/wiki/Main_Page", title: "Wikipedia, the free encyclopedia", customTitle: "", favicon: "", lastAccessedTime: 0, creationTime: 0}, isFolder: false, parentFolderObjectId: null} }, null], [{ action: 2, deviceId: [5], objectId: [57, 70, 144, 212, 237, 131, 12, 182, 117, 184, 46, 131, 46, 82, 113, 92], objectData: 'bookmark', bookmark:{ site:{ location: "https://brave.com/", title: "Brave Software | Building a Better Web", customTitle: "", favicon: "chrome-extension://mnojpmjdmbbfmejpflffifhffcmidifd/img/newtab/defaultTopSitesIcon/brave.ico", lastAccessedTime: 1, creationTime: 0}, isFolder: false, parentFolderObjectId: null} }, null]] + diff --git a/test/client/fixtures/resolveLaptop.js b/test/client/fixtures/resolveLaptop.js new file mode 100644 index 0000000..bea0fae --- /dev/null +++ b/test/client/fixtures/resolveLaptop.js @@ -0,0 +1 @@ +module.exports.data = [[{"action":0,"bookmark":{"isFolder":false,"parentFolderObjectId":[],"site":{"creationTime":0,"customTitle":"","favicon":"","lastAccessedTime":0,"location":"https://m.facebook.com/","title":"Facebook – log in or sign up"}},"deviceId":[1],"objectData":"bookmark","objectId":[180,199,181,215,249,207,92,243,63,69,164,188,146,53,214,145],"syncTimestamp":1499182364028},null],[{"action":1,"bookmark":{"isFolder":false,"site":{"creationTime":0,"customTitle":"","favicon":"https://abs.twimg.com/favicons/favicon.ico","lastAccessedTime":1499182519524,"location":"https://twitter.com/brave","title":"Brave Software (@brave) | Twitter"}},"deviceId":[0],"objectData":"bookmark","objectId":[102,169,71,255,160,7,199,37,174,1,89,148,37,235,137,188],"syncTimestamp":1499182523711},null],[{"action":0,"bookmark":{"isFolder":false,"parentFolderObjectId":[],"site":{"creationTime":0,"customTitle":"","favicon":"","lastAccessedTime":0,"location":"https://en.m.wikipedia.org/wiki/Main_Page","title":"Wikipedia, the free encyclopedia"}},"deviceId":[1],"objectData":"bookmark","objectId":[50,155,253,23,226,251,247,250,190,65,73,221,118,109,70,61],"syncTimestamp":1499182560767},null],[{"action":0,"bookmark":{"isFolder":false,"parentFolderObjectId":[],"site":{"creationTime":0,"customTitle":"","favicon":"","lastAccessedTime":0,"location":"https://www.yahoo.com/","title":"Yahoo"}},"deviceId":[1],"objectData":"bookmark","objectId":[100,238,226,152,162,241,78,165,80,209,69,56,43,239,246,120],"syncTimestamp":1499183235567},null],[{"action":1,"bookmark":{"isFolder":false,"site":{"creationTime":0,"customTitle":"","favicon":"chrome-extension://mnojpmjdmbbfmejpflffifhffcmidifd/img/newtab/defaultTopSitesIcon/brave.ico","lastAccessedTime":1,"location":"https://brave.com/","title":"Brave Software | Building a Better Web"}},"deviceId":[0],"objectData":"bookmark","objectId":[57,70,144,212,237,131,12,182,117,184,46,131,46,82,113,92],"syncTimestamp":1499183408150},null],[{"action":0,"bookmark":{"isFolder":false,"parentFolderObjectId":[],"site":{"creationTime":0,"customTitle":"","favicon":"","lastAccessedTime":0,"location":"https://www.theguardian.com/international","title":"News, sport and opinion from the Guardian's global edition | The Guardian"}},"deviceId":[2],"objectData":"bookmark","objectId":[50,18,21,48,179,186,120,100,165,225,251,230,29,214,223,181],"syncTimestamp":1499197431917},null],[{"action":0,"bookmark":{"isFolder":true,"parentFolderObjectId":[],"site":{"creationTime":0,"customTitle":"","favicon":"","lastAccessedTime":0,"location":"","title":"Folder1"}},"deviceId":[2],"objectData":"bookmark","objectId":[8,146,83,105,4,60,9,110,111,10,161,34,175,6,41,174],"syncTimestamp":1499197515513},null],[{"action":1,"bookmark":{"isFolder":false,"parentFolderObjectId":[8,146,83,105,4,60,9,110,111,10,161,34,175,6,41,174],"site":{"creationTime":0,"customTitle":"","favicon":"","lastAccessedTime":0,"location":"https://www.theguardian.com/international","title":"News, sport and opinion from the Guardian's global edition | The Guardian"}},"deviceId":[2],"objectData":"bookmark","objectId":[50,18,21,48,179,186,120,100,165,225,251,230,29,214,223,181],"syncTimestamp":1499197515547},null],[{"action":0,"bookmark":{"isFolder":true,"parentFolderObjectId":[],"site":{"creationTime":0,"customTitle":"","favicon":"","lastAccessedTime":0,"location":"","title":"Folder0"}},"deviceId":[2],"objectData":"bookmark","objectId":[185,137,250,90,121,233,6,219,254,150,22,101,172,45,193,26],"syncTimestamp":1499197572153},null],[{"action":1,"bookmark":{"isFolder":true,"parentFolderObjectId":[185,137,250,90,121,233,6,219,254,150,22,101,172,45,193,26],"site":{"creationTime":0,"customTitle":"","favicon":"","lastAccessedTime":0,"location":"","title":"Folder1"}},"deviceId":[2],"objectData":"bookmark","objectId":[8,146,83,105,4,60,9,110,111,10,161,34,175,6,41,174],"syncTimestamp":1499197572168},null],[{"action":1,"bookmark":{"isFolder":true,"parentFolderObjectId":[],"site":{"creationTime":0,"customTitle":"","favicon":"","lastAccessedTime":0,"location":"","title":"Folder1"}},"deviceId":[2],"objectData":"bookmark","objectId":[8,146,83,105,4,60,9,110,111,10,161,34,175,6,41,174],"syncTimestamp":1499197616732},null],[{"action":0,"bookmark":{"isFolder":false,"parentFolderObjectId":[],"site":{"creationTime":0,"customTitle":"","favicon":"","lastAccessedTime":0,"location":"https://m.slashdot.org/","title":"Slashdot"}},"deviceId":[2],"objectData":"bookmark","objectId":[28,88,77,105,60,148,56,216,234,167,75,220,142,91,173,37],"syncTimestamp":1499197733375},null],[{"action":0,"bookmark":{"isFolder":true,"parentFolderObjectId":[],"site":{"creationTime":0,"customTitle":"","favicon":"","lastAccessedTime":0,"location":"","title":"Folder2"}},"deviceId":[4],"objectData":"bookmark","objectId":[12,150,93,122,6,116,243,239,237,197,68,195,0,188,183,150],"syncTimestamp":1499276712538},null],[{"action":1,"bookmark":{"isFolder":false,"parentFolderObjectId":[12,150,93,122,6,116,243,239,237,197,68,195,0,188,183,150],"site":{"creationTime":0,"customTitle":"","favicon":"","lastAccessedTime":0,"location":"https://www.yahoo.com/","title":"Yahoo"}},"deviceId":[4],"objectData":"bookmark","objectId":[100,238,226,152,162,241,78,165,80,209,69,56,43,239,246,120],"syncTimestamp":1499276712550},null],[{"action":0,"bookmark":{"isFolder":true,"parentFolderObjectId":[],"site":{"creationTime":0,"customTitle":"","favicon":"","lastAccessedTime":0,"location":"","title":"Folder3"}},"deviceId":[4],"objectData":"bookmark","objectId":[186,183,34,202,153,217,44,45,153,87,34,117,39,115,246,80],"syncTimestamp":1499276733365},null],[{"action":1,"bookmark":{"isFolder":true,"parentFolderObjectId":[186,183,34,202,153,217,44,45,153,87,34,117,39,115,246,80],"site":{"creationTime":0,"customTitle":"","favicon":"","lastAccessedTime":0,"location":"","title":"Folder2"}},"deviceId":[4],"objectData":"bookmark","objectId":[12,150,93,122,6,116,243,239,237,197,68,195,0,188,183,150],"syncTimestamp":1499276733388},null],[{"action":1,"bookmark":{"isFolder":true,"parentFolderObjectId":[],"site":{"creationTime":0,"customTitle":"","favicon":"","lastAccessedTime":0,"location":"","title":"Folder2"}},"deviceId":[4],"objectData":"bookmark","objectId":[12,150,93,122,6,116,243,239,237,197,68,195,0,188,183,150],"syncTimestamp":1499276801913},null],[{"action":2,"bookmark":{"isFolder":false,"parentFolderObjectId":[],"site":{"creationTime":0,"customTitle":"","favicon":"","lastAccessedTime":0,"location":"https://m.slashdot.org/","title":"Slashdot"}},"deviceId":[4],"objectData":"bookmark","objectId":[28,88,77,105,60,148,56,216,234,167,75,220,142,91,173,37],"syncTimestamp":1499277601715},null],[{"action":2,"bookmark":{"isFolder":false,"parentFolderObjectId":[],"site":{"creationTime":0,"customTitle":"","favicon":"","lastAccessedTime":0,"location":"https://m.slashdot.org/","title":"Slashdot"}},"deviceId":[4],"objectData":"bookmark","objectId":[28,88,77,105,60,148,56,216,234,167,75,220,142,91,173,37],"syncTimestamp":1499277601736},null],[{"action":2,"bookmark":{"isFolder":false,"parentFolderObjectId":[],"site":{"creationTime":0,"customTitle":"","favicon":"","lastAccessedTime":0,"location":"https://m.slashdot.org/","title":"Slashdot"}},"deviceId":[4],"objectData":"bookmark","objectId":[28,88,77,105,60,148,56,216,234,167,75,220,142,91,173,37],"syncTimestamp":1499277601751},null],[{"action":2,"bookmark":{"isFolder":false,"parentFolderObjectId":[],"site":{"creationTime":0,"customTitle":"","favicon":"","lastAccessedTime":0,"location":"https://m.slashdot.org/","title":"Slashdot"}},"deviceId":[4],"objectData":"bookmark","objectId":[28,88,77,105,60,148,56,216,234,167,75,220,142,91,173,37],"syncTimestamp":1499277601768},null],[{"action":2,"bookmark":{"isFolder":false,"parentFolderObjectId":[],"site":{"creationTime":0,"customTitle":"","favicon":"","lastAccessedTime":0,"location":"https://m.slashdot.org/","title":"Slashdot"}},"deviceId":[4],"objectData":"bookmark","objectId":[28,88,77,105,60,148,56,216,234,167,75,220,142,91,173,37],"syncTimestamp":1499277601785},null],[{"action":2,"bookmark":{"isFolder":false,"site":{"creationTime":0,"customTitle":"","favicon":"","lastAccessedTime":0,"location":"https://m.facebook.com/","title":"Facebook – log in or sign up"}},"deviceId":[5],"objectData":"bookmark","objectId":[180,199,181,215,249,207,92,243,63,69,164,188,146,53,214,145],"syncTimestamp":1499277751881},null],[{"action":2,"bookmark":{"isFolder":false,"site":{"creationTime":0,"customTitle":"","favicon":"https://abs.twimg.com/favicons/favicon.ico","lastAccessedTime":1499182519524,"location":"https://twitter.com/brave","title":"Brave Software (@brave) | Twitter"}},"deviceId":[5],"objectData":"bookmark","objectId":[102,169,71,255,160,7,199,37,174,1,89,148,37,235,137,188],"syncTimestamp":1499277754662},null],[{"action":2,"bookmark":{"isFolder":false,"site":{"creationTime":0,"customTitle":"","favicon":"","lastAccessedTime":0,"location":"https://en.m.wikipedia.org/wiki/Main_Page","title":"Wikipedia, the free encyclopedia"}},"deviceId":[5],"objectData":"bookmark","objectId":[50,155,253,23,226,251,247,250,190,65,73,221,118,109,70,61],"syncTimestamp":1499277757092},null],[{"action":2,"bookmark":{"isFolder":false,"site":{"creationTime":0,"customTitle":"","favicon":"chrome-extension://mnojpmjdmbbfmejpflffifhffcmidifd/img/newtab/defaultTopSitesIcon/brave.ico","lastAccessedTime":1,"location":"https://brave.com/","title":"Brave Software | Building a Better Web"}},"deviceId":[5],"objectData":"bookmark","objectId":[57,70,144,212,237,131,12,182,117,184,46,131,46,82,113,92],"syncTimestamp":1499277759402},null]] diff --git a/test/client/recordUtil.js b/test/client/recordUtil.js index 2b2ee2e..7f14557 100644 --- a/test/client/recordUtil.js +++ b/test/client/recordUtil.js @@ -370,7 +370,22 @@ test('recordUtil.resolve', (t) => { }) test('recordUtil.resolveRecords()', (t) => { - t.plan(4) + t.plan(5) + + t.test(`${t.name} resolves same data cross-platform on laptop and android`, (t) => { + t.plan(1) + // Generated by logging Android input to RESOLVE_SYNC_RECORDS + const androidRecordsAndExistingObjects = require('./fixtures/resolveAndroid').data + // Generated by logging browser-laptop input to RESOLVE_SYNC_RECORDS + const laptopRecordsAndExistingObjects = require('./fixtures/resolveLaptop').data + const resolvedLaptop = recordUtil.resolveRecords(laptopRecordsAndExistingObjects) + resolvedLaptop.forEach((record) => { + // Ignore syncTimestamp on laptop since Android doesn't use it + delete record.syncTimestamp + }) + const resolvedAndroid = recordUtil.resolveRecords(androidRecordsAndExistingObjects) + t.deepEquals(resolvedLaptop, resolvedAndroid, `resolves same bookmarks on android and laptop`) + }) t.test(`${t.name} takes [ [{syncRecord}, {existingObject || null}], ... ] and returns resolved records [{syncRecord}, ...]`, (t) => { t.plan(1)