@@ -30,8 +30,10 @@ describe('Device users page - Add new device user', function () {
3030 cy . get ( '#lastName' ) . should ( 'be.visible' ) . type ( surname ) ;
3131
3232 cy . intercept ( 'POST' , '**/api/device-users/create' ) . as ( 'createUser' ) ;
33+ cy . intercept ( 'POST' , '**/api/device-users/index' ) . as ( 'reloadDeviceUsers' ) ;
3334 cy . get ( '#saveCreateBtn' ) . should ( 'be.visible' ) . should ( 'be.enabled' ) . click ( ) ;
3435 cy . wait ( '@createUser' , { timeout : 30000 } ) ;
36+ cy . wait ( '@reloadDeviceUsers' , { timeout : 30000 } ) ;
3537 cy . get ( '#newDeviceUserBtn' ) . should ( 'be.visible' ) ;
3638
3739 // Verify the user was created
@@ -75,34 +77,35 @@ describe('Device users page - Should not add new device user', function () {
7577 it ( 'should NOT add device user with only last name' , ( ) => {
7678 const lastName = generateRandmString ( ) ;
7779
78- cy . get ( '#newDeviceUserBtn' ) . should ( 'be.visible' ) . click ( ) ;
80+ cy . get ( '#newDeviceUserBtn' , { timeout : 10000 } ) . should ( 'be.visible' ) . click ( ) ;
7981 cy . get ( '#lastName' ) . should ( 'be.visible' ) . type ( lastName ) ;
8082
8183 // Verify save button is disabled
8284 cy . get ( '#saveCreateBtn' ) . should ( 'be.disabled' ) ;
8385
8486 cy . get ( '#cancelCreateBtn' ) . should ( 'be.visible' ) . click ( ) ;
85- cy . wait ( 500 ) ;
87+ cy . get ( '#newDeviceUserBtn' , { timeout : 10000 } ) . should ( 'be.visible' ) ;
8688 } ) ;
8789
8890 it ( 'should NOT add device user without first and last names' , ( ) => {
89- cy . get ( '#newDeviceUserBtn' ) . should ( 'be.visible' ) . click ( ) ;
91+ cy . get ( '#newDeviceUserBtn' , { timeout : 10000 } ) . should ( 'be.visible' ) . click ( ) ;
9092 cy . get ( '#firstName' ) . should ( 'be.visible' ) ;
9193
9294 // Verify save button is disabled
9395 cy . get ( '#saveCreateBtn' ) . should ( 'be.disabled' ) ;
9496
9597 cy . get ( '#cancelCreateBtn' ) . should ( 'be.visible' ) . click ( ) ;
98+ cy . get ( '#newDeviceUserBtn' , { timeout : 10000 } ) . should ( 'be.visible' ) ;
9699 cy . wait ( 500 ) ;
97100 } ) ;
98101
99102 it ( 'should NOT create user if cancel was clicked' , ( ) => {
100103 deviceUsersPage . rowNum ( ) . then ( ( rowCountBeforeCreation ) => {
101- cy . get ( '#newDeviceUserBtn' ) . should ( 'be.visible' ) . click ( ) ;
104+ cy . get ( '#newDeviceUserBtn' , { timeout : 10000 } ) . should ( 'be.visible' ) . click ( ) ;
102105 cy . get ( '#firstName' ) . should ( 'be.visible' ) ;
103106 cy . wait ( 500 ) ;
104107 cy . get ( '#cancelCreateBtn' ) . should ( 'be.visible' ) . click ( ) ;
105- cy . get ( '#newDeviceUserBtn' ) . should ( 'be.visible' ) ;
108+ cy . get ( '#newDeviceUserBtn' , { timeout : 10000 } ) . should ( 'be.visible' ) ;
106109 cy . wait ( 500 ) ;
107110
108111 deviceUsersPage . rowNum ( ) . then ( ( rowCountAfterCreation ) => {
@@ -119,10 +122,12 @@ describe('Device users page - Should not add new device user', function () {
119122 cy . get ( '#deviceUserFirstName' ) . each ( ( $el , index ) => {
120123 if ( $el . text ( ) === nameDeviceUser ) {
121124 cy . intercept ( 'POST' , '**/api/device-users/delete' ) . as ( 'deleteUser' ) ;
125+ cy . intercept ( 'POST' , '**/api/device-users/index' ) . as ( 'reloadDeviceUsers' ) ;
122126 cy . get ( '#deleteDeviceUserBtn' ) . eq ( index ) . click ( ) ;
123127 cy . get ( '#saveDeleteBtn' ) . should ( 'be.visible' ) . click ( ) ;
124128 cy . wait ( '@deleteUser' , { timeout : 30000 } ) ;
125- cy . get ( '#newDeviceUserBtn' ) . should ( 'be.visible' ) ;
129+ cy . wait ( '@reloadDeviceUsers' , { timeout : 30000 } ) ;
130+ cy . get ( '#newDeviceUserBtn' , { timeout : 10000 } ) . should ( 'be.visible' ) ;
126131 return false ; // break the loop
127132 }
128133 } ) ;
0 commit comments