TicketArticle.ts 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. // Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. import { faker } from '@faker-js/faker'
  3. import {
  4. EnumTicketArticleSenderName,
  5. type TicketArticle,
  6. } from '#shared/graphql/types.ts'
  7. import { convertToGraphQLId } from '#shared/graphql/utils.ts'
  8. import type { DeepPartial } from '#shared/types/utils.ts'
  9. export default (): DeepPartial<TicketArticle> => {
  10. const senderNumber = faker.number.int({ min: 0, max: 2 })
  11. const body = faker.lorem.paragraph()
  12. return {
  13. contentType: faker.helpers.arrayElement(['text/html', 'text/plain']),
  14. body,
  15. bodyWithUrls: body,
  16. attachmentsWithoutInline: [],
  17. sender: {
  18. id: convertToGraphQLId('TicketArticleSender', senderNumber + 1),
  19. name: [
  20. EnumTicketArticleSenderName.Agent,
  21. EnumTicketArticleSenderName.Customer,
  22. EnumTicketArticleSenderName.System,
  23. ][senderNumber],
  24. },
  25. // possible types: db/seeds/ticket_article_types.rb
  26. // we only generate emails to have consistent articles
  27. type: {
  28. __typename: 'TicketArticleType',
  29. id: convertToGraphQLId('TicketArticleType', 1),
  30. name: 'email',
  31. communication: false,
  32. },
  33. }
  34. }