@@ -22,7 +22,72 @@ public function __construct()
22
22
public function test_change_password_without_data_validation_error ()
23
23
{
24
24
$ this ->browse (function (Browser $ browser ) {
25
- // $browser->visit($this->path)->;
25
+ $ user = User::where ('email ' , 'admin@admin.com ' )->first ();
26
+ $ browser ->loginAs (User::find ($ user ->id ))
27
+ ->visit ($ this ->path )
28
+ ->type ('current_password ' , '' )
29
+ ->type ('new_password ' , '' )
30
+ ->type ('confirm_password ' , '' )
31
+ ->click ($ this ->changePasswordBtn )
32
+ ->assertPathIs ($ this ->path )
33
+ ->assertSee ('The current password field is required. ' )
34
+ ->assertSee ('The new password field is required. ' )
35
+ ->assertSee ('The confirm password field is required. ' );
36
+ });
37
+ }
38
+
39
+ public function test_without_current_password_show_validations ()
40
+ {
41
+ $ this ->browse (function (Browser $ browser ) {
42
+ $ user = User::where ('email ' , 'admin@admin.com ' )->first ();
43
+ $ browser ->loginAs (User::find ($ user ->id ))
44
+ ->visit ($ this ->path )
45
+ ->type ('new_password ' , 'Password1 ' )
46
+ ->type ('confirm_password ' , 'Password1 ' )
47
+ ->click ($ this ->changePasswordBtn )
48
+ ->assertPathIs ($ this ->path )
49
+ ->assertSee ('The current password field is required. ' );
50
+ });
51
+ }
52
+
53
+ public function test_wrong_password_does_not_allow_password_change ()
54
+ {
55
+ $ this ->browse (function (Browser $ browser ) {
56
+ $ user = User::where ('email ' , 'admin@admin.com ' )->first ();
57
+ $ browser ->loginAs (User::find ($ user ->id ))
58
+ ->visit ($ this ->path )
59
+ ->type ('current_password ' , 'wrongpassword ' )
60
+ ->type ('new_password ' , 'Password1 ' )
61
+ ->type ('confirm_password ' , 'Password1 ' )
62
+ ->click ($ this ->changePasswordBtn )
63
+ ->assertSee ('Check if your current password is correct. ' );
64
+ });
65
+ }
66
+
67
+ public function test_user_can_change_password_correctly_and_login_back ()
68
+ {
69
+ $ this ->browse (function (Browser $ browser ) {
70
+ $ user = User::where ('email ' , 'admin@admin.com ' )->first ();
71
+ $ browser ->loginAs (User::find ($ user ->id ))
72
+ ->visit ($ this ->path )
73
+ ->type ('current_password ' , 'password ' )
74
+ ->type ('new_password ' , 'Password1 ' )
75
+ ->type ('confirm_password ' , 'Password1 ' )
76
+ ->click ($ this ->changePasswordBtn )
77
+ ->assertPathIs ($ this ->path )
78
+ ->click ('#user-dropdown-menu ' )
79
+ ->click ('#logout-button ' )
80
+ ->assertPathIs ('/ ' )
81
+ ->visit ('/login ' )
82
+ ->type ('email ' , 'admin@admin.com ' )
83
+ ->type ('password ' , 'Password1 ' )
84
+ ->click ('.btn.btn-primary.btn-block.btn-flat ' )
85
+ ->assertPathIs ('/home ' )
86
+ ->visit ($ this ->path )
87
+ ->type ('current_password ' , 'Password1 ' )
88
+ ->type ('new_password ' , 'password ' )
89
+ ->type ('confirm_password ' , 'password ' )
90
+ ->click ($ this ->changePasswordBtn );
26
91
});
27
92
}
28
93
}
0 commit comments