guided-setup-manual-email-pre-configured.spec.ts 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. // Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. import { mockApplicationConfig } from '#tests/support/mock-applicationConfig.ts'
  3. import { visitView } from '#tests/support/components/visitView.ts'
  4. import { mockAuthentication } from '#tests/support/mock-authentication.ts'
  5. import { mockPermissions } from '#tests/support/mock-permissions.ts'
  6. import {
  7. EnumSystemSetupInfoStatus,
  8. EnumSystemSetupInfoType,
  9. } from '#shared/graphql/types.ts'
  10. import { mockEmailAddressesQuery } from '#desktop/entities/email-addresses/graphql/queries/emailAddresses.mocks.ts'
  11. import { mockSystemSetupInfoQuery } from '../graphql/queries/systemSetupInfo.mocks.ts'
  12. describe('guided setup manual email notification', () => {
  13. describe('when system is ready for optional steps and system_online_service is false', () => {
  14. beforeEach(() => {
  15. mockApplicationConfig({
  16. system_init_done: true,
  17. system_online_service: false,
  18. })
  19. mockPermissions(['admin'])
  20. mockAuthentication(true)
  21. })
  22. it('redirects to guided setup channels email step', async () => {
  23. mockSystemSetupInfoQuery({
  24. systemSetupInfo: {
  25. status: EnumSystemSetupInfoStatus.InProgress,
  26. type: EnumSystemSetupInfoType.Manual,
  27. },
  28. })
  29. const view = await visitView(
  30. '/guided-setup/manual/channels/email-pre-configured',
  31. )
  32. await vi.waitFor(() => {
  33. expect(
  34. view,
  35. 'correctly redirects to guided setup channels email screen',
  36. ).toHaveCurrentUrl('/guided-setup/manual/channels/email')
  37. })
  38. expect(view.getByText('Email Account')).toBeInTheDocument()
  39. expect(view.getByText('Email Address')).toBeInTheDocument()
  40. })
  41. })
  42. describe('when system is ready for optional steps and system_online_service is true', () => {
  43. beforeEach(() => {
  44. mockApplicationConfig({
  45. system_init_done: true,
  46. system_online_service: true,
  47. })
  48. mockPermissions(['admin'])
  49. mockAuthentication(true)
  50. })
  51. it('shows information about pre-configured email addresses', async () => {
  52. mockSystemSetupInfoQuery({
  53. systemSetupInfo: {
  54. status: EnumSystemSetupInfoStatus.InProgress,
  55. type: EnumSystemSetupInfoType.Manual,
  56. },
  57. })
  58. mockEmailAddressesQuery({
  59. emailAddresses: [
  60. {
  61. name: 'Example Corporation',
  62. email: 'example@zammad.com',
  63. },
  64. ],
  65. })
  66. const view = await visitView(
  67. '/guided-setup/manual/channels/email-pre-configured',
  68. )
  69. await vi.waitFor(() => {
  70. expect(
  71. view,
  72. 'correctly shows information about pre-configured email addresses',
  73. ).toHaveCurrentUrl('/guided-setup/manual/channels/email-pre-configured')
  74. })
  75. const labels = view.getAllByTestId('common-label')
  76. expect(labels[0]).toBeInTheDocument()
  77. expect(labels[0]).toHaveTextContent(
  78. 'Your Zammad has the following email address',
  79. )
  80. expect(
  81. view.getByText('Example Corporation <example@zammad.com>'),
  82. ).toBeInTheDocument()
  83. expect(labels[1]).toBeInTheDocument()
  84. expect(labels[1]).toHaveTextContent(
  85. 'If you want to use additional email addresses, you can configure them later',
  86. )
  87. })
  88. })
  89. })