ticket-detail-view-github.spec.ts 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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 getUuid from '#shared/utils/getUuid.ts'
  9. import { mockTicketExternalReferencesIssueTrackerItemListQuery } from '#desktop/pages/ticket/graphql/queries/ticketExternalReferencesIssueTrackerList.mocks.ts'
  10. describe('Ticket detail view GitHub integration', () => {
  11. it('displays GitHub integration on ticket detail page', async () => {
  12. mockPermissions(['ticket.agent'])
  13. await mockApplicationConfig({
  14. github_integration: true,
  15. })
  16. const ticket = createDummyTicket()
  17. mockTicketQuery({ ticket })
  18. const view = await visitView('/tickets/1')
  19. const sidebar = view.getByLabelText('Content sidebar')
  20. expect(
  21. within(sidebar).getByRole('button', { name: 'GitHub' }),
  22. ).toBeInTheDocument()
  23. })
  24. it('displays GitHub integration on ticket create page', async () => {
  25. mockPermissions(['ticket.agent'])
  26. await mockApplicationConfig({
  27. github_integration: true,
  28. })
  29. const uid = getUuid()
  30. const view = await visitView(`/ticket/create/${uid}`)
  31. const sidebar = view.getByLabelText('Content sidebar')
  32. expect(
  33. within(sidebar).getByRole('button', { name: 'GitHub' }),
  34. ).toBeInTheDocument()
  35. })
  36. it('hides GitHub integration when not available on ticket create screen', async () => {
  37. mockPermissions(['ticket.agent'])
  38. await mockApplicationConfig({
  39. github_integration: false,
  40. })
  41. const uid = getUuid()
  42. const view = await visitView(`/ticket/create/${uid}`)
  43. const sidebar = view.getByLabelText('Content sidebar')
  44. expect(
  45. within(sidebar).queryByRole('button', { name: 'GitHub' }),
  46. ).not.toBeInTheDocument()
  47. })
  48. it('hides GitHub integration when not available on ticket detail screen', async () => {
  49. mockPermissions(['ticket.agent'])
  50. await mockApplicationConfig({
  51. github_integration: false,
  52. })
  53. const ticket = createDummyTicket()
  54. mockTicketQuery({ ticket })
  55. mockTicketExternalReferencesIssueTrackerItemListQuery({
  56. ticketExternalReferencesIssueTrackerItemList: [],
  57. })
  58. const view = await visitView('/tickets/1')
  59. const sidebar = view.getByLabelText('Content sidebar')
  60. expect(
  61. within(sidebar).queryByRole('button', { name: 'GitHub' }),
  62. ).not.toBeInTheDocument()
  63. })
  64. })