Ticket.ts 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. // Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. import { faker } from '@faker-js/faker'
  3. import type { Ticket } from '#shared/graphql/types.ts'
  4. import { convertToGraphQLId } from '#shared/graphql/utils.ts'
  5. import type { DeepPartial } from '#shared/types/utils.ts'
  6. import type { ResolversMeta } from '../builders/index.ts'
  7. export default (
  8. _parent: unknown,
  9. _value: unknown,
  10. meta: ResolversMeta,
  11. ): DeepPartial<Ticket> => {
  12. const permissions = Reflect.get(
  13. globalThis,
  14. Symbol.for('tests.permissions'),
  15. ) as { names: string[] } | undefined
  16. const ticket: DeepPartial<Ticket> = {
  17. objectAttributeValues: [],
  18. customer: {
  19. id: convertToGraphQLId('User', 1),
  20. },
  21. mentions: {
  22. edges: [],
  23. totalCount: 0,
  24. },
  25. number: faker.number.int({ min: 1, max: 10000 }).toString(),
  26. policy: {
  27. destroy: true,
  28. update: true,
  29. agentReadAccess: !!permissions?.names.includes('ticket.agent'),
  30. },
  31. createArticleType: {
  32. __typename: 'TicketArticleType',
  33. id: convertToGraphQLId('TicketArticleType', 1),
  34. name: 'email',
  35. communication: false,
  36. },
  37. checklist: null,
  38. referencingChecklistTickets: [],
  39. }
  40. if (meta.variables.ticketNumber) {
  41. ticket.number = meta.variables.ticketNumber as string
  42. }
  43. return ticket
  44. }