File tree Expand file tree Collapse file tree 9 files changed +30
-7
lines changed
tests/Feature/Controllers Expand file tree Collapse file tree 9 files changed +30
-7
lines changed Original file line number Diff line number Diff line change @@ -61,9 +61,11 @@ protected function createPermissions()
6161 protected function assignPermissionsToRoles ()
6262 {
6363 $ this ->roles ->get (Role::SUPER_ADMIN ->value )->givePermissionTo ($ this ->superAdminPermissions );
64+ $ this ->roles ->get (Role::SUPER_ADMIN ->value )->givePermissionTo ($ this ->orgnaisationPermissions );
65+ $ this ->roles ->get (Role::SUPER_ADMIN ->value )->givePermissionTo ($ this ->postPermissions );
6466
65- $ this ->roles ->get (Role::ADMIN ->value )->givePermissionTo ($ this ->postPermissions );
6667 $ this ->roles ->get (Role::ADMIN ->value )->givePermissionTo ($ this ->orgnaisationPermissions );
68+ $ this ->roles ->get (Role::ADMIN ->value )->givePermissionTo ($ this ->postPermissions );
6769
6870 $ this ->roles ->get (Role::USER ->value )->givePermissionTo ($ this ->postPermissions );
6971 }
Original file line number Diff line number Diff line change 1515
1616 actingAs ($ user )
1717 ->get (route ('account.edit ' ))
18+ ->assertOk ()
1819 ->assertInertia (
1920 fn (Assert $ page ) => $ page
2021 ->component ('Account/Edit ' )
4243 'password ' => 'newPassword#123 ' ,
4344 ])
4445 ->assertRedirectToRoute ('account.edit ' )
46+ ->assertSessionDoesntHaveErrors ()
4547 ->assertSessionHas ('success ' , __ ('account.updated ' ));
4648
4749 expect ($ user ->refresh ())
6264 ]);
6365
6466 actingAs ($ user )
67+ ->from (route ('account.edit ' ))
6568 ->patch (route ('account.update ' ), $ newData = [
6669 'email ' => 'jim@test.com ' ,
6770 ])
68- ->assertSessionHasErrors ('email ' );
71+ ->assertSessionHasErrors ('email ' )
72+ ->assertRedirectToRoute ('account.edit ' );
6973
7074 expect ($ user ->refresh ()->email )->not ()->toBe ($ newData ['email ' ]);
7175 });
Original file line number Diff line number Diff line change 1313 test ('Can access the verification page ' , function () {
1414 actingAs (User::factory ()->unverified ()->create ())
1515 ->get (route ('verification.notice ' ))
16+ ->assertOk ()
1617 ->assertInertia (
1718 fn (Assert $ page ) => $ page
1819 ->component ('EmailVerification/Show ' )
3233 'id ' => $ user ->getKey (),
3334 'hash ' => sha1 ($ user ->getEmailForVerification ()),
3435 ]))
36+ ->assertSessionDoesntHaveErrors ()
3537 ->assertRedirectToRoute ('home ' );
3638
3739 expect ($ user ->refresh ()->email_verified_at )->not ()->toBeNull ();
4547 from (route ('verification.notice ' ))
4648 ->actingAs ($ user )
4749 ->post (route ('verification.send ' ))
50+ ->assertSessionDoesntHaveErrors ()
4851 ->assertRedirectToRoute ('verification.notice ' );
4952
5053 Notification::assertSentTo ($ user , Illuminate \Auth \Notifications \VerifyEmail::class);
Original file line number Diff line number Diff line change 1010 test ('Can access the home page ' , function () {
1111 actingAs (User::factory ()->create ())
1212 ->get (route ('home ' ))
13+ ->assertOk ()
1314 ->assertInertia (
1415 fn (Assert $ page ) => $ page
1516 ->component ('Dashboard/Index ' )
Original file line number Diff line number Diff line change 3737 'email ' => $ user ->email ,
3838 'password ' => '12345 ' ,
3939 ])
40+ ->assertSessionDoesntHaveErrors ()
4041 ->assertRedirectToRoute ('home ' );
4142
4243 assertAuthenticated ();
5556 'password ' => '12345 ' ,
5657 'redirect ' => $ redirect ,
5758 ])
59+ ->assertSessionDoesntHaveErrors ()
5860 ->assertRedirect ($ redirect );
5961
6062 assertAuthenticated ();
6971 'email ' => $ user ->email ,
7072 'password ' => 'test ' ,
7173 ])
72- ->assertsessionHasErrors ();
74+ ->assertSessionHasErrors ();
7375
7476 assertGuest ();
7577 });
Original file line number Diff line number Diff line change 1010 test ('Can logout ' , function () {
1111 actingAs (User::factory ()->create ())
1212 ->post (route ('logout ' ))
13+ ->assertSessionDoesntHaveErrors ()
1314 ->assertRedirectToRoute ('login ' );
1415
1516 assertGuest ();
1920describe ('Guests ' , function () {
2021 test ("Can't logout " , function () {
2122 post (route ('logout ' ))
23+ ->assertSessionDoesntHaveErrors ()
2224 ->assertRedirectToRoute ('login ' );
2325 });
2426});
Original file line number Diff line number Diff line change 11<?php
22
33use App \Models \User ;
4+ use Inertia \Testing \AssertableInertia as Assert ;
45
56use function Pest \Laravel \actingAs ;
67use function Pest \Laravel \from ;
2324 test ('Can see the edit page for their current organisation ' , function () {
2425 actingAs ($ this ->adminUser )
2526 ->get (route ('organisation.edit ' ))
26- ->assertOk ();
27+ ->assertOk ()
28+ ->assertInertia (
29+ fn (Assert $ page ) => $ page
30+ ->component ('Organisation/Edit ' )
31+ );
2732 });
2833
2934 test ("Can update their organisation's name " , function () {
3439 ->patch (route ('organisation.update ' ), [
3540 'name ' => 'New Name ' ,
3641 ])
42+ ->assertSessionDoesntHaveErrors ()
3743 ->assertRedirectToRoute ('organisation.edit ' );
3844
3945 expect ($ this ->adminUser ->organisation ->refresh ()->name )->toBe ('New Name ' );
7379describe ('Guests ' , function () {
7480 test ("Can't see the edit page of organisations " , function () {
7581 get (route ('organisation.edit ' ))
76- ->assertRedirect ( );
82+ ->assertRedirectToRoute ( ' login ' );
7783 });
7884
7985 test ("Can't update organisations " , function () {
8086 patch (route ('organisation.edit ' ))
81- ->assertRedirect ( );
87+ ->assertRedirectToRoute ( ' login ' );
8288 });
8389});
Original file line number Diff line number Diff line change 3939 'email ' => $ email ,
4040 'password ' => 'P$ssword12345# ' ,
4141 ])
42+ ->assertSessionDoesntHaveErrors ()
4243 ->assertRedirectToRoute ('home ' );
4344
4445 assertDatabaseHas ('users ' , [
Original file line number Diff line number Diff line change 2828 post (route ('password.store ' ), [
2929 'email ' => $ user ->email ,
3030 ])
31+ ->assertSessionDoesntHaveErrors ()
3132 ->assertRedirectToRoute ('login ' );
3233
3334 Notification::assertSentTo ($ user , ResetPassword::class);
4041 ->post (route ('password.store ' ), [
4142 'email ' => fake ()->email (),
4243 ])
43- ->assertsessionHasErrors ('email ' )
44+ ->assertSessionHasErrors ('email ' )
4445 ->assertRedirectToRoute ('password ' );
4546
4647 Notification::assertNothingSent ();
7576 'password ' => $ newPassword ,
7677 'password_confirmation ' => $ newPassword ,
7778 ]))
79+ ->assertSessionDoesntHaveErrors ()
7880 ->assertRedirectToRoute ('login ' );
7981});
You can’t perform that action at this time.
0 commit comments