guided-setup-manual-channel-email.spec.ts 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922
  1. // Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. import { getNode } from '@formkit/core'
  3. import {
  4. getByLabelText,
  5. getByRole,
  6. getByText,
  7. queryByText,
  8. } from '@testing-library/vue'
  9. import { mockApplicationConfig } from '#tests/support/mock-applicationConfig.ts'
  10. import { visitView } from '#tests/support/components/visitView.ts'
  11. import {
  12. EnumChannelEmailInboundAdapter,
  13. EnumChannelEmailOutboundAdapter,
  14. EnumChannelEmailSsl,
  15. EnumFormUpdaterId,
  16. EnumSystemSetupInfoStatus,
  17. } from '#shared/graphql/types.ts'
  18. import { mockAuthentication } from '#tests/support/mock-authentication.ts'
  19. import { mockPermissions } from '#tests/support/mock-permissions.ts'
  20. import { mockChannelEmailGuessConfigurationMutation } from '#desktop/entities/channel-email/graphql/mutations/channelEmailGuessConfiguration.mocks.ts'
  21. import { mockChannelEmailValidateConfigurationRoundtripMutation } from '#desktop/entities/channel-email/graphql/mutations/channelEmailValidateConfigurationRoundtrip.mocks.ts'
  22. import { mockChannelEmailValidateConfigurationInboundMutation } from '#desktop/entities/channel-email/graphql/mutations/channelEmailValidateConfigurationInbound.mocks.ts'
  23. import { mockFormUpdaterQuery } from '#shared/components/Form/graphql/queries/formUpdater.mocks.ts'
  24. import { mockChannelEmailValidateConfigurationOutboundMutation } from '#desktop/entities/channel-email/graphql/mutations/channelEmailValidateConfigurationOutbound.mocks.ts'
  25. import {
  26. mockChannelEmailAddMutation,
  27. waitForChannelEmailAddMutationCalls,
  28. } from '#desktop/entities/channel-email/graphql/mutations/channelEmailAdd.mocks.ts'
  29. import { mockSystemSetupInfoQuery } from '../graphql/queries/systemSetupInfo.mocks.ts'
  30. const inboundConfiguration = {
  31. adapter: EnumChannelEmailInboundAdapter.Imap,
  32. host: 'mail.test.dc.zammad.com',
  33. port: 993,
  34. ssl: EnumChannelEmailSsl.Ssl,
  35. user: 'zammad@mail.test.dc.zammad.com',
  36. password: 'zammad',
  37. sslVerify: true,
  38. folder: 'INBOX',
  39. }
  40. const outboundConfiguration = {
  41. adapter: EnumChannelEmailOutboundAdapter.Smtp,
  42. host: 'mail.test.dc.zammad.com',
  43. port: 25,
  44. user: 'zammad@mail.test.dc.zammad.com',
  45. password: 'zammad',
  46. sslVerify: false,
  47. }
  48. const sslVerificationWarningText =
  49. 'Turning off SSL verification is a security risk and should be used only temporary. Use this option at your own risk!'
  50. describe('guided setup manual channel email', () => {
  51. describe('when system is not ready', () => {
  52. beforeEach(() => {
  53. mockApplicationConfig({
  54. system_init_done: false,
  55. })
  56. })
  57. it('redirects to guided setup start', async () => {
  58. mockSystemSetupInfoQuery({
  59. systemSetupInfo: {
  60. status: EnumSystemSetupInfoStatus.New,
  61. type: null,
  62. },
  63. })
  64. const view = await visitView('/guided-setup/manual/channels/email')
  65. await vi.waitFor(() => {
  66. expect(
  67. view,
  68. 'correctly redirects to guided setup start screen',
  69. ).toHaveCurrentUrl('/guided-setup')
  70. })
  71. view.getByText('Set up a new system')
  72. })
  73. })
  74. describe('when system is ready for optional steps', () => {
  75. beforeEach(() => {
  76. mockApplicationConfig({
  77. system_init_done: true,
  78. })
  79. mockPermissions(['admin'])
  80. mockAuthentication(true)
  81. mockFormUpdaterQuery((variables) => {
  82. switch (variables.formUpdaterId) {
  83. case EnumFormUpdaterId.FormUpdaterUpdaterGuidedSetupEmailOutbound:
  84. return {
  85. formUpdater: {
  86. adapter: {
  87. initialValue: 'smtp',
  88. options: [
  89. {
  90. value: 'smtp',
  91. label: 'SMTP - configure your own outgoing SMTP settings',
  92. },
  93. {
  94. value: 'sendmail',
  95. label:
  96. 'Local MTA (Sendmail/Postfix/Exim/â\u0080¦) - use server setup',
  97. },
  98. ],
  99. },
  100. },
  101. }
  102. case EnumFormUpdaterId.FormUpdaterUpdaterGuidedSetupEmailInbound:
  103. default:
  104. return {
  105. formUpdater: {
  106. adapter: {
  107. initialValue: 'imap',
  108. options: [
  109. {
  110. value: 'imap',
  111. label: 'IMAP',
  112. },
  113. {
  114. value: 'pop3',
  115. label: 'POP3',
  116. },
  117. ],
  118. },
  119. },
  120. }
  121. }
  122. })
  123. })
  124. it('can redirect to invite step when guess is successful', async () => {
  125. const view = await visitView('/guided-setup/manual/channels/email')
  126. expect(view.getByText('Email Account')).toBeInTheDocument()
  127. expect(view.getByRole('button', { name: 'Go Back' })).toBeInTheDocument()
  128. const accountForm = view.getByTestId('channel-email-account')
  129. await view.events.type(
  130. getByLabelText(accountForm, 'Full Name'),
  131. 'Zammad Helpdesk',
  132. )
  133. await view.events.type(
  134. getByLabelText(accountForm, 'Email Address'),
  135. 'zammad@mail.test.dc.zammad.com',
  136. )
  137. await view.events.type(getByLabelText(accountForm, 'Password'), 'zammad')
  138. mockChannelEmailGuessConfigurationMutation({
  139. channelEmailGuessConfiguration: {
  140. result: {
  141. inboundConfiguration,
  142. outboundConfiguration,
  143. mailboxStats: {
  144. contentMessages: 0,
  145. archivePossible: false,
  146. archiveWeekRange: 2,
  147. },
  148. },
  149. },
  150. })
  151. mockChannelEmailValidateConfigurationRoundtripMutation({
  152. channelEmailValidateConfigurationRoundtrip: {
  153. success: true,
  154. },
  155. })
  156. await view.events.click(
  157. view.getByRole('button', {
  158. name: 'Connect and Continue',
  159. }),
  160. )
  161. await vi.waitFor(() => {
  162. expect(
  163. view,
  164. 'correctly redirects to guided setup invite step',
  165. ).toHaveCurrentUrl('/guided-setup/manual/invite')
  166. })
  167. })
  168. it('can show inbound configuration form when guess is unsuccessful', async () => {
  169. const view = await visitView('/guided-setup/manual/channels/email')
  170. const accountForm = view.getByTestId('channel-email-account')
  171. await view.events.type(
  172. getByLabelText(accountForm, 'Full Name'),
  173. 'Zammad Helpdesk',
  174. )
  175. await view.events.type(
  176. getByLabelText(accountForm, 'Email Address'),
  177. 'zammad@mail.test.dc.zammad.com',
  178. )
  179. await view.events.type(getByLabelText(accountForm, 'Password'), 'zammad')
  180. mockChannelEmailGuessConfigurationMutation({
  181. channelEmailGuessConfiguration: {
  182. result: {
  183. inboundConfiguration: null,
  184. outboundConfiguration: null,
  185. },
  186. },
  187. })
  188. await view.events.click(
  189. view.getByRole('button', {
  190. name: 'Connect and Continue',
  191. }),
  192. )
  193. expect(accountForm).not.toBeVisible()
  194. const inboundForm = view.getByTestId('channel-email-inbound')
  195. expect(inboundForm).toBeVisible()
  196. expect(getByRole(inboundForm, 'alert')).toHaveTextContent(
  197. 'The server settings could not be automatically detected. Please configure them manually.',
  198. )
  199. expect(view.getByRole('button', { name: 'Continue' })).toBeInTheDocument()
  200. })
  201. it('can show inbound configuration form when roundtrip is unsuccessful', async () => {
  202. const view = await visitView('/guided-setup/manual/channels/email')
  203. const accountForm = view.getByTestId('channel-email-account')
  204. await view.events.type(
  205. getByLabelText(accountForm, 'Full Name'),
  206. 'Zammad Helpdesk',
  207. )
  208. await view.events.type(
  209. getByLabelText(accountForm, 'Email Address'),
  210. 'zammad@mail.test.dc.zammad.com',
  211. )
  212. await view.events.type(getByLabelText(accountForm, 'Password'), 'zammad')
  213. mockChannelEmailGuessConfigurationMutation({
  214. channelEmailGuessConfiguration: {
  215. result: {
  216. inboundConfiguration,
  217. outboundConfiguration,
  218. mailboxStats: {
  219. contentMessages: 0,
  220. archivePossible: false,
  221. archiveWeekRange: 2,
  222. },
  223. },
  224. },
  225. })
  226. mockChannelEmailValidateConfigurationRoundtripMutation({
  227. channelEmailValidateConfigurationRoundtrip: {
  228. success: false,
  229. errors: [
  230. {
  231. message: 'Something went wrong',
  232. field: 'inbound.adapter',
  233. },
  234. ],
  235. },
  236. })
  237. await view.events.click(
  238. view.getByRole('button', {
  239. name: 'Connect and Continue',
  240. }),
  241. )
  242. expect(accountForm).not.toBeVisible()
  243. const inboundForm = view.getByTestId('channel-email-inbound')
  244. expect(inboundForm).toBeVisible()
  245. expect(getByText(inboundForm, 'Something went wrong')).toBeInTheDocument()
  246. })
  247. it('can show a form error when adding email channel is unsuccessful', async () => {
  248. const view = await visitView('/guided-setup/manual/channels/email')
  249. const accountForm = view.getByTestId('channel-email-account')
  250. await view.events.type(
  251. getByLabelText(accountForm, 'Full Name'),
  252. 'Zammad Helpdesk',
  253. )
  254. await view.events.type(
  255. getByLabelText(accountForm, 'Email Address'),
  256. 'zammad@mail.test.dc.zammad.com',
  257. )
  258. await view.events.type(getByLabelText(accountForm, 'Password'), 'zammad')
  259. mockChannelEmailGuessConfigurationMutation({
  260. channelEmailGuessConfiguration: {
  261. result: {
  262. inboundConfiguration,
  263. outboundConfiguration,
  264. mailboxStats: {
  265. contentMessages: 0,
  266. archivePossible: false,
  267. archiveWeekRange: 2,
  268. },
  269. },
  270. },
  271. })
  272. mockChannelEmailValidateConfigurationRoundtripMutation({
  273. channelEmailValidateConfigurationRoundtrip: {
  274. success: true,
  275. },
  276. })
  277. mockChannelEmailAddMutation({
  278. channelEmailAdd: {
  279. errors: [
  280. {
  281. message: 'The provided password is invalid.',
  282. field: 'password',
  283. },
  284. ],
  285. },
  286. })
  287. await view.events.click(
  288. view.getByRole('button', {
  289. name: 'Connect and Continue',
  290. }),
  291. )
  292. expect(accountForm).toBeVisible()
  293. expect(
  294. getByText(accountForm, 'The provided password is invalid.'),
  295. ).toBeInTheDocument()
  296. })
  297. it('can show inbound messages form when some messages are detected', async () => {
  298. const view = await visitView('/guided-setup/manual/channels/email')
  299. const accountForm = view.getByTestId('channel-email-account')
  300. await view.events.type(
  301. getByLabelText(accountForm, 'Full Name'),
  302. 'Zammad Helpdesk',
  303. )
  304. await view.events.type(
  305. getByLabelText(accountForm, 'Email Address'),
  306. 'zammad@mail.test.dc.zammad.com',
  307. )
  308. await view.events.type(getByLabelText(accountForm, 'Password'), 'zammad')
  309. mockChannelEmailGuessConfigurationMutation({
  310. channelEmailGuessConfiguration: {
  311. result: {
  312. inboundConfiguration: null,
  313. outboundConfiguration: null,
  314. },
  315. },
  316. })
  317. await view.events.click(
  318. view.getByRole('button', {
  319. name: 'Connect and Continue',
  320. }),
  321. )
  322. const inboundForm = view.getByTestId('channel-email-inbound')
  323. await view.events.type(
  324. getByLabelText(inboundForm, 'Host'),
  325. 'mail.test.dc.zammad.com',
  326. )
  327. await getNode('channel-email-inbound')?.settled
  328. mockChannelEmailValidateConfigurationInboundMutation({
  329. channelEmailValidateConfigurationInbound: {
  330. success: true,
  331. mailboxStats: {
  332. contentMessages: 3,
  333. archivePossible: true,
  334. archiveWeekRange: 2,
  335. },
  336. },
  337. })
  338. await view.events.click(
  339. view.getByRole('button', {
  340. name: 'Continue',
  341. }),
  342. )
  343. expect(inboundForm).not.toBeVisible()
  344. const inboundMessagesForm = view.getByTestId(
  345. 'channel-email-inbound-messages',
  346. )
  347. expect(inboundMessagesForm).toBeVisible()
  348. expect(inboundMessagesForm).toHaveTextContent(
  349. '3 email(s) were found in your mailbox. They will all be moved from your mailbox into Zammad.',
  350. )
  351. expect(inboundMessagesForm).toHaveTextContent(
  352. 'In addition, we have found emails in your mailbox that are older than 2 weeks. You can import such emails as an "archive", which means that no notifications are sent and the tickets have the status "closed". However, you can find them in Zammad anytime using the search function.',
  353. )
  354. expect(
  355. getByLabelText(inboundMessagesForm, 'Email import mode'),
  356. ).toBeInTheDocument()
  357. expect(view.getByRole('button', { name: 'Continue' })).toBeInTheDocument()
  358. })
  359. it('can show outbound configuration form when guess is unsuccessful', async () => {
  360. const view = await visitView('/guided-setup/manual/channels/email')
  361. const accountForm = view.getByTestId('channel-email-account')
  362. await view.events.type(
  363. getByLabelText(accountForm, 'Full Name'),
  364. 'Zammad Helpdesk',
  365. )
  366. await view.events.type(
  367. getByLabelText(accountForm, 'Email Address'),
  368. 'zammad@mail.test.dc.zammad.com',
  369. )
  370. await view.events.type(getByLabelText(accountForm, 'Password'), 'zammad')
  371. mockChannelEmailGuessConfigurationMutation({
  372. channelEmailGuessConfiguration: {
  373. result: {
  374. inboundConfiguration: null,
  375. outboundConfiguration: null,
  376. },
  377. },
  378. })
  379. await view.events.click(
  380. view.getByRole('button', {
  381. name: 'Connect and Continue',
  382. }),
  383. )
  384. const inboundForm = view.getByTestId('channel-email-inbound')
  385. await view.events.type(
  386. getByLabelText(inboundForm, 'Host'),
  387. 'mail.test.dc.zammad.com',
  388. )
  389. await getNode('channel-email-inbound')?.settled
  390. mockChannelEmailValidateConfigurationInboundMutation({
  391. channelEmailValidateConfigurationInbound: {
  392. success: true,
  393. mailboxStats: {
  394. contentMessages: 0,
  395. archivePossible: false,
  396. archiveWeekRange: 2,
  397. },
  398. },
  399. })
  400. await view.events.click(
  401. view.getByRole('button', {
  402. name: 'Continue',
  403. }),
  404. )
  405. expect(inboundForm).not.toBeVisible()
  406. const outboundForm = view.getByTestId('channel-email-outbound')
  407. expect(outboundForm).toBeVisible()
  408. expect(
  409. view.getByRole('button', { name: 'Save and Continue' }),
  410. ).toBeInTheDocument()
  411. })
  412. it('can show outbound configuration form when roundtrip is unsuccessful', async () => {
  413. const view = await visitView('/guided-setup/manual/channels/email')
  414. const accountForm = view.getByTestId('channel-email-account')
  415. await view.events.type(
  416. getByLabelText(accountForm, 'Full Name'),
  417. 'Zammad Helpdesk',
  418. )
  419. await view.events.type(
  420. getByLabelText(accountForm, 'Email Address'),
  421. 'zammad@mail.test.dc.zammad.com',
  422. )
  423. await view.events.type(getByLabelText(accountForm, 'Password'), 'zammad')
  424. mockChannelEmailGuessConfigurationMutation({
  425. channelEmailGuessConfiguration: {
  426. result: {
  427. inboundConfiguration,
  428. outboundConfiguration,
  429. mailboxStats: {
  430. contentMessages: 0,
  431. archivePossible: false,
  432. archiveWeekRange: 2,
  433. },
  434. },
  435. },
  436. })
  437. mockChannelEmailValidateConfigurationRoundtripMutation({
  438. channelEmailValidateConfigurationRoundtrip: {
  439. success: false,
  440. errors: [
  441. {
  442. message: 'Something went wrong',
  443. field: 'outbound.adapter',
  444. },
  445. ],
  446. },
  447. })
  448. await view.events.click(
  449. view.getByRole('button', {
  450. name: 'Connect and Continue',
  451. }),
  452. )
  453. expect(accountForm).not.toBeVisible()
  454. const outboundForm = view.getByTestId('channel-email-outbound')
  455. expect(outboundForm).toBeVisible()
  456. expect(
  457. getByText(outboundForm, 'Something went wrong'),
  458. ).toBeInTheDocument()
  459. })
  460. it('can add email channel and redirect to invite step', async () => {
  461. const view = await visitView('/guided-setup/manual/channels/email')
  462. const accountForm = view.getByTestId('channel-email-account')
  463. await view.events.type(
  464. getByLabelText(accountForm, 'Full Name'),
  465. 'Zammad Helpdesk',
  466. )
  467. await view.events.type(
  468. getByLabelText(accountForm, 'Email Address'),
  469. 'zammad@mail.test.dc.zammad.com',
  470. )
  471. await view.events.type(getByLabelText(accountForm, 'Password'), 'zammad')
  472. mockChannelEmailGuessConfigurationMutation({
  473. channelEmailGuessConfiguration: {
  474. result: {
  475. inboundConfiguration: null,
  476. outboundConfiguration: null,
  477. },
  478. },
  479. })
  480. await view.events.click(
  481. view.getByRole('button', {
  482. name: 'Connect and Continue',
  483. }),
  484. )
  485. const inboundForm = view.getByTestId('channel-email-inbound')
  486. await view.events.type(
  487. getByLabelText(inboundForm, 'Host'),
  488. 'mail.test.dc.zammad.com',
  489. )
  490. await getNode('channel-email-inbound')?.settled
  491. mockChannelEmailValidateConfigurationInboundMutation({
  492. channelEmailValidateConfigurationInbound: {
  493. success: true,
  494. mailboxStats: {
  495. contentMessages: 0,
  496. archivePossible: false,
  497. archiveWeekRange: 2,
  498. },
  499. },
  500. })
  501. await view.events.click(
  502. view.getByRole('button', {
  503. name: 'Continue',
  504. }),
  505. )
  506. const outboundForm = view.getByTestId('channel-email-outbound')
  507. await view.events.type(getByLabelText(outboundForm, 'Port'), '25')
  508. mockChannelEmailValidateConfigurationOutboundMutation({
  509. channelEmailValidateConfigurationOutbound: {
  510. success: true,
  511. },
  512. })
  513. mockChannelEmailValidateConfigurationRoundtripMutation({
  514. channelEmailValidateConfigurationRoundtrip: {
  515. success: true,
  516. },
  517. })
  518. mockChannelEmailAddMutation({
  519. channelEmailAdd: {
  520. channel: {
  521. options: {},
  522. group: {
  523. id: 'gid://zammad/Group/1',
  524. },
  525. },
  526. },
  527. })
  528. await view.events.click(
  529. view.getByRole('button', {
  530. name: 'Save and Continue',
  531. }),
  532. )
  533. const calls = await waitForChannelEmailAddMutationCalls()
  534. expect(calls.at(-1)?.variables).toEqual({
  535. input: {
  536. emailAddress: 'zammad@mail.test.dc.zammad.com',
  537. emailRealname: 'Zammad Helpdesk',
  538. inboundConfiguration: {
  539. adapter: 'imap',
  540. folder: '',
  541. host: 'mail.test.dc.zammad.com',
  542. keepOnServer: false,
  543. password: 'zammad',
  544. port: 993,
  545. ssl: 'ssl',
  546. sslVerify: true,
  547. user: 'zammad@mail.test.dc.zammad.com',
  548. },
  549. outboundConfiguration: {
  550. adapter: 'smtp',
  551. host: 'mail.test.dc.zammad.com',
  552. password: 'zammad',
  553. port: 25,
  554. sslVerify: false,
  555. user: 'zammad@mail.test.dc.zammad.com',
  556. },
  557. },
  558. })
  559. await vi.waitFor(() => {
  560. expect(view).toHaveCurrentUrl('/guided-setup/manual/invite')
  561. })
  562. })
  563. it('can show warning when SSL/STARTTLS is used and SSL verification is turned off in inbound form', async () => {
  564. const view = await visitView('/guided-setup/manual/channels/email')
  565. const accountForm = view.getByTestId('channel-email-account')
  566. await view.events.type(
  567. getByLabelText(accountForm, 'Full Name'),
  568. 'Zammad Helpdesk',
  569. )
  570. await view.events.type(
  571. getByLabelText(accountForm, 'Email Address'),
  572. 'zammad@mail.test.dc.zammad.com',
  573. )
  574. await view.events.type(getByLabelText(accountForm, 'Password'), 'zammad')
  575. mockChannelEmailGuessConfigurationMutation({
  576. channelEmailGuessConfiguration: {
  577. result: {
  578. inboundConfiguration: null,
  579. outboundConfiguration: null,
  580. },
  581. },
  582. })
  583. await view.events.click(
  584. view.getByRole('button', {
  585. name: 'Connect and Continue',
  586. }),
  587. )
  588. const inboundForm = view.getByTestId('channel-email-inbound')
  589. let alert = queryByText(inboundForm, sslVerificationWarningText)
  590. expect(alert).not.toBeInTheDocument()
  591. await view.events.click(getByLabelText(inboundForm, 'SSL verification'))
  592. alert = getByText(inboundForm, sslVerificationWarningText)
  593. expect(alert?.role).toBe('alert')
  594. await view.events.click(getByLabelText(inboundForm, 'SSL verification'))
  595. expect(alert).not.toBeInTheDocument()
  596. await view.events.click(getByLabelText(inboundForm, 'SSL verification'))
  597. alert = getByText(inboundForm, sslVerificationWarningText)
  598. expect(alert).toBeInTheDocument()
  599. const sslField = view.getByLabelText('SSL/STARTTLS')
  600. await view.events.click(sslField)
  601. await view.events.click(view.getAllByRole('option')[0])
  602. expect(alert).not.toBeInTheDocument()
  603. await view.events.click(sslField)
  604. await view.events.click(view.getAllByRole('option')[2])
  605. alert = queryByText(inboundForm, sslVerificationWarningText)
  606. expect(alert).not.toBeInTheDocument()
  607. await view.events.click(getByLabelText(inboundForm, 'SSL verification'))
  608. alert = getByText(inboundForm, sslVerificationWarningText)
  609. expect(alert).toBeInTheDocument()
  610. })
  611. it('can show warning when secure port is used and SSL verification is turned off in outbound form', async () => {
  612. const view = await visitView('/guided-setup/manual/channels/email')
  613. const accountForm = view.getByTestId('channel-email-account')
  614. await view.events.type(
  615. getByLabelText(accountForm, 'Full Name'),
  616. 'Zammad Helpdesk',
  617. )
  618. await view.events.type(
  619. getByLabelText(accountForm, 'Email Address'),
  620. 'zammad@mail.test.dc.zammad.com',
  621. )
  622. await view.events.type(getByLabelText(accountForm, 'Password'), 'zammad')
  623. mockChannelEmailGuessConfigurationMutation({
  624. channelEmailGuessConfiguration: {
  625. result: {
  626. inboundConfiguration: null,
  627. outboundConfiguration: null,
  628. },
  629. },
  630. })
  631. await view.events.click(
  632. view.getByRole('button', {
  633. name: 'Connect and Continue',
  634. }),
  635. )
  636. const inboundForm = view.getByTestId('channel-email-inbound')
  637. await view.events.type(
  638. getByLabelText(inboundForm, 'Host'),
  639. 'mail.test.dc.zammad.com',
  640. )
  641. await getNode('channel-email-inbound')?.settled
  642. mockChannelEmailValidateConfigurationInboundMutation({
  643. channelEmailValidateConfigurationInbound: {
  644. success: true,
  645. mailboxStats: {
  646. contentMessages: 0,
  647. archivePossible: false,
  648. archiveWeekRange: 2,
  649. },
  650. },
  651. })
  652. await view.events.click(
  653. view.getByRole('button', {
  654. name: 'Continue',
  655. }),
  656. )
  657. const outboundForm = view.getByTestId('channel-email-outbound')
  658. let alert = queryByText(outboundForm, sslVerificationWarningText)
  659. expect(alert).not.toBeInTheDocument()
  660. expect(
  661. getByLabelText(outboundForm, 'SSL verification'),
  662. ).not.toBeDisabled()
  663. await view.events.click(getByLabelText(outboundForm, 'SSL verification'))
  664. alert = getByText(outboundForm, sslVerificationWarningText)
  665. expect(alert?.role).toBe('alert')
  666. await view.events.click(getByLabelText(outboundForm, 'SSL verification'))
  667. expect(alert).not.toBeInTheDocument()
  668. await view.events.click(getByLabelText(outboundForm, 'SSL verification'))
  669. alert = getByText(outboundForm, sslVerificationWarningText)
  670. expect(alert).toBeInTheDocument()
  671. await view.events.type(getByLabelText(outboundForm, 'Port'), '25')
  672. await vi.waitFor(() => {
  673. expect(alert).not.toBeInTheDocument()
  674. expect(getByLabelText(outboundForm, 'SSL verification')).toBeDisabled()
  675. })
  676. await view.events.clear(getByLabelText(outboundForm, 'Port'))
  677. await vi.waitFor(() => {
  678. expect(
  679. getByLabelText(outboundForm, 'SSL verification'),
  680. ).not.toBeDisabled()
  681. })
  682. await view.events.click(getByLabelText(outboundForm, 'SSL verification'))
  683. await vi.waitFor(() => {
  684. alert = getByText(outboundForm, sslVerificationWarningText)
  685. expect(alert).toBeInTheDocument()
  686. expect(
  687. getByLabelText(outboundForm, 'SSL verification'),
  688. ).not.toBeDisabled()
  689. })
  690. await view.events.type(getByLabelText(outboundForm, 'Port'), '465')
  691. await vi.waitFor(() => {
  692. expect(
  693. getByLabelText(outboundForm, 'SSL verification'),
  694. ).not.toBeDisabled()
  695. })
  696. await vi.waitFor(() => {
  697. alert = getByText(outboundForm, sslVerificationWarningText)
  698. expect(alert).toBeInTheDocument()
  699. expect(
  700. getByLabelText(outboundForm, 'SSL verification'),
  701. ).not.toBeDisabled()
  702. })
  703. await view.events.type(getByLabelText(outboundForm, 'Port'), '587')
  704. await vi.waitFor(() => {
  705. expect(
  706. getByLabelText(outboundForm, 'SSL verification'),
  707. ).not.toBeDisabled()
  708. })
  709. await vi.waitFor(() => {
  710. alert = getByText(outboundForm, sslVerificationWarningText)
  711. expect(alert).toBeInTheDocument()
  712. expect(
  713. getByLabelText(outboundForm, 'SSL verification'),
  714. ).not.toBeDisabled()
  715. })
  716. })
  717. it('can go back to channels step', async () => {
  718. const view = await visitView('/guided-setup/manual/channels/email')
  719. const goBackButton = view.getByRole('button', { name: 'Go Back' })
  720. await view.events.click(goBackButton)
  721. await vi.waitFor(() => {
  722. expect(view, 'correctly redirects to channels step').toHaveCurrentUrl(
  723. '/guided-setup/manual/channels',
  724. )
  725. })
  726. })
  727. })
  728. })