2121 */
2222
2323import path from "path"
24+ import type { User } from "@nextcloud/cypress"
2425
25- export function uploadThreeVersions ( user ) {
26- cy . uploadContent ( user , new Blob ( [ 'v1' ] , { type : 'text/plain' } ) , 'text/plain' , '/test.txt' )
27- cy . wait ( 1000 )
28- cy . uploadContent ( user , new Blob ( [ 'v2' ] , { type : 'text/plain' } ) , 'text/plain' , '/test.txt' )
29- cy . wait ( 1000 )
30- cy . uploadContent ( user , new Blob ( [ 'v3' ] , { type : 'text/plain' } ) , 'text/plain' , '/test.txt' )
26+ export function uploadThreeVersions ( user : User , fileName : string ) {
27+ // A new version will not be created if the changes occur
28+ // within less than one second of each other.
29+ // eslint-disable-next-line cypress/no-unnecessary-waiting
30+ cy . uploadContent ( user , new Blob ( [ 'v1' ] , { type : 'text/plain' } ) , 'text/plain' , `/${ fileName } ` )
31+ . wait ( 1100 )
32+ . uploadContent ( user , new Blob ( [ 'v2' ] , { type : 'text/plain' } ) , 'text/plain' , `/${ fileName } ` )
33+ . wait ( 1100 )
34+ . uploadContent ( user , new Blob ( [ 'v3' ] , { type : 'text/plain' } ) , 'text/plain' , `/${ fileName } ` )
3135 cy . login ( user )
3236}
3337
@@ -52,7 +56,7 @@ export function openVersionMenu(index: number) {
5256 cy . get ( '[data-files-versions-version]' )
5357 . eq ( index ) . within ( ( ) => {
5458 cy . get ( '.action-item__menutoggle' ) . filter ( ':visible' )
55- . click ( )
59+ . click ( )
5660 } )
5761 } )
5862}
@@ -65,17 +69,17 @@ export function clickPopperAction(actionName: string) {
6569
6670export function nameVersion ( index : number , name : string ) {
6771 openVersionMenu ( index )
68- clickPopperAction ( " Name this version" )
72+ clickPopperAction ( ' Name this version' )
6973 cy . get ( ':focused' ) . type ( `${ name } {enter}` )
7074}
7175
72- export function assertVersionContent ( index : number , expectedContent : string ) {
76+ export function assertVersionContent ( filename : string , index : number , expectedContent : string ) {
7377 const downloadsFolder = Cypress . config ( 'downloadsFolder' )
7478
7579 openVersionMenu ( index )
76- clickPopperAction ( " Download version" )
80+ clickPopperAction ( ' Download version' )
7781
78- return cy . readFile ( path . join ( downloadsFolder , 'test.txt' ) )
82+ return cy . readFile ( path . join ( downloadsFolder , filename ) )
7983 . then ( ( versionContent ) => expect ( versionContent ) . to . equal ( expectedContent ) )
80- . then ( ( ) => cy . exec ( `rm ${ downloadsFolder } /test.txt ` ) )
84+ . then ( ( ) => cy . exec ( `rm ${ downloadsFolder } /${ filename } ` ) )
8185}
0 commit comments