ticket-detail-view-ticket-merge.spec.ts 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. // Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. import { within } from '@testing-library/vue'
  3. import { visitView } from '#tests/support/components/visitView.ts'
  4. import { mockApplicationConfig } from '#tests/support/mock-applicationConfig.ts'
  5. import { mockPermissions } from '#tests/support/mock-permissions.ts'
  6. import { mockTicketQuery } from '#shared/entities/ticket/graphql/queries/ticket.mocks.ts'
  7. import { createDummyTicket } from '#shared/entities/ticket-article/__tests__/mocks/ticket.ts'
  8. import { mockTicketRelationAndRecentTicketListsQuery } from '#desktop/pages/ticket/graphql/queries/ticketRelationAndRecentTicketLists.mocks.ts'
  9. import { mockLinkListQuery } from '../graphql/queries/linkList.mocks.ts'
  10. describe('Ticket detail view ticket merge', () => {
  11. it('allows to merge source ticket with a target ticket', async () => {
  12. mockPermissions(['ticket.agent'])
  13. mockTicketRelationAndRecentTicketListsQuery({
  14. ticketsRecentlyViewed: [createDummyTicket()],
  15. ticketsRecentByCustomer: [
  16. createDummyTicket({
  17. title: 'Foo Car',
  18. ticketId: '1111',
  19. }),
  20. ],
  21. })
  22. await mockApplicationConfig({
  23. time_accounting_types: true,
  24. })
  25. const ticket = createDummyTicket()
  26. mockTicketQuery({
  27. ticket,
  28. })
  29. mockLinkListQuery({
  30. linkList: [],
  31. })
  32. const view = await visitView('/tickets/1')
  33. const sidebar = view.getByLabelText('Content sidebar')
  34. await view.events.click(
  35. within(sidebar).getByRole('button', { name: 'Action menu button' }),
  36. )
  37. await view.events.click(await view.findByRole('button', { name: 'Merge' }))
  38. expect(
  39. await view.findByRole('heading', { name: 'Merge Tickets', level: 2 }),
  40. ).toBeInTheDocument()
  41. expect(await view.findByText('Recent Customer Tickets')).toBeInTheDocument()
  42. expect(view.getByText('Recently Viewed Tickets')).toBeInTheDocument()
  43. expect(view.getByText('Foo Car')).toBeInTheDocument()
  44. })
  45. })