Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions src/course-unit/CourseUnit.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,6 @@ describe('<CourseUnit />', () => {
expect(within(unitHeaderTitle).getByRole('button', { name: headerTitleMessages.altButtonEdit.defaultMessage })).toBeInTheDocument();
expect(within(unitHeaderTitle).getByRole('button', { name: headerTitleMessages.altButtonSettings.defaultMessage })).toBeInTheDocument();
expect(screen.getByRole('button', { name: headerNavigationsMessages.viewLiveButton.defaultMessage })).toBeInTheDocument();
expect(screen.getByRole('button', { name: headerNavigationsMessages.previewButton.defaultMessage })).toBeInTheDocument();
expect(screen.getByRole('button', { name: currentSectionName })).toBeInTheDocument();
expect(screen.getByRole('button', { name: currentSubSectionName })).toBeInTheDocument();
});
Expand Down Expand Up @@ -584,7 +583,6 @@ describe('<CourseUnit />', () => {
window.open = jest.fn();
render(<RootWrapper />);
const {
draft_preview_link: draftPreviewLink,
published_preview_link: publishedPreviewLink,
} = courseSectionVerticalMock;

Expand All @@ -593,11 +591,6 @@ describe('<CourseUnit />', () => {
userEvent.click(viewLiveButton);
expect(window.open).toHaveBeenCalled();
expect(window.open).toHaveBeenCalledWith(publishedPreviewLink, '_blank');

const previewButton = screen.getByRole('button', { name: headerNavigationsMessages.previewButton.defaultMessage });
userEvent.click(previewButton);
expect(window.open).toHaveBeenCalled();
expect(window.open).toHaveBeenCalledWith(draftPreviewLink, '_blank');
});

window.open = open;
Expand Down
22 changes: 7 additions & 15 deletions src/course-unit/header-navigations/HeaderNavigations.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,17 @@ import messages from './messages';

const HeaderNavigations = ({ headerNavigationsActions, category }) => {
const intl = useIntl();
const { handleViewLive, handlePreview, handleEdit } = headerNavigationsActions;
const { handleViewLive, handleEdit } = headerNavigationsActions;

return (
<nav className="header-navigations ml-auto flex-shrink-0">
{category === COURSE_BLOCK_NAMES.vertical.id && (
<>
<Button
variant="outline-primary"
onClick={handleViewLive}
>
{intl.formatMessage(messages.viewLiveButton)}
</Button>
<Button
variant="outline-primary"
onClick={handlePreview}
>
{intl.formatMessage(messages.previewButton)}
</Button>
</>
<Button
variant="outline-primary"
onClick={handleViewLive}
>
{intl.formatMessage(messages.viewLiveButton)}
</Button>
)}
{[COURSE_BLOCK_NAMES.libraryContent.id, COURSE_BLOCK_NAMES.splitTest.id].includes(category) && (
<Button
Expand Down
7 changes: 0 additions & 7 deletions src/course-unit/header-navigations/HeaderNavigations.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,10 @@ import HeaderNavigations from './HeaderNavigations';
import messages from './messages';

const handleViewLiveFn = jest.fn();
const handlePreviewFn = jest.fn();
const handleEditFn = jest.fn();

const headerNavigationsActions = {
handleViewLive: handleViewLiveFn,
handlePreview: handlePreviewFn,
handleEdit: handleEditFn,
};

Expand All @@ -30,7 +28,6 @@ describe('<HeaderNavigations />', () => {
const { getByRole } = renderComponent({ unitCategory: COURSE_BLOCK_NAMES.vertical.id });

expect(getByRole('button', { name: messages.viewLiveButton.defaultMessage })).toBeInTheDocument();
expect(getByRole('button', { name: messages.previewButton.defaultMessage })).toBeInTheDocument();
});

it('calls the correct handlers when clicking buttons for unit page', () => {
Expand All @@ -40,10 +37,6 @@ describe('<HeaderNavigations />', () => {
fireEvent.click(viewLiveButton);
expect(handleViewLiveFn).toHaveBeenCalledTimes(1);

const previewButton = getByRole('button', { name: messages.previewButton.defaultMessage });
fireEvent.click(previewButton);
expect(handlePreviewFn).toHaveBeenCalledTimes(1);

const editButton = queryByRole('button', { name: messages.editButton.defaultMessage });
expect(editButton).not.toBeInTheDocument();
});
Expand Down