Skip to content

Commit e3e6b93

Browse files
committed
test: update the server on local changes of url collisions
Signed-off-by: Marcel Klehr <[email protected]>
1 parent 4d8bcf7 commit e3e6b93

File tree

1 file changed

+61
-0
lines changed

1 file changed

+61
-0
lines changed

src/test/test.js

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -543,6 +543,67 @@ describe('Floccus', function() {
543543
false
544544
)
545545
})
546+
it('should update the server on local changes of url collisions', async function() {
547+
if (ACCOUNT_DATA.noCache) {
548+
return this.skip()
549+
}
550+
551+
const localRoot = account.getData().localRoot
552+
const fooFolder = await browser.bookmarks.create({
553+
title: 'foo',
554+
parentId: localRoot
555+
})
556+
const barFolder = await browser.bookmarks.create({
557+
title: 'bar',
558+
parentId: fooFolder.id
559+
})
560+
const bookmark1 = await browser.bookmarks.create({
561+
title: 'ur1l',
562+
url: 'http://ur1.l/',
563+
parentId: fooFolder.id
564+
})
565+
const bookmark2 = await browser.bookmarks.create({
566+
title: 'url',
567+
url: 'http://ur.l/',
568+
parentId: barFolder.id
569+
})
570+
await account.sync() // propagate to server
571+
expect(account.getData().error).to.not.be.ok
572+
573+
const newData = { url: 'http://ur.l/' }
574+
await browser.bookmarks.update(bookmark1.id, newData)
575+
await account.sync() // update on server
576+
expect(account.getData().error).to.not.be.ok
577+
578+
const tree = await getAllBookmarks(account)
579+
expectTreeEqual(
580+
tree,
581+
new Folder({
582+
title: tree.title,
583+
children: [
584+
new Folder({
585+
title: 'foo',
586+
children: [
587+
new Folder({
588+
title: 'bar',
589+
children: [
590+
new Bookmark({
591+
title: bookmark2.title,
592+
url: bookmark2.url
593+
})
594+
]
595+
}),
596+
new Bookmark({
597+
title: ACCOUNT_DATA.type === 'nextcloud-bookmarks' ? bookmark2.title : bookmark1.title,
598+
url: newData.url
599+
}),
600+
]
601+
})
602+
]
603+
}),
604+
false
605+
)
606+
})
546607
it('should update the server on local removals', async function() {
547608
if (ACCOUNT_DATA.noCache) {
548609
return this.skip()

0 commit comments

Comments
 (0)