Skip to content

Commit

Permalink
Merge pull request #1719 from floccusaddon/test/recreation
Browse files Browse the repository at this point in the history
test: Try removing and recreating a bookmark
  • Loading branch information
marcelklehr authored Oct 9, 2024
2 parents 0002c2f + b452198 commit e2479eb
Showing 1 changed file with 83 additions and 0 deletions.
83 changes: 83 additions & 0 deletions src/test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down

0 comments on commit e2479eb

Please sign in to comment.