mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-14 20:40:17 -05:00
8b9f69012c
Improve user behaviour on Mendeley/Zotero refresh screen UI GitOrigin-RevId: 50f83e88f14e1708d46dcfbd53c4e7d62684b4dc
84 lines
2.6 KiB
JavaScript
84 lines
2.6 KiB
JavaScript
import { screen } from '@testing-library/react'
|
|
import fetchMock from 'fetch-mock'
|
|
|
|
import { renderWithEditorContext } from '../../../helpers/render-with-context'
|
|
import FileViewHeader from '../../../../../frontend/js/features/file-view/components/file-view-header'
|
|
import { USER_ID } from '../../../helpers/editor-providers'
|
|
|
|
describe('<FileViewHeader/>', function () {
|
|
const urlFile = {
|
|
name: 'example.tex',
|
|
linkedFileData: {
|
|
url: 'https://overleaf.com',
|
|
provider: 'url',
|
|
},
|
|
created: new Date(2021, 1, 17, 3, 24).toISOString(),
|
|
}
|
|
|
|
const projectFile = {
|
|
name: 'example.tex',
|
|
linkedFileData: {
|
|
v1_source_doc_id: 'v1-source-id',
|
|
source_project_id: 'source-project-id',
|
|
source_entity_path: '/source-entity-path.ext',
|
|
provider: 'project_file',
|
|
importer_id: USER_ID,
|
|
},
|
|
created: new Date(2021, 1, 17, 3, 24).toISOString(),
|
|
}
|
|
|
|
const projectOutputFile = {
|
|
name: 'example.pdf',
|
|
linkedFileData: {
|
|
v1_source_doc_id: 'v1-source-id',
|
|
source_output_file_path: '/source-entity-path.ext',
|
|
provider: 'project_output_file',
|
|
},
|
|
created: new Date(2021, 1, 17, 3, 24).toISOString(),
|
|
}
|
|
|
|
beforeEach(function () {
|
|
fetchMock.reset()
|
|
})
|
|
|
|
describe('header text', function () {
|
|
it('Renders the correct text for a file with the url provider', function () {
|
|
renderWithEditorContext(<FileViewHeader file={urlFile} />)
|
|
screen.getByText('Imported from', { exact: false })
|
|
screen.getByText('at 3:24 am Wed, 17th Feb 21', {
|
|
exact: false,
|
|
})
|
|
})
|
|
|
|
it('Renders the correct text for a file with the project_file provider', function () {
|
|
renderWithEditorContext(<FileViewHeader file={projectFile} />)
|
|
screen.getByText('Imported from', { exact: false })
|
|
screen.getByText('Another project', { exact: false })
|
|
screen.getByText('/source-entity-path.ext, at 3:24 am Wed, 17th Feb 21', {
|
|
exact: false,
|
|
})
|
|
})
|
|
|
|
it('Renders the correct text for a file with the project_output_file provider', function () {
|
|
renderWithEditorContext(
|
|
<FileViewHeader
|
|
file={projectOutputFile}
|
|
storeReferencesKeys={() => {}}
|
|
/>
|
|
)
|
|
screen.getByText('Imported from the output of', { exact: false })
|
|
screen.getByText('Another project', { exact: false })
|
|
screen.getByText('/source-entity-path.ext, at 3:24 am Wed, 17th Feb 21', {
|
|
exact: false,
|
|
})
|
|
})
|
|
})
|
|
|
|
describe('The download button', function () {
|
|
it('exists', function () {
|
|
renderWithEditorContext(<FileViewHeader file={urlFile} />)
|
|
|
|
screen.getByText('Download', { exact: false })
|
|
})
|
|
})
|
|
})
|