@@ -5232,6 +5232,132 @@ describe('Floccus', function() {
52325232 expectTreeEqual ( secondLocalTree1 , secondLocalTree2 , true , true )
52335233 } )
52345234
5235+ it ( 'should synchronize ordering (2)' , async function ( ) {
5236+ if ( ACCOUNT_DATA . type === 'linkwarden' || ACCOUNT_DATA . type === 'karakeep' ) {
5237+ return this . skip ( )
5238+ }
5239+ expect (
5240+ ( await getAllBookmarks ( account1 ) ) . children
5241+ ) . to . have . lengthOf ( 0 )
5242+
5243+ const localRoot1 = account1 . getData ( ) . localRoot
5244+ const fooFolder = await browser . bookmarks . create ( {
5245+ title : 'foo' ,
5246+ parentId : localRoot1
5247+ } )
5248+ const folder11 = await browser . bookmarks . create ( {
5249+ title : 'folder11' ,
5250+ parentId : fooFolder . id
5251+ } )
5252+ const folder12 = await browser . bookmarks . create ( {
5253+ title : 'folder12' ,
5254+ parentId : fooFolder . id
5255+ } )
5256+ const bookmark11 = await browser . bookmarks . create ( {
5257+ title : 'url11' ,
5258+ url : 'http://ur.l/' ,
5259+ parentId : fooFolder . id
5260+ } )
5261+ const bookmark12 = await browser . bookmarks . create ( {
5262+ title : 'url12' ,
5263+ url : 'http://ur.ll/' ,
5264+ parentId : fooFolder . id
5265+ } )
5266+
5267+ await account1 . sync ( )
5268+ expect ( account1 . getData ( ) . error ) . to . not . be . ok
5269+
5270+ await account2 . sync ( )
5271+ expect ( account2 . getData ( ) . error ) . to . not . be . ok
5272+
5273+ console . log ( 'Checking local folder after initial sync' )
5274+
5275+ const localTree1 = await account1 . localTree . getBookmarksTree ( true )
5276+ const localTree2 = await account2 . localTree . getBookmarksTree ( true )
5277+ localTree2 . title = localTree1 . title
5278+ expectTreeEqual ( localTree1 , localTree2 , true , true )
5279+
5280+ const localTree1Foo = localTree1 . children . find ( item => item . title === 'foo' )
5281+ const localTree2Foo = localTree2 . children . find ( item => item . title === 'foo' )
5282+
5283+ const newBookmark1 = await browser . bookmarks . create ( {
5284+ title : 'newBookmark1' ,
5285+ url : 'http://ur.lllll/' ,
5286+ parentId : localTree1Foo . id
5287+ } )
5288+ await browser . bookmarks . move ( newBookmark1 . id , { index : 0 } )
5289+ await browser . bookmarks . move ( folder11 . id , { index : 4 } )
5290+ await browser . bookmarks . move ( folder12 . id , { index : 3 } )
5291+ await browser . bookmarks . move ( bookmark11 . id , { index : 2 } )
5292+ await browser . bookmarks . move ( bookmark12 . id , { index : 1 } )
5293+
5294+ const newBookmark2 = await browser . bookmarks . create ( {
5295+ title : 'newBookmark2' ,
5296+ url : 'http://ur.llllll/' ,
5297+ parentId : localTree2Foo . id
5298+ } )
5299+ await browser . bookmarks . move ( newBookmark2 . id , { index : 3 } )
5300+
5301+ await account1 . sync ( )
5302+ expect ( account1 . getData ( ) . error ) . to . not . be . ok
5303+
5304+ await account2 . sync ( )
5305+ expect ( account2 . getData ( ) . error ) . to . not . be . ok
5306+
5307+ await account1 . sync ( )
5308+ expect ( account1 . getData ( ) . error ) . to . not . be . ok
5309+
5310+ const secondLocalTree1 = await account1 . localTree . getBookmarksTree (
5311+ true
5312+ )
5313+
5314+ expectTreeEqual (
5315+ secondLocalTree1 ,
5316+ new Folder ( {
5317+ title : secondLocalTree1 . title ,
5318+ children : [
5319+ new Folder ( {
5320+ title : 'foo' ,
5321+ children : [
5322+ new Bookmark ( {
5323+ title : 'newBookmark1' ,
5324+ url : newBookmark1 . url
5325+ } ) ,
5326+ new Bookmark ( {
5327+ title : 'url12' ,
5328+ url : bookmark12 . url
5329+ } ) ,
5330+ new Bookmark ( {
5331+ title : 'url11' ,
5332+ url : bookmark11 . url
5333+ } ) ,
5334+ new Folder ( {
5335+ title : 'folder12' ,
5336+ children : [ ]
5337+ } ) ,
5338+ new Bookmark ( {
5339+ title : 'newBookmark2' ,
5340+ url : newBookmark2 . url
5341+ } ) ,
5342+ new Folder ( {
5343+ title : 'folder11' ,
5344+ children : [ ]
5345+ } ) ,
5346+ ]
5347+ } ) ,
5348+ ]
5349+ } ) ,
5350+ true ,
5351+ true
5352+ )
5353+
5354+ const secondLocalTree2 = await account2 . localTree . getBookmarksTree (
5355+ true
5356+ )
5357+ secondLocalTree2 . title = secondLocalTree1 . title
5358+ expectTreeEqual ( secondLocalTree1 , secondLocalTree2 , true , true )
5359+ } )
5360+
52355361 // Skipping this, because nextcloud adapter currently
52365362 // isn't able to track bookmarks across dirs, thus in this
52375363 // scenario both bookmarks survive :/
0 commit comments