TicketDuplicateDetectionDialog.spec.ts 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. // Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. import { renderComponent } from '#tests/support/components/index.ts'
  3. import { mockApplicationConfig } from '#tests/support/mock-applicationConfig.ts'
  4. import type { TicketDuplicateDetectionItem } from '#shared/entities/ticket/types.ts'
  5. import TicketDuplicateDetectionDialog from '../TicketDuplicateDetectionDialog.vue'
  6. describe('TicketDuplicateDetectionDialog.vue', () => {
  7. beforeEach(() => {
  8. mockApplicationConfig({
  9. ticket_duplicate_detection_title: 'Foo',
  10. ticket_duplicate_detection_body: 'Bar',
  11. })
  12. })
  13. it('renders configured title and message', () => {
  14. const view = renderComponent(TicketDuplicateDetectionDialog, {
  15. props: {
  16. name: 'duplicate-ticket-detection',
  17. tickets: [],
  18. },
  19. })
  20. expect(view.getByText('Foo')).toBeInTheDocument()
  21. expect(view.getByText('Bar')).toBeInTheDocument()
  22. })
  23. it('renders provided ticket items', () => {
  24. const testTickets: TicketDuplicateDetectionItem[] = [
  25. [1, '27001', 'Test Ticket 1'],
  26. [2, '27002', 'Test Ticket 2'],
  27. [3, '27003', 'Test Ticket 3'],
  28. [4, '27004', 'Test Ticket 4'],
  29. [5, '27005', 'Test Ticket 5'],
  30. ]
  31. const view = renderComponent(TicketDuplicateDetectionDialog, {
  32. props: {
  33. name: 'duplicate-ticket-detection',
  34. tickets: testTickets,
  35. },
  36. router: true,
  37. })
  38. testTickets.forEach((testTicket) => {
  39. const ticketNumber = `#${testTicket[1]}`
  40. const ticketNumberElement = view.getByText(ticketNumber)
  41. expect(ticketNumberElement).toBeInTheDocument()
  42. expect(ticketNumberElement.closest('a')).toHaveAttribute(
  43. 'href',
  44. `/tickets/${testTicket[0]}`,
  45. )
  46. const ticketTitle = testTicket[2]
  47. expect(view.getByText(ticketTitle)).toBeInTheDocument()
  48. })
  49. })
  50. })