123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999 |
- // Copyright (C) 2012-2025 Zammad Foundation, https://zammad-foundation.org/
- import { getNode } from '@formkit/core'
- import {
- getByLabelText,
- getByRole,
- getByText,
- queryByLabelText,
- queryByText,
- } from '@testing-library/vue'
- 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 { mockPermissions } from '#tests/support/mock-permissions.ts'
- import { mockFormUpdaterQuery } from '#shared/components/Form/graphql/queries/formUpdater.mocks.ts'
- import {
- EnumChannelEmailInboundAdapter,
- EnumChannelEmailOutboundAdapter,
- EnumChannelEmailSsl,
- EnumFormUpdaterId,
- EnumSystemSetupInfoStatus,
- } from '#shared/graphql/types.ts'
- import {
- mockChannelEmailAddMutation,
- waitForChannelEmailAddMutationCalls,
- } from '#desktop/entities/channel-email/graphql/mutations/channelEmailAdd.mocks.ts'
- import { mockChannelEmailGuessConfigurationMutation } from '#desktop/entities/channel-email/graphql/mutations/channelEmailGuessConfiguration.mocks.ts'
- import { mockChannelEmailValidateConfigurationInboundMutation } from '#desktop/entities/channel-email/graphql/mutations/channelEmailValidateConfigurationInbound.mocks.ts'
- import { mockChannelEmailValidateConfigurationOutboundMutation } from '#desktop/entities/channel-email/graphql/mutations/channelEmailValidateConfigurationOutbound.mocks.ts'
- import { mockChannelEmailValidateConfigurationRoundtripMutation } from '#desktop/entities/channel-email/graphql/mutations/channelEmailValidateConfigurationRoundtrip.mocks.ts'
- import { mockSystemSetupInfoQuery } from '../graphql/queries/systemSetupInfo.mocks.ts'
- const inboundConfiguration = {
- adapter: EnumChannelEmailInboundAdapter.Imap,
- host: 'mail.test.dc.zammad.com',
- port: 993,
- ssl: EnumChannelEmailSsl.Ssl,
- user: 'zammad@mail.test.dc.zammad.com',
- password: 'zammad',
- sslVerify: true,
- folder: 'INBOX',
- }
- const outboundConfiguration = {
- adapter: EnumChannelEmailOutboundAdapter.Smtp,
- host: 'mail.test.dc.zammad.com',
- port: 25,
- user: 'zammad@mail.test.dc.zammad.com',
- password: 'zammad',
- sslVerify: false,
- }
- const sslVerificationWarningText =
- 'Turning off SSL verification is a security risk and should be used only temporary. Use this option at your own risk!'
- describe('guided setup manual channel email', () => {
- describe('when system is not ready', () => {
- beforeEach(() => {
- mockApplicationConfig({
- system_init_done: false,
- })
- })
- it('redirects to guided setup start', async () => {
- mockSystemSetupInfoQuery({
- systemSetupInfo: {
- status: EnumSystemSetupInfoStatus.New,
- type: null,
- },
- })
- const view = await visitView('/guided-setup/manual/channels/email')
- await vi.waitFor(() => {
- expect(
- view,
- 'correctly redirects to guided setup start screen',
- ).toHaveCurrentUrl('/guided-setup')
- })
- view.getByText('Set up a new system')
- })
- })
- describe('when system is ready for optional steps', () => {
- beforeEach(() => {
- mockApplicationConfig({
- system_init_done: true,
- })
- mockPermissions(['admin'])
- mockAuthentication(true)
- mockFormUpdaterQuery((variables) => {
- switch (variables.formUpdaterId) {
- case EnumFormUpdaterId.FormUpdaterUpdaterGuidedSetupEmailArchive:
- return {
- formUpdater: {
- fields: {
- archive_state_id: {
- initialValue: 4,
- options: [
- {
- value: 1,
- label: 'new',
- },
- {
- value: 2,
- label: 'open',
- },
- {
- value: 3,
- label: 'pending reminder',
- },
- {
- value: 4,
- label: 'closed',
- },
- {
- value: 5,
- label: 'merged',
- },
- {
- value: 6,
- label: 'pending close',
- },
- ],
- },
- },
- },
- }
- case EnumFormUpdaterId.FormUpdaterUpdaterGuidedSetupEmailOutbound:
- return {
- formUpdater: {
- fields: {
- adapter: {
- initialValue: 'smtp',
- options: [
- {
- value: 'smtp',
- label:
- 'SMTP - configure your own outgoing SMTP settings',
- },
- {
- value: 'sendmail',
- label:
- 'Local MTA (Sendmail/Postfix/Exim/â\u0080¦) - use server setup',
- },
- ],
- },
- },
- },
- }
- case EnumFormUpdaterId.FormUpdaterUpdaterGuidedSetupEmailInbound:
- default:
- return {
- formUpdater: {
- fields: {
- adapter: {
- initialValue: 'imap',
- options: [
- {
- value: 'imap',
- label: 'IMAP',
- },
- {
- value: 'pop3',
- label: 'POP3',
- },
- ],
- },
- },
- },
- }
- }
- })
- })
- it('can redirect to invite step when guess is successful', async () => {
- const view = await visitView('/guided-setup/manual/channels/email')
- expect(view.getByText('Email Account')).toBeInTheDocument()
- expect(view.getByRole('button', { name: 'Go Back' })).toBeInTheDocument()
- const accountForm = view.getByTestId('channel-email-account')
- await view.events.type(
- getByLabelText(accountForm, 'Full name'),
- 'Zammad Helpdesk',
- )
- await view.events.type(
- getByLabelText(accountForm, 'Email address'),
- 'zammad@mail.test.dc.zammad.com',
- )
- await view.events.type(getByLabelText(accountForm, 'Password'), 'zammad')
- mockChannelEmailGuessConfigurationMutation({
- channelEmailGuessConfiguration: {
- result: {
- inboundConfiguration,
- outboundConfiguration,
- mailboxStats: {
- contentMessages: 0,
- },
- },
- },
- })
- mockChannelEmailValidateConfigurationRoundtripMutation({
- channelEmailValidateConfigurationRoundtrip: {
- success: true,
- },
- })
- await view.events.click(
- view.getByRole('button', {
- name: 'Connect and Continue',
- }),
- )
- await vi.waitFor(() => {
- expect(
- view,
- 'correctly redirects to guided setup invite step',
- ).toHaveCurrentUrl('/guided-setup/manual/invite')
- })
- })
- it('can show inbound configuration form when guess is unsuccessful', async () => {
- const view = await visitView('/guided-setup/manual/channels/email')
- const accountForm = view.getByTestId('channel-email-account')
- await view.events.type(
- getByLabelText(accountForm, 'Full name'),
- 'Zammad Helpdesk',
- )
- await view.events.type(
- getByLabelText(accountForm, 'Email address'),
- 'zammad@mail.test.dc.zammad.com',
- )
- await view.events.type(getByLabelText(accountForm, 'Password'), 'zammad')
- mockChannelEmailGuessConfigurationMutation({
- channelEmailGuessConfiguration: {
- result: {
- inboundConfiguration: null,
- outboundConfiguration: null,
- },
- },
- })
- await view.events.click(
- view.getByRole('button', {
- name: 'Connect and Continue',
- }),
- )
- expect(accountForm).not.toBeVisible()
- const inboundForm = view.getByTestId('channel-email-inbound')
- expect(inboundForm).toBeVisible()
- expect(getByRole(inboundForm, 'alert')).toHaveTextContent(
- 'The server settings could not be automatically detected. Please configure them manually.',
- )
- expect(view.getByRole('button', { name: 'Continue' })).toBeInTheDocument()
- })
- it('can show inbound configuration form when roundtrip is unsuccessful', async () => {
- const view = await visitView('/guided-setup/manual/channels/email')
- const accountForm = view.getByTestId('channel-email-account')
- await view.events.type(
- getByLabelText(accountForm, 'Full name'),
- 'Zammad Helpdesk',
- )
- await view.events.type(
- getByLabelText(accountForm, 'Email address'),
- 'zammad@mail.test.dc.zammad.com',
- )
- await view.events.type(getByLabelText(accountForm, 'Password'), 'zammad')
- mockChannelEmailGuessConfigurationMutation({
- channelEmailGuessConfiguration: {
- result: {
- inboundConfiguration,
- outboundConfiguration,
- mailboxStats: {
- contentMessages: 0,
- },
- },
- },
- })
- mockChannelEmailValidateConfigurationRoundtripMutation({
- channelEmailValidateConfigurationRoundtrip: {
- success: false,
- errors: [
- {
- message: 'Something went wrong',
- field: 'inbound.adapter',
- },
- ],
- },
- })
- await view.events.click(
- view.getByRole('button', {
- name: 'Connect and Continue',
- }),
- )
- expect(accountForm).not.toBeVisible()
- const inboundForm = view.getByTestId('channel-email-inbound')
- expect(inboundForm).toBeVisible()
- expect(getByText(inboundForm, 'Something went wrong')).toBeInTheDocument()
- })
- it('can show a form error when adding email channel is unsuccessful', async () => {
- const view = await visitView('/guided-setup/manual/channels/email')
- const accountForm = view.getByTestId('channel-email-account')
- await view.events.type(
- getByLabelText(accountForm, 'Full name'),
- 'Zammad Helpdesk',
- )
- await view.events.type(
- getByLabelText(accountForm, 'Email address'),
- 'zammad@mail.test.dc.zammad.com',
- )
- await view.events.type(getByLabelText(accountForm, 'Password'), 'zammad')
- mockChannelEmailGuessConfigurationMutation({
- channelEmailGuessConfiguration: {
- result: {
- inboundConfiguration,
- outboundConfiguration,
- mailboxStats: {
- contentMessages: 0,
- },
- },
- },
- })
- mockChannelEmailValidateConfigurationRoundtripMutation({
- channelEmailValidateConfigurationRoundtrip: {
- success: true,
- },
- })
- mockChannelEmailAddMutation({
- channelEmailAdd: {
- errors: [
- {
- message: 'The provided password is invalid.',
- field: 'password',
- },
- ],
- },
- })
- await view.events.click(
- view.getByRole('button', {
- name: 'Connect and Continue',
- }),
- )
- expect(accountForm).toBeVisible()
- expect(
- getByText(accountForm, 'The provided password is invalid.'),
- ).toBeInTheDocument()
- })
- it('can show inbound messages form when some messages are detected', async () => {
- const view = await visitView('/guided-setup/manual/channels/email')
- const accountForm = view.getByTestId('channel-email-account')
- await view.events.type(
- getByLabelText(accountForm, 'Full name'),
- 'Zammad Helpdesk',
- )
- await view.events.type(
- getByLabelText(accountForm, 'Email address'),
- 'zammad@mail.test.dc.zammad.com',
- )
- await view.events.type(getByLabelText(accountForm, 'Password'), 'zammad')
- mockChannelEmailGuessConfigurationMutation({
- channelEmailGuessConfiguration: {
- result: {
- inboundConfiguration: null,
- outboundConfiguration: null,
- },
- },
- })
- await view.events.click(
- view.getByRole('button', {
- name: 'Connect and Continue',
- }),
- )
- const inboundForm = view.getByTestId('channel-email-inbound')
- await view.events.type(
- getByLabelText(inboundForm, 'Host'),
- 'mail.test.dc.zammad.com',
- )
- await getNode('channel-email-inbound')?.settled
- mockChannelEmailValidateConfigurationInboundMutation({
- channelEmailValidateConfigurationInbound: {
- success: true,
- mailboxStats: {
- contentMessages: 3,
- },
- },
- })
- await view.events.click(
- view.getByRole('button', {
- name: 'Continue',
- }),
- )
- expect(inboundForm).not.toBeVisible()
- const inboundMessagesForm = view.getByTestId(
- 'channel-email-inbound-messages',
- )
- expect(inboundMessagesForm).toBeVisible()
- expect(inboundMessagesForm).toHaveTextContent(
- '3 email(s) were found in your mailbox. They will all be moved from your mailbox into Zammad.',
- )
- expect(inboundMessagesForm).toHaveTextContent(
- 'You can import some of your emails as an "archive", which means that no notifications are sent and the tickets will be in a target state that you define.',
- )
- expect(inboundMessagesForm).toHaveTextContent(
- 'You can find archived emails in Zammad anytime using the search function, like for any other ticket.',
- )
- expect(
- getByLabelText(inboundMessagesForm, 'Archive emails'),
- ).toBeInTheDocument()
- expect(
- getByLabelText(inboundMessagesForm, 'Archive cut-off time'),
- ).toBeDescribedBy(
- 'Emails before the cut-off time are imported as archived tickets. Emails after the cut-off time are imported as regular tickets.',
- )
- expect(
- getByLabelText(inboundMessagesForm, 'Archive ticket target state'),
- ).toBeInTheDocument()
- await view.events.click(
- getByLabelText(inboundMessagesForm, 'Archive emails'),
- )
- expect(
- queryByLabelText(inboundMessagesForm, 'Archive cut-off time'),
- ).not.toBeInTheDocument()
- expect(
- queryByLabelText(inboundMessagesForm, 'Archive ticket target state'),
- ).not.toBeInTheDocument()
- expect(view.getByRole('button', { name: 'Continue' })).toBeInTheDocument()
- })
- it('can show outbound configuration form when guess is unsuccessful', async () => {
- const view = await visitView('/guided-setup/manual/channels/email')
- const accountForm = view.getByTestId('channel-email-account')
- await view.events.type(
- getByLabelText(accountForm, 'Full name'),
- 'Zammad Helpdesk',
- )
- await view.events.type(
- getByLabelText(accountForm, 'Email address'),
- 'zammad@mail.test.dc.zammad.com',
- )
- await view.events.type(getByLabelText(accountForm, 'Password'), 'zammad')
- mockChannelEmailGuessConfigurationMutation({
- channelEmailGuessConfiguration: {
- result: {
- inboundConfiguration: null,
- outboundConfiguration: null,
- },
- },
- })
- await view.events.click(
- view.getByRole('button', {
- name: 'Connect and Continue',
- }),
- )
- const inboundForm = view.getByTestId('channel-email-inbound')
- await view.events.type(
- getByLabelText(inboundForm, 'Host'),
- 'mail.test.dc.zammad.com',
- )
- await getNode('channel-email-inbound')?.settled
- mockChannelEmailValidateConfigurationInboundMutation({
- channelEmailValidateConfigurationInbound: {
- success: true,
- mailboxStats: {
- contentMessages: 0,
- },
- },
- })
- await view.events.click(
- view.getByRole('button', {
- name: 'Continue',
- }),
- )
- expect(inboundForm).not.toBeVisible()
- const outboundForm = view.getByTestId('channel-email-outbound')
- expect(outboundForm).toBeVisible()
- expect(
- view.getByRole('button', { name: 'Save and Continue' }),
- ).toBeInTheDocument()
- })
- it('can show outbound configuration form when roundtrip is unsuccessful', async () => {
- const view = await visitView('/guided-setup/manual/channels/email')
- const accountForm = view.getByTestId('channel-email-account')
- await view.events.type(
- getByLabelText(accountForm, 'Full name'),
- 'Zammad Helpdesk',
- )
- await view.events.type(
- getByLabelText(accountForm, 'Email address'),
- 'zammad@mail.test.dc.zammad.com',
- )
- await view.events.type(getByLabelText(accountForm, 'Password'), 'zammad')
- mockChannelEmailGuessConfigurationMutation({
- channelEmailGuessConfiguration: {
- result: {
- inboundConfiguration,
- outboundConfiguration,
- mailboxStats: {
- contentMessages: 0,
- },
- },
- },
- })
- mockChannelEmailValidateConfigurationRoundtripMutation({
- channelEmailValidateConfigurationRoundtrip: {
- success: false,
- errors: [
- {
- message: 'Something went wrong',
- field: 'outbound.adapter',
- },
- ],
- },
- })
- await view.events.click(
- view.getByRole('button', {
- name: 'Connect and Continue',
- }),
- )
- expect(accountForm).not.toBeVisible()
- const outboundForm = view.getByTestId('channel-email-outbound')
- expect(outboundForm).toBeVisible()
- expect(
- getByText(outboundForm, 'Something went wrong'),
- ).toBeInTheDocument()
- })
- it('can add email channel and redirect to invite step', async () => {
- const view = await visitView('/guided-setup/manual/channels/email')
- const accountForm = view.getByTestId('channel-email-account')
- await view.events.type(
- getByLabelText(accountForm, 'Full name'),
- 'Zammad Helpdesk',
- )
- await view.events.type(
- getByLabelText(accountForm, 'Email address'),
- 'zammad@mail.test.dc.zammad.com',
- )
- await view.events.type(getByLabelText(accountForm, 'Password'), 'zammad')
- mockChannelEmailGuessConfigurationMutation({
- channelEmailGuessConfiguration: {
- result: {
- inboundConfiguration: null,
- outboundConfiguration: null,
- },
- },
- })
- await view.events.click(
- view.getByRole('button', {
- name: 'Connect and Continue',
- }),
- )
- const inboundForm = view.getByTestId('channel-email-inbound')
- await view.events.type(
- getByLabelText(inboundForm, 'Host'),
- 'mail.test.dc.zammad.com',
- )
- await getNode('channel-email-inbound')?.settled
- mockChannelEmailValidateConfigurationInboundMutation({
- channelEmailValidateConfigurationInbound: {
- success: true,
- mailboxStats: {
- contentMessages: 1,
- },
- },
- })
- await view.events.click(
- view.getByRole('button', {
- name: 'Continue',
- }),
- )
- const inboundMessagesForm = view.getByTestId(
- 'channel-email-inbound-messages',
- )
- await view.events.type(
- getByLabelText(inboundMessagesForm, 'Archive cut-off time'),
- '2025-01-01 00:00',
- )
- await getNode('channel-email-inbound-messages')?.settled
- await view.events.click(
- view.getByRole('button', {
- name: 'Continue',
- }),
- )
- const outboundForm = view.getByTestId('channel-email-outbound')
- await view.events.type(getByLabelText(outboundForm, 'Port'), '25')
- mockChannelEmailValidateConfigurationOutboundMutation({
- channelEmailValidateConfigurationOutbound: {
- success: true,
- },
- })
- mockChannelEmailValidateConfigurationRoundtripMutation({
- channelEmailValidateConfigurationRoundtrip: {
- success: true,
- },
- })
- mockChannelEmailAddMutation({
- channelEmailAdd: {
- channel: {
- options: {},
- group: {
- id: 'gid://zammad/Group/1',
- },
- },
- },
- })
- await view.events.click(
- view.getByRole('button', {
- name: 'Save and Continue',
- }),
- )
- const calls = await waitForChannelEmailAddMutationCalls()
- expect(calls.at(-1)?.variables).toEqual({
- input: {
- emailAddress: 'zammad@mail.test.dc.zammad.com',
- emailRealname: 'Zammad Helpdesk',
- inboundConfiguration: {
- adapter: 'imap',
- folder: '',
- host: 'mail.test.dc.zammad.com',
- keepOnServer: false,
- password: 'zammad',
- port: 993,
- ssl: 'ssl',
- sslVerify: true,
- user: 'zammad@mail.test.dc.zammad.com',
- archive: true,
- archiveBefore: '2025-01-01T00:00:00Z',
- archiveStateId: 4,
- },
- outboundConfiguration: {
- adapter: 'smtp',
- host: 'mail.test.dc.zammad.com',
- password: 'zammad',
- port: 25,
- sslVerify: false,
- user: 'zammad@mail.test.dc.zammad.com',
- },
- },
- })
- await vi.waitFor(() => {
- expect(view).toHaveCurrentUrl('/guided-setup/manual/invite')
- })
- })
- it('can show warning when SSL/STARTTLS is used and SSL verification is turned off in inbound form', async () => {
- const view = await visitView('/guided-setup/manual/channels/email')
- const accountForm = view.getByTestId('channel-email-account')
- await view.events.type(
- getByLabelText(accountForm, 'Full name'),
- 'Zammad Helpdesk',
- )
- await view.events.type(
- getByLabelText(accountForm, 'Email address'),
- 'zammad@mail.test.dc.zammad.com',
- )
- await view.events.type(getByLabelText(accountForm, 'Password'), 'zammad')
- mockChannelEmailGuessConfigurationMutation({
- channelEmailGuessConfiguration: {
- result: {
- inboundConfiguration: null,
- outboundConfiguration: null,
- },
- },
- })
- await view.events.click(
- view.getByRole('button', {
- name: 'Connect and Continue',
- }),
- )
- const inboundForm = view.getByTestId('channel-email-inbound')
- let alert = queryByText(inboundForm, sslVerificationWarningText)
- expect(alert).not.toBeInTheDocument()
- await view.events.click(getByLabelText(inboundForm, 'SSL verification'))
- alert = getByText(inboundForm, sslVerificationWarningText)
- expect(alert?.role).toBe('alert')
- await view.events.click(getByLabelText(inboundForm, 'SSL verification'))
- expect(alert).not.toBeInTheDocument()
- await view.events.click(getByLabelText(inboundForm, 'SSL verification'))
- alert = getByText(inboundForm, sslVerificationWarningText)
- expect(alert).toBeInTheDocument()
- const sslField = view.getByLabelText('SSL/STARTTLS')
- await view.events.click(sslField)
- await view.events.click(view.getAllByRole('option')[0])
- expect(alert).not.toBeInTheDocument()
- await view.events.click(sslField)
- await view.events.click(view.getAllByRole('option')[2])
- alert = queryByText(inboundForm, sslVerificationWarningText)
- expect(alert).not.toBeInTheDocument()
- await view.events.click(getByLabelText(inboundForm, 'SSL verification'))
- alert = getByText(inboundForm, sslVerificationWarningText)
- expect(alert).toBeInTheDocument()
- })
- it('can show warning when secure port is used and SSL verification is turned off in outbound form', async () => {
- const view = await visitView('/guided-setup/manual/channels/email')
- const accountForm = view.getByTestId('channel-email-account')
- await view.events.type(
- getByLabelText(accountForm, 'Full name'),
- 'Zammad Helpdesk',
- )
- await view.events.type(
- getByLabelText(accountForm, 'Email address'),
- 'zammad@mail.test.dc.zammad.com',
- )
- await view.events.type(getByLabelText(accountForm, 'Password'), 'zammad')
- mockChannelEmailGuessConfigurationMutation({
- channelEmailGuessConfiguration: {
- result: {
- inboundConfiguration: null,
- outboundConfiguration: null,
- },
- },
- })
- await view.events.click(
- view.getByRole('button', {
- name: 'Connect and Continue',
- }),
- )
- const inboundForm = view.getByTestId('channel-email-inbound')
- await view.events.type(
- getByLabelText(inboundForm, 'Host'),
- 'mail.test.dc.zammad.com',
- )
- await getNode('channel-email-inbound')?.settled
- mockChannelEmailValidateConfigurationInboundMutation({
- channelEmailValidateConfigurationInbound: {
- success: true,
- mailboxStats: {
- contentMessages: 0,
- },
- },
- })
- await view.events.click(
- view.getByRole('button', {
- name: 'Continue',
- }),
- )
- const outboundForm = view.getByTestId('channel-email-outbound')
- let alert = queryByText(outboundForm, sslVerificationWarningText)
- expect(alert).not.toBeInTheDocument()
- expect(
- getByLabelText(outboundForm, 'SSL verification'),
- ).not.toBeDisabled()
- await view.events.click(getByLabelText(outboundForm, 'SSL verification'))
- alert = getByText(outboundForm, sslVerificationWarningText)
- expect(alert?.role).toBe('alert')
- await view.events.click(getByLabelText(outboundForm, 'SSL verification'))
- expect(alert).not.toBeInTheDocument()
- await view.events.click(getByLabelText(outboundForm, 'SSL verification'))
- alert = getByText(outboundForm, sslVerificationWarningText)
- expect(alert).toBeInTheDocument()
- await view.events.type(getByLabelText(outboundForm, 'Port'), '25')
- await vi.waitFor(() => {
- expect(alert).not.toBeInTheDocument()
- expect(getByLabelText(outboundForm, 'SSL verification')).toBeDisabled()
- })
- await view.events.clear(getByLabelText(outboundForm, 'Port'))
- await vi.waitFor(() => {
- expect(
- getByLabelText(outboundForm, 'SSL verification'),
- ).not.toBeDisabled()
- })
- await view.events.click(getByLabelText(outboundForm, 'SSL verification'))
- await vi.waitFor(() => {
- alert = getByText(outboundForm, sslVerificationWarningText)
- expect(alert).toBeInTheDocument()
- expect(
- getByLabelText(outboundForm, 'SSL verification'),
- ).not.toBeDisabled()
- })
- await view.events.type(getByLabelText(outboundForm, 'Port'), '465')
- await vi.waitFor(() => {
- expect(
- getByLabelText(outboundForm, 'SSL verification'),
- ).not.toBeDisabled()
- })
- await vi.waitFor(() => {
- alert = getByText(outboundForm, sslVerificationWarningText)
- expect(alert).toBeInTheDocument()
- expect(
- getByLabelText(outboundForm, 'SSL verification'),
- ).not.toBeDisabled()
- })
- await view.events.type(getByLabelText(outboundForm, 'Port'), '587')
- await vi.waitFor(() => {
- expect(
- getByLabelText(outboundForm, 'SSL verification'),
- ).not.toBeDisabled()
- })
- await vi.waitFor(() => {
- alert = getByText(outboundForm, sslVerificationWarningText)
- expect(alert).toBeInTheDocument()
- expect(
- getByLabelText(outboundForm, 'SSL verification'),
- ).not.toBeDisabled()
- })
- })
- it('can go back to channels step', async () => {
- const view = await visitView('/guided-setup/manual/channels/email')
- const goBackButton = view.getByRole('button', { name: 'Go Back' })
- await view.events.click(goBackButton)
- await vi.waitFor(() => {
- expect(view, 'correctly redirects to channels step').toHaveCurrentUrl(
- '/guided-setup/manual/channels',
- )
- })
- })
- })
- })
|