From 13c5387ae7b729c709969d5e52c028fb96f6e7b0 Mon Sep 17 00:00:00 2001 From: Peter Kulko <93188219+pkulkoraccoongang@users.noreply.github.com> Date: Mon, 29 Apr 2024 21:40:40 +0200 Subject: [PATCH] fix: fixes and refactorings after rebase (#237) * fix: fixes and refactorings after rebase * refactor: after review --- src/course-outline/CourseOutline.scss | 1 + src/course-unit/CourseUnit.test.jsx | 15 +++++++---- .../course-xblock/CourseXBlock.jsx | 1 - .../course-xblock/CourseXBlock.scss | 5 ---- src/course-unit/course-xblock/messages.js | 8 ------ src/course-unit/header-title/HeaderTitle.jsx | 2 +- src/course-unit/header-title/messages.js | 8 ------ .../modal-dropzone/ModalDropzone.test.jsx | 27 +++++++++++++++++-- 8 files changed, 37 insertions(+), 30 deletions(-) diff --git a/src/course-outline/CourseOutline.scss b/src/course-outline/CourseOutline.scss index 94ca859d07..f7fff905fb 100644 --- a/src/course-outline/CourseOutline.scss +++ b/src/course-outline/CourseOutline.scss @@ -7,4 +7,5 @@ @import "./empty-placeholder/EmptyPlaceholder"; @import "./highlights-modal/HighlightsModal"; @import "./publish-modal/PublishModal"; +@import "../generic/drag-helper/SortableItem"; @import "./xblock-status/XBlockStatus"; diff --git a/src/course-unit/CourseUnit.test.jsx b/src/course-unit/CourseUnit.test.jsx index cec2b09768..a5976e87bc 100644 --- a/src/course-unit/CourseUnit.test.jsx +++ b/src/course-unit/CourseUnit.test.jsx @@ -597,6 +597,14 @@ describe('', () => { name: 'New Cloned XBlock', block_id: '1234567890', block_type: 'drag-and-drop-v2', + actions: { + canCopy: true, + canDuplicate: true, + canMove: true, + canManageAccess: true, + canManageTags: true, + canDelete: true, + }, user_partition_info: {}, }, ], @@ -990,10 +998,7 @@ describe('', () => { children: [ { ...courseVerticalChildrenMock.children[0], - actions: { - ...courseVerticalChildrenMock.children[0].actions, - updatedXBlockActions, - }, + actions: updatedXBlockActions, }, ], }); @@ -1009,7 +1014,7 @@ describe('', () => { const moveBtn = queryByRole('button', { name: courseXBlockMessages.blockLabelButtonMove.defaultMessage }); const copyToClipboardBtn = queryByRole('button', { name: courseXBlockMessages.blockLabelButtonCopyToClipboard.defaultMessage }); const manageAccessBtn = queryByRole('button', { name: courseXBlockMessages.blockLabelButtonManageAccess.defaultMessage }); - const manageTagsBtn = queryByRole('button', { name: courseXBlockMessages.blockLabelButtonManageTags.defaultMessage }); + const manageTagsBtn = queryByRole('link', { name: courseXBlockMessages.blockLabelButtonManageTags.defaultMessage }); expect(deleteBtn).not.toBeInTheDocument(); expect(duplicateBtn).not.toBeInTheDocument(); diff --git a/src/course-unit/course-xblock/CourseXBlock.jsx b/src/course-unit/course-xblock/CourseXBlock.jsx index eeb959cd85..f1e2698dd0 100644 --- a/src/course-unit/course-xblock/CourseXBlock.jsx +++ b/src/course-unit/course-xblock/CourseXBlock.jsx @@ -2,7 +2,6 @@ import { memo, useEffect, useRef, useMemo, useState, } from 'react'; import PropTypes from 'prop-types'; -import classNames from 'classnames'; import { useDispatch, useSelector } from 'react-redux'; import { ActionRow, Card, Dropdown, Icon, IconButton, useToggle, Sheet, OverlayTrigger, Tooltip, Button, diff --git a/src/course-unit/course-xblock/CourseXBlock.scss b/src/course-unit/course-xblock/CourseXBlock.scss index 05aabb693b..7eeb06c90a 100644 --- a/src/course-unit/course-xblock/CourseXBlock.scss +++ b/src/course-unit/course-xblock/CourseXBlock.scss @@ -22,11 +22,6 @@ font-size: $font-size-sm; } - .pgn__card-header-subtitle-md { - margin-top: 0; - font-size: 1rem; - } - .pgn__card-header-title-md { font: 700 1.375rem/1.75rem $font-family-sans-serif; color: $black; diff --git a/src/course-unit/course-xblock/messages.js b/src/course-unit/course-xblock/messages.js index a67aeff2c0..1343b0783c 100644 --- a/src/course-unit/course-xblock/messages.js +++ b/src/course-unit/course-xblock/messages.js @@ -54,14 +54,6 @@ const messages = defineMessages({ id: 'course-authoring.course-unit.xblock.button.manageTags.label', defaultMessage: 'Manage tags', }, - visibilityMessage: { - id: 'course-authoring.course-unit.xblock.visibility.message', - defaultMessage: 'Access restricted to: {selectedGroupsLabel}', - }, - validationSummary: { - id: 'course-authoring.course-unit.xblock.validation.summary', - defaultMessage: 'This component has validation issues.', - }, expandTooltip: { id: 'course-authoring.course-unit.xblock.expandTooltip', defaultMessage: 'Collapse/Expand this block', diff --git a/src/course-unit/header-title/HeaderTitle.jsx b/src/course-unit/header-title/HeaderTitle.jsx index 734df5b449..0d29404ba6 100644 --- a/src/course-unit/header-title/HeaderTitle.jsx +++ b/src/course-unit/header-title/HeaderTitle.jsx @@ -50,7 +50,7 @@ const HeaderTitle = ({ return ( <> -
+
{isTitleEditFormOpen ? ( ', () => { await expect(uploadAssets(courseId, fileData, () => {})).rejects.toThrow('Network Error'); }); + it('displays an error message when the file size exceeds the limit', async () => { + const maxSizeInBytes = 20 * 1000 * 1000; + + const { getByText, getByRole } = render(); + const dropzoneInput = getByRole('presentation', { hidden: true }); + + const imageFile = new File( + [new ArrayBuffer(maxSizeInBytes + 1)], + 'test-file.png', + { type: 'image/png' }, + ); + + userEvent.upload(dropzoneInput.firstChild, imageFile); + + await waitFor(() => { + // Assert that the error message is displayed + const maxSizeInMB = maxSizeInBytes / (1000 * 1000); + const expectedErrorMessage = messages.uploadImageDropzoneInvalidSizeMore + .defaultMessage.replace('{maxSize}', maxSizeInMB); + expect(getByText(expectedErrorMessage)).toBeInTheDocument(); + }); + }); + it('displays a custom error message when the file size exceeds the limit', async () => { const maxSizeInBytes = 20 * 1000 * 1000; const expectedErrorMessage = 'Custom error message'; @@ -144,13 +167,13 @@ describe('', () => { ); const dropzoneInput = getByRole('presentation', { hidden: true }); - const fileToUpload = new File( + const imageFile = new File( [new ArrayBuffer(maxSizeInBytes + 1)], 'test-file.png', { type: 'image/png' }, ); - userEvent.upload(dropzoneInput.firstChild, fileToUpload); + userEvent.upload(dropzoneInput.firstChild, imageFile); await waitFor(() => { expect(getByText(expectedErrorMessage)).toBeInTheDocument();