[ARVADOS-WORKBENCH2] created: 2.1.0-125-g55c77cf6
Git user
git at public.arvados.org
Mon Dec 7 19:40:55 UTC 2020
at 55c77cf6945551bbb2500c213be48db84315b445 (commit)
commit 55c77cf6945551bbb2500c213be48db84315b445
Author: Daniel Kutyła <daniel.kutyla at contractors.roche.com>
Date: Mon Dec 7 20:39:33 2020 +0100
16812: Fixed img preview for collection items
Arvados-DCO-1.1-Signed-off-by: Daniel Kutyła <daniel.kutyla at contractors.roche.com>
diff --git a/src/components/file-tree/file-thumbnail.test.tsx b/src/components/file-tree/file-thumbnail.test.tsx
new file mode 100644
index 00000000..708275bd
--- /dev/null
+++ b/src/components/file-tree/file-thumbnail.test.tsx
@@ -0,0 +1,33 @@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import * as React from "react";
+import { shallow, configure } from "enzyme";
+import { FileThumbnail } from "./file-thumbnail";
+import { CollectionFileType } from '../../models/collection-file';
+import * as Adapter from 'enzyme-adapter-react-16';
+
+configure({ adapter: new Adapter() });
+
+jest.mock('is-image', () => ({
+ 'default': () => true,
+}));
+
+describe("<DropdownMenu />", () => {
+ let file;
+
+ beforeEach(() => {
+ file = {
+ name: 'test-image',
+ type: CollectionFileType.FILE,
+ url: 'http://test.com/c=test-hash/t=test-token/test-image.jpg',
+ size: 300
+ };
+ });
+
+ it("renders file thumbnail with proper src", () => {
+ const fileThumbnail = shallow(<FileThumbnail file={file} />);
+ expect(fileThumbnail.html()).toBe('<img class="Component-thumbnail-1" alt="test-image" src="http://test.com/c=test-hash"/>');
+ });
+});
diff --git a/src/components/file-tree/file-thumbnail.tsx b/src/components/file-tree/file-thumbnail.tsx
index e1a0d5e0..8ab554a1 100644
--- a/src/components/file-tree/file-thumbnail.tsx
+++ b/src/components/file-tree/file-thumbnail.tsx
@@ -7,6 +7,7 @@ import isImage from 'is-image';
import { withStyles, WithStyles } from '@material-ui/core';
import { FileTreeData } from '~/components/file-tree/file-tree-data';
import { CollectionFileType } from '~/models/collection-file';
+import { sanitizeToken } from "~/views-components/context-menu/actions/helpers";
export interface FileThumbnailProps {
file: FileTreeData;
@@ -32,5 +33,5 @@ const ImageFileThumbnail = imageFileThumbnailStyle(
<img
className={classes.thumbnail}
alt={file.name}
- src={file.url} />
+ src={sanitizeToken(file.url, false)} />
);
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list