mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-29 12:13:43 -05:00
Fix a few minor test issues (#5415)
* Remove signal.abort() * Fix usage of .toString * Fix requests for files * Fix story GitOrigin-RevId: 37ab4be34a8975881aed2329d4b67f8df74837d8
This commit is contained in:
parent
845b2fbc04
commit
adf8828860
4 changed files with 21 additions and 7 deletions
|
@ -46,7 +46,6 @@ export default class DocumentCompiler {
|
||||||
}
|
}
|
||||||
|
|
||||||
destroy() {
|
destroy() {
|
||||||
this.signal.abort()
|
|
||||||
this.debouncedAutoCompile.cancel()
|
this.debouncedAutoCompile.cancel()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -404,16 +404,16 @@ export const CompileError = () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
const Inner = () => {
|
const Inner = () => {
|
||||||
const { recompile } = usePdfPreviewContext()
|
const { startCompile } = usePdfPreviewContext()
|
||||||
|
|
||||||
const handleStatusChange = useCallback(
|
const handleStatusChange = useCallback(
|
||||||
event => {
|
event => {
|
||||||
setStatus(event.target.value)
|
setStatus(event.target.value)
|
||||||
window.setTimeout(() => {
|
window.setTimeout(() => {
|
||||||
recompile()
|
startCompile()
|
||||||
}, 0)
|
}, 0)
|
||||||
},
|
},
|
||||||
[recompile]
|
[startCompile]
|
||||||
)
|
)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -10,6 +10,7 @@ import FileView from '../../../../../frontend/js/features/file-view/components/f
|
||||||
|
|
||||||
describe('<FileView/>', function () {
|
describe('<FileView/>', function () {
|
||||||
const textFile = {
|
const textFile = {
|
||||||
|
id: 'text-file',
|
||||||
name: 'example.tex',
|
name: 'example.tex',
|
||||||
linkedFileData: {
|
linkedFileData: {
|
||||||
v1_source_doc_id: 'v1-source-id',
|
v1_source_doc_id: 'v1-source-id',
|
||||||
|
@ -35,6 +36,15 @@ describe('<FileView/>', function () {
|
||||||
|
|
||||||
describe('for a text file', function () {
|
describe('for a text file', function () {
|
||||||
it('shows a loading indicator while the file is loading', async function () {
|
it('shows a loading indicator while the file is loading', async function () {
|
||||||
|
fetchMock.head('express:/project/:project_id/file/:file_id', {
|
||||||
|
status: 201,
|
||||||
|
headers: { 'Content-Length': 10000 },
|
||||||
|
})
|
||||||
|
fetchMock.get(
|
||||||
|
'express:/project/:project_id/file/:file_id',
|
||||||
|
'Text file content'
|
||||||
|
)
|
||||||
|
|
||||||
renderWithEditorContext(
|
renderWithEditorContext(
|
||||||
<FileView file={textFile} storeReferencesKeys={() => {}} />
|
<FileView file={textFile} storeReferencesKeys={() => {}} />
|
||||||
)
|
)
|
||||||
|
@ -45,8 +55,13 @@ describe('<FileView/>', function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('shows messaging if the text view could not be loaded', async function () {
|
it('shows messaging if the text view could not be loaded', async function () {
|
||||||
|
const unpreviewableTextFile = {
|
||||||
|
...textFile,
|
||||||
|
name: 'example.not-tex',
|
||||||
|
}
|
||||||
|
|
||||||
renderWithEditorContext(
|
renderWithEditorContext(
|
||||||
<FileView file={textFile} storeReferencesKeys={() => {}} />
|
<FileView file={unpreviewableTextFile} storeReferencesKeys={() => {}} />
|
||||||
)
|
)
|
||||||
|
|
||||||
await screen.findByText('Sorry, no preview is available', {
|
await screen.findByText('Sorry, no preview is available', {
|
||||||
|
|
|
@ -6,8 +6,8 @@ import { pathToFileURL } from 'url'
|
||||||
import PdfJsViewer from '../../../../../frontend/js/features/pdf-preview/components/pdf-js-viewer'
|
import PdfJsViewer from '../../../../../frontend/js/features/pdf-preview/components/pdf-js-viewer'
|
||||||
|
|
||||||
const example = pathToFileURL(
|
const example = pathToFileURL(
|
||||||
path.join(__dirname, '../fixtures/test-example.pdf').toString()
|
path.join(__dirname, '../fixtures/test-example.pdf')
|
||||||
)
|
).toString()
|
||||||
|
|
||||||
const exampleCorrupt = pathToFileURL(
|
const exampleCorrupt = pathToFileURL(
|
||||||
path.join(__dirname, '../fixtures/test-example-corrupt.pdf')
|
path.join(__dirname, '../fixtures/test-example-corrupt.pdf')
|
||||||
|
|
Loading…
Reference in a new issue