30
     ˆÀ�þBä‹8Ø�@1»_ÏÆ365Ë¿ÉÈ m    // Copyright (C) 2012-2026 Zammad Foundation, https://zammad-foundation.org/

import { EntityType } from '#desktop/components/CommonSimpleEntityList/types.ts'

export default {
  type: EntityType.Organization,
  component: () =>
    import('#desktop/components/CommonSimpleEntityList/entity/OrganizationEntity.vue'),
  emptyMessage: __('No organizations found'),
}
  !   �236Äa–ßi~” T¾R( 	Å €ÆÀ¦-ÿÉ  ì    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html><head>
<title>404 Not Found</title>
</head><body>
<h1>Not Found</h1>
<p>The requested URL was not found on this server.</p>
</body></html>
      ˆÂ�þB7B³Ž˜ÆI%m—åþÇƒq×ÌÀ¾É q    // Copyright (C) 2012-2026 Zammad Foundation, https://zammad-foundation.org/

import { fireEvent } from '@testing-library/vue'

import { getByIconName, queryByIconName } from '#tests/support/components/iconQueries.ts'
import { renderComponent } from '#tests/support/components/index.ts'
import { mockApplicationConfig } from '#tests/support/mock-applicationConfig.ts'

import CommonFileListItem from '../CommonFileListItem.vue'

import type { FileListFile } from '../types.ts'

const touch = vi.hoisted(() => ({ isTouchDevice: false }))

// A real ref, so the template unwraps it â€” a plain `{ value }` stub would always read
//   as truthy there.
vi.mock('#shared/composables/useTouchDevice.ts', async () => {
  const { computed } = await import('vue')

  return {
    useTouchDevice: () => ({ isTouchDevice: computed(() => touch.isTouchDevice) }),
  }
})

const image: FileListFile = {
  internalId: 1,
  name: 'IMG_1234.png',
  type: 'image/png',
  size: 248_000,
  preview: '/api/attachments/1?preview=1',
  downloadUrl: '/api/attachments/1?disposition=attachment',
}

const calendar: FileListFile = {
  internalId: 2,
  name: 'SomeMeetingFile.ics',
  type: 'text/calendar',
  size: 248_000,
  preview: '/api/attachments/2?preview=1',
  downloadUrl: '/api/attachments/2?disposition=attachment',
}

const table: FileListFile = {
  internalId: 3,
  name: 'SomeTableFile.csv',
  type: 'text/csv',
  size: 248_000,
  preview: '',
  downloadUrl: '/api/attachments/3?disposition=attachment',
}

const renderItem = (file: FileListFile, props: { noRemove?: boolean } = {}) =>
  renderComponent(CommonFileListItem, {
    props: { file, ...props },
    router: true,
    store: true,
  })

describe('CommonFileListItem', () => {
  beforeEach(() => {
    touch.isTouchDevice = false

    mockApplicationConfig({
      api_path: '/api',
      'active_storage.content_types_allowed_inline': ['image/png', 'image/jpeg'],
    })
  })

  describe('previewable files', () => {
    it('renders an image with its thumbnail on the neutral surface', () => {
      const view = renderItem(image)

      const thumbnail = view.getByAltText('Image name: IMG_1234.png')
      expect(thumbnail).toHaveAttribute('src', '/api/attachments/1?preview=1')

      expect(view.getByText('IMG_1234')).toBeInTheDocument()
      expect(view.getByText('.png')).toBeInTheDocument()
      expect(view.getByText('242 KB')).toBeInTheDocument()

      expect(view.getByTestId('file-list-item')).toHaveClass('bg-neutral-50', 'dark:bg-gray-500')
    })

    it('emits preview with the image type', async () => {
      const view = renderItem(image)

      await view.events.click(view.getByRole('button', { name: 'Preview IMG_1234.png' }))

      expect(view.emitted().preview).toEqual([['image']])
    })

    it('emits preview with the calendar type', async () => {
      const view = renderItem(calendar)

      const button = view.getByRole('button', { name: 'Preview SomeMeetingFile.ics' })

      // No thumbnail for a calendar file â€” it shows its content-type icon instead
      //   (`calendar` is aliased to `file-calendar` on desktop).
      expect(view.queryByAltText('Image of SomeMeetingFile.ics')).not.toBeInTheDocument()
      expect(getByIconName(button, 'file-calendar')).toBeInTheDocument()

      await view.events.click(button)

      expect(view.emitted().pre