]> BookStack Code Mirror - bookstack/commitdiff
Notifications: Made improvements from manual testing
authorDan Brown <redacted>
Wed, 16 Aug 2023 19:15:49 +0000 (20:15 +0100)
committerDan Brown <redacted>
Wed, 16 Aug 2023 19:15:49 +0000 (20:15 +0100)
- Added titles for preference pages.
- Added extra check for non-guest for notifications on preferences page.

app/Users/Controllers/UserPreferencesController.php
resources/views/users/preferences/index.blade.php
tests/User/UserPreferencesTest.php

index d73bb2d0cd31e07b1bcffb443eed388cef69982e..503aeaeb0c9d23032746cf72fd67634678f2aa43 100644 (file)
@@ -33,6 +33,8 @@ class UserPreferencesController extends Controller
         $shortcuts = UserShortcutMap::fromUserPreferences();
         $enabled = setting()->getForCurrentUser('ui-shortcuts-enabled', false);
 
+        $this->setPageTitle(trans('preferences.shortcuts_interface'));
+
         return view('users.preferences.shortcuts', [
             'shortcuts' => $shortcuts,
             'enabled' => $enabled,
@@ -70,6 +72,7 @@ class UserPreferencesController extends Controller
         $query = $permissions->restrictEntityRelationQuery($query, 'watches', 'watchable_id', 'watchable_type');
         $watches = $query->with('watchable')->paginate(20);
 
+        $this->setPageTitle(trans('preferences.notifications'));
         return view('users.preferences.notifications', [
             'preferences' => $preferences,
             'watches' => $watches,
index a79245acb5ad7c97e4f74a6e502322dec81545df..689628370fd3f1f91e625213ca73e3890ade0126 100644 (file)
@@ -13,7 +13,7 @@
             </div>
         </section>
 
-        @if(userCan('receive-notifications'))
+        @if(signedInUser() && userCan('receive-notifications'))
             <section class="card content-wrap auto-height items-center justify-space-between gap-m flex-container-row">
                 <div>
                     <h2 class="list-heading">{{ trans('preferences.notifications') }}</h2>
index bc023b4cd3d4fb78a970e1809e25183292851ac8..4ee04ea67a7090755c6e8dd6fe63a6f0b37ca60a 100644 (file)
@@ -15,13 +15,15 @@ class UserPreferencesTest extends TestCase
         $resp->assertSee('Edit Profile');
     }
 
-    public function test_index_view_accessible_but_without_profile_for_guest_user()
+    public function test_index_view_accessible_but_without_profile_and_notifications_for_guest_user()
     {
         $this->setSettings(['app-public' => 'true']);
+        $this->permissions->grantUserRolePermissions($this->users->guest(), ['receive-notifications']);
         $resp = $this->get('/preferences');
         $resp->assertOk();
         $resp->assertSee('Interface Keyboard Shortcuts');
         $resp->assertDontSee('Edit Profile');
+        $resp->assertDontSee('Notification');
     }
     public function test_interface_shortcuts_updating()
     {