personal-setting-devices-a11y.spec.ts 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. // Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. import { axe } from 'vitest-axe'
  3. import { visitView } from '#tests/support/components/visitView.ts'
  4. import { mockPermissions } from '#tests/support/mock-permissions.ts'
  5. import { mockUserCurrent } from '#tests/support/mock-userCurrent.ts'
  6. import { mockUserCurrentDeviceListQuery } from '../graphql/queries/userCurrentDeviceList.mocks.ts'
  7. const generateFingerprintSpy = vi.fn()
  8. vi.mock('#shared/utils/browser.ts', () => {
  9. return {
  10. generateFingerprint: () => {
  11. generateFingerprintSpy()
  12. return 'dummy'
  13. },
  14. }
  15. })
  16. const userCurrentDeviceList = [
  17. {
  18. id: '1',
  19. name: 'Chrome on Mac',
  20. fingerprint: 'dummy',
  21. location: 'Germany, Berlin',
  22. updatedAt: '2024-02-01T12:00:00Z',
  23. },
  24. {
  25. id: '2',
  26. name: 'Firefox on Mac',
  27. fingerprint: 'random',
  28. location: 'Germany, Frankfurt',
  29. updatedAt: '2024-01-01T12:00:00Z',
  30. },
  31. ]
  32. describe('testing devices a11y view', async () => {
  33. beforeEach(() => {
  34. mockUserCurrent({
  35. firstname: 'John',
  36. lastname: 'Doe',
  37. })
  38. mockPermissions(['user_preferences.device'])
  39. mockUserCurrentDeviceListQuery({ userCurrentDeviceList })
  40. })
  41. it('has no accessibility violations', async () => {
  42. const view = await visitView('/personal-setting/devices')
  43. const results = await axe(view.html())
  44. expect(results).toHaveNoViolations()
  45. })
  46. })