diff --git a/src/test/test.js b/src/test/test.js index ef9f0aacb9..4935fc673a 100644 --- a/src/test/test.js +++ b/src/test/test.js @@ -1893,6 +1893,102 @@ describe('Floccus', function() { Boolean(account.server.orderFolder) ) }) + it('should move items without confusing folders', async function() { + const localRoot = account.getData().localRoot + + const aFolder = await browser.bookmarks.create({ + title: 'a', + parentId: localRoot + }) + const bFolder = await browser.bookmarks.create({ + title: 'b', + parentId: localRoot + }) + const dFolder = await browser.bookmarks.create({ + title: 'd', + parentId: localRoot + }) + const cFolder1 = await browser.bookmarks.create({ + title: 'c', + parentId: aFolder.id + }) + await browser.bookmarks.create({ + title: 'url', + url: 'http://ur.l/', + parentId: cFolder1.id + }) + const cFolder2 = await browser.bookmarks.create({ + title: 'c', + parentId: bFolder.id + }) + await browser.bookmarks.create({ + title: 'test', + url: 'http://urrr.l/', + parentId: cFolder2.id + }) + + await account.sync() // propagate to server + expect(account.getData().error).to.not.be.ok + + // move b into a in client + await browser.bookmarks.move(cFolder1.id, { parentId: dFolder.id }) + await browser.bookmarks.move(cFolder2.id, { parentId: localRoot }) + + await account.sync() // propagate to server + expect(account.getData().error).to.not.be.ok + + const tree = await getAllBookmarks(account) + expectTreeEqual( + tree, + new Folder({ + title: tree.title, + children: [ + new Folder({ + title: 'a', + children: [] + }), + new Folder({ + title: 'b', + children: [] + }), + new Folder({ + title: 'd', + children: [ + new Folder({ + title: 'c', + children: [ + new Bookmark({ + title: 'url', + url: 'http://ur.l/', + }) + ] + }) + ] + }), + new Folder({ + title: 'c', + children: [ + new Bookmark({ + title: 'test', + url: 'http://urrr.l/', + }) + ] + }), + ] + }), + false, + Boolean(account.server.orderFolder) + ) + + const localTree = await account.localTree.getBookmarksTree(true) + localTree.title = tree.title + expectTreeEqual( + localTree, + tree, + false, + Boolean(account.server.orderFolder) + ) + }) it('should integrate existing items from both sides', async function() { const localRoot = account.getData().localRoot