0
0
Fork 0
mirror of https://github.com/BookStackApp/BookStack.git synced 2025-04-17 10:02:38 +00:00

Added tests and translations for dark-mode components

This commit is contained in:
Dan Brown 2020-04-11 20:44:23 +01:00
parent 573c848d51
commit 50669e3f4a
No known key found for this signature in database
GPG key ID: 46D9F943C24A2EF9
3 changed files with 21 additions and 2 deletions
resources
lang/en
views/common
tests/User

View file

@ -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',

View file

@ -76,9 +76,9 @@
{{ csrf_field() }}
{{ method_field('patch') }}
@if(setting()->getForCurrentUser('dark-mode-enabled'))
<button>@icon('light-mode')Light Mode</button>
<button>@icon('light-mode'){{ trans('common.light_mode') }}</button>
@else
<button>@icon('dark-mode')Dark Mode</button>
<button>@icon('dark-mode'){{ trans('common.dark_mode') }}</button>
@endif
</form>
</li>

View file

@ -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');
}
}