@@ -4,43 +4,50 @@ const Editor = '.ReactCodeMirror textarea'
44
55/* global Cypress, cy */
66
7- Cypress . Commands . add ( 'setInitialPassword' , newPassword => {
8- if ( Cypress . env ( 'E2E_TEST_ENV' ) === 'local' ) {
9- // We assume pw already set on local
10- return
11- }
12- cy . title ( ) . should ( 'include' , 'Neo4j Browser' )
13-
14- cy
15- . get ( 'input[data-test-id="boltaddress"]' )
16- . clear ( )
17- . type ( 'bolt://localhost:7687' )
18-
19- cy . get ( 'input[data-test-id="username"]' ) . should ( 'have.value' , 'neo4j' )
20- cy . get ( 'input[data-test-id="password"]' ) . should ( 'have.value' , '' )
7+ Cypress . Commands . add (
8+ 'setInitialPassword' ,
9+ (
10+ newPassword ,
11+ initialPassword = 'neo4j' ,
12+ username = 'neo4j' ,
13+ force = false
14+ ) => {
15+ if ( Cypress . env ( 'E2E_TEST_ENV' ) === 'local' && ! force ) {
16+ // We assume pw already set on local
17+ return
18+ }
19+ cy . title ( ) . should ( 'include' , 'Neo4j Browser' )
2120
22- cy . get ( 'input[data-test-id="password"]' ) . type ( 'neo4j' )
21+ cy . get ( 'input[data-test-id="boltaddress"]' )
22+ . clear ( )
23+ . type ( 'bolt://localhost:7687' )
2324
24- cy . get ( 'input[data-test-id="username"]' ) . should ( 'have.value' , 'neo4j' )
25+ cy . get ( 'input[data-test-id="username"]' )
26+ . clear ( )
27+ . type ( username )
28+ cy . get ( 'input[data-test-id="password"]' ) . type ( initialPassword )
2529
26- cy . get ( 'button[data-test-id="connect"]' ) . click ( )
30+ cy . get ( 'button[data-test-id="connect"]' ) . click ( )
2731
28- // update password
29- cy . get ( 'input[data-test-id="newPassword"]' )
30- cy . get ( 'input[data-test-id="newPassword"]' ) . should ( 'have.value' , '' )
31- cy
32- . get ( 'input[data-test-id="newPasswordConfirmation"]' )
33- . should ( 'have.value' , '' )
32+ // update password
33+ cy . get ( 'input[data-test-id="newPassword"]' )
34+ cy . get ( 'input[data-test-id="newPassword"]' ) . should ( 'have.value' , '' )
35+ cy . get ( 'input[data-test-id="newPasswordConfirmation"]' ) . should (
36+ 'have.value' ,
37+ ''
38+ )
3439
35- cy . get ( 'input[data-test-id="newPassword"]' ) . type ( newPassword )
36- cy . get ( 'input[data-test-id="newPasswordConfirmation"]' ) . type ( newPassword )
37- cy . get ( 'button[data-test-id="changePassword"]' ) . click ( )
40+ cy . get ( 'input[data-test-id="newPassword"]' ) . type ( newPassword )
41+ cy . get ( 'input[data-test-id="newPasswordConfirmation"]' ) . type ( newPassword )
42+ cy . get ( 'button[data-test-id="changePassword"]' ) . click ( )
3843
39- cy . get ( 'input[data-test-id="changePassword"]' ) . should ( 'not.be.visible' )
40- cy
41- . get ( '[data-test-id="frameCommand"]' , { timeout : 10000 } )
42- . should ( 'contain' , ':play start' )
43- } )
44+ cy . get ( 'input[data-test-id="changePassword"]' ) . should ( 'not.be.visible' )
45+ cy . get ( '[data-test-id="frameCommand"]' , { timeout : 10000 } ) . should (
46+ 'contain' ,
47+ ':play start'
48+ )
49+ }
50+ )
4451Cypress . Commands . add (
4552 'connect' ,
4653 (
@@ -53,31 +60,25 @@ Cypress.Commands.add(
5360 cy . executeCommand ( ':clear' )
5461 cy . executeCommand ( ':server connect' )
5562
56- cy
57- . get ( 'input[data-test-id="boltaddress"]' )
63+ cy . get ( 'input[data-test-id="boltaddress"]' )
5864 . clear ( )
5965 . type ( host )
6066
61- cy . get ( 'input[data-test-id="username"]' ) . should ( 'have.value' , 'neo4j' )
62- cy . get ( 'input[data-test-id="password"]' ) . should ( 'have.value' , '' )
63-
64- cy
65- . get ( 'input[data-test-id="username"]' )
67+ cy . get ( 'input[data-test-id="username"]' )
6668 . clear ( )
6769 . type ( username )
68- cy
69- . get ( 'input[data-test-id="password"]' )
70+ cy . get ( 'input[data-test-id="password"]' )
7071 . clear ( )
7172 . type ( password )
7273
7374 cy . get ( 'button[data-test-id="connect"]' ) . click ( )
7475 if ( makeAssertions ) {
75- cy
76- . get ( '[data-test-id="frame"]' , { timeout : 10000 } )
77- . should ( 'have.length' , 2 )
76+ cy . get ( '[data-test-id="frame"]' , { timeout : 10000 } ) . should (
77+ 'have.length' ,
78+ 2
79+ )
7880 cy . wait ( 500 )
79- cy
80- . get ( '[data-test-id="frameCommand"]' )
81+ cy . get ( '[data-test-id="frameCommand"]' )
8182 . first ( )
8283 . should ( 'contain' , ':play start' )
8384 cy . executeCommand ( ':clear' )
@@ -94,12 +95,13 @@ Cypress.Commands.add('executeCommand', query => {
9495 cy . get ( SubmitQueryButton ) . click ( )
9596} )
9697Cypress . Commands . add ( 'waitForCommandResult' , ( ) => {
97- cy
98- . get ( '[data-test-id="frame-loaded-contents"]' , { timeout : 40000 } )
99- . should ( 'be.visible' )
98+ cy . get ( '[data-test-id="frame-loaded-contents"]' , { timeout : 40000 } ) . should (
99+ 'be.visible'
100+ )
100101} )
101102Cypress . Commands . add ( 'resultContains' , str => {
102- cy
103- . get ( '[data-test-id="frameContents"]' , { timeout : 40000 } )
104- . should ( 'contain' , str )
103+ cy . get ( '[data-test-id="frameContents"]' , { timeout : 40000 } ) . should (
104+ 'contain' ,
105+ str
106+ )
105107} )
0 commit comments