Merge pull request #22178 from overleaf/jpa-file-view-hash-2

[web] migrate file-view to download from history-v1 (via web) 2/2

GitOrigin-RevId: 93172cbbd2d19a55bb27f5b0ca0b494f815a3632
This commit is contained in:
Jakob Ackermann
2024-11-28 09:06:37 +00:00
committed by Copybot
parent ce0d5fd383
commit faff4f1d7e
10 changed files with 46 additions and 97 deletions
@@ -151,23 +151,10 @@ describe('Path utils', function () {
const preview = previewByPath(
rootFolder,
'test-project-id',
'test-folder/example.png',
false
'test-folder/example.png'
)
expect(preview).to.deep.equal({
url: '/project/test-project-id/file/test-file-in-folder',
extension: 'png',
})
})
it('returns handles history file-tree', function () {
const preview = previewByPath(
rootFolder,
'test-project-id',
'test-folder/example.png',
true
)
expect(preview).to.deep.equal({
url: '/project/test-project-id/blob/42',
url: '/project/test-project-id/blob/42?fallback=test-file-in-folder',
extension: 'png',
})
})
@@ -23,12 +23,12 @@ describe('<FileViewText/>', function () {
})
it('renders a text view', async function () {
fetchMock.head('express:/project/:project_id/file/:file_id', {
fetchMock.head('express:/project/:project_id/blob/:hash', {
status: 201,
headers: { 'Content-Length': 10000 },
})
fetchMock.get(
'express:/project/:project_id/file/:file_id',
'express:/project/:project_id/blob/:hash',
'Text file content'
)
@@ -36,12 +36,12 @@ describe('<FileView/>', function () {
describe('for a text file', function () {
it('shows a loading indicator while the file is loading', async function () {
fetchMock.head('express:/project/:project_id/file/:file_id', {
fetchMock.head('express:/project/:project_id/blob/:hash', {
status: 201,
headers: { 'Content-Length': 10000 },
})
fetchMock.get(
'express:/project/:project_id/file/:file_id',
'express:/project/:project_id/blob/:hash',
'Text file content'
)