Skip to content

Commit b265b14

Browse files
authored
Revert "fix: unit link in preview mode"
This reverts commit 65be2d4.
1 parent 3f29e06 commit b265b14

2 files changed

Lines changed: 4 additions & 38 deletions

File tree

src/courseware/course/sidebar/sidebars/course-outline/components/SidebarUnit.test.jsx

Lines changed: 2 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,12 @@ describe('<SidebarUnit />', () => {
3636
};
3737
};
3838

39-
function renderWithProvider(props = {}, sidebarContext = defaultSidebarContext, pathname = '/course') {
39+
function renderWithProvider(props = {}, sidebarContext = defaultSidebarContext) {
4040
const { container } = render(
4141
<AppProvider store={store} wrapWithRouter={false}>
4242
<IntlProvider locale="en">
4343
<SidebarContext.Provider value={{ ...sidebarContext }}>
44-
<MemoryRouter initialEntries={[{ pathname }]}>
44+
<MemoryRouter>
4545
<SidebarUnit
4646
isFirst
4747
id={unit.id}
@@ -138,34 +138,4 @@ describe('<SidebarUnit />', () => {
138138
expect(window.sessionStorage.getItem('hideCourseOutlineSidebar')).toEqual('true');
139139
});
140140
});
141-
142-
describe('UnitLinkWrapper', () => {
143-
describe('course in preview mode', () => {
144-
beforeEach(async () => {
145-
await initTestStore();
146-
renderWithProvider({ unit: { ...unit } }, { ...defaultSidebarContext, shouldDisplayFullScreen: true }, '/preview/course');
147-
});
148-
149-
it('href includes /preview', async () => {
150-
const unitLink = screen.getByText(unit.title).closest('a');
151-
const linkHref = unitLink.getAttribute('href');
152-
153-
expect(linkHref.includes('/preview/')).toBeTruthy();
154-
});
155-
});
156-
157-
describe('course in live mode', () => {
158-
beforeEach(async () => {
159-
await initTestStore();
160-
renderWithProvider({ unit: { ...unit } }, { ...defaultSidebarContext, shouldDisplayFullScreen: true });
161-
});
162-
163-
it('href does not include /preview/', async () => {
164-
const unitLink = screen.getByText(unit.title).closest('a');
165-
const linkHref = unitLink.getAttribute('href');
166-
167-
expect(linkHref.includes('/preview/')).toBeFalsy();
168-
});
169-
});
170-
});
171141
});

src/courseware/course/sidebar/sidebars/course-outline/components/UnitLinkWrapper.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react';
2-
import { Link, useLocation } from 'react-router-dom';
2+
import { Link } from 'react-router-dom';
33

44
import { useCourseOutlineSidebar } from '../hooks';
55

@@ -27,14 +27,10 @@ const UnitLinkWrapper: React.FC<Props> = ({
2727
children,
2828
}) => {
2929
const { handleUnitClick } = useCourseOutlineSidebar();
30-
const { pathname } = useLocation();
31-
const isPreview = pathname.startsWith('/preview');
32-
const baseUrl = `/course/${courseId}/${sequenceId}/${id}`;
33-
const link = isPreview ? `/preview${baseUrl}` : baseUrl;
3430

3531
return (
3632
<Link
37-
to={link}
33+
to={`/course/${courseId}/${sequenceId}/${id}`}
3834
className="row w-100 m-0 d-flex align-items-center text-gray-700"
3935
onClick={() => handleUnitClick({ sequenceId, activeUnitId, id })}
4036
>

0 commit comments

Comments
 (0)