TicketState.ts 857 B

123456789101112131415161718192021222324252627
  1. // Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. import { faker } from '@faker-js/faker'
  3. import type { TicketState } from '#shared/graphql/types.ts'
  4. import {
  5. convertToGraphQLId,
  6. getIdFromGraphQLId,
  7. } from '#shared/graphql/utils.ts'
  8. import type { DeepPartial } from '#shared/types/utils.ts'
  9. import { updateGeneratedIds } from '../builders/utils.ts'
  10. const states: (() => DeepPartial<TicketState>)[] = [
  11. () => ({ id: convertToGraphQLId('TicketState', 1), name: 'new' }),
  12. () => ({ id: convertToGraphQLId('TicketState', 2), name: 'open' }),
  13. ]
  14. export default (): DeepPartial<TicketState> => {
  15. const state: DeepPartial<TicketState> = faker.helpers.arrayElement(states)()
  16. state.stateType = {
  17. id: state.id,
  18. name: state.name,
  19. }
  20. updateGeneratedIds('TicketState', getIdFromGraphQLId(state.id!))
  21. return state
  22. }