12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- // Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
- import { renderComponent } from '#tests/support/components/index.ts'
- import { TicketState } from '#shared/entities/ticket/types.ts'
- import { EnumTicketStateColorCode } from '#shared/graphql/types.ts'
- import TicketItem from '../TicketItem.vue'
- import type { TicketItemData } from '../types.ts'
- vi.hoisted(() => {
- const now = new Date(2022, 1, 1, 20, 0, 0, 0)
- vi.setSystemTime(now)
- })
- describe('ticket item display', () => {
- it('renders correctly', () => {
- const ticket: TicketItemData = {
- id: '54321',
- number: '12345',
- internalId: 1,
- state: { name: TicketState.Open },
- title: 'test ticket',
- customer: {
- fullname: 'John Doe',
- },
- updatedAt: new Date(2022, 1, 1, 10, 0, 0, 0).toISOString(),
- updatedBy: {
- id: '456',
- fullname: 'Jane Doe',
- },
- priority: {
- name: '3 high',
- uiColor: 'high-priority',
- defaultCreate: false,
- },
- stateColorCode: EnumTicketStateColorCode.Open,
- }
- const view = renderComponent(TicketItem, {
- props: {
- entity: ticket,
- },
- store: true,
- router: true,
- })
- expect(view.getByRole('group')).toHaveClass('text-yellow')
- expect(view.getByIconName('check-circle-no')).toHaveAccessibleName(
- '(state: open)',
- )
- expect(view.getByText('#12345 · John Doe')).toBeInTheDocument()
- expect(view.getByText('test ticket')).toBeInTheDocument()
- expect(
- view.getByText('edited 10 hours ago by Jane Doe'),
- ).toBeInTheDocument()
- const priority = view.getByText('3 high')
- expect(priority).toBeInTheDocument()
- expect(priority).toHaveClasses(['bg-red-dark', 'text-red-bright'])
- })
- it('renders when something is missing', () => {
- const ticket: TicketItemData = {
- id: '54321',
- number: '12345',
- internalId: 1,
- state: { name: TicketState.Open },
- title: 'test ticket',
- stateColorCode: EnumTicketStateColorCode.Open,
- }
- const view = renderComponent(TicketItem, {
- props: {
- entity: ticket,
- },
- store: true,
- router: true,
- })
- expect(view.getByRole('group')).toHaveClass('text-yellow')
- expect(view.getByIconName('check-circle-no')).toHaveAccessibleName(
- '(state: open)',
- )
- expect(view.getByText('#12345')).toBeInTheDocument()
- expect(view.queryByText(/·/)).not.toBeInTheDocument()
- expect(view.getByText('test ticket')).toBeInTheDocument()
- expect(view.queryByTestId('stringUpdated')).not.toBeInTheDocument()
- expect(view.queryByText('3 high')).not.toBeInTheDocument()
- })
- })
|