From 80cc5e37bc08f3c334f5f01c85a79648281a7621 Mon Sep 17 00:00:00 2001 From: Navin Karkera Date: Wed, 8 Nov 2023 21:22:36 +0530 Subject: [PATCH] refactor: improve course outline page feat: lms live link chore: update outline link fix: course outline link refactor: remove unnecessary css and rename test file refactor: remove unnecessary css from outlineSidebar test: make use of message variable instead of hardcoded text refactor: remove unnecessary h5 class test: use test id for detecting component refactor: update course outline url and some default messages --- src/CourseAuthoringRoutes.jsx | 2 +- src/course-outline/CourseOutline.jsx | 9 ++-- src/course-outline/CourseOutline.scss | 1 - src/course-outline/CourseOutline.test.jsx | 11 ++-- src/course-outline/data/api.js | 5 ++ .../enable-highlights-modal/messages.js | 2 +- .../header-navigations/HeaderNavigations.jsx | 11 ++-- .../header-navigations/HeaderNavigations.scss | 6 --- ...on.test.jsx => HeaderNavigations.test.jsx} | 8 +-- src/course-outline/hooks.jsx | 7 +-- .../outline-sidebar/OulineSidebar.scss | 3 -- .../outline-sidebar/OutlineSidebar.jsx | 4 +- .../outline-sidebar/OutlineSidebar.test.jsx | 53 ++++++++++++------- src/course-outline/status-bar/StatusBar.jsx | 16 +++--- src/course-outline/status-bar/StatusBar.scss | 2 +- src/course-outline/status-bar/messages.js | 4 +- src/generic/sub-header/SubHeader.jsx | 5 +- src/help-urls/__mocks__/helpUrls.js | 35 ++++++++++++ src/help-urls/__mocks__/index.js | 2 + src/help-urls/data/api.js | 4 +- .../entrance-exam/index.jsx | 2 +- 21 files changed, 115 insertions(+), 77 deletions(-) rename src/course-outline/header-navigations/{HeaderNavigation.test.jsx => HeaderNavigations.test.jsx} (92%) delete mode 100644 src/course-outline/outline-sidebar/OulineSidebar.scss create mode 100644 src/help-urls/__mocks__/helpUrls.js create mode 100644 src/help-urls/__mocks__/index.js diff --git a/src/CourseAuthoringRoutes.jsx b/src/CourseAuthoringRoutes.jsx index e6f675a267..6ff7f475bd 100644 --- a/src/CourseAuthoringRoutes.jsx +++ b/src/CourseAuthoringRoutes.jsx @@ -42,7 +42,7 @@ const CourseAuthoringRoutes = () => { } /> { return ( <> - +
{showSuccessAlert ? ( @@ -71,7 +71,6 @@ const CourseOutline = ({ courseId }) => { className="mt-5" title={intl.formatMessage(messages.headingTitle)} subtitle={intl.formatMessage(messages.headingSubtitle)} - withSubHeaderContent={false} headerActions={( { @@ -94,7 +93,7 @@ const CourseOutline = ({ courseId }) => {
diff --git a/src/course-outline/CourseOutline.scss b/src/course-outline/CourseOutline.scss index 516e4b7d39..732420365c 100644 --- a/src/course-outline/CourseOutline.scss +++ b/src/course-outline/CourseOutline.scss @@ -1,3 +1,2 @@ @import "./header-navigations/HeaderNavigations"; -@import "./outline-sidebar/OulineSidebar"; @import "./status-bar/StatusBar"; diff --git a/src/course-outline/CourseOutline.test.jsx b/src/course-outline/CourseOutline.test.jsx index 4087cfeee7..b6d98bc470 100644 --- a/src/course-outline/CourseOutline.test.jsx +++ b/src/course-outline/CourseOutline.test.jsx @@ -1,7 +1,5 @@ import React from 'react'; -import { - render, waitFor, cleanup, -} from '@testing-library/react'; +import { render, waitFor } from '@testing-library/react'; import { IntlProvider } from '@edx/frontend-platform/i18n'; import { AppProvider } from '@edx/frontend-platform/react'; import { initializeMockApp } from '@edx/frontend-platform'; @@ -127,9 +125,8 @@ describe('', () => { expect(getByText('4/9 completed')).toBeInTheDocument(); }); - it('check enable highlights when enable highlights query is successfully', async () => { - cleanup(); - const { getByText } = render(); + it('check highlights are enabled after enable highlights query is successful', async () => { + const { findByTestId } = render(); axiosMock .onGet(getCourseOutlineIndexApiUrl(courseId)) @@ -148,6 +145,6 @@ describe('', () => { .reply(200); await executeThunk(enableCourseHighlightsEmailsQuery(courseId), store.dispatch); - expect(getByText('Enabled')).toBeInTheDocument(); + expect(await findByTestId('highlights-enabled-span')).toBeInTheDocument(); }); }); diff --git a/src/course-outline/data/api.js b/src/course-outline/data/api.js index dbc68e8cb9..9b613bf81c 100644 --- a/src/course-outline/data/api.js +++ b/src/course-outline/data/api.js @@ -2,22 +2,27 @@ import { camelCaseObject, getConfig } from '@edx/frontend-platform'; import { getAuthenticatedHttpClient } from '@edx/frontend-platform/auth'; const getApiBaseUrl = () => getConfig().STUDIO_BASE_URL; + export const getCourseOutlineIndexApiUrl = (courseId) => `${getApiBaseUrl()}/api/contentstore/v1/course_index/${courseId}`; + export const getCourseBestPracticesApiUrl = ({ courseId, excludeGraded, all, }) => `${getApiBaseUrl()}/api/courses/v1/quality/${courseId}/?exclude_graded=${excludeGraded}&all=${all}`; + export const getCourseLaunchApiUrl = ({ courseId, gradedOnly, validateOras, all, }) => `${getApiBaseUrl()}/api/courses/v1/validation/${courseId}/?graded_only=${gradedOnly}&validate_oras=${validateOras}&all=${all}`; + export const getEnableHighlightsEmailsApiUrl = (courseId) => { const formattedCourseId = courseId.split('course-v1:')[1]; return `${getApiBaseUrl()}/xblock/block-v1:${formattedCourseId}+type@course+block@course`; }; + export const getCourseReindexApiUrl = (reindexLink) => `${getApiBaseUrl()}${reindexLink}`; /** diff --git a/src/course-outline/enable-highlights-modal/messages.js b/src/course-outline/enable-highlights-modal/messages.js index 8a3842ff04..dbad07e941 100644 --- a/src/course-outline/enable-highlights-modal/messages.js +++ b/src/course-outline/enable-highlights-modal/messages.js @@ -19,7 +19,7 @@ const messages = defineMessages({ }, cancelButton: { id: 'course-authoring.course-outline.status-bar.modal.cancelButton', - defaultMessage: 'Not yet', + defaultMessage: 'Cancel', }, submitButton: { id: 'course-authoring.course-outline.status-bar.modal.submitButton', diff --git a/src/course-outline/header-navigations/HeaderNavigations.jsx b/src/course-outline/header-navigations/HeaderNavigations.jsx index 897cebf8df..57cdd693e2 100644 --- a/src/course-outline/header-navigations/HeaderNavigations.jsx +++ b/src/course-outline/header-navigations/HeaderNavigations.jsx @@ -5,6 +5,7 @@ import { Button, OverlayTrigger, Tooltip } from '@edx/paragon'; import { Add as IconAdd, ArrowDropDown as ArrowDownIcon, + ArrowDropUp as ArrowUpIcon, } from '@edx/paragon/icons'; import messages from './messages'; @@ -17,7 +18,7 @@ const HeaderNavigations = ({ }) => { const intl = useIntl(); const { - handleNewSection, handleReIndex, handleExpandAll, handleViewLive, + handleNewSection, handleReIndex, handleExpandAll, lmsLink, } = headerNavigationsActions; return ( @@ -57,8 +58,7 @@ const HeaderNavigations = ({ )}