12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- // Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
- import { faker } from '@faker-js/faker'
- import type { Ticket } from '#shared/graphql/types.ts'
- import { convertToGraphQLId } from '#shared/graphql/utils.ts'
- import type { DeepPartial } from '#shared/types/utils.ts'
- import type { ResolversMeta } from '../builders/index.ts'
- export default (
- _parent: unknown,
- _value: unknown,
- meta: ResolversMeta,
- ): DeepPartial<Ticket> => {
- const permissions = Reflect.get(
- globalThis,
- Symbol.for('tests.permissions'),
- ) as { names: string[] } | undefined
- const ticket: DeepPartial<Ticket> = {
- objectAttributeValues: [],
- customer: {
- id: convertToGraphQLId('User', 1),
- },
- mentions: {
- edges: [],
- totalCount: 0,
- },
- number: faker.number.int({ min: 1, max: 10000 }).toString(),
- policy: {
- destroy: true,
- update: true,
- agentReadAccess: permissions?.names.includes('ticket.agent') ?? false,
- },
- createArticleType: {
- __typename: 'TicketArticleType',
- id: convertToGraphQLId('TicketArticleType', 1),
- name: 'email',
- communication: false,
- },
- }
- if (meta.variables.ticketNumber) {
- ticket.number = meta.variables.ticketNumber as string
- }
- return ticket
- }
|