123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115 |
- // Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
- import { renderComponent } from '#tests/support/components/index.ts'
- import OrganizationItem from '../OrganizationItem.vue'
- import type { OrganizationItemData } 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 now = new Date(2022, 1, 1)
- vi.setSystemTime(now)
- const organization: OrganizationItemData = {
- id: '54321',
- ticketsCount: {
- open: 2,
- closed: 1,
- },
- internalId: 3,
- name: 'lorem ipsum',
- active: true,
- members: {
- edges: [
- {
- node: { fullname: 'Erik Wise' },
- },
- {
- node: { fullname: 'Peter Smith' },
- },
- ],
- totalCount: 3,
- },
- updatedAt: new Date(2022, 1, 1, 10, 0, 0, 0).toISOString(),
- updatedBy: {
- id: '456',
- fullname: 'Jane Doe',
- },
- }
- const view = renderComponent(OrganizationItem, {
- props: {
- entity: organization,
- },
- store: true,
- })
- expect(view.getByText('lorem ipsum')).toBeInTheDocument()
- expect(view.getByText(/2 tickets/)).toBeInTheDocument()
- expect(view.getByText(/·/)).toBeInTheDocument()
- expect(view.getByText(/Erik Wise, Peter Smith, \+1/)).toBeInTheDocument()
- expect(
- view.getByText('edited 10 hours ago by Jane Doe'),
- ).toBeInTheDocument()
- })
- it('renders when something is missing', () => {
- const organization: OrganizationItemData = {
- id: '54321',
- internalId: 2,
- ticketsCount: {
- open: 1,
- closed: 0,
- },
- name: 'lorem ipsum',
- active: true,
- }
- const view = renderComponent(OrganizationItem, {
- props: {
- entity: organization,
- },
- store: true,
- })
- expect(view.getByText('lorem ipsum')).toBeInTheDocument()
- expect(view.getByText(/1 ticket/)).toBeInTheDocument()
- expect(view.queryByText(/·/)).not.toBeInTheDocument()
- expect(view.queryByTestId('stringUpdated')).not.toBeInTheDocument()
- })
- it('renders VIP status', () => {
- const organization: OrganizationItemData = {
- id: '54321',
- internalId: 2,
- ticketsCount: {
- open: 1,
- closed: 0,
- },
- name: 'lorem ipsum',
- active: true,
- vip: true,
- }
- const view = renderComponent(OrganizationItem, {
- props: {
- entity: organization,
- },
- store: true,
- })
- expect(view.getByLabelText('Avatar (lorem ipsum)')).toBeAvatarElement({
- vip: true,
- active: true,
- type: 'organization',
- })
- })
- })
|