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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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 { EnumSystemSetupInfoStatus } from '#shared/graphql/types.ts'
  5. import { mockAuthentication } from '#tests/support/mock-authentication.ts'
  6. import { mockPermissions } from '#tests/support/mock-permissions.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. })