guided-setup-manual-finish.spec.ts 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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 finish', () => {
  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/finish')
  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('redirects to home screen after a timeout', async () => {
  41. vi.useFakeTimers()
  42. const view = await visitView('/guided-setup/manual/finish')
  43. await vi.runAllTimersAsync()
  44. vi.useRealTimers()
  45. await vi.waitFor(() => {
  46. expect(view, 'correctly redirects to home screen').toHaveCurrentUrl('/')
  47. })
  48. })
  49. })
  50. })