ticket-a11y.spec.ts 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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 {
  5. mockGraphQLApi,
  6. mockGraphQLSubscription,
  7. } from '#tests/support/mock-graphql-api.ts'
  8. import { mockTicketOverviews } from '#tests/support/mocks/ticket-overviews.ts'
  9. import { waitUntil, waitUntilApisResolved } from '#tests/support/utils.ts'
  10. import { OrganizationDocument } from '#shared/entities/organization/graphql/queries/organization.api.ts'
  11. import { OrganizationUpdatesDocument } from '#shared/entities/organization/graphql/subscriptions/organizationUpdates.api.ts'
  12. import {
  13. defaultOrganization,
  14. mockOrganizationObjectAttributes,
  15. } from '#mobile/entities/organization/__tests__/mocks/organization-mocks.ts'
  16. import {
  17. defaultUser,
  18. mockUserDetailsApis,
  19. } from '#mobile/entities/user/__tests__/mocks/user-mocks.ts'
  20. import { mockTicketDetailViewGql } from './mocks/detail-view.ts'
  21. import { mockTicketsByOverview } from './mocks/overview.ts'
  22. describe('testing ticket a11y', () => {
  23. beforeEach(() => {
  24. mockTicketOverviews()
  25. })
  26. test('ticket overview has no accessibility violations', async () => {
  27. mockTicketsByOverview([])
  28. await visitView('/tickets/view')
  29. const results = await axe(document.body)
  30. expect(results).toHaveNoViolations()
  31. })
  32. test('ticket detail view has no accessibility violations', async () => {
  33. const { waitUntilTicketLoaded } = mockTicketDetailViewGql()
  34. const view = await visitView('/tickets/1')
  35. expect(view.getByTestId('loader-list')).toBeInTheDocument()
  36. expect(view.getByTestId('loader-title')).toBeInTheDocument()
  37. expect(view.getByTestId('loader-header')).toBeInTheDocument()
  38. await waitUntilTicketLoaded()
  39. const results = await axe(document.body)
  40. expect(results).toHaveNoViolations()
  41. })
  42. test('ticket organization information has no accessibility violations', async () => {
  43. mockTicketDetailViewGql()
  44. const mockApi = mockGraphQLApi(OrganizationDocument).willResolve({
  45. organization: defaultOrganization(),
  46. })
  47. mockGraphQLSubscription(OrganizationUpdatesDocument)
  48. const mockAttributes = mockOrganizationObjectAttributes()
  49. await visitView('/tickets/1/information/organization')
  50. await waitUntil(() => mockApi.calls.resolve && mockAttributes.calls.resolve)
  51. const results = await axe(document.body)
  52. expect(results).toHaveNoViolations()
  53. })
  54. test('ticket user information has no accessibility violations', async () => {
  55. mockTicketDetailViewGql()
  56. const { mockUser, mockAttributes } = mockUserDetailsApis(defaultUser(), {
  57. skipMockOnlineNotificationSeen: true,
  58. })
  59. await visitView('/tickets/1/information/customer')
  60. await waitUntilApisResolved(mockUser, mockAttributes)
  61. const results = await axe(document.body)
  62. expect(results).toHaveNoViolations()
  63. })
  64. })