Skip to content

Commit c4ce85d

Browse files
committed
refactor: remove legacy waffle flags consumption 1.b.ii
1 parent 18a7d5b commit c4ce85d

4 files changed

Lines changed: 5 additions & 48 deletions

File tree

src/course-unit/add-component/AddComponent.test.tsx

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
/* eslint-disable react/prop-types */
33
import userEvent, { UserEvent } from '@testing-library/user-event';
44

5-
import { mockWaffleFlags } from '@src/data/apiHooks.mock';
65
import { RenderResult } from '@testing-library/react';
76
import {
87
act,
@@ -360,19 +359,6 @@ describe('<AddComponent />', () => {
360359
}, expect.any(Function));
361360
});
362361

363-
it('adds a PDF block and launches the legacy iframe editor', async () => {
364-
const user = userEvent.setup();
365-
mockWaffleFlags({ useNewPdfEditor: false });
366-
const { getByRole, queryAllByRole } = renderComponent();
367-
await createPdfBlock({ getByRole, queryAllByRole, user });
368-
expect(handleCreateNewCourseXBlockMock).toHaveBeenCalled();
369-
expect(handleCreateNewCourseXBlockMock).toHaveBeenCalledWith({
370-
parentLocator: '123',
371-
type: COMPONENT_TYPES.pdf,
372-
// Setting the category and not supplying an additional function launches the traditional editor.
373-
category: COMPONENT_TYPES.pdf,
374-
});
375-
});
376362

377363
it('verifies "Text" component selection in modal', async () => {
378364
const user = userEvent.setup();

src/course-unit/add-component/AddComponent.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ const AddComponent = ({
8686
const [selectedComponents, setSelectedComponents] = useState<SelectedComponent[]>([]);
8787
const [usageId, setUsageId] = useState(null);
8888
const { sendMessageToIframe } = useIframe();
89-
const { useVideoGalleryFlow, useNewPdfEditor } = useWaffleFlags(courseId ?? undefined);
89+
const { useVideoGalleryFlow } = useWaffleFlags(courseId ?? undefined);
9090

9191
const courseUnit = useSelector(getCourseUnitData);
9292
const sequenceId = courseUnit?.ancestorInfo?.ancestors?.[0]?.id;
@@ -181,13 +181,13 @@ const AddComponent = ({
181181
// *in code* and not just in UI seems like a mistake in retrospect.
182182
//
183183
// There will be more of these, and soon.
184-
if (moduleName === COMPONENT_TYPES.pdf && useNewPdfEditor) {
184+
if (moduleName === COMPONENT_TYPES.pdf) {
185185
handleCreateNewCourseXBlock(
186186
{ type: moduleName, parentLocator: blockId },
187187
/* istanbul ignore next */
188188
({ courseKey, locator }) => {
189189
setCourseId(courseKey);
190-
setBlockType(moduleName);
190+
setBlockType(moduleName ?? null);
191191
setNewBlockId(locator);
192192
showXBlockEditorModal();
193193
},

src/course-unit/breadcrumbs/Breadcrumbs.test.tsx

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -151,23 +151,4 @@ describe('<Breadcrumbs />', () => {
151151
expect(dropdownItem).toHaveAttribute('href', url);
152152
});
153153

154-
it('falls back to window.location.href when the waffle flag is disabled', async () => {
155-
const user = userEvent.setup();
156-
// eslint-disable-next-line @typescript-eslint/naming-convention
157-
const { ancestor_xblocks: [{ children: [{ display_name, url }] }] } = courseSectionVerticalMock;
158-
axiosMock
159-
.onGet(getApiWaffleFlagsUrl(courseId))
160-
.reply(200, { useNewCourseOutlinePage: false });
161-
162-
const { getByText, getByRole } = renderComponent();
163-
164-
const dropdownBtn = getByText(breadcrumbsExpected.section.displayName);
165-
await user.click(dropdownBtn);
166-
167-
const dropdownItem = getByRole('link', { name: display_name });
168-
// We need waitFor here because the waffle flag defaults to true but asynchronously loads false from our axiosMock
169-
await waitFor(() => {
170-
expect(dropdownItem).toHaveAttribute('href', `${getConfig().STUDIO_BASE_URL}${url}`);
171-
});
172-
});
173154
});

src/course-unit/breadcrumbs/Breadcrumbs.tsx

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,31 +5,21 @@ import {
55
ArrowDropDown as ArrowDropDownIcon,
66
ChevronRight as ChevronRightIcon,
77
} from '@openedx/paragon/icons';
8-
import { getConfig } from '@edx/frontend-platform';
9-
10-
import { useWaffleFlags } from '../../data/apiHooks';
118
import { getCourseSectionVertical } from '../data/selectors';
129
import { adoptCourseSectionUrl, subsectionFirstUnitEditUrl } from '../utils';
1310

1411
const Breadcrumbs = ({ courseId, parentUnitId }: { courseId: string; parentUnitId: string; }) => {
1512
const { ancestorXblocks = [] } = useSelector(getCourseSectionVertical);
16-
const waffleFlags = useWaffleFlags(courseId);
17-
18-
const getPathToCourseOutlinePage = (url) => (waffleFlags.useNewCourseOutlinePage
19-
? url :
20-
`${getConfig().STUDIO_BASE_URL}${url}`);
2113

22-
const getPathToCourseUnitPage = (url) => (waffleFlags.useNewUnitPage
23-
? adoptCourseSectionUrl({ url, courseId, parentUnitId })
24-
: `${getConfig().STUDIO_BASE_URL}${url}`);
14+
const getPathToCourseUnitPage = (url) => adoptCourseSectionUrl({ url, courseId, parentUnitId });
2515

2616
// based on the level of breadcrumbs the url will differ
2717
// at the subsection level it should navigate to the first unit if available
2818
// if no unit then navigate to the subsection outline
2919
function getPathToCoursePage(index, url, usageKey: string) {
3020
let navUrl: string;
3121
if (index === 0) {
32-
navUrl = getPathToCourseOutlinePage(url);
22+
navUrl = url;
3323
} else if (index === 1) {
3424
navUrl = subsectionFirstUnitEditUrl({ courseId, subsectionId: usageKey });
3525
} else {

0 commit comments

Comments
 (0)