@@ -3020,6 +3020,154 @@ describe('Floccus', function() {
30203020 true
30213021 )
30223022 } )
3023+ it ( 'should not be confused by changes while syncing' , async function ( ) {
3024+ if ( ACCOUNT_DATA . noCache ) {
3025+ return this . skip ( )
3026+ }
3027+
3028+ const localRoot = account . getData ( ) . localRoot
3029+ const fooFolder = await browser . bookmarks . create ( {
3030+ title : 'foo' ,
3031+ parentId : localRoot
3032+ } )
3033+ const barFolder = await browser . bookmarks . create ( {
3034+ title : 'bar' ,
3035+ parentId : fooFolder . id
3036+ } )
3037+ const bookmark = await browser . bookmarks . create ( {
3038+ title : 'url' ,
3039+ url : 'http://ur.l/' ,
3040+ parentId : barFolder . id
3041+ } )
3042+
3043+ await account . sync ( ) // propagate to server
3044+ expect ( account . getData ( ) . error ) . to . not . be . ok
3045+
3046+ const bookmark2 = await browser . bookmarks . create ( {
3047+ title : 'url2' ,
3048+ url : 'http://ur2.l/' ,
3049+ parentId : barFolder . id
3050+ } )
3051+
3052+ // Make changes while sync is happening
3053+ let bookmark3
3054+ await Promise . all ( [
3055+ account . sync ( ) ,
3056+ ( async function ( ) {
3057+ await new Promise ( resolve => setTimeout ( resolve , 1500 ) )
3058+ bookmark3 = await browser . bookmarks . create ( {
3059+ title : 'url3' ,
3060+ url : 'http://ur3.l/' ,
3061+ parentId : barFolder . id
3062+ } )
3063+ } ) ( )
3064+ ] )
3065+ expect ( account . getData ( ) . error ) . to . not . be . ok
3066+
3067+ const tree = await getAllBookmarks ( account )
3068+ expectTreeEqual (
3069+ tree ,
3070+ new Folder ( {
3071+ title : tree . title ,
3072+ children : [
3073+ new Folder ( {
3074+ title : 'foo' ,
3075+ children : [
3076+ new Folder ( {
3077+ title : 'bar' ,
3078+ children : [
3079+ new Bookmark ( {
3080+ title : bookmark . title ,
3081+ url : bookmark . url
3082+ } ) ,
3083+ new Bookmark ( {
3084+ title : bookmark2 . title ,
3085+ url : bookmark2 . url
3086+ } ) ,
3087+ ]
3088+ } )
3089+ ]
3090+ } )
3091+ ]
3092+ } ) ,
3093+ false
3094+ )
3095+ const localTree = await account . localTree . getBookmarksTree ( true )
3096+ expectTreeEqual (
3097+ localTree ,
3098+ new Folder ( {
3099+ title : tree . title ,
3100+ children : [
3101+ new Folder ( {
3102+ title : 'foo' ,
3103+ children : [
3104+ new Folder ( {
3105+ title : 'bar' ,
3106+ children : [
3107+ new Bookmark ( {
3108+ title : bookmark . title ,
3109+ url : bookmark . url
3110+ } ) ,
3111+ new Bookmark ( {
3112+ title : bookmark2 . title ,
3113+ url : bookmark2 . url
3114+ } ) ,
3115+ new Bookmark ( {
3116+ title : bookmark3 . title ,
3117+ url : bookmark3 . url
3118+ } ) ,
3119+ ]
3120+ } )
3121+ ]
3122+ } )
3123+ ]
3124+ } ) ,
3125+ false
3126+ )
3127+
3128+ // Sync again to check if bookmark 3 gets picked
3129+ await account . sync ( )
3130+ expect ( account . getData ( ) . error ) . to . not . be . ok
3131+
3132+ const tree2 = await getAllBookmarks ( account )
3133+ expectTreeEqual (
3134+ tree2 ,
3135+ new Folder ( {
3136+ title : tree . title ,
3137+ children : [
3138+ new Folder ( {
3139+ title : 'foo' ,
3140+ children : [
3141+ new Folder ( {
3142+ title : 'bar' ,
3143+ children : [
3144+ new Bookmark ( {
3145+ title : bookmark . title ,
3146+ url : bookmark . url
3147+ } ) ,
3148+ new Bookmark ( {
3149+ title : bookmark2 . title ,
3150+ url : bookmark2 . url
3151+ } ) ,
3152+ new Bookmark ( {
3153+ title : bookmark3 . title ,
3154+ url : bookmark3 . url
3155+ } ) ,
3156+ ]
3157+ } )
3158+ ]
3159+ } )
3160+ ]
3161+ } ) ,
3162+ false
3163+ )
3164+ const localTree2 = await account . localTree . getBookmarksTree ( true )
3165+ expectTreeEqual (
3166+ localTree2 ,
3167+ tree2 ,
3168+ false
3169+ )
3170+ } )
30233171 context ( 'with slave mode' , function ( ) {
30243172 it ( "shouldn't create local bookmarks on the server" , async function ( ) {
30253173 await account . setData ( { strategy : 'slave' } )
0 commit comments