@@ -6,15 +6,35 @@ const gotoNextPage = () => {
6
6
}
7
7
8
8
describe ( 'Minimal test, to check the setup before testing details' , ( ) => {
9
- it ( 'Attach passport and tazkira ' , ( ) => {
9
+ it ( 'Click through wizard and fill some of the forms ' , ( ) => {
10
10
cy . visit ( '/?token=demoToken' )
11
- cy . get ( 'input[id="#/properties/passport-file-input"]' , { timeout : 30000 } )
11
+ cy . log ( 'In case of a dev build it might take some time to jit compile…' )
12
+ cy . log ( 'The next test might fail, when the id is taken by another property with the same name. This sometimes happens with the combination of jsonforms and next dev builds.' )
13
+ cy . get ( '[data-testid="SendIcon"]' ) . click ( )
14
+ gotoNextPage ( )
15
+ /** TODO We need proper test selectors from jsonforms inputs.
16
+ * - selectors should be stable in next dev builds
17
+ * - selectors should be uniq when properties are reused at different places or we always need select the parent component (form) first
18
+ **/
19
+ cy . get ( 'input[id="#/properties/passportExisting-input"]' , { timeout : 30000 } )
20
+ . click ( )
21
+ cy . wait ( 300 )
22
+ cy . get ( 'input[id="passportAttachment-file-input"]' , { timeout : 30000 } )
12
23
. attachFile ( 'passport.jpg' )
13
- cy . get ( 'input[id="#/properties/tazkira-file-input"]' , { timeout : 30000 } )
24
+ cy . get ( 'input[id="#/properties/tazkiraExisting-input"]' , { timeout : 30000 } )
25
+ . click ( )
26
+ cy . wait ( 300 )
27
+ cy . get ( 'input[id="tazkiraAttachment-file-input"]' , { timeout : 30000 } )
14
28
. attachFile ( 'tazkira.jpg' )
15
29
cy . wait ( 300 )
16
30
31
+ cy . get ( 'input[id="attachment-description-tazkira.jpg"]' , { timeout : 30000 } )
32
+ . type ( 'This is my Tazkira' )
33
+ cy . wait ( 300 )
34
+
17
35
gotoNextPage ( )
36
+ cy . get ( 'textarea[id="#/properties/risksCV-input"]' )
37
+ . type ( 'risks…' )
18
38
} )
19
39
20
40
it ( 'Submit the formData' , ( ) => {
@@ -30,24 +50,27 @@ describe('Minimal test, to check the setup before testing details', () => {
30
50
} )
31
51
32
52
it ( 'Decrypt formData' , ( ) => {
33
- cy . log ( 'We expect, the test key is imported (gpg --import backend/data/keys/test.sec.gpg)' ) // TODO we should use a separate keyring
53
+ // TODO we should use a separate keyring
54
+ let formData
34
55
cy . exec ( '(cd ../../backend/data/upload/demoToken/; gpg --decrypt --passphrase "test" "$(ls -t formData* | head -n1)")' )
35
56
. then ( $result => {
36
- const formData = JSON . parse ( $result . stdout )
37
- cy . log ( formData )
57
+ const formData_ = JSON . parse ( $result . stdout )
58
+ formData = formData_
38
59
expect ( formData ) . to . have . any . keys ( 'general' )
39
- expect ( formData . general ) . to . have . any . keys ( 'firstName' )
40
- expect ( formData . general . firstName ) . to . equal ( 'Max' )
41
- expect ( formData . general ) . to . have . any . keys ( 'lastName' )
42
- expect ( formData . general . lastName ) . to . equal ( 'Mustermann' )
60
+ expect ( formData . general ) . to . have . any . keys ( 'passportAttachment' )
61
+ expect ( formData . general . passportAttachment . uploadStatus ) . to . equal ( 200 )
62
+ expect ( formData . general . passportAttachment . fileType ) . to . equal ( 'image/jpeg' )
63
+ expect ( formData . general ) . to . have . any . keys ( 'tazkiraAttachment' )
64
+ expect ( formData . general . tazkiraAttachment . uploadStatus ) . to . equal ( 200 )
65
+ expect ( formData . general . tazkiraAttachment . fileType ) . to . equal ( 'image/jpeg' )
66
+ expect ( formData . general . tazkiraAttachment . description ) . to . equal ( 'This is my Tazkira' )
43
67
expect ( formData ) . to . have . any . keys ( 'risks' )
44
68
expect ( formData . risks ) . to . have . any . keys ( 'risksCV' )
45
69
expect ( formData . risks . risksCV ) . to . equal ( 'risks…' )
46
- } )
47
- cy . exec ( '(cd ../../backend/data/upload/demoToken/; ls -lct)")' )
48
- . then ( $result => {
49
- cy . log ( $result . stdout )
50
- expect ( '' ) . to . equal ( 'fnord' )
51
- } )
70
+ } ) . then ( ( ) =>
71
+ cy . exec ( `(cd ../../backend/data/upload/demoToken/; gpg --decrypt --passphrase "test" attachment_${ formData . general . passportAttachment . id } _*.gpg) | cmp - cypress/fixtures/passport.jpg` )
72
+ ) . then ( ( ) =>
73
+ cy . exec ( `(cd ../../backend/data/upload/demoToken/; gpg --decrypt --passphrase "test" attachment_${ formData . general . tazkiraAttachment . id } _*.gpg) | cmp - cypress/fixtures/tazkira.jpg` )
74
+ )
52
75
} )
53
76
} )
0 commit comments