ticket-create-a11y.spec.ts 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. // Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. import { waitFor } from '@testing-library/vue'
  3. import { axe } from 'vitest-axe'
  4. import { visitView } from '#tests/support/components/visitView.ts'
  5. import { mockApplicationConfig } from '#tests/support/mock-applicationConfig.ts'
  6. import { mockPermissions } from '#tests/support/mock-permissions.ts'
  7. import {
  8. mockTicketSharedDraftStartListQuery,
  9. waitForTicketSharedDraftStartListQueryCalls,
  10. } from '#shared/entities/ticket-shared-draft-start/graphql/queries/ticketSharedDraftStartList.mocks.ts'
  11. import { waitForUserQueryCalls } from '#shared/entities/user/graphql/queries/user.mocks.ts'
  12. import { mockUserCurrentTaskbarItemListQuery } from '#desktop/entities/user/current/graphql/queries/userCurrentTaskbarItemList.mocks.ts'
  13. import {
  14. handleMockFormUpdaterQuery,
  15. handleMockOrganizationQuery,
  16. handleMockUserQuery,
  17. } from '#desktop/pages/ticket/__tests__/support/ticket-create-helpers.ts'
  18. describe('testing tickets create a11y view', async () => {
  19. beforeEach(() => {
  20. mockApplicationConfig({
  21. ui_ticket_create_available_types: ['phone-in', 'phone-out', 'email-out'],
  22. customer_ticket_create: true,
  23. })
  24. mockPermissions(['ticket.agent'])
  25. mockUserCurrentTaskbarItemListQuery({
  26. userCurrentTaskbarItemList: [],
  27. })
  28. })
  29. afterEach(() => {
  30. document.body.innerHTML = ''
  31. })
  32. it('has no accessibility violations in main content', async () => {
  33. handleMockFormUpdaterQuery()
  34. const view = await visitView('/tickets/create')
  35. const results = await axe(view.html())
  36. expect(results).toHaveNoViolations()
  37. })
  38. it('has no accessibility violations in customer sidebar', async () => {
  39. handleMockFormUpdaterQuery({
  40. customer_id: {
  41. value: 2,
  42. },
  43. })
  44. handleMockUserQuery()
  45. const view = await visitView('/tickets/create')
  46. await waitForUserQueryCalls()
  47. await waitFor(() => {
  48. expect(
  49. view.getByRole('complementary', {
  50. name: 'Content sidebar',
  51. }),
  52. ).toBeInTheDocument()
  53. })
  54. const results = await axe(view.html())
  55. expect(results).toHaveNoViolations()
  56. })
  57. it('has no accessibility violations in organization sidebar', async () => {
  58. handleMockFormUpdaterQuery({
  59. customer_id: {
  60. value: 2,
  61. options: [
  62. {
  63. value: 2,
  64. label: 'Nicole Braun',
  65. heading: 'Zammad Foundation',
  66. },
  67. ],
  68. },
  69. })
  70. handleMockUserQuery()
  71. const view = await visitView('/tickets/create', {
  72. global: {
  73. stubs: {
  74. 'transition-group': false,
  75. },
  76. },
  77. })
  78. await waitForUserQueryCalls()
  79. await waitFor(() => {
  80. expect(
  81. view.getByRole('complementary', {
  82. name: 'Content sidebar',
  83. }),
  84. ).toBeInTheDocument()
  85. })
  86. handleMockOrganizationQuery()
  87. await view.events.click(view.getByLabelText('Organization'))
  88. const results = await axe(view.html())
  89. expect(results).toHaveNoViolations()
  90. })
  91. it('has no accessibility violations in shared drafts sidebar', async () => {
  92. handleMockFormUpdaterQuery({
  93. group_id: {
  94. value: 1,
  95. options: [
  96. {
  97. value: 1,
  98. label: 'Users',
  99. },
  100. ],
  101. },
  102. })
  103. mockTicketSharedDraftStartListQuery({
  104. ticketSharedDraftStartList: [],
  105. })
  106. const view = await visitView('/tickets/create')
  107. await waitForTicketSharedDraftStartListQueryCalls()
  108. await waitFor(() => {
  109. expect(
  110. view.getByRole('complementary', {
  111. name: 'Content sidebar',
  112. }),
  113. ).toBeInTheDocument()
  114. })
  115. const results = await axe(view.html())
  116. expect(results).toHaveNoViolations()
  117. })
  118. })