personal-setting-appearance.spec.ts 1.2 KB

1234567891011121314151617181920212223242526272829303132
  1. // Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. import { visitView } from '#tests/support/components/visitView.ts'
  3. import { waitForAccountAppearanceMutationCalls } from '../graphql/mutations/accountAppearance.mocks.ts'
  4. describe('appearance page', () => {
  5. it('update appearance to dark', async () => {
  6. const view = await visitView('/personal-setting/appearance')
  7. const darkMode = view.getByText('Dark')
  8. const lightMode = view.getByText('Light')
  9. const syncWithComputer = view.getByText('Sync with computer')
  10. await view.events.click(darkMode)
  11. expect(view.getByLabelText('Dark')).toBeChecked()
  12. const calls = await waitForAccountAppearanceMutationCalls()
  13. expect(calls.at(-1)?.variables).toEqual({ theme: 'dark' })
  14. expect(window.matchMedia('(prefers-color-scheme: light)').matches).toBe(
  15. false,
  16. )
  17. await view.events.click(lightMode)
  18. await vi.waitUntil(() => calls.length === 2)
  19. expect(calls.at(-1)?.variables).toEqual({ theme: 'light' })
  20. expect(window.matchMedia('(prefers-color-scheme: dark)').matches).toBe(
  21. false,
  22. )
  23. await view.events.click(syncWithComputer)
  24. expect(view.getByLabelText('Sync with computer')).toBeChecked()
  25. })
  26. })