guided-setup-start.spec.ts 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  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 {
  5. EnumSystemSetupInfoStatus,
  6. EnumSystemSetupInfoType,
  7. } from '#shared/graphql/types.ts'
  8. import { mockSystemSetupInfoQuery } from '../graphql/queries/systemSetupInfo.mocks.ts'
  9. import { mockSystemSetupLockMutation } from '../graphql/mutations/systemSetupLock.mocks.ts'
  10. import { mockSystemSetupInfo } from './mocks/mock-systemSetupInfo.ts'
  11. describe('guided setup start', () => {
  12. describe('when system initialization is done', () => {
  13. beforeEach(() => {
  14. mockApplicationConfig({
  15. system_init_done: true,
  16. })
  17. })
  18. it('redirects to login window', async () => {
  19. const view = await visitView('/guided-setup')
  20. // Check that we ware on the login page
  21. expect(view.getByText('Username / Email')).toBeInTheDocument()
  22. expect(view.getByText('Password')).toBeInTheDocument()
  23. expect(view.getByText('Sign in')).toBeInTheDocument()
  24. })
  25. })
  26. describe('when system is not ready', () => {
  27. beforeEach(() => {
  28. mockApplicationConfig({
  29. system_init_done: false,
  30. })
  31. })
  32. it('shows guided setup screen and opens manual setup on click', async () => {
  33. mockSystemSetupInfoQuery({
  34. systemSetupInfo: {
  35. status: EnumSystemSetupInfoStatus.New,
  36. type: null,
  37. },
  38. })
  39. mockSystemSetupLockMutation({
  40. systemSetupLock: {
  41. resource: 'Zammad::System::Setup',
  42. value: 'random-uuid',
  43. },
  44. })
  45. const view = await visitView('/guided-setup')
  46. const manualSetupButton = view.getByText('Set up a new system')
  47. expect(manualSetupButton).toBeInTheDocument()
  48. expect(
  49. view.getByText('Or migrate from another system'),
  50. ).toBeInTheDocument()
  51. await view.events.click(manualSetupButton)
  52. await vi.waitFor(() => {
  53. expect(
  54. view,
  55. 'correctly redirects to guided setup manual',
  56. ).toHaveCurrentUrl('/guided-setup/manual')
  57. })
  58. expect(view.getByRole('button', { name: 'Go Back' })).toBeInTheDocument()
  59. expect(view.getByText('Create Administrator Account')).toBeInTheDocument()
  60. })
  61. it('shows guided setup screen and opens import setup on click', async () => {
  62. mockSystemSetupInfoQuery({
  63. systemSetupInfo: {
  64. status: EnumSystemSetupInfoStatus.New,
  65. type: null,
  66. },
  67. })
  68. mockSystemSetupLockMutation({
  69. systemSetupLock: {
  70. resource: 'Zammad::System::Setup',
  71. value: 'random-uuid',
  72. },
  73. })
  74. const view = await visitView('/guided-setup')
  75. const importSetupButton = view.getByText('Or migrate from another system')
  76. expect(importSetupButton).toBeInTheDocument()
  77. await view.events.click(importSetupButton)
  78. await vi.waitFor(() => {
  79. expect(
  80. view,
  81. 'correctly redirects to guided setup import',
  82. ).toHaveCurrentUrl('/guided-setup/import')
  83. })
  84. expect(
  85. view.getByRole('button', { name: 'Freshdesk Beta' }),
  86. ).toBeInTheDocument()
  87. expect(
  88. view.getByRole('button', { name: 'Kayako Beta' }),
  89. ).toBeInTheDocument()
  90. expect(
  91. view.getByRole('button', { name: 'OTRS Beta' }),
  92. ).toBeInTheDocument()
  93. expect(
  94. view.getByRole('button', { name: 'Zendesk Beta' }),
  95. ).toBeInTheDocument()
  96. expect(view.getByRole('button', { name: 'Go Back' })).toBeInTheDocument()
  97. })
  98. it('shows guided setup manual screen when lock exists', async () => {
  99. mockSystemSetupInfo({
  100. status: EnumSystemSetupInfoStatus.InProgress,
  101. type: EnumSystemSetupInfoType.Manual,
  102. lockValue: 'random-uuid-lock',
  103. })
  104. mockSystemSetupInfoQuery({
  105. systemSetupInfo: {
  106. status: EnumSystemSetupInfoStatus.InProgress,
  107. type: EnumSystemSetupInfoType.Manual,
  108. },
  109. })
  110. const view = await visitView('/guided-setup')
  111. await vi.waitFor(() => {
  112. expect(
  113. view,
  114. 'correctly redirects to guided setup manual',
  115. ).toHaveCurrentUrl('/guided-setup/manual')
  116. })
  117. expect(view.getByRole('button', { name: 'Go Back' })).toBeInTheDocument()
  118. expect(view.getByText('Create Administrator Account')).toBeInTheDocument()
  119. })
  120. })
  121. })