CommonTicketCreateLink.spec.ts 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  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 { mockPermissions } from '#tests/support/mock-permissions.ts'
  5. import CommonTicketCreateLink from '../CommonTicketCreateLink.vue'
  6. describe('CommonTicketCreateLink', () => {
  7. it('shows the create link for agents when customer ticket create is enabled', () => {
  8. mockPermissions(['ticket.agent'])
  9. mockApplicationConfig({
  10. customer_ticket_create: true,
  11. })
  12. const view = renderComponent(CommonTicketCreateLink, {
  13. router: true,
  14. store: true,
  15. })
  16. const link = view.getByRole('link')
  17. expect(link).toHaveAttribute('aria-label', 'Create new ticket')
  18. })
  19. it('hides the create link for customer when customer ticket create is disabled', () => {
  20. mockPermissions(['ticket.customer'])
  21. mockApplicationConfig({
  22. customer_ticket_create: false,
  23. })
  24. const view = renderComponent(CommonTicketCreateLink, {
  25. router: true,
  26. store: true,
  27. })
  28. expect(view.queryByRole('link')).not.toBeInTheDocument()
  29. })
  30. })