123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125 |
- // Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
- import { waitFor, within } from '@testing-library/vue'
- 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 { waitForTicketCreateMutationCalls } from '#shared/entities/ticket/graphql/mutations/create.mocks.ts'
- import { EnumTicketExternalReferencesIssueTrackerItemState } from '#shared/graphql/types.ts'
- import getUuid from '#shared/utils/getUuid.ts'
- import {
- handleCustomerMock,
- handleMockFormUpdaterQuery,
- handleMockUserQuery,
- } from '#desktop/pages/ticket/__tests__/support/ticket-create-helpers.ts'
- import { mockTicketExternalReferencesIssueTrackerItemAddMutation } from '../graphql/mutations/ticketExternalReferencesIssueTrackerItemAdd.mocks.ts'
- import { mockTicketExternalReferencesIssueTrackerItemListQuery } from '../graphql/queries/ticketExternalReferencesIssueTrackerList.mocks.ts'
- describe('Ticket create GitHub links', () => {
- beforeEach(() => {
- mockApplicationConfig({
- github_integration: true,
- ui_task_mananger_max_task_count: 30,
- ui_ticket_create_available_types: ['phone-in', 'phone-out', 'email-out'],
- })
- mockPermissions(['ticket.agent'])
- })
- it('submits a new ticket with github links', async () => {
- handleMockFormUpdaterQuery({
- pending_time: {
- show: false,
- },
- })
- mockTicketExternalReferencesIssueTrackerItemListQuery({
- ticketExternalReferencesIssueTrackerItemList: [],
- })
- const uid = getUuid()
- const view = await visitView(`/ticket/create/${uid}`)
- await view.events.click(view.getByRole('button', { name: 'GitHub' }))
- await waitFor(() =>
- expect(
- view.getByRole('heading', { level: 1, name: 'New Ticket' }),
- ).toBeInTheDocument(),
- )
- await view.events.type(view.getByLabelText('Title'), 'Test Ticket')
- await handleCustomerMock(view)
- handleMockUserQuery()
- await view.events.click(
- view.getByRole('option', {
- name: 'Avatar (Nicole Braun) Nicole Braun – Zammad Foundation',
- }),
- )
- await view.events.click(view.getByLabelText('Text'))
- await view.events.type(view.getByLabelText('Text'), 'Test ticket text')
- await view.events.click(view.getByLabelText('Group'))
- await view.events.click(view.getByRole('option', { name: 'Users' }))
- await view.events.click(view.getByLabelText('Priority'))
- await view.events.click(view.getByRole('option', { name: '2 normal' }))
- await view.events.click(view.getByLabelText('State'))
- await view.events.click(view.getByRole('option', { name: 'open' }))
- const sidebar = view.getByLabelText('Content sidebar')
- await view.events.click(
- await within(sidebar).findByRole('button', {
- name: 'Link Issue',
- }),
- )
- const flyout = await view.findByRole('complementary', {
- name: 'GitHub: Link issue',
- })
- await view.events.type(
- within(flyout).getByLabelText('Issue URL'),
- 'https://github.com/zammad/zammad/issues/123',
- )
- mockTicketExternalReferencesIssueTrackerItemAddMutation({
- ticketExternalReferencesIssueTrackerItemAdd: {
- issueTrackerItem: {
- issueId: 123,
- url: 'https://github.com/zammad/zammad/issues/123',
- title: 'Issue 1',
- state: EnumTicketExternalReferencesIssueTrackerItemState.Open,
- },
- errors: null,
- },
- })
- await view.events.click(
- within(flyout).getByRole('button', { name: 'Link Issue' }),
- )
- expect(await within(sidebar).findByText('#123 Issue 1')).toBeInTheDocument()
- await view.events.click(view.getByRole('button', { name: 'Create' }))
- const calls = await waitForTicketCreateMutationCalls()
- expect(calls.at(-1)?.variables.input).toEqual(
- expect.objectContaining({
- externalReferences: {
- github: ['https://github.com/zammad/zammad/issues/123'],
- },
- }),
- )
- })
- })
|