diff --git a/src/components/ImageCard/ImageUploader.jsx b/src/components/ImageCard/ImageUploader.jsx index bfe1103bbb..c01bd548f7 100644 --- a/src/components/ImageCard/ImageUploader.jsx +++ b/src/components/ImageCard/ImageUploader.jsx @@ -17,7 +17,7 @@ const { iotPrefix } = settings; const i18nDefaults = { dropContainerLabelText: 'Drag and drop file here or click to select file', dropContainerDescText: - 'Max file size is 1MB. Supported file types are: JPEG, PNG, GIF, WEBP, TIFF, JPEG2000', + 'Max file size is 1MB. Supported file types are: APNG, AVIF, GIF, JPEG, PNG, WebP', uploadByURLCancel: 'Cancel', uploadByURLButton: 'OK', browseImages: 'Browse images', @@ -44,7 +44,7 @@ const propTypes = { }; const defaultProps = { - accept: ['JPEG', 'PNG', 'GIF', 'WEBP', 'TIFF', 'JPEG2000'], + accept: ['APNG', 'AVIF', 'GIF', 'JPEG', 'PNG', 'WebP'], onBrowseClick: () => {}, onUpload: () => {}, i18n: i18nDefaults, diff --git a/src/components/ImageCard/ImageUploader.test.jsx b/src/components/ImageCard/ImageUploader.test.jsx index e69de29bb2..1f27385d6d 100644 --- a/src/components/ImageCard/ImageUploader.test.jsx +++ b/src/components/ImageCard/ImageUploader.test.jsx @@ -0,0 +1,28 @@ +import React from 'react'; +import { render, screen } from '@testing-library/react'; +import userEvent from '@testing-library/user-event'; + +import ImageUploader from './ImageUploader'; + +describe('ImageUploader', () => { + it('will switch to URL upload screen', () => { + render(); + + const insertFromURLBtn = screen.getByText(/Insert from URL/); + userEvent.click(insertFromURLBtn); + expect(screen.getAllByText(/OK/)).toHaveLength(1); + }); + + it('will upload and use an image from URL', async () => { + render(); + + const insertFromURLBtn = screen.getByText(/Insert from URL/); + userEvent.click(insertFromURLBtn); + await userEvent.type( + screen.getAllByTitle('Type or insert URL'), + 'http://placekitten.com/200/300' + ); + userEvent.click(insertFromURLBtn); + expect(screen.querySelectorAll('.iot--image-card-img')).toHaveLength(1); + }); +});