guided-setup-a11y.spec.ts 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380
  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. fields: {
  137. adapter: {
  138. initialValue: 'sendmail',
  139. options: [
  140. {
  141. value: 'smtp',
  142. label: 'SMTP - configure your own outgoing SMTP settings',
  143. },
  144. {
  145. value: 'sendmail',
  146. label:
  147. 'Local MTA (Sendmail/Postfix/Exim/â\u0080¦) - use server setup',
  148. },
  149. ],
  150. },
  151. notification_sender: {
  152. initialValue: 'Zammad Helpdesk <noreply@zammad.example.com>',
  153. },
  154. },
  155. },
  156. })
  157. mockChannelEmailValidateConfigurationOutboundMutation({
  158. channelEmailValidateConfigurationOutbound: {
  159. success: true,
  160. errors: null,
  161. },
  162. })
  163. mockChannelEmailSetNotificationConfigurationMutation({
  164. channelEmailSetNotificationConfiguration: {
  165. success: true,
  166. },
  167. })
  168. const view = await visitView('/guided-setup/manual/email-notification')
  169. const results = await axe(view.html())
  170. expect(results).toHaveNoViolations()
  171. })
  172. it('has no accessibility violations in the channels screen', async () => {
  173. mockApplicationConfig({
  174. system_init_done: true,
  175. })
  176. mockPermissions(['admin'])
  177. mockAuthentication(true)
  178. const view = await visitView('/guided-setup/manual/channels')
  179. const results = await axe(view.html())
  180. expect(results).toHaveNoViolations()
  181. })
  182. it('has no accessibility violations in the email channel screen', async () => {
  183. mockApplicationConfig({
  184. system_init_done: true,
  185. })
  186. mockPermissions(['admin'])
  187. mockAuthentication(true)
  188. mockFormUpdaterQuery((variables) => {
  189. switch (variables.formUpdaterId) {
  190. case EnumFormUpdaterId.FormUpdaterUpdaterGuidedSetupEmailOutbound:
  191. return {
  192. formUpdater: {
  193. fields: {
  194. adapter: {
  195. initialValue: 'smtp',
  196. options: [
  197. {
  198. value: 'smtp',
  199. label: 'SMTP - configure your own outgoing SMTP settings',
  200. },
  201. {
  202. value: 'sendmail',
  203. label:
  204. 'Local MTA (Sendmail/Postfix/Exim/â\u0080¦) - use server setup',
  205. },
  206. ],
  207. },
  208. },
  209. },
  210. }
  211. case EnumFormUpdaterId.FormUpdaterUpdaterGuidedSetupEmailInbound:
  212. default:
  213. return {
  214. formUpdater: {
  215. fields: {
  216. adapter: {
  217. initialValue: 'imap',
  218. options: [
  219. {
  220. value: 'imap',
  221. label: 'IMAP',
  222. },
  223. {
  224. value: 'pop3',
  225. label: 'POP3',
  226. },
  227. ],
  228. },
  229. },
  230. },
  231. }
  232. }
  233. })
  234. const view = await visitView('/guided-setup/manual/channels/email')
  235. const results = await axe(view.html())
  236. expect(results).toHaveNoViolations()
  237. })
  238. it('has no accessibility violations in the pre-configured email address screen', async () => {
  239. mockApplicationConfig({
  240. system_init_done: true,
  241. system_online_service: true,
  242. })
  243. mockPermissions(['admin'])
  244. mockAuthentication(true)
  245. mockSystemSetupInfoQuery({
  246. systemSetupInfo: {
  247. status: EnumSystemSetupInfoStatus.InProgress,
  248. type: EnumSystemSetupInfoType.Manual,
  249. },
  250. })
  251. mockEmailAddressesQuery({
  252. emailAddresses: [
  253. {
  254. name: 'Example Corporation',
  255. email: 'example@zammad.com',
  256. },
  257. ],
  258. })
  259. const view = await visitView(
  260. '/guided-setup/manual/channels/email-pre-configured',
  261. )
  262. const results = await axe(view.html())
  263. expect(results).toHaveNoViolations()
  264. })
  265. it('has no accessibility violations in the invite screen', async () => {
  266. mockApplicationConfig({
  267. system_init_done: true,
  268. })
  269. mockPermissions(['admin'])
  270. mockAuthentication(true)
  271. mockFormUpdaterQuery({
  272. formUpdater: {
  273. fields: {
  274. role_ids: {
  275. initialValue: [2],
  276. options: [
  277. {
  278. value: 1,
  279. label: 'Admin',
  280. description: 'To configure your system.',
  281. },
  282. {
  283. value: 2,
  284. label: 'Agent',
  285. description: 'To work on Tickets.',
  286. },
  287. {
  288. value: 3,
  289. label: 'Customer',
  290. description: 'People who create Tickets ask for help.',
  291. },
  292. ],
  293. },
  294. group_ids: {
  295. options: [
  296. {
  297. value: 1,
  298. label: 'Users',
  299. },
  300. {
  301. value: 2,
  302. label: 'some group1',
  303. },
  304. ],
  305. },
  306. },
  307. },
  308. })
  309. const view = await visitView('/guided-setup/manual/invite')
  310. const results = await axe(view.html())
  311. expect(results).toHaveNoViolations()
  312. })
  313. it('has no accessibility violations in the finish screen', async () => {
  314. mockApplicationConfig({
  315. system_init_done: true,
  316. })
  317. mockPermissions(['admin'])
  318. mockAuthentication(true)
  319. const view = await visitView('/guided-setup/manual/finish')
  320. const results = await axe(view.html())
  321. expect(results).toHaveNoViolations()
  322. })
  323. })