guided-setup-a11y.spec.ts 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372
  1. // Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. import { axe } from 'vitest-axe'
  3. import '#tests/graphql/builders/mocks.ts'
  4. import { visitView } from '#tests/support/components/visitView.ts'
  5. import { mockApplicationConfig } from '#tests/support/mock-applicationConfig.ts'
  6. import { mockAuthentication } from '#tests/support/mock-authentication.ts'
  7. import { mockPermissions } from '#tests/support/mock-permissions.ts'
  8. import { mockFormUpdaterQuery } from '#shared/components/Form/graphql/queries/formUpdater.mocks.ts'
  9. import {
  10. EnumFormUpdaterId,
  11. EnumSystemSetupInfoStatus,
  12. EnumSystemSetupInfoType,
  13. } from '#shared/graphql/types.ts'
  14. import { mockChannelEmailSetNotificationConfigurationMutation } from '#desktop/entities/channel-email/graphql/mutations/channelEmailSetNotificationConfiguration.mocks.ts'
  15. import { mockChannelEmailValidateConfigurationOutboundMutation } from '#desktop/entities/channel-email/graphql/mutations/channelEmailValidateConfigurationOutbound.mocks.ts'
  16. import { mockEmailAddressesQuery } from '#desktop/entities/email-addresses/graphql/queries/emailAddresses.mocks.ts'
  17. import { mockSystemImportStartMutation } from '../graphql/mutations/systemImportStart.mocks.ts'
  18. import { mockSystemImportStateQuery } from '../graphql/queries/systemImportState.mocks.ts'
  19. import { mockSystemSetupInfoQuery } from '../graphql/queries/systemSetupInfo.mocks.ts'
  20. import { mockSystemSetupInfo } from './mocks/mock-systemSetupInfo.ts'
  21. describe('testing admin password request a11y', () => {
  22. beforeEach(() => {
  23. mockApplicationConfig({
  24. system_init_done: false,
  25. })
  26. })
  27. it('has no accessibility violations in the info screen', async () => {
  28. mockSystemSetupInfoQuery({
  29. systemSetupInfo: {
  30. status: EnumSystemSetupInfoStatus.New,
  31. type: null,
  32. },
  33. })
  34. const view = await visitView('/guided-setup')
  35. const results = await axe(view.html())
  36. expect(results).toHaveNoViolations()
  37. })
  38. it('has no accessibility violations in the import selection screen', async () => {
  39. mockSystemSetupInfoQuery({
  40. systemSetupInfo: {
  41. status: EnumSystemSetupInfoStatus.InProgress,
  42. type: EnumSystemSetupInfoType.Import,
  43. },
  44. })
  45. const view = await visitView('/guided-setup/import')
  46. const results = await axe(view.html())
  47. expect(results).toHaveNoViolations()
  48. })
  49. it('has no accessibility violations in the import source screen', async () => {
  50. mockSystemSetupInfo({
  51. status: EnumSystemSetupInfoStatus.InProgress,
  52. type: EnumSystemSetupInfoType.Import,
  53. lockValue: 'random-uuid-lock',
  54. importSource: 'freshdesk',
  55. })
  56. const view = await visitView('/guided-setup/import/freshdesk')
  57. const results = await axe(view.html())
  58. expect(results).toHaveNoViolations()
  59. })
  60. beforeEach(() => {
  61. mockApplicationConfig({
  62. system_init_done: false,
  63. import_mode: false,
  64. import_backend: 'freshdesk',
  65. })
  66. })
  67. it('has no accessibility violations in the import source start screen', async () => {
  68. mockSystemSetupInfo({
  69. status: EnumSystemSetupInfoStatus.InProgress,
  70. type: EnumSystemSetupInfoType.Import,
  71. lockValue: 'random-uuid-lock',
  72. importSource: 'freshdesk',
  73. })
  74. mockSystemSetupInfoQuery({
  75. systemSetupInfo: {
  76. status: EnumSystemSetupInfoStatus.InProgress,
  77. type: EnumSystemSetupInfoType.Import,
  78. },
  79. })
  80. mockSystemImportStartMutation({
  81. systemImportStart: {
  82. success: true,
  83. },
  84. })
  85. mockSystemImportStateQuery({
  86. systemImportState: {
  87. finishedAt: null,
  88. startedAt: null,
  89. },
  90. })
  91. const view = await visitView('/guided-setup/import/freshdesk/start')
  92. const results = await axe(view.html())
  93. expect(results).toHaveNoViolations()
  94. })
  95. it('has no accessibility violations in the import source status screen', async () => {
  96. mockSystemImportStateQuery({
  97. systemImportState: {
  98. result: null,
  99. finishedAt: null,
  100. startedAt: null,
  101. },
  102. })
  103. const view = await visitView('/guided-setup/import/freshdesk/status')
  104. const results = await axe(view.html())
  105. expect(results).toHaveNoViolations()
  106. })
  107. it('has no accessibility violations in the admin screen', async () => {
  108. mockSystemSetupInfoQuery({
  109. systemSetupInfo: {
  110. status: EnumSystemSetupInfoStatus.New,
  111. type: null,
  112. },
  113. })
  114. const view = await visitView('/guided-setup/manual/admin')
  115. const results = await axe(view.html())
  116. expect(results).toHaveNoViolations()
  117. })
  118. it('has no accessibility violations in the system information screen', async () => {
  119. mockApplicationConfig({
  120. system_init_done: true,
  121. })
  122. mockPermissions(['admin'])
  123. mockAuthentication(true)
  124. const view = await visitView('/guided-setup/manual/system-information')
  125. const results = await axe(view.html())
  126. expect(results).toHaveNoViolations()
  127. })
  128. it('has no accessibility violations in the email notification screen', async () => {
  129. mockApplicationConfig({
  130. system_init_done: true,
  131. })
  132. mockPermissions(['admin'])
  133. mockAuthentication(true)
  134. mockFormUpdaterQuery({
  135. formUpdater: {
  136. adapter: {
  137. initialValue: 'sendmail',
  138. options: [
  139. {
  140. value: 'smtp',
  141. label: 'SMTP - configure your own outgoing SMTP settings',
  142. },
  143. {
  144. value: 'sendmail',
  145. label:
  146. 'Local MTA (Sendmail/Postfix/Exim/â\u0080¦) - use server setup',
  147. },
  148. ],
  149. },
  150. notification_sender: {
  151. initialValue: 'Zammad Helpdesk <noreply@zammad.example.com>',
  152. },
  153. },
  154. })
  155. mockChannelEmailValidateConfigurationOutboundMutation({
  156. channelEmailValidateConfigurationOutbound: {
  157. success: true,
  158. errors: null,
  159. },
  160. })
  161. mockChannelEmailSetNotificationConfigurationMutation({
  162. channelEmailSetNotificationConfiguration: {
  163. success: true,
  164. },
  165. })
  166. const view = await visitView('/guided-setup/manual/email-notification')
  167. const results = await axe(view.html())
  168. expect(results).toHaveNoViolations()
  169. })
  170. it('has no accessibility violations in the channels screen', async () => {
  171. mockApplicationConfig({
  172. system_init_done: true,
  173. })
  174. mockPermissions(['admin'])
  175. mockAuthentication(true)
  176. const view = await visitView('/guided-setup/manual/channels')
  177. const results = await axe(view.html())
  178. expect(results).toHaveNoViolations()
  179. })
  180. it('has no accessibility violations in the email channel screen', async () => {
  181. mockApplicationConfig({
  182. system_init_done: true,
  183. })
  184. mockPermissions(['admin'])
  185. mockAuthentication(true)
  186. mockFormUpdaterQuery((variables) => {
  187. switch (variables.formUpdaterId) {
  188. case EnumFormUpdaterId.FormUpdaterUpdaterGuidedSetupEmailOutbound:
  189. return {
  190. formUpdater: {
  191. adapter: {
  192. initialValue: 'smtp',
  193. options: [
  194. {
  195. value: 'smtp',
  196. label: 'SMTP - configure your own outgoing SMTP settings',
  197. },
  198. {
  199. value: 'sendmail',
  200. label:
  201. 'Local MTA (Sendmail/Postfix/Exim/â\u0080¦) - use server setup',
  202. },
  203. ],
  204. },
  205. },
  206. }
  207. case EnumFormUpdaterId.FormUpdaterUpdaterGuidedSetupEmailInbound:
  208. default:
  209. return {
  210. formUpdater: {
  211. adapter: {
  212. initialValue: 'imap',
  213. options: [
  214. {
  215. value: 'imap',
  216. label: 'IMAP',
  217. },
  218. {
  219. value: 'pop3',
  220. label: 'POP3',
  221. },
  222. ],
  223. },
  224. },
  225. }
  226. }
  227. })
  228. const view = await visitView('/guided-setup/manual/channels/email')
  229. const results = await axe(view.html())
  230. expect(results).toHaveNoViolations()
  231. })
  232. it('has no accessibility violations in the pre-configured email address screen', async () => {
  233. mockApplicationConfig({
  234. system_init_done: true,
  235. system_online_service: true,
  236. })
  237. mockPermissions(['admin'])
  238. mockAuthentication(true)
  239. mockSystemSetupInfoQuery({
  240. systemSetupInfo: {
  241. status: EnumSystemSetupInfoStatus.InProgress,
  242. type: EnumSystemSetupInfoType.Manual,
  243. },
  244. })
  245. mockEmailAddressesQuery({
  246. emailAddresses: [
  247. {
  248. name: 'Example Corporation',
  249. email: 'example@zammad.com',
  250. },
  251. ],
  252. })
  253. const view = await visitView(
  254. '/guided-setup/manual/channels/email-pre-configured',
  255. )
  256. const results = await axe(view.html())
  257. expect(results).toHaveNoViolations()
  258. })
  259. it('has no accessibility violations in the invite screen', async () => {
  260. mockApplicationConfig({
  261. system_init_done: true,
  262. })
  263. mockPermissions(['admin'])
  264. mockAuthentication(true)
  265. mockFormUpdaterQuery({
  266. formUpdater: {
  267. role_ids: {
  268. initialValue: [2],
  269. options: [
  270. {
  271. value: 1,
  272. label: 'Admin',
  273. description: 'To configure your system.',
  274. },
  275. {
  276. value: 2,
  277. label: 'Agent',
  278. description: 'To work on Tickets.',
  279. },
  280. {
  281. value: 3,
  282. label: 'Customer',
  283. description: 'People who create Tickets ask for help.',
  284. },
  285. ],
  286. },
  287. group_ids: {
  288. options: [
  289. {
  290. value: 1,
  291. label: 'Users',
  292. },
  293. {
  294. value: 2,
  295. label: 'some group1',
  296. },
  297. ],
  298. },
  299. },
  300. })
  301. const view = await visitView('/guided-setup/manual/invite')
  302. const results = await axe(view.html())
  303. expect(results).toHaveNoViolations()
  304. })
  305. it('has no accessibility violations in the finish screen', async () => {
  306. mockApplicationConfig({
  307. system_init_done: true,
  308. })
  309. mockPermissions(['admin'])
  310. mockAuthentication(true)
  311. const view = await visitView('/guided-setup/manual/finish')
  312. const results = await axe(view.html())
  313. expect(results).toHaveNoViolations()
  314. })
  315. })