diff --git a/resources/lang/en/common.php b/resources/lang/en/common.php
index c8b4a2b22..68c58b92b 100644
--- a/resources/lang/en/common.php
+++ b/resources/lang/en/common.php
@@ -66,6 +66,8 @@ return [
'profile_menu' => 'Profile Menu',
'view_profile' => 'View Profile',
'edit_profile' => 'Edit Profile',
+ 'dark_mode' => 'Dark Mode',
+ 'light_mode' => 'Light Mode',
// Layout tabs
'tab_info' => 'Info',
diff --git a/resources/views/common/header.blade.php b/resources/views/common/header.blade.php
index af7aaeeb0..98bd01788 100644
--- a/resources/views/common/header.blade.php
+++ b/resources/views/common/header.blade.php
@@ -76,9 +76,9 @@
{{ csrf_field() }}
{{ method_field('patch') }}
@if(setting()->getForCurrentUser('dark-mode-enabled'))
-
+
@else
-
+
@endif
diff --git a/tests/User/UserPreferencesTest.php b/tests/User/UserPreferencesTest.php
index b70d52dfa..0db4f803a 100644
--- a/tests/User/UserPreferencesTest.php
+++ b/tests/User/UserPreferencesTest.php
@@ -75,4 +75,21 @@ class UserPreferencesTest extends TestCase
$invalidKeyRequest = $this->patch('/settings/users/' . $editor->id.'/update-expansion-preference/my-home-details', ['expand' => 'true']);
$invalidKeyRequest->assertStatus(500);
}
+
+ public function test_toggle_dark_mode()
+ {
+ $home = $this->actingAs($this->getEditor())->get('/');
+ $home->assertElementNotExists('.dark-mode');
+ $home->assertSee('Dark Mode');
+
+ $this->assertEquals(false, setting()->getForCurrentUser('dark-mode-enabled', false));
+ $prefChange = $this->patch('/settings/users/toggle-dark-mode');
+ $prefChange->assertRedirect();
+ $this->assertEquals(true, setting()->getForCurrentUser('dark-mode-enabled'));
+
+ $home = $this->actingAs($this->getEditor())->get('/');
+ $home->assertElementExists('.dark-mode');
+ $home->assertDontSee('Dark Mode');
+ $home->assertSee('Light Mode');
+ }
}
\ No newline at end of file