Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fixed course rerun route #993

Merged
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
5 changes: 3 additions & 2 deletions src/studio-home/card-item/CardItem.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { initializeMockApp, getConfig } from '@edx/frontend-platform';
import { studioHomeMock } from '../__mocks__';
import messages from '../messages';
import initializeStore from '../../store';
import { trimSlashes } from './utils';
import CardItem from '.';

jest.mock('react-redux', () => ({
Expand Down Expand Up @@ -50,7 +51,7 @@ describe('<CardItem />', () => {
const courseTitleLink = getByText(props.displayName);
expect(courseTitleLink).toHaveAttribute('href', `${getConfig().STUDIO_BASE_URL}${props.url}`);
const btnReRunCourse = getByText(messages.btnReRunText.defaultMessage);
expect(btnReRunCourse).toHaveAttribute('href', props.rerunLink);
expect(btnReRunCourse).toHaveAttribute('href', trimSlashes(props.rerunLink));
const viewLiveLink = getByText(messages.viewLiveBtnText.defaultMessage);
expect(viewLiveLink).toHaveAttribute('href', props.lmsLink);
});
Expand All @@ -63,7 +64,7 @@ describe('<CardItem />', () => {
const dropDownMenu = getByTestId('toggle-dropdown');
fireEvent.click(dropDownMenu);
const btnReRunCourse = getByText(messages.btnReRunText.defaultMessage);
expect(btnReRunCourse).toHaveAttribute('href', props.rerunLink);
expect(btnReRunCourse).toHaveAttribute('href', trimSlashes(props.rerunLink));
const viewLiveLink = getByText(messages.viewLiveBtnText.defaultMessage);
expect(viewLiveLink).toHaveAttribute('href', props.lmsLink);
});
Expand Down
5 changes: 3 additions & 2 deletions src/studio-home/card-item/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { getConfig } from '@edx/frontend-platform';
import { COURSE_CREATOR_STATES } from '../../constants';
import { getStudioHomeData } from '../data/selectors';
import messages from '../messages';
import { trimSlashes } from './utils';

const CardItem = ({
intl,
Expand Down Expand Up @@ -69,7 +70,7 @@ const CardItem = ({
/>
<Dropdown.Menu>
{isShowRerunLink && (
<Dropdown.Item href={rerunLink}>
<Dropdown.Item href={trimSlashes(rerunLink)}>
{messages.btnReRunText.defaultMessage}
</Dropdown.Item>
)}
Expand All @@ -83,7 +84,7 @@ const CardItem = ({
{isShowRerunLink && (
<Hyperlink
className="small"
destination={rerunLink}
destination={trimSlashes(rerunLink)}
key={`action-row-rerunLink-${courseKey}`}
>
{intl.formatMessage(messages.btnReRunText)}
Expand Down
7 changes: 7 additions & 0 deletions src/studio-home/card-item/utils.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/**
* Removes leading and trailing slashes from a string.
* @param {string} str - The string to trim.
* @returns {string} The trimmed string.
*/
// eslint-disable-next-line import/prefer-default-export
export const trimSlashes = (str) => str.replace(/^\/|\/$/g, '');
Loading