Fix: render images not converted to pdf, refactor doc detail rendering (#5475)

This commit is contained in:
shamoon authored and GitHub committed 2024-01-20 08:26:24 -08:00
1 parent 5781a0d51f
commit 5842944d1e
4 files changed
+116 -47

No files matched your search

@@ -996,6 +996,53 @@ describe('DocumentDetailComponent', () => {
expect(closeSpy).toHaveBeenCalled()
})
it('should change preview element by render type', () => {
component.metadata = { has_archive_version: true }
initNormally()
fixture.detectChanges()
expect(component.contentRenderType).toEqual(component.ContentRenderType.PDF)
expect(
fixture.debugElement.query(By.css('pdf-viewer-container'))
).not.toBeUndefined()
component.metadata = {
has_archive_version: false,
original_mime_type: 'text/plain',
}
fixture.detectChanges()
expect(component.contentRenderType).toEqual(
component.ContentRenderType.Text
)
expect(
fixture.debugElement.query(By.css('div.preview-sticky'))
).not.toBeUndefined()
component.metadata = {
has_archive_version: false,
original_mime_type: 'image/jpg',
}
fixture.detectChanges()
expect(component.contentRenderType).toEqual(
component.ContentRenderType.Image
)
expect(
fixture.debugElement.query(By.css('.preview-sticky img'))
).not.toBeUndefined()
component.metadata = {
has_archive_version: false,
original_mime_type:
'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
}
fixture.detectChanges()
expect(component.contentRenderType).toEqual(
component.ContentRenderType.Other
)
expect(
fixture.debugElement.query(By.css('object.preview-sticky'))
).not.toBeUndefined()
})
function initNormally() {
jest
.spyOn(activatedRoute, 'paramMap', 'get')