personal-setting-locale.spec.ts 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. // Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. import { visitView } from '#tests/support/components/visitView.ts'
  3. import { waitForUserCurrentLocaleMutationCalls } from '#shared/entities/user/current/graphql/mutations/userCurrentLocale.mocks.ts'
  4. import { mockLocalesQuery } from '#shared/graphql/queries/locales.mocks.ts'
  5. import { EnumTextDirection } from '#shared/graphql/types.ts'
  6. describe('locale page', () => {
  7. it('can change language', async () => {
  8. mockLocalesQuery({
  9. locales: [
  10. {
  11. locale: 'de-de',
  12. name: 'Deutsch',
  13. dir: EnumTextDirection.Ltr,
  14. alias: 'de',
  15. active: true,
  16. },
  17. {
  18. locale: 'ar',
  19. name: 'Arabic',
  20. dir: EnumTextDirection.Rtl,
  21. alias: null,
  22. active: true,
  23. },
  24. ],
  25. })
  26. const view = await visitView('/personal-setting/locale')
  27. const localeField = view.getByLabelText('Your language')
  28. await view.events.click(localeField)
  29. const arabicLocale = view.getByText('Arabic')
  30. await view.events.click(arabicLocale)
  31. const calls = await waitForUserCurrentLocaleMutationCalls()
  32. expect(calls.at(-1)?.variables).toEqual({ locale: 'ar' })
  33. expect(localeField).not.toHaveTextContent('Your language')
  34. })
  35. it('has link to zammad translations', async () => {
  36. const view = await visitView('/personal-setting/locale')
  37. expect(
  38. view.queryByText('You can help translating Zammad.'),
  39. ).toBeInTheDocument()
  40. })
  41. })