From b452198d6785283322d0900309d425de5e48fa1f Mon Sep 17 00:00:00 2001 From: Marcel Klehr Date: Thu, 12 Sep 2024 15:51:10 +0200 Subject: [PATCH] test: Try removing and recreating a bookmark Signed-off-by: Marcel Klehr --- src/test/test.js | 83 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) diff --git a/src/test/test.js b/src/test/test.js index 58e1017814..c5c3defd60 100644 --- a/src/test/test.js +++ b/src/test/test.js @@ -589,6 +589,89 @@ describe('Floccus', function() { false ) }) + it('should update the server on local removals and recreations', async function() { + if (ACCOUNT_DATA.noCache) { + return this.skip() + } + expect( + (await getAllBookmarks(account)).children + ).to.have.lengthOf(0) + + const localRoot = account.getData().localRoot + const fooFolder = await browser.bookmarks.create({ + title: 'foo', + parentId: localRoot + }) + const barFolder = await browser.bookmarks.create({ + title: 'bar', + parentId: fooFolder.id + }) + const bookmark = await browser.bookmarks.create({ + title: 'url', + url: 'http://ur.l/', + parentId: barFolder.id + }) + await account.sync() // propagate to server + expect(account.getData().error).to.not.be.ok + + await browser.bookmarks.remove(bookmark.id) + await account.sync() // update on 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: 'foo', + children: [ + new Folder({ + title: 'bar', + children: [] + }) + ] + }) + ] + }), + false + ) + + const bookmark2 = await browser.bookmarks.create({ + title: 'url', + url: 'http://ur.l/', + parentId: barFolder.id + }) + + await account.sync() // update on server + expect(account.getData().error).to.not.be.ok + + const tree2 = await getAllBookmarks(account) + expectTreeEqual( + tree2, + new Folder({ + title: tree2.title, + children: [ + new Folder({ + title: 'foo', + children: [ + new Folder({ + title: 'bar', + children: [ + new Bookmark({ + url: bookmark2.url, + title: bookmark2.title + }) + ] + }) + ] + }) + ] + }), + false + ) + }) it('should update the server on local folder moves', async function() { const localRoot = account.getData().localRoot const fooFolder = await browser.bookmarks.create({