online-notification-a11y.spec.ts 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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 { mockUserCurrent } from '#tests/support/mock-userCurrent.ts'
  9. import { waitUntil } from '#tests/support/utils.ts'
  10. import { mockOnlineNotificationQuery } from '#shared/entities/online-notification/__tests__/mocks/online-notification-mocks.ts'
  11. import { OnlineNotificationsDocument } from '#shared/entities/online-notification/graphql/queries/onlineNotifications.api.ts'
  12. import { OnlineNotificationsCountDocument } from '#shared/entities/online-notification/graphql/subscriptions/onlineNotificationsCount.api.ts'
  13. const testNotifications: any[] = [
  14. {
  15. metaObject: {
  16. __typename: 'Ticket',
  17. id: '111',
  18. internalId: 111,
  19. title: 'Ticket Title 1',
  20. },
  21. },
  22. {
  23. metaObject: {
  24. __typename: 'Ticket',
  25. id: '222',
  26. internalId: 222,
  27. title: 'Ticket Title 2',
  28. },
  29. },
  30. {
  31. seen: true,
  32. metaObject: {
  33. __typename: 'Ticket',
  34. id: '333',
  35. internalId: 333,
  36. title: 'Ticket Title 3',
  37. },
  38. },
  39. ]
  40. describe('testing online notification a11y', () => {
  41. beforeEach(async () => {
  42. mockUserCurrent({
  43. firstname: 'John',
  44. lastname: 'Doe',
  45. })
  46. const userUpdateSubscription = mockGraphQLSubscription(
  47. OnlineNotificationsCountDocument,
  48. )
  49. await userUpdateSubscription.next({
  50. data: {
  51. onlineNotificationsCount: {
  52. __typename: 'OnlineNotificationsCountPayload',
  53. unseenCount: 2,
  54. },
  55. },
  56. })
  57. })
  58. it('has no accessibility violations', async () => {
  59. const mockApi = mockGraphQLApi(OnlineNotificationsDocument).willResolve(
  60. mockOnlineNotificationQuery(testNotifications),
  61. )
  62. const view = await visitView('/notifications')
  63. await waitUntil(() => mockApi.calls.resolve)
  64. const results = await axe(view.html())
  65. expect(results).toHaveNoViolations()
  66. })
  67. })