12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- // Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
- import { mockApplicationConfig } from '#tests/support/mock-applicationConfig.ts'
- import { visitView } from '#tests/support/components/visitView.ts'
- import { EnumSystemSetupInfoStatus } from '#shared/graphql/types.ts'
- import { useAuthenticationStore } from '#shared/stores/authentication.ts'
- import { mockSystemSetupInfoQuery } from '../graphql/queries/systemSetupInfo.mocks.ts'
- describe('guided setup admin user creation', () => {
- describe('when system initialization is done', () => {
- beforeEach(() => {
- mockApplicationConfig({
- system_init_done: true,
- })
- })
- it('redirects to login window', async () => {
- const view = await visitView('/guided-setup/manual')
- // Check that we ware on the login page
- expect(view.getByText('Username / Email')).toBeInTheDocument()
- expect(view.getByText('Password')).toBeInTheDocument()
- expect(view.getByText('Sign in')).toBeInTheDocument()
- })
- })
- describe('when system is not ready', () => {
- beforeEach(() => {
- mockApplicationConfig({
- system_init_done: false,
- })
- })
- it('shows guided setup screen and opens manual setup on click', async () => {
- mockSystemSetupInfoQuery({
- systemSetupInfo: {
- status: EnumSystemSetupInfoStatus.New,
- type: null,
- },
- })
- const view = await visitView('/guided-setup')
- view.getByText('Set up a new system').click()
- await vi.waitFor(() => {
- expect(
- view,
- 'correctly redirects to guided setup manual',
- ).toHaveCurrentUrl('/guided-setup/manual')
- })
- expect(view.getByText('Create Administrator Account')).toBeInTheDocument()
- const firstNameField = view.getByLabelText('First name')
- const lastNameField = view.getByLabelText('Last name')
- const emailField = view.getByLabelText('Email')
- const passwordField = view.getByLabelText('Password')
- const confirmPasswordField = view.getByLabelText('Confirm password')
- expect(firstNameField).toBeInTheDocument()
- expect(lastNameField).toBeInTheDocument()
- expect(emailField).toBeInTheDocument()
- expect(passwordField).toBeInTheDocument()
- expect(confirmPasswordField).toBeInTheDocument()
- await view.events.type(firstNameField, 'Bender')
- await view.events.type(lastNameField, 'Rodriguez')
- await view.events.type(emailField, 'bender.rodriguez@futurama.corp')
- await view.events.type(passwordField, 'planetexpress')
- await view.events.type(confirmPasswordField, 'planetexpress')
- const createAccountButton = view.getByRole('button', {
- name: 'Create account',
- })
- await view.events.click(createAccountButton)
- await vi.waitFor(() => {
- expect(
- view,
- 'correctly redirects to guided setup manual system information step',
- ).toHaveCurrentUrl('/guided-setup/manual/system-information')
- })
- expect(useAuthenticationStore().authenticated).toBe(true)
- })
- })
- })
|