@@ -22,43 +22,17 @@ context('Collection Operations', () => {
2222 cy . visit ( '/' , {
2323 onBeforeLoad ( win ) {
2424 fetchSpy = cy . spy ( win , 'fetch' )
25- win . ExFile = class extends win . File {
26- constructor ( root , data , fileName , options ) {
27- super ( data , fileName , options ) ;
28- this . root = root ;
29- }
30- webkitGetAsEntry ( ) {
31- const me = this ;
32- return {
33- isDirectory : false ,
34- isFile : true ,
35- fullPath : this . root + this . name ,
36- file : callback => callback ( this ) ,
37- } ;
38- }
39- }
40- win . ExDir = class extends win . ExFile {
41- constructor ( root , entries , fileName , options ) {
42- super ( root , [ ] , fileName , options ) ;
43- this . entries = entries . map ( entry => entry . webkitGetAsEntry ( ) ) ;
44- }
45- webkitGetAsEntry ( ) {
46- const me = this ;
47- return {
48- isDirectory : true ,
49- isFile : false ,
50- fullPath : this . root + this . name ,
51- createReader : ( ) => ( { readEntries : callback => callback ( this . entries ) } ) ,
52- } ;
53- }
54- }
5525 }
5626 } ) ;
5727 } )
5828 after ( ( ) => {
5929 // delete the test collection
6030 new Cypress . Promise ( resolve => FSApi . remove ( connection , '/db/test' , true ) . then ( resolve ) . catch ( resolve ) )
6131 } )
32+ afterEach ( ( ) => {
33+ // make sure the tree has rendered all its items properly
34+ cy . wait ( 10 )
35+ } )
6236
6337 it ( 'should display creation options' , ( ) => {
6438 cy . get ( '.fusion-view' )
@@ -186,32 +160,10 @@ context('Collection Operations', () => {
186160 . should ( 'exist' )
187161 } )
188162
189- it ( 'should upload a document' , ( ) => {
190- cy . window ( ) . then ( win => {
191- const file = new win . ExFile ( '/' , [ new Blob ( [ 'sample text content.' ] ) ] , 'test.txt' , { type : 'text/plain' } )
192-
193- const originalDataTransfer = new win . DataTransfer ( ) ;
194- originalDataTransfer . items . add ( file ) ;
195- const dataTransfer = {
196- ...originalDataTransfer ,
197- items : [ file ] ,
198- files : [ file ] ,
199- } ;
200- dataTransfer . getData = ( ...args ) => originalDataTransfer . getData ( ...args ) ;
201-
202- cy . get ( '[node-id$=test]' )
203- . trigger ( 'dragover' , { dataTransfer } )
204- . trigger ( 'drop' , { dataTransfer } )
205- fetchSpy . calledWithMatch ( Cypress . env ( 'API_HOST' ) + '/exist/restxq/fusiondb/document?uri=/db/test/test.txt' , { method : 'PUT' } )
206- cy . get ( '[node-id$="test\\/test.txt"]' )
207- . should ( 'be.visible' )
208- } )
209- } )
210-
211163 it ( 'should upload a collection' , ( ) => {
212- cy . window ( ) . then ( win => {
213- const file = new win . ExFile ( '/col /' , [ new Blob ( [ 'sample text content.' ] ) ] , 'test2 .txt' , { type : 'text/plain' } )
214- const dir = new win . ExDir ( '/' , [ file ] , 'col ' )
164+ cy . extendedFiles ( ) . then ( win => {
165+ const file = new win . ExFile ( '/uploaded_col /' , [ new Blob ( [ 'sample text content.' ] ) ] , 'uploaded_test .txt' , { type : 'text/plain' } )
166+ const dir = new win . ExDir ( '/' , [ file ] , 'uploaded_col ' )
215167
216168 const originalDataTransfer = new win . DataTransfer ( ) ;
217169 originalDataTransfer . items . add ( file ) ;
@@ -225,11 +177,11 @@ context('Collection Operations', () => {
225177 cy . get ( '[node-id$=test]' )
226178 . trigger ( 'dragover' , { dataTransfer } )
227179 . trigger ( 'drop' , { dataTransfer } )
228- fetchSpy . calledWithMatch ( Cypress . env ( 'API_HOST' ) + '/exist/restxq/fusiondb/document?uri=/db/test/col ' , { method : 'PUT' } )
229- cy . get ( '[node-id$="test\\/col "]' )
180+ fetchSpy . calledWithMatch ( Cypress . env ( 'API_HOST' ) + '/exist/restxq/fusiondb/document?uri=/db/test/uploaded_col ' , { method : 'PUT' } )
181+ cy . get ( '[node-id$="test\\/uploaded_col "]' )
230182 . should ( 'be.visible' )
231183 . click ( )
232- cy . get ( '[node-id$="col \\/test2 .txt"]' )
184+ cy . get ( '[node-id$="uploaded_col \\/uploaded_test .txt"]' )
233185 . should ( 'be.visible' )
234186 } )
235187 } )
0 commit comments