useTicketCreateView.spec.ts 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. // Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. import { mockApplicationConfig } from '#tests/support/mock-applicationConfig.ts'
  3. import { mockPermissions } from '#tests/support/mock-permissions.ts'
  4. import { useTicketCreateView } from '../useTicketCreateView.ts'
  5. describe('useTicketCreateView', () => {
  6. it('check for agent permission and setting customer ticket create enabled', () => {
  7. mockPermissions(['ticket.agent'])
  8. mockApplicationConfig({
  9. customer_ticket_create: true,
  10. })
  11. const { ticketCreateEnabled } = useTicketCreateView()
  12. expect(ticketCreateEnabled.value).toBe(true)
  13. })
  14. it('check for agent permission and setting customer ticket create disabled', () => {
  15. mockPermissions(['ticket.agent'])
  16. mockApplicationConfig({
  17. customer_ticket_create: true,
  18. })
  19. const { ticketCreateEnabled } = useTicketCreateView()
  20. expect(ticketCreateEnabled.value).toBe(true)
  21. })
  22. it('check for customer permission and setting customer ticket create enabled', () => {
  23. mockPermissions(['ticket.customer'])
  24. mockApplicationConfig({
  25. customer_ticket_create: true,
  26. })
  27. const { ticketCreateEnabled } = useTicketCreateView()
  28. expect(ticketCreateEnabled.value).toBe(true)
  29. })
  30. it('check for customer permission and setting customer ticket create disabled', () => {
  31. mockPermissions(['ticket.customer'])
  32. mockApplicationConfig({
  33. customer_ticket_create: false,
  34. })
  35. const { ticketCreateEnabled } = useTicketCreateView()
  36. expect(ticketCreateEnabled.value).toBe(false)
  37. })
  38. it('check for agent, but no customer permission', () => {
  39. mockPermissions(['ticket.agent'])
  40. const { isTicketCustomer } = useTicketCreateView()
  41. expect(isTicketCustomer.value).toBe(false)
  42. })
  43. it('check for agent + customer permission', () => {
  44. mockPermissions(['ticket.agent', 'ticket.customer'])
  45. const { isTicketCustomer } = useTicketCreateView()
  46. expect(isTicketCustomer.value).toBe(false)
  47. })
  48. it('check for no agent, but customer permission', () => {
  49. mockPermissions(['ticket.customer'])
  50. const { isTicketCustomer } = useTicketCreateView()
  51. expect(isTicketCustomer.value).toBe(true)
  52. })
  53. })