123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- // 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 { mockPermissions } from '#tests/support/mock-permissions.ts'
- import { waitForNextTick } from '#tests/support/utils.ts'
- import { waitForFormUpdaterQueryCalls } from '#shared/components/Form/graphql/queries/formUpdater.mocks.ts'
- import { waitForTicketCreateMutationCalls } from '#shared/entities/ticket/graphql/mutations/create.mocks.ts'
- import { convertToGraphQLId } from '#shared/graphql/utils.ts'
- import { handleMockFormUpdaterQuery } from '#desktop/pages/ticket/__tests__/support/ticket-create-helpers.ts'
- describe('ticket create view - splitting of a ticket article', async () => {
- const ticketTitle = 'split title'
- const articleId = 666
- const ticketId = 123
- beforeEach(() => {
- mockApplicationConfig({
- ui_ticket_create_available_types: ['phone-in', 'phone-out', 'email-out'],
- })
- mockPermissions(['ticket.agent'])
- handleMockFormUpdaterQuery()
- })
- it('applies given ticket article', async () => {
- handleMockFormUpdaterQuery({
- title: { value: ticketTitle },
- split_article_id: articleId,
- })
- const view = await visitView(
- '/ticket/create??splitTicketArticleId=ticket_article_gid',
- )
- const formUpdaterCalls = await waitForFormUpdaterQueryCalls()
- expect(formUpdaterCalls.at(-1)?.variables).toEqual(
- expect.objectContaining({
- meta: expect.objectContaining({
- additionalData: expect.objectContaining({
- splitTicketArticleId: 'ticket_article_gid',
- }),
- }),
- }),
- )
- await waitForNextTick()
- expect(view.getByLabelText('Title')).toHaveValue(ticketTitle)
- })
- it('submits linking when creating', async () => {
- handleMockFormUpdaterQuery({
- title: { value: ticketTitle },
- body: { value: 'body' },
- group_id: {
- value: 1,
- options: [
- {
- value: 1,
- label: 'Users',
- },
- {
- value: 2,
- label: 'some group1',
- },
- ],
- },
- customer_id: { value: 1 },
- link_ticket_id: { value: ticketId },
- pending_time: { show: false },
- })
- const view = await visitView(
- '/ticket/create??splitTicketArticleId=ticket_article_gid',
- )
- await waitForFormUpdaterQueryCalls()
- await view.events.click(view.getByRole('button', { name: 'Create' }))
- const ticketCreateCalls = await waitForTicketCreateMutationCalls()
- expect(ticketCreateCalls.at(-1)?.variables).toEqual(
- expect.objectContaining({
- input: expect.objectContaining({
- title: ticketTitle,
- links: [
- {
- linkType: 'child',
- linkObjectId: convertToGraphQLId('Ticket', ticketId),
- },
- ],
- }),
- }),
- )
- })
- })
|