guided-setup-manual-channels.spec.ts 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. // Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. import { visitView } from '#tests/support/components/visitView.ts'
  3. import { mockApplicationConfig } from '#tests/support/mock-applicationConfig.ts'
  4. import { mockAuthentication } from '#tests/support/mock-authentication.ts'
  5. import { mockPermissions } from '#tests/support/mock-permissions.ts'
  6. import { EnumSystemSetupInfoStatus } from '#shared/graphql/types.ts'
  7. import { mockSystemSetupInfoQuery } from '../graphql/queries/systemSetupInfo.mocks.ts'
  8. describe('guided setup manual channels', () => {
  9. describe('when system is not ready', () => {
  10. beforeEach(() => {
  11. mockApplicationConfig({
  12. system_init_done: false,
  13. })
  14. })
  15. it('redirects to guided setup start', async () => {
  16. mockSystemSetupInfoQuery({
  17. systemSetupInfo: {
  18. status: EnumSystemSetupInfoStatus.New,
  19. type: null,
  20. },
  21. })
  22. const view = await visitView('/guided-setup/manual/channels')
  23. await vi.waitFor(() => {
  24. expect(
  25. view,
  26. 'correctly redirects to guided setup start screen',
  27. ).toHaveCurrentUrl('/guided-setup')
  28. })
  29. view.getByText('Set up a new system')
  30. })
  31. })
  32. describe('when system is ready for optional steps', () => {
  33. beforeEach(() => {
  34. mockApplicationConfig({
  35. system_init_done: true,
  36. })
  37. mockPermissions(['admin'])
  38. mockAuthentication(true)
  39. })
  40. it('can redirect to email channel step', async () => {
  41. const view = await visitView('/guided-setup/manual/channels')
  42. expect(view.getByText('Connect Channels')).toBeInTheDocument()
  43. expect(view.getByRole('button', { name: 'Skip' })).toBeInTheDocument()
  44. const emailChannelButton = view.getByRole('button', {
  45. name: 'Email Channel',
  46. })
  47. await view.events.click(emailChannelButton)
  48. await vi.waitFor(() => {
  49. expect(
  50. view,
  51. 'correctly redirects to guided setup email channel step',
  52. ).toHaveCurrentUrl('/guided-setup/manual/channels/email')
  53. })
  54. })
  55. it('can go back to email notification step', async () => {
  56. const view = await visitView('/guided-setup/manual/channels')
  57. const goBackButton = view.getByRole('button', { name: 'Go Back' })
  58. await view.events.click(goBackButton)
  59. await vi.waitFor(() => {
  60. expect(
  61. view,
  62. 'correctly redirects to email notification step',
  63. ).toHaveCurrentUrl('/guided-setup/manual/email-notification')
  64. })
  65. })
  66. it('can skip to the last step', async () => {
  67. const view = await visitView('/guided-setup/manual/channels')
  68. const skipButton = view.getByRole('button', { name: 'Skip' })
  69. await view.events.click(skipButton)
  70. await vi.waitFor(() => {
  71. expect(view, 'correctly redirects to the last step').toHaveCurrentUrl(
  72. '/guided-setup/manual/finish',
  73. )
  74. })
  75. })
  76. })
  77. })