]> BookStack Code Mirror - bookstack/blobdiff - tests/User/UserPreferencesTest.php
Remove Dumps
[bookstack] / tests / User / UserPreferencesTest.php
index 1b16b0b4544994d5e34f0bad54b190a92fbd0a85..4a6cba7b32c59ceee59a2f5e060ca7b9d3729a0b 100644 (file)
@@ -156,6 +156,19 @@ class UserPreferencesTest extends TestCase
         $this->assertPermissionError($resp);
     }
 
+    public function test_notification_comment_options_only_exist_if_comments_active()
+    {
+        $resp = $this->asEditor()->get('/preferences/notifications');
+        $resp->assertSee('Notify upon comments');
+        $resp->assertSee('Notify upon replies');
+
+        setting()->put('app-disable-comments', true);
+
+        $resp = $this->get('/preferences/notifications');
+        $resp->assertDontSee('Notify upon comments');
+        $resp->assertDontSee('Notify upon replies');
+    }
+
     public function test_update_sort_preference()
     {
         $editor = $this->users->editor();
@@ -242,6 +255,22 @@ class UserPreferencesTest extends TestCase
         $this->withHtml($home)->assertElementExists('.dark-mode');
     }
 
+    public function test_dark_mode_toggle_endpoint_changes_to_light_when_dark_by_default()
+    {
+        config()->set('setting-defaults.user.dark-mode-enabled', true);
+        $editor = $this->users->editor();
+
+        $this->assertEquals(true, setting()->getUser($editor, 'dark-mode-enabled'));
+        $prefChange = $this->actingAs($editor)->patch('/preferences/toggle-dark-mode');
+        $prefChange->assertRedirect();
+        $this->assertEquals(false, setting()->getUser($editor, 'dark-mode-enabled'));
+
+        $home = $this->get('/');
+        $this->withHtml($home)->assertElementNotExists('.dark-mode');
+        $home->assertDontSee('Light Mode');
+        $home->assertSee('Dark Mode');
+    }
+
     public function test_books_view_type_preferences_when_list()
     {
         $editor = $this->users->editor();