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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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 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. })