-
- {filename} Uploaded on {createdAt}
-
-
id: {id || 'undefined'}
-
fileName: {filename || 'undefined'}
-
contentType: {contentType || 'undefined'}
-
url: {url || 'undefined'}
-
createdAt: {createdAt || 'undefined'}
-
rotation: {rotation || 'undefined'}
-
-
- {mockFiles.map((file) => (
- -
- {file.filename} - Added on {file.createdAt}
-
- ))}
-
-
-
-
+ default: ({ id, filename, contentType, url, createdAt, rotation, filePath, onError }) => {
+ if (filePath === '404') {
+ onError('content error happening');
+ return
nothing to see here
;
+ }
+ return (
+
+
+ {filename} Uploaded on {createdAt}
+
+
id: {id || 'undefined'}
+
fileName: {filename || 'undefined'}
+
contentType: {contentType || 'undefined'}
+
url: {url || 'undefined'}
+
createdAt: {createdAt || 'undefined'}
+
rotation: {rotation || 'undefined'}
+
+
+ {mockFiles.map((file) => (
+ -
+ {file.filename} - Added on {file.createdAt}
+
+ ))}
+
+
+
+
+
-
- ),
+ );
+ },
}));
describe('DocumentViewer component', () => {
@@ -180,6 +196,46 @@ describe('DocumentViewer component', () => {
expect(screen.getByText('id: undefined')).toBeInTheDocument();
});
+ describe('regarding content errors', () => {
+ const errorMessageText = 'If your document does not display, please refresh your browser.';
+ const downloadLinkText = 'Download file';
+ it('no error message normally', async () => {
+ render(
+
+
+ ,
+ );
+ expect(screen.queryByText(errorMessageText)).toBeNull();
+ });
+
+ it('download link normally', async () => {
+ render(
+
+
+ ,
+ );
+ expect(screen.getByText(downloadLinkText)).toBeVisible();
+ });
+
+ it('show message on content error', async () => {
+ render(
+
+
+ ,
+ );
+ expect(screen.getByText(errorMessageText)).toBeVisible();
+ });
+
+ it('download link on content error', async () => {
+ render(
+
+
+ ,
+ );
+ expect(screen.getByText(downloadLinkText)).toBeVisible();
+ });
+ });
+
describe('when clicking download Download All Files button', () => {
it('downloads a bulk packet', async () => {
const mockResponse = {
diff --git a/yarn.lock b/yarn.lock
index 4d2683f08bd..b3e5f4a5ce7 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -4583,9 +4583,9 @@
resolved "https://registry.yarnpkg.com/@tootallnate/once/-/once-2.0.0.tgz#f544a148d3ab35801c1f633a7441fd87c2e484bf"
integrity sha512-XCuKFP5PS55gnMVu3dty8KPatLqUoy/ZYzDzAGCQ8JNFCkLXzmI7vNHCR+XpbZaMWQK/vQubr7PkYq8g470J/A==
-"@transcom/react-file-viewer@git+https://github.com/transcom/react-file-viewer#v1.2.4":
- version "1.2.4"
- resolved "git+https://github.com/transcom/react-file-viewer#d4396dc8bf0acdd646e93ea82d23acf3bc0d5b0f"
+"@transcom/react-file-viewer@git+https://github.com/transcom/react-file-viewer#v1.2.5":
+ version "1.2.5"
+ resolved "git+https://github.com/transcom/react-file-viewer#4d9924ae58a6acdfcfb353235e034ff98fde5458"
dependencies:
pdfjs-dist "1.8.357"
prop-types "^15.5.10"