@@ -2103,6 +2103,143 @@ describe('Floccus', function() {
21032103 false
21042104 )
21052105 } )
2106+ it ( 'should move items without confusing folders (2)' , async function ( ) {
2107+ const localRoot = account . getData ( ) . localRoot
2108+
2109+ const folder1 = await browser . bookmarks . create ( {
2110+ title : 'a' ,
2111+ parentId : localRoot
2112+ } )
2113+ const folder2 = await browser . bookmarks . create ( {
2114+ title : 'b' ,
2115+ parentId : folder1 . id
2116+ } )
2117+ const folder3 = await browser . bookmarks . create ( {
2118+ title : 'c' ,
2119+ parentId : folder2 . id
2120+ } )
2121+ const folder4 = await browser . bookmarks . create ( {
2122+ title : 'd' ,
2123+ parentId : localRoot
2124+ } )
2125+ const folder5 = await browser . bookmarks . create ( {
2126+ title : 'e' ,
2127+ parentId : folder4 . id ,
2128+ } )
2129+ const folder6 = await browser . bookmarks . create ( {
2130+ title : 'f' ,
2131+ parentId : folder5 . id ,
2132+ } )
2133+ const folderX = await browser . bookmarks . create ( {
2134+ title : 'X' ,
2135+ parentId : folder3 . id ,
2136+ } )
2137+ await browser . bookmarks . create ( {
2138+ title : 'url' ,
2139+ url : 'http://ur.l/' ,
2140+ parentId : folderX . id
2141+ } )
2142+ const folderX2 = await browser . bookmarks . create ( {
2143+ title : 'X' ,
2144+ parentId : folder6 . id ,
2145+ } )
2146+ await browser . bookmarks . create ( {
2147+ title : 'test' ,
2148+ url : 'http://urrr.l/' ,
2149+ parentId : folderX2 . id
2150+ } )
2151+ const test2Bm = await browser . bookmarks . create ( {
2152+ title : 'test2' ,
2153+ url : 'http://urrr2.l/' ,
2154+ parentId : folder1 . id
2155+ } )
2156+
2157+ await account . sync ( ) // propagate to server
2158+ expect ( account . getData ( ) . error ) . to . not . be . ok
2159+
2160+ await account . sync ( ) // make sure order is propagated
2161+ expect ( account . getData ( ) . error ) . to . not . be . ok
2162+
2163+ await account . init ( ) // Remove the cache
2164+
2165+ await browser . bookmarks . move ( folderX . id , { parentId : folder2 . id } )
2166+ await browser . bookmarks . move ( folderX2 . id , { parentId : folder5 . id } )
2167+ await browser . bookmarks . move ( test2Bm . id , { parentId : folderX . id } )
2168+
2169+ await account . sync ( ) // propagate to server
2170+ expect ( account . getData ( ) . error ) . to . not . be . ok
2171+
2172+ const tree = await getAllBookmarks ( account )
2173+ expectTreeEqual (
2174+ tree ,
2175+ new Folder ( {
2176+ title : tree . title ,
2177+ children : [
2178+ new Folder ( {
2179+ title : 'a' ,
2180+ children : [
2181+ new Folder ( {
2182+ title : 'b' ,
2183+ children : [
2184+ new Folder ( {
2185+ title : 'c' ,
2186+ children : [ ] ,
2187+ } ) ,
2188+ new Folder ( {
2189+ title : 'X' ,
2190+ children : [
2191+ new Bookmark ( {
2192+ title : 'url' ,
2193+ url : 'http://ur.l/' ,
2194+ } ) ,
2195+ new Bookmark ( {
2196+ title : 'test2' ,
2197+ url : 'http://urrr2.l/' ,
2198+ } ) ,
2199+ ] ,
2200+ } ) ,
2201+ ] ,
2202+ } ) ,
2203+ ] ,
2204+ } ) ,
2205+ new Folder ( {
2206+ title : 'd' ,
2207+ children : [
2208+ new Folder ( {
2209+ title : 'e' ,
2210+ children : [
2211+ new Folder ( {
2212+ title : 'f' ,
2213+ children : [ ] ,
2214+ } ) ,
2215+ new Folder ( {
2216+ title : 'X' ,
2217+ children : [
2218+ new Bookmark ( {
2219+ title : 'test' ,
2220+ url : 'http://urrr.l/' ,
2221+ } ) ,
2222+ ] ,
2223+ } ) ,
2224+ ] ,
2225+ } ) ,
2226+ ] ,
2227+ } ) ,
2228+ ] ,
2229+ } ) ,
2230+ false ,
2231+ false
2232+ )
2233+
2234+ const localTree = await account . localTree . getBookmarksTree ( true )
2235+ localTree . title = tree . title
2236+ expectTreeEqual (
2237+ localTree ,
2238+ tree ,
2239+ false ,
2240+ false
2241+ )
2242+ } )
21062243 it ( 'should integrate existing items from both sides' , async function ( ) {
21072244 const localRoot = account . getData ( ) . localRoot
21082245
0 commit comments