Skip to content

Commit

Permalink
fix: set the other icon type as the default file thumbnail
Browse files Browse the repository at this point in the history
  • Loading branch information
MellyGray committed Oct 31, 2023
1 parent 975220d commit f4bb101
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import styles from './FileThumbnail.module.scss'
import { FileType } from '../../../../../../../../files/domain/models/File'
import { FileTypeToFileIconMap } from './FileTypeToFileIconMap'
import { IconName } from '@iqss/dataverse-design-system'

export function FileThumbnailIcon({ type }: { type: FileType }) {
const icon = FileTypeToFileIconMap[type.value] || FileTypeToFileIconMap.default
const icon = FileTypeToFileIconMap[type.value] || IconName.OTHER

return (
<span className={`${styles.icon} ${icon} ${styles.container}`} role="img" aria-label={icon}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { FileMother } from '../../../../../../../../files/domain/models/FileMoth
import { FileRepository } from '../../../../../../../../../../src/files/domain/repositories/FileRepository'
import { FileUserPermissionsMother } from '../../../../../../../../files/domain/models/FileUserPermissionsMother'
import { FilePermissionsProvider } from '../../../../../../../../../../src/sections/file/file-permissions/FilePermissionsProvider'
import { FileType } from '../../../../../../../../../../src/files/domain/models/File'

const fileRepository: FileRepository = {} as FileRepository
describe('FileThumbnail', () => {
Expand Down Expand Up @@ -68,19 +69,19 @@ describe('FileThumbnail', () => {
cy.customMount(<FileThumbnail file={file} />)

cy.findByAltText(file.name).should('not.exist')
cy.findByText('icon-file').should('exist')
cy.findByText('icon-other').should('exist')

cy.findByText('Restricted File Icon').should('exist').parent().trigger('mouseover')
cy.findByText('File Access: Restricted').should('exist')
cy.findByText('Restricted with access Icon').should('not.exist')
})

it('renders FileThumbnailIcon when thumbnail is not provided', () => {
const file = FileMother.createDefault()
const file = FileMother.createDefault({ type: new FileType('application/pdf') })

cy.customMount(<FileThumbnail file={file} />)

cy.findByText('icon-file').should('exist')
cy.findByText('icon-document').should('exist')

cy.findByText('Restricted File Icon').should('not.exist')
cy.findByText('Restricted with access Icon').should('not.exist')
Expand All @@ -91,7 +92,7 @@ describe('FileThumbnail', () => {

cy.customMount(<FileThumbnail file={file} />)

cy.findByText('icon-file').should('exist')
cy.findByText('icon-other').should('exist')

cy.findByText('Restricted File Icon').should('exist')
cy.findByText('Restricted File Icon').should('exist').parent().trigger('mouseover')
Expand All @@ -114,7 +115,7 @@ describe('FileThumbnail', () => {
</FilePermissionsProvider>
)

cy.findByText('icon-file').should('exist')
cy.findByText('icon-other').should('exist')

cy.findByText('Restricted File Icon').should('not.exist')
cy.findByText('Restricted with access Icon').should('exist').parent().trigger('mouseover')
Expand Down

0 comments on commit f4bb101

Please sign in to comment.