Skip to content

Commit

Permalink
fix: fixes and refactorings after rebase (#237)
Browse files Browse the repository at this point in the history
* fix: fixes and refactorings after rebase

* refactor: after review
  • Loading branch information
PKulkoRaccoonGang authored and monteri committed May 3, 2024
1 parent defd01f commit 13c5387
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 30 deletions.
1 change: 1 addition & 0 deletions src/course-outline/CourseOutline.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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";
15 changes: 10 additions & 5 deletions src/course-unit/CourseUnit.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -597,6 +597,14 @@ describe('<CourseUnit />', () => {
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: {},
},
],
Expand Down Expand Up @@ -990,10 +998,7 @@ describe('<CourseUnit />', () => {
children: [
{
...courseVerticalChildrenMock.children[0],
actions: {
...courseVerticalChildrenMock.children[0].actions,
updatedXBlockActions,
},
actions: updatedXBlockActions,
},
],
});
Expand All @@ -1009,7 +1014,7 @@ describe('<CourseUnit />', () => {
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();
Expand Down
1 change: 0 additions & 1 deletion src/course-unit/course-xblock/CourseXBlock.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
5 changes: 0 additions & 5 deletions src/course-unit/course-xblock/CourseXBlock.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 0 additions & 8 deletions src/course-unit/course-xblock/messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
2 changes: 1 addition & 1 deletion src/course-unit/header-title/HeaderTitle.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ const HeaderTitle = ({

return (
<>
<div className="d-flex align-items-center lead">
<div className="d-flex align-items-center lead" data-testid="unit-header-title">
{isTitleEditFormOpen ? (
<Form.Group className="m-0">
<Form.Control
Expand Down
8 changes: 0 additions & 8 deletions src/course-unit/header-title/messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,6 @@ const messages = defineMessages({
defaultMessage: 'Access to some content in this unit is restricted to specific groups of learners.',
description: 'The label text of some content restriction in this unit',
},
definedVisibilityMessage: {
id: 'course-authoring.course-unit.heading.visibility.defined.message',
defaultMessage: 'Access to this unit is restricted to: {selectedGroupsLabel}',
},
commonVisibilityMessage: {
id: 'course-authoring.course-unit.heading.visibility.common.message',
defaultMessage: 'Access to some content in this unit is restricted to specific groups of learners.',
},
});

export default messages;
27 changes: 25 additions & 2 deletions src/generic/modal-dropzone/ModalDropzone.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,29 @@ describe('<ModalDropzone />', () => {
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(<RootWrapper {...props} maxSize={maxSizeInBytes} />);
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';
Expand All @@ -144,13 +167,13 @@ describe('<ModalDropzone />', () => {
);
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();
Expand Down

0 comments on commit 13c5387

Please sign in to comment.