Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Maintenance: Implemented automatic system set-up for new desktop view.
Co-authored-by: Dusan Vuckovic <dv@zammad.com> Co-authored-by: Martin Gruner <mg@zammad.com>
- Loading branch information
Showing
20 changed files
with
634 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
app/frontend/apps/desktop/pages/guided-setup/__tests__/guided-setup-automated-info.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
// Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/ | ||
|
||
import { visitView } from '#tests/support/components/visitView.ts' | ||
import { mockApplicationConfig } from '#tests/support/mock-applicationConfig.ts' | ||
import { mockAuthentication } from '#tests/support/mock-authentication.ts' | ||
import { EnumSystemSetupInfoStatus } from '#shared/graphql/types.ts' | ||
import { mockSystemSetupInfoQuery } from '../graphql/queries/systemSetupInfo.mocks.ts' | ||
|
||
describe('guided setup automated info', () => { | ||
describe('when system is not ready', () => { | ||
beforeEach(() => { | ||
mockApplicationConfig({ | ||
system_init_done: false, | ||
}) | ||
|
||
mockSystemSetupInfoQuery({ | ||
systemSetupInfo: { | ||
status: EnumSystemSetupInfoStatus.Automated, | ||
type: null, | ||
}, | ||
}) | ||
}) | ||
|
||
it('shows info screen', async () => { | ||
const view = await visitView('/guided-setup/automated') | ||
|
||
expect(view.getByText('Automated Setup')).toBeInTheDocument() | ||
expect(view.queryByIconName('spinner')).not.toBeInTheDocument() | ||
|
||
expect( | ||
view.getByText('This system is configured for automated setup.'), | ||
).toBeInTheDocument() | ||
|
||
expect(view.getByText('Please use the provided URL.')).toBeInTheDocument() | ||
}) | ||
|
||
it('redirects to info screen first', async () => { | ||
const view = await visitView('/guided-setup') | ||
|
||
await vi.waitFor(() => { | ||
expect( | ||
view, | ||
'correctly redirects to guided setup automated info screen', | ||
).toHaveCurrentUrl('/guided-setup/automated') | ||
}) | ||
}) | ||
}) | ||
|
||
describe('when system is ready', () => { | ||
beforeEach(() => { | ||
mockApplicationConfig({ | ||
system_init_done: true, | ||
}) | ||
mockAuthentication(true) | ||
}) | ||
|
||
it('redirects to home screen', async () => { | ||
const view = await visitView('/guided-setup/automated') | ||
|
||
await vi.waitFor(() => { | ||
expect(view, 'correctly redirects to home screen').toHaveCurrentUrl('/') | ||
}) | ||
}) | ||
}) | ||
}) |
125 changes: 125 additions & 0 deletions
125
app/frontend/apps/desktop/pages/guided-setup/__tests__/guided-setup-automated-run.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
// Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/ | ||
|
||
import { flushPromises } from '@vue/test-utils' | ||
import { visitView } from '#tests/support/components/visitView.ts' | ||
import { mockApplicationConfig } from '#tests/support/mock-applicationConfig.ts' | ||
import { mockAuthentication } from '#tests/support/mock-authentication.ts' | ||
import { EnumSystemSetupInfoStatus } from '#shared/graphql/types.ts' | ||
import { | ||
mockSystemSetupRunAutoWizardMutation, | ||
waitForSystemSetupRunAutoWizardMutationCalls, | ||
} from '#desktop/pages/guided-setup/graphql/mutations/systemSetupRunAutoWizard.mocks.ts' | ||
import { mockSystemSetupInfoQuery } from '../graphql/queries/systemSetupInfo.mocks.ts' | ||
|
||
describe('guided setup automated run', () => { | ||
describe('when system is not ready', () => { | ||
beforeEach(() => { | ||
mockApplicationConfig({ | ||
system_init_done: false, | ||
}) | ||
|
||
mockAuthentication(false) | ||
|
||
mockSystemSetupInfoQuery({ | ||
systemSetupInfo: { | ||
status: EnumSystemSetupInfoStatus.Automated, | ||
type: null, | ||
}, | ||
}) | ||
}) | ||
|
||
it('redirects to home screen after successful setup', async () => { | ||
vi.useFakeTimers() | ||
|
||
const view = await visitView('/guided-setup/automated/run') | ||
|
||
expect(view.getByText('Automated Setup')).toBeInTheDocument() | ||
expect(view.getByIconName('spinner')).toBeInTheDocument() | ||
|
||
expect( | ||
view.getByText('Relax, your system is being set up…'), | ||
).toBeInTheDocument() | ||
|
||
await flushPromises() | ||
|
||
expect( | ||
view.getByText( | ||
'The system was configured successfully. You are being redirected.', | ||
), | ||
).toBeInTheDocument() | ||
|
||
await vi.runAllTimersAsync() | ||
vi.useRealTimers() | ||
|
||
await vi.waitFor(() => { | ||
expect(view, 'correctly redirects to home screen').toHaveCurrentUrl('/') | ||
}) | ||
}) | ||
|
||
it('shows an alert message and hides spinner on errors', async () => { | ||
mockSystemSetupRunAutoWizardMutation({ | ||
systemSetupRunAutoWizard: { | ||
errors: [ | ||
{ | ||
message: 'An unexpected error occurred during system setup.', | ||
field: null, | ||
}, | ||
], | ||
}, | ||
}) | ||
|
||
const view = await visitView('/guided-setup/automated/run') | ||
await flushPromises() | ||
|
||
expect(view.getByText('Automated Setup')).toBeInTheDocument() | ||
expect(view.queryByIconName('spinner')).not.toBeInTheDocument() | ||
|
||
expect( | ||
view.getByText('An unexpected error occurred during system setup.'), | ||
).toBeInTheDocument() | ||
}) | ||
|
||
it('supports optional token parameter', async () => { | ||
await visitView('/guided-setup/automated/run/s3cr3t-t0k3n') | ||
await flushPromises() | ||
|
||
const calls = await waitForSystemSetupRunAutoWizardMutationCalls() | ||
|
||
expect(calls.at(-1)?.variables).toEqual( | ||
expect.objectContaining({ | ||
token: 's3cr3t-t0k3n', | ||
}), | ||
) | ||
}) | ||
}) | ||
|
||
describe('when system is ready', () => { | ||
beforeEach(() => { | ||
mockApplicationConfig({ | ||
system_init_done: true, | ||
}) | ||
}) | ||
|
||
it('redirects to home screen', async () => { | ||
mockAuthentication(true) | ||
|
||
const view = await visitView('/guided-setup/automated/run') | ||
|
||
await vi.waitFor(() => { | ||
expect(view, 'correctly redirects to home screen').toHaveCurrentUrl('/') | ||
}) | ||
}) | ||
|
||
it('redirects to login screen', async () => { | ||
mockAuthentication(false) | ||
|
||
const view = await visitView('/guided-setup/automated/run') | ||
|
||
await vi.waitFor(() => { | ||
expect(view, 'correctly redirects to login screen').toHaveCurrentUrl( | ||
'/login', | ||
) | ||
}) | ||
}) | ||
}) | ||
}) |
File renamed without changes.
26 changes: 26 additions & 0 deletions
26
...rontend/apps/desktop/pages/guided-setup/graphql/mutations/systemSetupRunAutoWizard.api.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import * as Types from '#shared/graphql/types.ts'; | ||
|
||
import gql from 'graphql-tag'; | ||
import { SessionFragmentDoc } from '../../../../../../shared/graphql/fragments/session.api'; | ||
import { ErrorsFragmentDoc } from '../../../../../../shared/graphql/fragments/errors.api'; | ||
import * as VueApolloComposable from '@vue/apollo-composable'; | ||
import * as VueCompositionApi from 'vue'; | ||
export type ReactiveFunction<TParam> = () => TParam; | ||
|
||
export const SystemSetupRunAutoWizardDocument = gql` | ||
mutation systemSetupRunAutoWizard($token: String) { | ||
systemSetupRunAutoWizard(token: $token) { | ||
session { | ||
...session | ||
} | ||
errors { | ||
...errors | ||
} | ||
} | ||
} | ||
${SessionFragmentDoc} | ||
${ErrorsFragmentDoc}`; | ||
export function useSystemSetupRunAutoWizardMutation(options: VueApolloComposable.UseMutationOptions<Types.SystemSetupRunAutoWizardMutation, Types.SystemSetupRunAutoWizardMutationVariables> | ReactiveFunction<VueApolloComposable.UseMutationOptions<Types.SystemSetupRunAutoWizardMutation, Types.SystemSetupRunAutoWizardMutationVariables>> = {}) { | ||
return VueApolloComposable.useMutation<Types.SystemSetupRunAutoWizardMutation, Types.SystemSetupRunAutoWizardMutationVariables>(SystemSetupRunAutoWizardDocument, options); | ||
} | ||
export type SystemSetupRunAutoWizardMutationCompositionFunctionResult = VueApolloComposable.UseMutationReturn<Types.SystemSetupRunAutoWizardMutation, Types.SystemSetupRunAutoWizardMutationVariables>; |
10 changes: 10 additions & 0 deletions
10
...ontend/apps/desktop/pages/guided-setup/graphql/mutations/systemSetupRunAutoWizard.graphql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
mutation systemSetupRunAutoWizard($token: String) { | ||
systemSetupRunAutoWizard(token: $token) { | ||
session { | ||
...session | ||
} | ||
errors { | ||
...errors | ||
} | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
...ntend/apps/desktop/pages/guided-setup/graphql/mutations/systemSetupRunAutoWizard.mocks.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import * as Types from '#shared/graphql/types.ts'; | ||
|
||
import * as Mocks from '#tests/graphql/builders/mocks.ts' | ||
import * as Operations from './systemSetupRunAutoWizard.api.ts' | ||
|
||
export function mockSystemSetupRunAutoWizardMutation(defaults: Mocks.MockDefaultsValue<Types.SystemSetupRunAutoWizardMutation, Types.SystemSetupRunAutoWizardMutationVariables>) { | ||
return Mocks.mockGraphQLResult(Operations.SystemSetupRunAutoWizardDocument, defaults) | ||
} | ||
|
||
export function waitForSystemSetupRunAutoWizardMutationCalls() { | ||
return Mocks.waitForGraphQLMockCalls<Types.SystemSetupRunAutoWizardMutation>(Operations.SystemSetupRunAutoWizardDocument) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
...d/apps/desktop/pages/guided-setup/views/GuidedSetupAutomated/GuidedSetupAutomatedInfo.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<!-- Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/ --> | ||
|
||
<script setup lang="ts"> | ||
import LayoutPublicPage from '#desktop/components/layout/LayoutPublicPage/LayoutPublicPage.vue' | ||
</script> | ||
|
||
<template> | ||
<LayoutPublicPage box-size="medium" :title="__('Automated Setup')"> | ||
<div class="text-center"> | ||
<CommonLabel>{{ | ||
$t('This system is configured for automated setup.') | ||
}}</CommonLabel> | ||
<CommonLabel>{{ $t('Please use the provided URL.') }}</CommonLabel> | ||
</div> | ||
</LayoutPublicPage> | ||
</template> |
Oops, something went wrong.