-
Notifications
You must be signed in to change notification settings - Fork 738
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Maintenance: Desktop view - App theme defaulted to light mode on init…
…ial setup
- Loading branch information
Showing
15 changed files
with
363 additions
and
451 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 42 additions & 1 deletion
43
...rontend/apps/desktop/pages/personal-setting/__tests__/personal-setting-appearance.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,74 @@ | ||
// Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/ | ||
|
||
import { visitView } from '#tests/support/components/visitView.ts' | ||
import { mockUserCurrent } from '#tests/support/mock-userCurrent.ts' | ||
|
||
import { waitForUserCurrentAppearanceMutationCalls } from '../graphql/mutations/userCurrentAppearance.mocks.ts' | ||
import { EnumAppearanceTheme } from '#shared/graphql/types.ts' | ||
|
||
import { waitForUserCurrentAppearanceMutationCalls } from '#desktop/pages/personal-setting/graphql/mutations/userCurrentAppearance.mocks.ts' | ||
|
||
describe('appearance page', () => { | ||
it('should have dark theme set', async () => { | ||
mockUserCurrent({ | ||
preferences: { | ||
theme: EnumAppearanceTheme.Dark, | ||
}, | ||
}) | ||
|
||
const view = await visitView('/personal-setting/appearance') | ||
|
||
expect(view.getByRole('radio', { checked: true })).toHaveTextContent('dark') | ||
}) | ||
|
||
it('should have light theme set', async () => { | ||
mockUserCurrent({ | ||
preferences: { | ||
theme: EnumAppearanceTheme.Light, | ||
}, | ||
}) | ||
|
||
const view = await visitView('/personal-setting/appearance') | ||
|
||
expect(view.getByRole('radio', { checked: true })).toHaveTextContent( | ||
'light', | ||
) | ||
}) | ||
|
||
it('update appearance to dark', async () => { | ||
mockUserCurrent({ | ||
preferences: { | ||
theme: EnumAppearanceTheme.Light, | ||
}, | ||
}) | ||
const view = await visitView('/personal-setting/appearance') | ||
|
||
expect(view.getByLabelText('Light')).toBeChecked() | ||
|
||
const darkMode = view.getByText('Dark') | ||
const lightMode = view.getByText('Light') | ||
const syncWithComputer = view.getByText('Sync with computer') | ||
|
||
await view.events.click(darkMode) | ||
|
||
expect(view.getByLabelText('Dark')).toBeChecked() | ||
|
||
const calls = await waitForUserCurrentAppearanceMutationCalls() | ||
|
||
expect(calls.at(-1)?.variables).toEqual({ theme: 'dark' }) | ||
expect(window.matchMedia('(prefers-color-scheme: light)').matches).toBe( | ||
false, | ||
) | ||
|
||
await view.events.click(lightMode) | ||
await vi.waitUntil(() => calls.length === 2) | ||
|
||
expect(calls.at(-1)?.variables).toEqual({ theme: 'light' }) | ||
expect(window.matchMedia('(prefers-color-scheme: dark)').matches).toBe( | ||
false, | ||
) | ||
|
||
await view.events.click(syncWithComputer) | ||
|
||
expect(view.getByLabelText('Sync with computer')).toBeChecked() | ||
}) | ||
}) |
79 changes: 0 additions & 79 deletions
79
...frontend/apps/desktop/pages/personal-setting/composables/__tests__/useThemeUpdate.spec.ts
This file was deleted.
Oops, something went wrong.
70 changes: 0 additions & 70 deletions
70
app/frontend/apps/desktop/pages/personal-setting/composables/useThemeUpdate.ts
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.