Ticket.ts 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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') ?? false,
  30. },
  31. createArticleType: {
  32. __typename: 'TicketArticleType',
  33. id: convertToGraphQLId('TicketArticleType', 1),
  34. name: 'email',
  35. communication: false,
  36. },
  37. }
  38. if (meta.variables.ticketNumber) {
  39. ticket.number = meta.variables.ticketNumber as string
  40. }
  41. return ticket
  42. }