From 79470ea4b7a93e2aca5c6081c0dbdb3c5ef4d1a8 Mon Sep 17 00:00:00 2001 From: Dan Brown Date: Wed, 16 Aug 2023 20:15:49 +0100 Subject: [PATCH] Notifications: Made improvements from manual testing - Added titles for preference pages. - Added extra check for non-guest for notifications on preferences page. --- app/Users/Controllers/UserPreferencesController.php | 3 +++ resources/views/users/preferences/index.blade.php | 2 +- tests/User/UserPreferencesTest.php | 4 +++- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/app/Users/Controllers/UserPreferencesController.php b/app/Users/Controllers/UserPreferencesController.php index d73bb2d0c..503aeaeb0 100644 --- a/app/Users/Controllers/UserPreferencesController.php +++ b/app/Users/Controllers/UserPreferencesController.php @@ -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, diff --git a/resources/views/users/preferences/index.blade.php b/resources/views/users/preferences/index.blade.php index a79245acb..689628370 100644 --- a/resources/views/users/preferences/index.blade.php +++ b/resources/views/users/preferences/index.blade.php @@ -13,7 +13,7 @@ - @if(userCan('receive-notifications')) + @if(signedInUser() && userCan('receive-notifications'))

{{ trans('preferences.notifications') }}

diff --git a/tests/User/UserPreferencesTest.php b/tests/User/UserPreferencesTest.php index bc023b4cd..4ee04ea67 100644 --- a/tests/User/UserPreferencesTest.php +++ b/tests/User/UserPreferencesTest.php @@ -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() {