Skip to content

Commit

Permalink
fix(tests)
Browse files Browse the repository at this point in the history
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
  • Loading branch information
marcelklehr committed Nov 27, 2024
1 parent 030b7d5 commit 763f464
Showing 1 changed file with 85 additions and 3 deletions.
88 changes: 85 additions & 3 deletions src/test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4904,10 +4904,10 @@ describe('Floccus', function() {
windowType: 'normal' // no devtools or panels or popups
})
await browser.tabs.remove(tabs.filter(tab => tab.url.startsWith('http')).map(tab => tab.id))
await awaitTabsUpdated()
} catch (e) {
console.error(e)
}
await awaitTabsUpdated()
if (ACCOUNT_DATA.type === 'git') {
await account.server.clearServer()
} else if (ACCOUNT_DATA.type !== 'fake') {
Expand Down Expand Up @@ -5115,14 +5115,14 @@ describe('Floccus', function() {
serverMark2 = {
title: 'Example Domain',
url: 'https://example.org/#test3',
parentId: windowFolderId,
parentId: tree.children[0].id,
location: ItemLocation.SERVER
}
await adapter.createBookmark(
new Bookmark(serverMark2)
)

await adapter.updateBookmark({ ...serverMark, id: serverMarkId, url: 'https://example.org/#test2', title: 'Example Domain', parentId: windowFolderId })
await adapter.updateBookmark({ ...serverMark, id: serverMarkId, url: 'https://example.org/#test2', title: 'Example Domain', parentId: tree.children[0].id })
})

await account.setData({...account.getData(), strategy: 'slave'})
Expand All @@ -5148,6 +5148,88 @@ describe('Floccus', function() {
false
)
})
it('should sync tabs correctly when merging server and local changes', async function() {
const adapter = account.server
const serverTree = await getAllBookmarks(account)
let windowFolderId, serverMark, serverMarkId
await withSyncConnection(account, async() => {
windowFolderId = await adapter.createFolder(new Folder({
parentId: serverTree.id,
title: 'Window 0',
location: ItemLocation.SERVER
}))
serverMark = {
title: 'Example Domain',
url: 'https://example.org/#test1',
parentId: windowFolderId,
location: ItemLocation.SERVER
}

serverMarkId = await adapter.createBookmark(
new Bookmark(serverMark)
)
})

await account.sync()
expect(account.getData().error).to.not.be.ok

let tree = await getAllBookmarks(account)
expectTreeEqual(
tree,
new Folder({
title: tree.title,
children: [
new Folder({
title: 'Window 0',
children: [
new Bookmark({ title: 'Example Domain', url: 'https://example.org/#test1' }),
]
})
]
}),
false
)

let serverMark2
await withSyncConnection(account, async() => {
serverMark2 = {
title: 'Example Domain',
url: 'https://example.org/#test3',
parentId: tree.children[0].id,
location: ItemLocation.SERVER
}
await adapter.createBookmark(
new Bookmark(serverMark2)
)

await adapter.updateBookmark({ ...serverMark, id: serverMarkId, url: 'https://example.org/#test2', title: 'Example Domain', parentId: tree.children[0].id })
})

await browser.tabs.create({url: 'https://example.org/#test4'})
await awaitTabsUpdated()

await account.sync()
expect(account.getData().error).to.not.be.ok

tree = await getAllBookmarks(account)
expectTreeEqual(
tree,
new Folder({
title: tree.title,
children: [
new Folder({
title: 'Window 0',
children: [
new Bookmark({ title: 'Example Domain', url: 'https://example.org/#test3' }),
new Bookmark({ title: 'Example Domain', url: 'https://example.org/#test2' }),
new Bookmark({ title: 'Example Domain', url: 'https://example.org/#test4' }),
]
})
]
}),
false
)
})
})
})
})
Expand Down

0 comments on commit 763f464

Please sign in to comment.