account-a11y.spec.ts 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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 { mockGraphQLApi } from '#tests/support/mock-graphql-api.ts'
  5. import { mockUserCurrent } from '#tests/support/mock-userCurrent.ts'
  6. import { UserCurrentAvatarActiveDocument } from '../graphql/queries/userCurrentAvatarActive.api.ts'
  7. const mockAvatarImage =
  8. 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg=='
  9. const getAvatarObject = (deletable: boolean) => {
  10. return {
  11. id: 'Z2lkOi8vemFtbWFkL0F2YXRhci8yNA',
  12. default: true,
  13. deletable,
  14. initial: false,
  15. imageFull: mockAvatarImage,
  16. imageResize: mockAvatarImage,
  17. createdAt: '2022-07-12T06:54:45Z',
  18. updatedAt: '2022-07-12T06:54:45Z',
  19. }
  20. }
  21. const mockActiveAvatar = async (deletable = true) => {
  22. mockGraphQLApi(UserCurrentAvatarActiveDocument).willResolve({
  23. userCurrentAvatarActive: getAvatarObject(deletable),
  24. })
  25. }
  26. describe('testing account a11y', () => {
  27. beforeEach(() => {
  28. mockUserCurrent({
  29. lastname: 'Doe',
  30. firstname: 'John',
  31. })
  32. })
  33. test('account overview has no accessibility violations', async () => {
  34. const view = await visitView('/account')
  35. const results = await axe(view.html())
  36. expect(results).toHaveNoViolations()
  37. })
  38. test('avatar editor has no accessibility violations', async () => {
  39. mockActiveAvatar()
  40. const view = await visitView('/user/current/avatar')
  41. const results = await axe(view.html())
  42. expect(results).toHaveNoViolations()
  43. })
  44. })