@@ -10,38 +10,6 @@ let window = null;
10
10
let stub = null ;
11
11
export const randomFileName = `fileName${ Math . random ( ) * 10000 } ` ;
12
12
13
- const doesDocumentContainText = ( text : string ) => {
14
- cy . findByRole ( 'document' )
15
- . contains ( new RegExp ( escapeRegExp ( text ) , 'i' ) )
16
- . should ( 'exist' ) ;
17
- } ;
18
-
19
- const clickButtonWithText = ( name : string ) => {
20
- cy . findByRole ( 'button' , {
21
- name : new RegExp ( `${ escapeRegExp ( name ) } ` , 'i' ) ,
22
- } ) . click ( ) ;
23
- } ;
24
-
25
- const typeInInputHandler = ( field : string , value : string ) => {
26
- cy . findInputField ( field ) . type ( value ) ;
27
- } ;
28
-
29
- const fileInputUpload = ( fileCount : number = 1 , folderName ?: string ) => {
30
- const folderFiles = [ ] ;
31
- for ( let i = 1 ; i <= fileCount ; i ++ ) {
32
- const fileName = folderName
33
- ? `${ folderName } /${ randomFileName } -${ i } `
34
- : `${ randomFileName } -${ i } ` ;
35
-
36
- folderFiles . push ( {
37
- contents : Cypress . Buffer . from ( `File ${ i } content` ) ,
38
- fileName,
39
- mimeType : 'text/plain' ,
40
- } ) ;
41
- }
42
- cy . get ( 'input[type="file"]' ) . selectFile ( folderFiles , { force : true } ) ;
43
- } ;
44
-
45
13
const getRoute = ( routeMatcher : { headers : { [ key : string ] : string } } ) => {
46
14
return `${ routeMatcher . headers ?. [ 'X-Amz-Target' ] || 'route' } ` ;
47
15
} ;
@@ -272,10 +240,10 @@ When('I type a new {string}', (field: string) => {
272
240
cy . findInputField ( field ) . typeAliasWithStatus ( field , `${ Date . now ( ) } ` ) ;
273
241
} ) ;
274
242
275
- When ( 'I type a new {string} with value {string}' , typeInInputHandler ) ;
243
+ When ( 'I type a new {string} with value {string}' , cy . typeInInputHandler ) ;
276
244
277
245
When ( 'I type a new {string} with random value' , ( field : string ) => {
278
- typeInInputHandler ( field , randomFileName ) ;
246
+ cy . typeInInputHandler ( field , randomFileName ) ;
279
247
} ) ;
280
248
281
249
When ( 'I lose focus on {string} input' , ( field : string ) => {
@@ -306,10 +274,10 @@ Then('I press the {string} key', (key: string) => {
306
274
cy . get ( 'body' ) . type ( key ) ;
307
275
} ) ;
308
276
309
- When ( 'I click the button containing {string}' , clickButtonWithText ) ;
277
+ When ( 'I click the button containing {string}' , cy . clickButtonWithText ) ;
310
278
311
279
When ( 'I click the button containing random name' , ( ) => {
312
- clickButtonWithText ( randomFileName ) ;
280
+ cy . clickButtonWithText ( randomFileName ) ;
313
281
} ) ;
314
282
315
283
When ( 'I click the first button containing {string}' , ( name : string ) => {
@@ -388,11 +356,11 @@ Then('I see tab {string}', (search: string) => {
388
356
cy . findAllByRole ( 'tab' ) . first ( ) . should ( 'be.visible' ) . contains ( search ) ;
389
357
} ) ;
390
358
391
- Then ( 'I see {string}' , doesDocumentContainText ) ;
359
+ Then ( 'I see {string}' , cy . doesDocumentContainText ) ;
392
360
393
361
Then ( 'I see {string} files with random names' , ( count : string ) => {
394
362
for ( let i = 1 ; i <= parseInt ( count ) ; i ++ ) {
395
- doesDocumentContainText ( `${ randomFileName } -${ i } ` ) ;
363
+ cy . doesDocumentContainText ( `${ randomFileName } -${ i } ` ) ;
396
364
}
397
365
} ) ;
398
366
@@ -679,11 +647,11 @@ Then('I see the {string} radio button checked', (label: string) => {
679
647
} ) ;
680
648
681
649
When ( 'I upload {string} files with random names' , ( count : string ) =>
682
- fileInputUpload ( parseInt ( count ) )
650
+ cy . fileInputUpload ( randomFileName , parseInt ( count ) )
683
651
) ;
684
652
685
653
When (
686
654
'I upload a folder {string} with {string} files with random names' ,
687
655
( folderName : string , count : string ) =>
688
- fileInputUpload ( parseInt ( count ) , folderName )
656
+ cy . fileInputUpload ( ` ${ folderName } / ${ randomFileName } ` , parseInt ( count ) )
689
657
) ;
0 commit comments