diff --git a/src/app.test.ts b/src/app.test.ts
index 6d140d2380..62f731814d 100644
--- a/src/app.test.ts
+++ b/src/app.test.ts
@@ -9,6 +9,7 @@ import {
} from '@openedx/frontend-base';
import { learningApp } from './index';
+import { courseInfoStripApp } from './widgets/CourseInfoStrip';
import { coursewareSearchApp } from './widgets/CoursewareSearch';
import { coursewareTabApp } from './widgets/CoursewareTab';
import { datesTabApp } from './widgets/DatesTab';
@@ -24,6 +25,7 @@ import {
coursewareRole,
learningCourseRole,
learningRole,
+ pathwayRole,
} from './constants';
const [main] = learningApp.routes ?? [];
@@ -35,6 +37,7 @@ describe('learningApp', () => {
expect(learningApp.appId).toBe('org.openedx.frontend.app.learning');
expect(learningApp.slots).toEqual([
...(learningHeaderApp.slots ?? []),
+ ...(courseInfoStripApp.slots ?? []),
...(coursewareSearchApp.slots ?? []),
...(discussionsSidebarApp.slots ?? []),
...(outlineTabApp.slots ?? []),
@@ -87,6 +90,7 @@ describe('learningApp', () => {
[':sequenceId/:unitId', [coursewareRole]],
]);
expect(nonCourse.map((route) => [route.path, route.handle?.roles])).toEqual([
+ ['pathway/:pathwayId', [pathwayRole]],
['goal-unsubscribe/:token', undefined],
['redirect', undefined],
['preferences-unsubscribe/:userToken/:updatePatch?', undefined],
@@ -121,6 +125,10 @@ describe('role resolution', () => {
expect(url).not.toMatch(/:targetUserId/);
});
+ it('pathway resolves to the pathway, which prefix-matches every pathway tab', () => {
+ expect(getUrlByRouteRole(pathwayRole)).toBe('/learning/pathway/:pathwayId');
+ });
+
it('courseware resolves to the bare course path (an index route, hence the slash), not a sequence, unit or preview path', () => {
const url = getUrlByRouteRole(coursewareRole);
expect(url).toBe('/learning/course/:courseId/');
diff --git a/src/constants.ts b/src/constants.ts
index 742ceec20a..760c65419f 100644
--- a/src/constants.ts
+++ b/src/constants.ts
@@ -6,6 +6,7 @@ export const courseOutlineRole = 'org.openedx.frontend.role.courseOutline';
export const courseDatesRole = 'org.openedx.frontend.role.courseDates';
export const courseProgressRole = 'org.openedx.frontend.role.courseProgress';
export const coursewareRole = 'org.openedx.frontend.role.courseware';
+export const pathwayRole = 'org.openedx.frontend.role.pathway';
export const dashboardRole = 'org.openedx.frontend.role.dashboard';
export const profileRole = 'org.openedx.frontend.role.profile';
diff --git a/src/index.ts b/src/index.ts
index f68e437715..1e7c27b9bd 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -37,6 +37,7 @@ export { default as ContentIFrame } from './courseware/course/sequence/Unit/Cont
export { getIFrameUrl } from './courseware/course/sequence/Unit/urls';
export { default as UnitNavigation } from './courseware/course/sequence/sequence-navigation/UnitNavigation';
export { CompletionIcon } from './courseware/course/sidebar/sidebars/course-outline/components/CompletionIcon';
+export { PathwayTabLink } from './pathways/pathway-tabs/PathwayTabLink';
// Data a widget cannot get from its slot's props.
export { useExamsData } from './course-home/progress-tab/hooks';
diff --git a/src/pages/PathwayAchievementsPage.test.tsx b/src/pages/PathwayAchievementsPage.test.tsx
new file mode 100644
index 0000000000..09784a984b
--- /dev/null
+++ b/src/pages/PathwayAchievementsPage.test.tsx
@@ -0,0 +1,48 @@
+import { screen } from '@testing-library/react';
+
+import * as api from '@src/pathways/data/api';
+import { dataEngineering, dataEngineeringAchievements } from '@src/pathways/data/__fixtures__/pathways';
+import routes from '@src/routes';
+import { renderRoutes } from '@src/tests/render';
+
+const mockGetPathway = jest.spyOn(api, 'getPathway');
+const mockGetPathwayAchievements = jest.spyOn(api, 'getPathwayAchievements');
+
+const pathwayId = dataEngineering.pathway.id;
+const path = `/learning/pathway/${pathwayId}/achievements`;
+
+describe('PathwayAchievementsPage', () => {
+ beforeEach(() => {
+ mockGetPathway.mockResolvedValue(dataEngineering);
+ mockGetPathwayAchievements.mockResolvedValue(dataEngineeringAchievements);
+ });
+
+ it('shows a card for each achievement of the pathway in the URL', async () => {
+ renderRoutes(routes, path);
+
+ expect(await screen.findAllByRole('button', { name: 'View certificate' }))
+ .toHaveLength(dataEngineeringAchievements.length);
+ dataEngineeringAchievements.forEach(({ displayName }) => {
+ expect(screen.getByText(displayName)).toBeInTheDocument();
+ });
+ expect(screen.getByRole('link', { name: 'Achievements' })).toHaveClass('active');
+ expect(mockGetPathway).toHaveBeenCalledWith(pathwayId);
+ expect(mockGetPathwayAchievements).toHaveBeenCalledWith(pathwayId);
+ });
+
+ it('tells the learner they have no achievements yet when the pathway has none', async () => {
+ mockGetPathwayAchievements.mockResolvedValue([]);
+ renderRoutes(routes, path);
+
+ expect(await screen.findByText('No achievements earned yet.')).toBeInTheDocument();
+ expect(screen.queryByRole('button', { name: 'View certificate' })).not.toBeInTheDocument();
+ });
+
+ it('shows an error instead of the achievements when they cannot be loaded', async () => {
+ mockGetPathwayAchievements.mockRejectedValue(new Error('network error'));
+ renderRoutes(routes, path);
+
+ expect(await screen.findByText('There was an error loading this pathway.')).toBeInTheDocument();
+ expect(screen.queryByRole('button', { name: 'View certificate' })).not.toBeInTheDocument();
+ });
+});
diff --git a/src/pages/PathwayAchievementsPage.tsx b/src/pages/PathwayAchievementsPage.tsx
new file mode 100644
index 0000000000..cff186fcab
--- /dev/null
+++ b/src/pages/PathwayAchievementsPage.tsx
@@ -0,0 +1,28 @@
+import { useParams } from 'react-router-dom';
+
+import { usePathway, usePathwayAchievements } from '@src/pathways/data/apiHooks';
+import { PATHWAY_TAB_SLUGS } from '@src/pathways/pathway-tabs/constants';
+import { PathwayAchievements } from '@src/pathways/pathways-achievements/PathwayAchievements';
+import { TabPage } from '@src/pathways/tab-page/TabPage';
+
+const PathwayAchievementsPage = () => {
+ const { pathwayId } = useParams();
+
+ const metadataQuery = usePathway(pathwayId);
+ const tabDataQuery = usePathwayAchievements(pathwayId);
+
+ return (
+
+
+
+ );
+};
+
+export default PathwayAchievementsPage;
diff --git a/src/pages/PathwayOutlinePage.tsx b/src/pages/PathwayOutlinePage.tsx
new file mode 100644
index 0000000000..10b4085a5a
--- /dev/null
+++ b/src/pages/PathwayOutlinePage.tsx
@@ -0,0 +1,23 @@
+import { useParams } from 'react-router-dom';
+
+import { usePathway } from '@src/pathways/data/apiHooks';
+import { PATHWAY_TAB_SLUGS } from '@src/pathways/pathway-tabs/constants';
+import { TabPage } from '@src/pathways/tab-page/TabPage';
+
+const PathwayOutlinePage = () => {
+ const { pathwayId } = useParams();
+
+ const metadataQuery = usePathway(pathwayId);
+
+ return (
+
+ Outline
+
+ );
+};
+
+export default PathwayOutlinePage;
diff --git a/src/pages/PathwayPages.test.tsx b/src/pages/PathwayPages.test.tsx
new file mode 100644
index 0000000000..5c419d0843
--- /dev/null
+++ b/src/pages/PathwayPages.test.tsx
@@ -0,0 +1,43 @@
+import { render, screen } from '@testing-library/react';
+import { MemoryRouter, Route, Routes } from 'react-router-dom';
+
+import { usePathway } from '@src/pathways/data/apiHooks';
+import { TabPage } from '@src/pathways/tab-page/TabPage';
+import PathwayOutlinePage from './PathwayOutlinePage';
+
+jest.mock('@src/pathways/data/apiHooks', () => ({
+ usePathway: jest.fn(),
+}));
+
+jest.mock('@src/pathways/tab-page/TabPage', () => ({
+ TabPage: jest.fn(({ children }) =>
{children}
),
+}));
+
+const metadataQuery = { data: undefined };
+
+// The pathway pages render their content inside the pathway TabPage
+describe.each([
+ { Page: PathwayOutlinePage, activeTabSlug: 'outline', content: 'Outline' },
+])('$Page.name', ({ Page, activeTabSlug, content }) => {
+ beforeEach(() => {
+ jest.clearAllMocks();
+ (usePathway as jest.Mock).mockReturnValue(metadataQuery);
+ });
+
+ it('renders its tab of the pathway in the URL', () => {
+ render(
+
+
+ } />
+
+ ,
+ );
+
+ expect(usePathway).toHaveBeenCalledWith('pathway-1');
+ expect(TabPage).toHaveBeenCalledWith(
+ expect.objectContaining({ activeTabSlug, pathwayId: 'pathway-1', pathwayStatus: { metadataQuery } }),
+ expect.anything(),
+ );
+ expect(screen.getByText(content)).toBeInTheDocument();
+ });
+});
diff --git a/src/pages/PathwayProgressPage.test.tsx b/src/pages/PathwayProgressPage.test.tsx
new file mode 100644
index 0000000000..9e19c04401
--- /dev/null
+++ b/src/pages/PathwayProgressPage.test.tsx
@@ -0,0 +1,53 @@
+import { screen } from '@testing-library/react';
+
+import * as api from '@src/pathways/data/api';
+import {
+ dataEngineering, dataEngineeringAchievements, dataEngineeringProgress,
+} from '@src/pathways/data/__fixtures__/pathways';
+import routes from '@src/routes';
+import { renderRoutes } from '@src/tests/render';
+
+const mockGetPathway = jest.spyOn(api, 'getPathway');
+const mockGetPathwayAchievements = jest.spyOn(api, 'getPathwayAchievements');
+const mockGetPathwayProgress = jest.spyOn(api, 'getPathwayProgress');
+
+const pathwayId = dataEngineering.pathway.id;
+const path = `/learning/pathway/${pathwayId}/progress`;
+
+describe('PathwayProgressPage', () => {
+ beforeEach(() => {
+ mockGetPathway.mockResolvedValue(dataEngineering);
+ mockGetPathwayProgress.mockResolvedValue(dataEngineeringProgress);
+ mockGetPathwayAchievements.mockResolvedValue([]);
+ });
+
+ it('shows the completion, grades and achievements of the pathway in the URL', async () => {
+ renderRoutes(routes, path);
+
+ expect(await screen.findByRole('heading', { name: 'Bootcamp completion' })).toBeInTheDocument();
+ expect(screen.getByRole('img', { name: '3 of 6 items completed' })).toBeInTheDocument();
+ expect(screen.getByRole('row', { name: /Data Pipelines/ })).toBeInTheDocument();
+ expect(screen.getByText('No achievements earned')).toBeInTheDocument();
+ expect(screen.getByRole('link', { name: 'Progress' })).toHaveClass('active');
+
+ expect(mockGetPathway).toHaveBeenCalledWith(pathwayId);
+ expect(mockGetPathwayProgress).toHaveBeenCalledWith(pathwayId);
+ expect(mockGetPathwayAchievements).toHaveBeenCalledWith(pathwayId);
+ });
+
+ it('links to the achievements when the learner has earned some', async () => {
+ mockGetPathwayAchievements.mockResolvedValue(dataEngineeringAchievements);
+ renderRoutes(routes, path);
+
+ expect(await screen.findByRole('link', { name: 'View achievements' }))
+ .toHaveAttribute('href', `/learning/pathway/${pathwayId}/achievements`);
+ });
+
+ it('shows an error instead of the progress when it cannot be loaded', async () => {
+ mockGetPathwayProgress.mockRejectedValue(new Error('network error'));
+ renderRoutes(routes, path);
+
+ expect(await screen.findByText('There was an error loading this pathway.')).toBeInTheDocument();
+ expect(screen.queryByRole('heading', { name: 'Bootcamp completion' })).not.toBeInTheDocument();
+ });
+});
diff --git a/src/pages/PathwayProgressPage.tsx b/src/pages/PathwayProgressPage.tsx
new file mode 100644
index 0000000000..191b3c2a0c
--- /dev/null
+++ b/src/pages/PathwayProgressPage.tsx
@@ -0,0 +1,33 @@
+import { useParams } from 'react-router-dom';
+
+import { usePathway, usePathwayAchievements, usePathwayProgress } from '@src/pathways/data/apiHooks';
+import { PATHWAY_TAB_SLUGS } from '@src/pathways/pathway-tabs/constants';
+import { PathwayProgress } from '@src/pathways/pathway-progress/PathwayProgress';
+import { TabPage } from '@src/pathways/tab-page/TabPage';
+
+const PathwayProgressPage = () => {
+ const { pathwayId } = useParams() as { pathwayId: string };
+
+ const metadataQuery = usePathway(pathwayId);
+ const progressQuery = usePathwayProgress(pathwayId);
+ const achievementsQuery = usePathwayAchievements(pathwayId);
+
+ return (
+
+
+
+ );
+};
+
+export default PathwayProgressPage;
diff --git a/src/pathways/data/__fixtures__/pathways.ts b/src/pathways/data/__fixtures__/pathways.ts
new file mode 100644
index 0000000000..ed4a10afdc
--- /dev/null
+++ b/src/pathways/data/__fixtures__/pathways.ts
@@ -0,0 +1,158 @@
+import type {
+ PathwayAchievementData, PathwayData, PathwayProgressData, PathwaysByCourse,
+} from '../types';
+
+export const dataEngineering: PathwayData = {
+ pathway: {
+ id: 'pathway-1',
+ content: { displayName: 'Data Engineering Fundamentals' },
+ itemCount: 6,
+ category: 'bootcamp',
+ categoryLabel: 'Bootcamp',
+ },
+ progress: { completedItemCount: 3 },
+ provider: { name: 'MIT OpenCourseWare' },
+};
+
+export const machineLearning: PathwayData = {
+ pathway: {
+ id: 'pathway-2',
+ content: { displayName: 'Introduction to Machine Learning' },
+ itemCount: 12,
+ category: 'tutorial',
+ categoryLabel: 'Tutorial',
+ categoryBackgroundColor: '#FCE4F3',
+ categoryTextColor: '#9B1766',
+ },
+ progress: { completedItemCount: 0 },
+ provider: { name: 'Stanford' },
+};
+
+export const loremIpsum: PathwayData = {
+ pathway: {
+ id: 'pathway-3',
+ content: { displayName: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod' },
+ itemCount: 4,
+ category: 'tutorial',
+ categoryLabel: 'Tutorial',
+ },
+ progress: { completedItemCount: 1 },
+ provider: { name: 'Stanford' },
+};
+
+export const sedUt: PathwayData = {
+ pathway: {
+ id: 'pathway-4',
+ content: { displayName: 'Sed ut perspiciatis unde omnis iste natus' },
+ itemCount: 3,
+ category: 'tutorial',
+ categoryLabel: 'Tutorial',
+ },
+ progress: { completedItemCount: 0 },
+};
+
+export const nemoEnim: PathwayData = {
+ pathway: {
+ id: 'pathway-5',
+ content: { displayName: 'Nemo enim ipsam voluptatem' },
+ itemCount: 5,
+ category: 'certificate',
+ categoryLabel: 'Certificate',
+ },
+ progress: { completedItemCount: 2 },
+};
+
+export const courseIdWithPathways = 'course-v1:edX+DemoX+Demo_Course';
+export const courseIdWithManyPathways = 'course-v1:edX+Many+Pathways';
+export const courseIdWithoutPathways = 'course-v1:edX+No+Pathways';
+
+export const pathwaysByCourse: PathwaysByCourse = {
+ [courseIdWithPathways]: [dataEngineering, machineLearning],
+ [courseIdWithManyPathways]: [dataEngineering, machineLearning, loremIpsum, sedUt, nemoEnim],
+};
+
+export const dataEngineeringProgress: PathwayProgressData = {
+ id: 'pathway-1',
+ itemCount: 6,
+ completedItemCount: 3,
+ grades: [
+ {
+ displayName: 'Introduction to Data Engineering',
+ progress: 100,
+ passGrade: 70,
+ currentGrade: 85,
+ detailsUrl: '/learning/course/course-v1:edX+DE101+2026/progress',
+ },
+ {
+ displayName: 'Data Pipelines',
+ progress: 40,
+ passGrade: 70,
+ currentGrade: 30,
+ detailsUrl: '/learning/course/course-v1:edX+DE102+2026/progress',
+ },
+ {
+ displayName: 'Data Warehousing',
+ progress: 65,
+ passGrade: 60,
+ currentGrade: 55,
+ detailsUrl: '/learning/course/course-v1:edX+DE103+2026/progress',
+ },
+ {
+ displayName: 'Stream Processing',
+ progress: 0,
+ passGrade: 70,
+ currentGrade: 0,
+ detailsUrl: '/learning/course/course-v1:edX+DE104+2026/progress',
+ },
+ {
+ displayName: 'Machine Learning Operations for Production Systems on Kubernetes',
+ progress: 20,
+ passGrade: 70,
+ currentGrade: 15,
+ detailsUrl: '/learning/course/course-v1:edX+DE105+2026/progress',
+ },
+ ],
+};
+
+export const dataEngineeringAchievements: PathwayAchievementData[] = [
+ {
+ credentialId: 'a1b2c3d4e5f60718293a4b5c6d7e8f90',
+ displayName: 'Data Engineering Fundamentals',
+ providerName: 'MIT OpenCourseWare',
+ completedOn: '2026-08-11',
+ certificateUrl: '/certificates/a1b2c3d4e5f60718293a4b5c6d7e8f90',
+ isOverarching: true,
+ },
+ {
+ credentialId: 'b2c3d4e5f60718293a4b5c6d7e8f90a1',
+ displayName: 'Introduction to Data Engineering with Python, SQL and Cloud Tools',
+ providerName: 'MIT OpenCourseWare',
+ completedOn: '2026-07-02',
+ certificateUrl: '/certificates/b2c3d4e5f60718293a4b5c6d7e8f90a1',
+ isOverarching: false,
+ },
+ {
+ credentialId: 'c3d4e5f60718293a4b5c6d7e8f90a1b2',
+ displayName: 'Data Pipelines',
+ providerName: 'MIT OpenCourseWare',
+ completedOn: '2026-07-20',
+ certificateUrl: '/certificates/c3d4e5f60718293a4b5c6d7e8f90a1b2',
+ isOverarching: false,
+ },
+ {
+ credentialId: 'd4e5f60718293a4b5c6d7e8f90a1b2c3',
+ displayName: 'Data Warehousing',
+ providerName: 'MIT OpenCourseWare',
+ completedOn: '2026-07-28',
+ certificateUrl: '/certificates/d4e5f60718293a4b5c6d7e8f90a1b2c3',
+ isOverarching: false,
+ },
+ {
+ credentialId: 'e5f60718293a4b5c6d7e8f90a1b2c3d4',
+ displayName: 'Stream Processing',
+ providerName: 'MIT OpenCourseWare',
+ completedOn: '2026-08-05',
+ certificateUrl: '/certificates/e5f60718293a4b5c6d7e8f90a1b2c3d4',
+ isOverarching: false,
+ },
+];
diff --git a/src/pathways/data/api.test.ts b/src/pathways/data/api.test.ts
new file mode 100644
index 0000000000..c8129f3707
--- /dev/null
+++ b/src/pathways/data/api.test.ts
@@ -0,0 +1,33 @@
+import {
+ getPathway, getPathwayAchievements, getPathwayProgress, getPathwaysByCourse,
+} from './api';
+
+describe('course-pathways api', () => {
+ describe('getPathwaysByCourse', () => {
+ // Until the backend exists, no course has pathways
+ it('returns an empty map', async () => {
+ await expect(getPathwaysByCourse(['course-v1:edX+DemoX+Demo_Course'])).resolves.toEqual({});
+ });
+ });
+
+ describe('getPathway', () => {
+ // Until the backend exists, every request fails
+ it('fails', async () => {
+ await expect(getPathway('pathway-1')).rejects.toThrow();
+ });
+ });
+
+ describe('getPathwayProgress', () => {
+ // Until the backend exists, every request fails
+ it('fails', async () => {
+ await expect(getPathwayProgress('pathway-1')).rejects.toThrow();
+ });
+ });
+
+ describe('getPathwayAchievements', () => {
+ // Until the backend exists, every request fails
+ it('fails', async () => {
+ await expect(getPathwayAchievements('pathway-1')).rejects.toThrow();
+ });
+ });
+});
diff --git a/src/pathways/data/api.ts b/src/pathways/data/api.ts
new file mode 100644
index 0000000000..17367c0c29
--- /dev/null
+++ b/src/pathways/data/api.ts
@@ -0,0 +1,42 @@
+import type {
+ PathwayAchievementData, PathwayData, PathwayProgressData, PathwaysByCourse,
+} from './types';
+
+// TODO The backend is missing.
+// This endpoint should receive a list of course IDs and return a map
+// containing the pathways in which the learner is enrolled for each course.
+// The response must be mapped here to the `PathwayData` shape.
+// eslint-disable-next-line @typescript-eslint/no-unused-vars
+export const getPathwaysByCourse = async (_courseIds: string[]): Promise => ({});
+
+// TODO The backend is missing.
+// This endpoint should receive a pathway ID and return that pathway, with the learner's
+// progress in it. A missing pathway or a learner without access must make the request fail.
+// The response must be mapped here to the `PathwayData` shape.
+// Until then, every request fails.
+// eslint-disable-next-line @typescript-eslint/no-unused-vars
+export const getPathway = async (_pathwayId: string): Promise => {
+ throw new Error('The pathway backend is missing');
+};
+
+// TODO The backend is missing.
+// This endpoint should receive a pathway ID and return the learner's progress in that pathway,
+// with the grade of each of its items.
+// The response must be mapped here to the `PathwayProgressData` shape. The `detailsUrl` of each grade must come
+// complete from the backend (absolute, or with the path the destination app is mounted at): an item is not always a
+// course, so the UI cannot build it.
+// Until then, every request fails.
+// eslint-disable-next-line @typescript-eslint/no-unused-vars
+export const getPathwayProgress = async (_pathwayId: string): Promise => {
+ throw new Error('The pathway progress backend is missing');
+};
+
+// TODO The backend is missing.
+// This endpoint should receive a pathway ID and return the achievements the learner
+// has earned in that pathway: the certificate of the pathway itself and those of its items.
+// The response must be mapped here to the `PathwayAchievementData` shape.
+// Until then, every request fails.
+// eslint-disable-next-line @typescript-eslint/no-unused-vars
+export const getPathwayAchievements = async (_pathwayId: string): Promise => {
+ throw new Error('The pathway achievements backend is missing');
+};
diff --git a/src/pathways/data/apiHooks.test.tsx b/src/pathways/data/apiHooks.test.tsx
new file mode 100644
index 0000000000..842cb7cbd9
--- /dev/null
+++ b/src/pathways/data/apiHooks.test.tsx
@@ -0,0 +1,164 @@
+import { renderHook, waitFor } from '@testing-library/react';
+import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
+
+import * as api from './api';
+import {
+ useCoursePathways, usePathway, usePathwayAchievements, usePathwayProgress,
+} from './apiHooks';
+import {
+ courseIdWithPathways,
+ courseIdWithoutPathways,
+ dataEngineering,
+ dataEngineeringAchievements,
+ dataEngineeringProgress,
+ machineLearning,
+ pathwaysByCourse,
+} from './__fixtures__/pathways';
+
+const mockGetPathway = jest.spyOn(api, 'getPathway');
+const mockGetPathwayAchievements = jest.spyOn(api, 'getPathwayAchievements');
+const mockGetPathwayProgress = jest.spyOn(api, 'getPathwayProgress');
+const mockGetPathwaysByCourse = jest.spyOn(api, 'getPathwaysByCourse');
+
+const buildWrapper = () => {
+ const queryClient = new QueryClient({
+ defaultOptions: { queries: { retry: false } },
+ });
+ const wrapper = ({ children }) => (
+ {children}
+ );
+ return { wrapper };
+};
+
+describe('course-pathways apiHooks', () => {
+ beforeEach(() => {
+ mockGetPathway.mockReset();
+ mockGetPathwayAchievements.mockReset();
+ mockGetPathwayProgress.mockReset();
+ mockGetPathwaysByCourse.mockReset();
+ });
+
+ describe('useCoursePathways', () => {
+ it('requests the pathways of the given course', async () => {
+ mockGetPathwaysByCourse.mockResolvedValue(pathwaysByCourse);
+ const { wrapper } = buildWrapper();
+ const { result } = renderHook(() => useCoursePathways(courseIdWithPathways), { wrapper });
+
+ await waitFor(() => expect(result.current.isSuccess).toBe(true));
+ expect(mockGetPathwaysByCourse).toHaveBeenCalledWith([courseIdWithPathways]);
+ });
+
+ it('returns only the pathways of the given course', async () => {
+ mockGetPathwaysByCourse.mockResolvedValue(pathwaysByCourse);
+ const { wrapper } = buildWrapper();
+ const { result } = renderHook(() => useCoursePathways(courseIdWithPathways), { wrapper });
+
+ await waitFor(() => expect(result.current.isSuccess).toBe(true));
+ expect(result.current.data).toEqual([dataEngineering, machineLearning]);
+ });
+
+ it('returns an empty list when the course has no pathways', async () => {
+ mockGetPathwaysByCourse.mockResolvedValue(pathwaysByCourse);
+ const { wrapper } = buildWrapper();
+ const { result } = renderHook(() => useCoursePathways(courseIdWithoutPathways), { wrapper });
+
+ await waitFor(() => expect(result.current.isSuccess).toBe(true));
+ expect(result.current.data).toEqual([]);
+ });
+
+ it('does not request anything without a course', () => {
+ const { wrapper } = buildWrapper();
+ const { result } = renderHook(() => useCoursePathways(undefined), { wrapper });
+
+ expect(result.current.fetchStatus).toBe('idle');
+ expect(result.current.data).toBeUndefined();
+ expect(mockGetPathwaysByCourse).not.toHaveBeenCalled();
+ });
+
+ it('exposes the error when the request fails', async () => {
+ mockGetPathwaysByCourse.mockRejectedValue(new Error('network error'));
+ const { wrapper } = buildWrapper();
+ const { result } = renderHook(() => useCoursePathways(courseIdWithPathways), { wrapper });
+
+ await waitFor(() => expect(result.current.isError).toBe(true));
+ expect(result.current.data).toBeUndefined();
+ });
+ });
+
+ describe('usePathway', () => {
+ const pathwayId = dataEngineering.pathway.id;
+
+ it('returns the requested pathway', async () => {
+ mockGetPathway.mockResolvedValue(dataEngineering);
+ const { wrapper } = buildWrapper();
+ const { result } = renderHook(() => usePathway(pathwayId), { wrapper });
+
+ await waitFor(() => expect(result.current.isSuccess).toBe(true));
+ expect(mockGetPathway).toHaveBeenCalledWith(pathwayId);
+ expect(result.current.data).toEqual(dataEngineering);
+ });
+
+ it('does not request anything when disabled', () => {
+ const { wrapper } = buildWrapper();
+ const { result } = renderHook(() => usePathway(pathwayId, { enabled: false }), { wrapper });
+
+ expect(result.current.fetchStatus).toBe('idle');
+ expect(mockGetPathway).not.toHaveBeenCalled();
+ });
+
+ it('does not request anything without a pathway', () => {
+ const { wrapper } = buildWrapper();
+ const { result } = renderHook(() => usePathway(undefined), { wrapper });
+
+ expect(result.current.fetchStatus).toBe('idle');
+ expect(result.current.data).toBeUndefined();
+ expect(mockGetPathway).not.toHaveBeenCalled();
+ });
+ });
+
+ describe('usePathwayProgress', () => {
+ const pathwayId = dataEngineeringProgress.id;
+
+ it('returns the progress in the requested pathway', async () => {
+ mockGetPathwayProgress.mockResolvedValue(dataEngineeringProgress);
+ const { wrapper } = buildWrapper();
+ const { result } = renderHook(() => usePathwayProgress(pathwayId), { wrapper });
+
+ await waitFor(() => expect(result.current.isSuccess).toBe(true));
+ expect(mockGetPathwayProgress).toHaveBeenCalledWith(pathwayId);
+ expect(result.current.data).toEqual(dataEngineeringProgress);
+ });
+
+ it('does not request anything without a pathway', () => {
+ const { wrapper } = buildWrapper();
+ const { result } = renderHook(() => usePathwayProgress(undefined), { wrapper });
+
+ expect(result.current.fetchStatus).toBe('idle');
+ expect(result.current.data).toBeUndefined();
+ expect(mockGetPathwayProgress).not.toHaveBeenCalled();
+ });
+ });
+
+ describe('usePathwayAchievements', () => {
+ const pathwayId = dataEngineering.pathway.id;
+
+ it('returns the achievements earned in the requested pathway', async () => {
+ mockGetPathwayAchievements.mockResolvedValue(dataEngineeringAchievements);
+ const { wrapper } = buildWrapper();
+ const { result } = renderHook(() => usePathwayAchievements(pathwayId), { wrapper });
+
+ await waitFor(() => expect(result.current.isSuccess).toBe(true));
+ expect(mockGetPathwayAchievements).toHaveBeenCalledWith(pathwayId);
+ expect(result.current.data).toEqual(dataEngineeringAchievements);
+ });
+
+ it('does not request anything without a pathway', () => {
+ const { wrapper } = buildWrapper();
+ const { result } = renderHook(() => usePathwayAchievements(undefined), { wrapper });
+
+ expect(result.current.fetchStatus).toBe('idle');
+ expect(result.current.data).toBeUndefined();
+ expect(mockGetPathwayAchievements).not.toHaveBeenCalled();
+ });
+ });
+});
diff --git a/src/pathways/data/apiHooks.ts b/src/pathways/data/apiHooks.ts
new file mode 100644
index 0000000000..1d7d2e17aa
--- /dev/null
+++ b/src/pathways/data/apiHooks.ts
@@ -0,0 +1,46 @@
+import { appId } from '@src/constants';
+import { skipToken, useQuery } from '@tanstack/react-query';
+
+import {
+ getPathway, getPathwayAchievements, getPathwayProgress, getPathwaysByCourse,
+} from './api';
+import type { PathwayData } from './types';
+
+export const coursePathwaysQueryKeys = {
+ all: [appId, 'coursePathways'] as const,
+ course: (courseId: string) => [...coursePathwaysQueryKeys.all, courseId] as const,
+};
+
+export const pathwayQueryKeys = {
+ all: [appId, 'pathway'] as const,
+ pathway: (pathwayId: string) => [...pathwayQueryKeys.all, pathwayId] as const,
+ progress: (pathwayId: string) => [...pathwayQueryKeys.pathway(pathwayId), 'progress'] as const,
+ achievements: (pathwayId: string) => [...pathwayQueryKeys.pathway(pathwayId), 'achievements'] as const,
+};
+
+// Pathways in which the learner is enrolled that include the given course.
+export const useCoursePathways = (courseId?: string) => useQuery({
+ queryKey: coursePathwaysQueryKeys.course(courseId!),
+ queryFn: courseId ? () => getPathwaysByCourse([courseId]) : skipToken,
+ select: (pathwaysByCourse): PathwayData[] => pathwaysByCourse[courseId!] ?? [],
+});
+
+// The given pathway, with the learner's progress in it. With `enabled: false` it only reads what the pathway page
+// has already loaded.
+export const usePathway = (pathwayId?: string, { enabled = true }: { enabled?: boolean } = {}) => useQuery({
+ queryKey: pathwayQueryKeys.pathway(pathwayId!),
+ queryFn: pathwayId ? () => getPathway(pathwayId) : skipToken,
+ enabled,
+});
+
+// The learner's progress in the given pathway.
+export const usePathwayProgress = (pathwayId?: string) => useQuery({
+ queryKey: pathwayQueryKeys.progress(pathwayId!),
+ queryFn: pathwayId ? () => getPathwayProgress(pathwayId) : skipToken,
+});
+
+// The achievements the learner has earned in the given pathway.
+export const usePathwayAchievements = (pathwayId?: string) => useQuery({
+ queryKey: pathwayQueryKeys.achievements(pathwayId!),
+ queryFn: pathwayId ? () => getPathwayAchievements(pathwayId) : skipToken,
+});
diff --git a/src/pathways/data/types.ts b/src/pathways/data/types.ts
new file mode 100644
index 0000000000..9e63ff6106
--- /dev/null
+++ b/src/pathways/data/types.ts
@@ -0,0 +1,46 @@
+// The shape the UI needs. The API layer is in charge of mapping the backend response to it.
+export interface PathwayData {
+ pathway: {
+ id: string;
+ content: {
+ displayName: string;
+ };
+ itemCount: number;
+ category: string;
+ categoryLabel: string;
+ categoryBackgroundColor?: string;
+ categoryTextColor?: string;
+ };
+ progress?: {
+ completedItemCount: number;
+ };
+ provider?: {
+ name: string;
+ };
+}
+
+export interface GradeData {
+ displayName: string;
+ progress: number;
+ passGrade: number;
+ currentGrade: number;
+ detailsUrl: string;
+}
+
+export interface PathwayProgressData {
+ id: string;
+ itemCount: number;
+ completedItemCount: number;
+ grades: GradeData[];
+}
+
+export interface PathwayAchievementData {
+ credentialId: string;
+ displayName: string;
+ providerName: string;
+ completedOn: string;
+ certificateUrl: string;
+ isOverarching: boolean;
+}
+
+export type PathwaysByCourse = Record;
diff --git a/src/pathways/pathway-progress/AchievementsInfo.test.tsx b/src/pathways/pathway-progress/AchievementsInfo.test.tsx
new file mode 100644
index 0000000000..24a49c10ac
--- /dev/null
+++ b/src/pathways/pathway-progress/AchievementsInfo.test.tsx
@@ -0,0 +1,34 @@
+import { render, screen } from '@testing-library/react';
+import { MemoryRouter } from 'react-router-dom';
+import { IntlProvider } from '@openedx/frontend-base';
+
+import { AchievementsInfo } from './AchievementsInfo';
+
+const renderComponent = (hasAchievements: boolean) => render(
+
+
+
+
+ ,
+);
+
+describe('AchievementsInfo', () => {
+ it('links to the pathway achievements when the learner has some', () => {
+ renderComponent(true);
+
+ expect(screen.getByText('Achievements available')).toBeInTheDocument();
+ expect(screen.getByText(
+ "Showcase your certificates on LinkedIn, or your resume today. Access your Bootcamp's achievements below.",
+ )).toBeInTheDocument();
+ expect(screen.getByRole('link', { name: 'View achievements' }))
+ .toHaveAttribute('href', '/learning/pathway/pathway-1/achievements');
+ });
+
+ it('tells the learner there are no achievements yet, without a link', () => {
+ renderComponent(false);
+
+ expect(screen.getByText('No achievements earned')).toBeInTheDocument();
+ expect(screen.getByText('No certificates earned yet.')).toBeInTheDocument();
+ expect(screen.queryByRole('link')).not.toBeInTheDocument();
+ });
+});
diff --git a/src/pathways/pathway-progress/AchievementsInfo.tsx b/src/pathways/pathway-progress/AchievementsInfo.tsx
new file mode 100644
index 0000000000..345acb11e8
--- /dev/null
+++ b/src/pathways/pathway-progress/AchievementsInfo.tsx
@@ -0,0 +1,42 @@
+import { Link } from 'react-router-dom';
+
+import { FormattedMessage } from '@openedx/frontend-base';
+import { Button } from '@openedx/paragon';
+
+import { PATHWAY_TAB_SLUGS } from '../pathway-tabs/constants';
+import { getPathwayTabUrl } from '../urls';
+import messages from './messages';
+
+export interface AchievementsInfoProps {
+ pathwayId: string;
+ categoryLabel: string;
+ hasAchievements: boolean;
+}
+
+export const AchievementsInfo = ({ pathwayId, categoryLabel, hasAchievements }: AchievementsInfoProps) => {
+ const title = hasAchievements ? messages.achievementsInfoTitle : messages.achievementsInfoEmptyTitle;
+ const description = hasAchievements
+ ? messages.achievementsInfoDescription
+ : messages.achievementsInfoEmptyDescription;
+
+ return (
+
+
+
+
+
+
+
+ {hasAchievements && (
+
+
+
+ )}
+
+ );
+};
diff --git a/src/pathways/pathway-progress/PathwayGrades.test.tsx b/src/pathways/pathway-progress/PathwayGrades.test.tsx
new file mode 100644
index 0000000000..212c41de9c
--- /dev/null
+++ b/src/pathways/pathway-progress/PathwayGrades.test.tsx
@@ -0,0 +1,67 @@
+import { render, screen, within } from '@testing-library/react';
+import { MemoryRouter } from 'react-router-dom';
+import { IntlProvider } from '@openedx/frontend-base';
+
+import { dataEngineeringProgress } from '@src/pathways/data/__fixtures__/pathways';
+
+import { PathwayGrades } from './PathwayGrades';
+
+const { grades } = dataEngineeringProgress;
+
+const renderComponent = () => render(
+
+
+
+
+ ,
+);
+
+const getRow = (displayName: string) => screen.getByRole('row', { name: new RegExp(displayName) });
+
+describe('PathwayGrades', () => {
+ it('shows a row with the progress and grades of each course as percentages', () => {
+ renderComponent();
+
+ // The header row plus one row per grade.
+ expect(screen.getAllByRole('row')).toHaveLength(grades.length + 1);
+
+ const row = within(getRow('Data Pipelines'));
+ expect(row.getByText('40%')).toBeInTheDocument();
+ expect(row.getByText('70%')).toBeInTheDocument();
+ expect(row.getByText('30%')).toBeInTheDocument();
+ });
+
+ it('colors the current grade by whether it reaches the pass grade', () => {
+ renderComponent();
+
+ // 85% with a 70% pass grade
+ expect(within(getRow('Introduction to Data Engineering')).getByText('85%')).toHaveClass('text-success');
+ // 30% with a 70% pass grade
+ expect(within(getRow('Data Pipelines')).getByText('30%')).toHaveClass('text-danger');
+ });
+
+ it('shows no current grade for a course without progress', () => {
+ renderComponent();
+
+ const row = within(getRow('Stream Processing'));
+ expect(row.getByText('-')).toBeInTheDocument();
+ expect(row.queryByText('0%', { selector: '.text-danger' })).not.toBeInTheDocument();
+ });
+
+ it('names the column of the details links for assistive technologies only', () => {
+ renderComponent();
+
+ const header = screen.getByRole('columnheader', { name: 'Actions' });
+ expect(within(header).getByText('Actions')).toHaveClass('sr-only');
+ });
+
+ it('links each course to its grade details', () => {
+ renderComponent();
+
+ grades.forEach(({ displayName, detailsUrl }) => {
+ const link = within(getRow(displayName)).getByRole('link', { name: `View details for ${displayName}` });
+ expect(link).toHaveAttribute('href', detailsUrl);
+ expect(link).toHaveTextContent('View details');
+ });
+ });
+});
diff --git a/src/pathways/pathway-progress/PathwayGrades.tsx b/src/pathways/pathway-progress/PathwayGrades.tsx
new file mode 100644
index 0000000000..9424001165
--- /dev/null
+++ b/src/pathways/pathway-progress/PathwayGrades.tsx
@@ -0,0 +1,88 @@
+import { FormattedMessage, useIntl } from '@openedx/frontend-base';
+import { DataTable } from '@openedx/paragon';
+
+import type { GradeData } from '@src/pathways/data/types';
+
+import { Link } from 'react-router-dom';
+import messages from './messages';
+import { PathwayProgressRing } from './progress-ring/PathwayProgressRing';
+
+// The cells are defined outside of `PathwayGrades` so React does not remount them on every render.
+const PercentCell = ({ value }: { value: number }) => {
+ const intl = useIntl();
+ return <>{intl.formatNumber(value / 100, { style: 'percent' })}>;
+};
+
+const ProgressCell = ({ value }: { value: number }) => (
+
+
+
+
+);
+
+// Green when the course is passed, red otherwise
+const CurrentGradeCell = ({ value, row }: { value: number; row: { original: GradeData } }) => {
+ if (row.original.progress === 0) {
+ return <>->;
+ }
+
+ return (
+ = row.original.passGrade ? 'text-success' : 'text-danger'}>
+
+
+ );
+};
+
+// Every row shows the same link text, so the accessible name includes the course to tell them apart.
+const DetailsCell = ({ row }: { row: { original: GradeData } }) => {
+ const intl = useIntl();
+ return (
+
+
+
+ );
+};
+
+export const PathwayGrades = ({ grades }: { grades: GradeData[] }) => {
+ const intl = useIntl();
+
+ return (
+ {intl.formatMessage(messages.gradesActionsColumn)},
+ Cell: DetailsCell,
+ },
+ ]}
+ >
+
+
+ );
+};
diff --git a/src/pathways/pathway-progress/PathwayProgress.test.tsx b/src/pathways/pathway-progress/PathwayProgress.test.tsx
new file mode 100644
index 0000000000..8663282259
--- /dev/null
+++ b/src/pathways/pathway-progress/PathwayProgress.test.tsx
@@ -0,0 +1,48 @@
+import { IntlProvider } from '@openedx/frontend-base';
+import { render, screen } from '@testing-library/react';
+
+import { dataEngineeringProgress } from '../data/__fixtures__/pathways';
+import { AchievementsInfo } from './AchievementsInfo';
+import { PathwayCompletion } from './pathway-completion/PathwayCompletion';
+import { PathwayGrades } from './PathwayGrades';
+import { PathwayProgress } from './PathwayProgress';
+
+jest.mock('./AchievementsInfo', () => ({ AchievementsInfo: jest.fn(() => null) }));
+jest.mock('./pathway-completion/PathwayCompletion', () => ({ PathwayCompletion: jest.fn(() => null) }));
+jest.mock('./PathwayGrades', () => ({ PathwayGrades: jest.fn(() => null) }));
+
+const props = {
+ pathwayId: 'pathway-1',
+ categoryLabel: 'Bootcamp',
+ itemCount: dataEngineeringProgress.itemCount,
+ completedItemCount: dataEngineeringProgress.completedItemCount,
+ grades: dataEngineeringProgress.grades,
+ hasAchievements: true,
+};
+
+describe('PathwayProgress', () => {
+ beforeEach(() => {
+ jest.clearAllMocks();
+ });
+
+ it('shows the progress heading as the main one, and the grades heading beneath it', () => {
+ render( );
+
+ expect(screen.getByRole('heading', { level: 1 })).toBeInTheDocument();
+ expect(screen.getByRole('heading', { level: 2 })).toHaveClass('h1');
+ });
+
+ it('hands the completion, the grades and the achievements their part of the progress', () => {
+ render( );
+
+ expect(PathwayCompletion).toHaveBeenCalledWith(
+ { categoryLabel: 'Bootcamp', total: props.itemCount, completed: props.completedItemCount },
+ expect.anything(),
+ );
+ expect(PathwayGrades).toHaveBeenCalledWith({ grades: props.grades }, expect.anything());
+ expect(AchievementsInfo).toHaveBeenCalledWith(
+ { pathwayId: 'pathway-1', categoryLabel: 'Bootcamp', hasAchievements: true },
+ expect.anything(),
+ );
+ });
+});
diff --git a/src/pathways/pathway-progress/PathwayProgress.tsx b/src/pathways/pathway-progress/PathwayProgress.tsx
new file mode 100644
index 0000000000..3f0b831a06
--- /dev/null
+++ b/src/pathways/pathway-progress/PathwayProgress.tsx
@@ -0,0 +1,55 @@
+import { FormattedMessage } from '@openedx/frontend-base';
+import { Col, Row, Stack } from '@openedx/paragon';
+
+import type { GradeData } from '../data/types';
+import messages from './messages';
+import { AchievementsInfo } from './AchievementsInfo';
+import { PathwayCompletion } from './pathway-completion/PathwayCompletion';
+import { PathwayGrades } from './PathwayGrades';
+
+export interface PathwayProgressProps {
+ pathwayId: string;
+ categoryLabel: string;
+ itemCount: number;
+ completedItemCount: number;
+ grades: GradeData[];
+ hasAchievements: boolean;
+}
+
+export const PathwayProgress = ({
+ pathwayId,
+ categoryLabel,
+ itemCount,
+ completedItemCount,
+ grades,
+ hasAchievements,
+}: PathwayProgressProps) => (
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+);
diff --git a/src/pathways/pathway-progress/messages.ts b/src/pathways/pathway-progress/messages.ts
new file mode 100644
index 0000000000..e8086c93f0
--- /dev/null
+++ b/src/pathways/pathway-progress/messages.ts
@@ -0,0 +1,76 @@
+import { defineMessages } from '@openedx/frontend-base';
+
+const messages = defineMessages({
+ progressTitle: {
+ id: 'learning.pathways.progress.title',
+ defaultMessage: 'Your Progress',
+ description: 'Title of the progress section in the progress page',
+ },
+ gradesTitle: {
+ id: 'learning.pathways.progress.grades.title',
+ defaultMessage: 'Grades',
+ description: 'Title of the grades section in the progress page',
+ },
+ gradesCourseColumn: {
+ id: 'learning.pathways.progress.grades.table.course',
+ defaultMessage: 'Course',
+ description: 'Label for the Course column in the grades table',
+ },
+ gradesProgressColumn: {
+ id: 'learning.pathways.progress.grades.table.progress',
+ defaultMessage: 'Progress',
+ description: 'Label for the Progress column in the grades table',
+ },
+ gradesPassGradeColumn: {
+ id: 'learning.pathways.progress.grades.table.pass-grade',
+ defaultMessage: 'Pass Grade',
+ description: 'Label for the Pass Grade column in the grades table',
+ },
+ gradesCurrentGradeColumn: {
+ id: 'learning.pathways.progress.grades.table.current-grade',
+ defaultMessage: 'Current Grade',
+ description: 'Label for the Current Grade column in the grades table',
+ },
+ gradesActionsColumn: {
+ id: 'learning.pathways.progress.grades.table.actions',
+ defaultMessage: 'Actions',
+ description: 'Accessible label for the column of the grades table with the View details links. It is not shown on screen',
+ },
+ gradesViewDetails: {
+ id: 'learning.pathways.progress.grades.table.view-details',
+ defaultMessage: 'View details',
+ description: 'Label for the View details links in the grades table',
+ },
+ gradesViewDetailsFor: {
+ id: 'learning.pathways.progress.grades.table.view-details-for',
+ defaultMessage: 'View details for {courseName}',
+ description: 'Accessible label for the View details links in the grades table',
+ },
+ achievementsInfoEmptyTitle: {
+ id: 'learning.pathways.progress.achievements-info.empty.title',
+ defaultMessage: 'No achievements earned',
+ description: 'Title of the empty state of the achievements info card',
+ },
+ achievementsInfoEmptyDescription: {
+ id: 'learning.pathways.progress.achievements-info.empty.description',
+ defaultMessage: 'No certificates earned yet.',
+ description: 'Description of the empty state of the achievements info card',
+ },
+ achievementsInfoTitle: {
+ id: 'learning.pathways.progress.achievements-info.title',
+ defaultMessage: 'Achievements available',
+ description: 'Title of the achievements info card',
+ },
+ achievementsInfoDescription: {
+ id: 'learning.pathways.progress.achievements-info.description',
+ defaultMessage: "Showcase your certificates on LinkedIn, or your resume today. Access your {categoryLabel}'s achievements below.",
+ description: 'Description of the achievements info card',
+ },
+ achievementsInfoButton: {
+ id: 'learning.pathways.progress.achievements-info.button',
+ defaultMessage: 'View achievements',
+ description: 'Label of the button of the achievements info card',
+ },
+});
+
+export default messages;
diff --git a/src/pathways/pathway-progress/pathway-completion/PathwayCompletion.test.tsx b/src/pathways/pathway-progress/pathway-completion/PathwayCompletion.test.tsx
new file mode 100644
index 0000000000..70c6430964
--- /dev/null
+++ b/src/pathways/pathway-progress/pathway-completion/PathwayCompletion.test.tsx
@@ -0,0 +1,21 @@
+import { render, screen } from '@testing-library/react';
+import { IntlProvider } from '@openedx/frontend-base';
+
+import { PathwayCompletion } from './PathwayCompletion';
+
+const renderComponent = () => render(
+
+
+ ,
+);
+
+describe('PathwayCompletion', () => {
+ it('names the pathway category in its title and description', () => {
+ renderComponent();
+
+ expect(screen.getByRole('heading', { name: 'Bootcamp completion' })).toBeInTheDocument();
+ expect(
+ screen.getByText('This represents how many items you have completed in this Bootcamp.'),
+ ).toBeInTheDocument();
+ });
+});
diff --git a/src/pathways/pathway-progress/pathway-completion/PathwayCompletion.tsx b/src/pathways/pathway-progress/pathway-completion/PathwayCompletion.tsx
new file mode 100644
index 0000000000..0387e3535c
--- /dev/null
+++ b/src/pathways/pathway-progress/pathway-completion/PathwayCompletion.tsx
@@ -0,0 +1,31 @@
+import { FormattedMessage } from '@openedx/frontend-base';
+import messages from './messages';
+import { PathwayProgressDonut } from './PathwayProgressDonut';
+
+export interface PathwayCompletionProps {
+ categoryLabel: string;
+ completed: number;
+ total: number;
+}
+
+export const PathwayCompletion = ({
+ categoryLabel,
+ completed,
+ total,
+}: PathwayCompletionProps) => (
+
+);
diff --git a/src/pathways/pathway-progress/pathway-completion/PathwayProgressDonut.scss b/src/pathways/pathway-progress/pathway-completion/PathwayProgressDonut.scss
new file mode 100644
index 0000000000..b0d927bf4c
--- /dev/null
+++ b/src/pathways/pathway-progress/pathway-completion/PathwayProgressDonut.scss
@@ -0,0 +1,21 @@
+.learning-pathway-progress-donut {
+ width: 100%;
+ max-width: 178px;
+
+ .donut-count,
+ .donut-label {
+ fill: var(--pgn-color-primary-500);
+ font-family: var(--pgn-typography-font-family-sans-serif);
+ text-anchor: middle;
+ }
+
+ .donut-count {
+ font-size: 8px;
+ font-weight: var(--pgn-typography-font-weight-bold);
+ }
+
+ .donut-label {
+ font-size: 3.2px;
+ font-weight: var(--pgn-typography-font-weight-normal);
+ }
+}
diff --git a/src/pathways/pathway-progress/pathway-completion/PathwayProgressDonut.test.tsx b/src/pathways/pathway-progress/pathway-completion/PathwayProgressDonut.test.tsx
new file mode 100644
index 0000000000..a696935d54
--- /dev/null
+++ b/src/pathways/pathway-progress/pathway-completion/PathwayProgressDonut.test.tsx
@@ -0,0 +1,35 @@
+import { render, screen } from '@testing-library/react';
+import { IntlProvider } from '@openedx/frontend-base';
+
+import { PathwayProgressDonut } from './PathwayProgressDonut';
+
+const renderComponent = (completed: number, total: number) => render(
+
+
+ ,
+);
+
+const getSegment = (container: HTMLElement) => container.querySelector('.progress-ring-segment');
+
+describe('PathwayProgressDonut', () => {
+ it('shows the completed and total items in its center and describes them to assistive technologies', () => {
+ renderComponent(1, 6);
+
+ expect(screen.getByText('1/6')).toBeInTheDocument();
+ expect(screen.getByText('completed')).toBeInTheDocument();
+ expect(screen.getByRole('img', { name: '1 of 6 items completed' })).toBeInTheDocument();
+ });
+
+ it('fills the share of the ring that is completed', () => {
+ const { container } = renderComponent(3, 6);
+
+ expect(getSegment(container)).toHaveAttribute('stroke-dasharray', '50 50');
+ });
+
+ it('does not fill the ring when the pathway has no items', () => {
+ const { container } = renderComponent(0, 0);
+
+ expect(getSegment(container)).toBeNull();
+ expect(screen.getByText('0/0')).toBeInTheDocument();
+ });
+});
diff --git a/src/pathways/pathway-progress/pathway-completion/PathwayProgressDonut.tsx b/src/pathways/pathway-progress/pathway-completion/PathwayProgressDonut.tsx
new file mode 100644
index 0000000000..8a46ac06f0
--- /dev/null
+++ b/src/pathways/pathway-progress/pathway-completion/PathwayProgressDonut.tsx
@@ -0,0 +1,28 @@
+import { useIntl } from '@openedx/frontend-base';
+
+import { PathwayProgressRing } from '../progress-ring/PathwayProgressRing';
+import messages from './messages';
+
+export interface PathwayProgressDonutProps {
+ completed: number;
+ total: number;
+}
+
+export const PathwayProgressDonut = ({ completed, total }: PathwayProgressDonutProps) => {
+ const intl = useIntl();
+ const percentage = total > 0 ? (completed / total) * 100 : 0;
+
+ return (
+
+
+ {`${completed}/${total}`}
+ {intl.formatMessage(messages.completed)}
+
+
+ );
+};
diff --git a/src/pathways/pathway-progress/pathway-completion/messages.ts b/src/pathways/pathway-progress/pathway-completion/messages.ts
new file mode 100644
index 0000000000..2292a67137
--- /dev/null
+++ b/src/pathways/pathway-progress/pathway-completion/messages.ts
@@ -0,0 +1,26 @@
+import { defineMessages } from '@openedx/frontend-base';
+
+const messages = defineMessages({
+ completed: {
+ id: 'learning.pathways.progress.donut.completed',
+ defaultMessage: 'completed',
+ description: 'Label shown below the completed/total count in the center of the pathway progress donut chart',
+ },
+ completedItems: {
+ id: 'learning.pathways.progress.donut.completedItems',
+ defaultMessage: '{completed} of {total} items completed',
+ description: 'Accessible label of the pathway progress donut chart',
+ },
+ completionTitle: {
+ id: 'learning.pathways.progress.completion.title',
+ defaultMessage: '{categoryLabel} completion',
+ description: 'Title of the Completion section',
+ },
+ completionDescription: {
+ id: 'learning.pathways.progress.completion.description',
+ defaultMessage: 'This represents how many items you have completed in this {categoryLabel}.',
+ description: 'Description of the Completion section',
+ },
+});
+
+export default messages;
diff --git a/src/pathways/pathway-progress/progress-ring/PathwayProgressRing.scss b/src/pathways/pathway-progress/progress-ring/PathwayProgressRing.scss
new file mode 100644
index 0000000000..6254a5b0ad
--- /dev/null
+++ b/src/pathways/pathway-progress/progress-ring/PathwayProgressRing.scss
@@ -0,0 +1,27 @@
+.learning-pathway-progress-ring {
+ .progress-ring-track,
+ .progress-ring-segment {
+ fill: transparent;
+ stroke-width: 6px;
+ }
+
+ .progress-ring-track {
+ stroke: var(--pgn-color-light-400);
+ }
+
+ .progress-ring-segment {
+ stroke: var(--pgn-color-primary-500);
+ }
+
+ // Small rings, shown next to a value, need a thicker stroke to stay visible.
+ &.learning-pathway-progress-ring-sm {
+ flex-shrink: 0;
+ width: 1.5rem;
+ height: 1.5rem;
+
+ .progress-ring-track,
+ .progress-ring-segment {
+ stroke-width: 9px;
+ }
+ }
+}
diff --git a/src/pathways/pathway-progress/progress-ring/PathwayProgressRing.test.tsx b/src/pathways/pathway-progress/progress-ring/PathwayProgressRing.test.tsx
new file mode 100644
index 0000000000..8045cfc0c0
--- /dev/null
+++ b/src/pathways/pathway-progress/progress-ring/PathwayProgressRing.test.tsx
@@ -0,0 +1,35 @@
+import { render } from '@testing-library/react';
+
+import { PathwayProgressRing } from './PathwayProgressRing';
+
+const getSegment = (container: HTMLElement) => container.querySelector('.progress-ring-segment');
+
+describe('PathwayProgressRing', () => {
+ it('fills the given share of the ring', () => {
+ const { container } = render( );
+
+ expect(getSegment(container)).toHaveAttribute('stroke-dasharray', '25 75');
+ });
+
+ it('does not fill the ring when the percentage is zero', () => {
+ const { container } = render( );
+
+ expect(getSegment(container)).toBeNull();
+ });
+
+ it('does not fill more than the whole ring', () => {
+ const { container } = render( );
+
+ expect(getSegment(container)).toHaveAttribute('stroke-dasharray', '100 0');
+ });
+
+ it('passes the other props to the svg', () => {
+ const { container } = render(
+ ,
+ );
+
+ const svg = container.querySelector('svg');
+ expect(svg).toHaveClass('learning-pathway-progress-ring', 'extra');
+ expect(svg).toHaveAttribute('aria-hidden', 'true');
+ });
+});
diff --git a/src/pathways/pathway-progress/progress-ring/PathwayProgressRing.tsx b/src/pathways/pathway-progress/progress-ring/PathwayProgressRing.tsx
new file mode 100644
index 0000000000..82373a71b6
--- /dev/null
+++ b/src/pathways/pathway-progress/progress-ring/PathwayProgressRing.tsx
@@ -0,0 +1,43 @@
+import classNames from 'classnames';
+import type { ReactNode, SVGProps } from 'react';
+
+// A radius that gives a circumference of 100, so the stroke dash values are percentages.
+const RADIUS = 15.91549430918954;
+// Strokes start at 3 o'clock; shifting them back a quarter of the circle starts them at 12 o'clock.
+const TOP_OFFSET = 25;
+
+export interface PathwayProgressRingProps extends Omit, 'children'> {
+ percentage: number;
+ // Drawn in the center of the ring, in the 42x42 coordinates of its viewBox.
+ children?: ReactNode;
+}
+
+export const PathwayProgressRing = ({
+ percentage,
+ className,
+ children,
+ ...props
+}: PathwayProgressRingProps) => {
+ const filled = Math.min(Math.max(percentage, 0), 100);
+
+ return (
+
+
+ {filled > 0 && (
+
+ )}
+ {children}
+
+ );
+};
diff --git a/src/pathways/pathway-tabs/PathwayTabLink.tsx b/src/pathways/pathway-tabs/PathwayTabLink.tsx
new file mode 100644
index 0000000000..ac9fa7d35b
--- /dev/null
+++ b/src/pathways/pathway-tabs/PathwayTabLink.tsx
@@ -0,0 +1,24 @@
+import classNames from 'classnames';
+import { Link } from 'react-router-dom';
+
+interface PathwayTabLinkProps {
+ slug: string;
+ activeTabSlug?: string;
+ url: string;
+ title: string;
+}
+
+export const PathwayTabLink = ({
+ slug, activeTabSlug, url, title,
+}: PathwayTabLinkProps) => {
+ const isActive = slug === activeTabSlug;
+ return (
+
+ {title}
+
+ );
+};
diff --git a/src/pathways/pathway-tabs/PathwayTabLinksList.test.tsx b/src/pathways/pathway-tabs/PathwayTabLinksList.test.tsx
new file mode 100644
index 0000000000..03842e6997
--- /dev/null
+++ b/src/pathways/pathway-tabs/PathwayTabLinksList.test.tsx
@@ -0,0 +1,35 @@
+import { render, screen } from '@testing-library/react';
+import { MemoryRouter } from 'react-router-dom';
+
+import { PathwayTabLinksList } from './PathwayTabLinksList';
+
+const tabs = [
+ { tabId: 'home', title: 'Home', url: '/pathway/pathway-1/home' },
+ { tabId: 'progress', title: 'Progress', url: '/pathway/pathway-1/progress' },
+ { tabId: 'achievements', title: 'Achievements', url: '/pathway/pathway-1/achievements' },
+];
+
+describe('PathwayTabLinksList', () => {
+ it('renders a link for each tab', () => {
+ render( , { wrapper: MemoryRouter });
+
+ expect(screen.getAllByRole('link')).toHaveLength(3);
+ expect(screen.getByRole('link', { name: 'Progress' })).toHaveAttribute('href', '/pathway/pathway-1/progress');
+ });
+
+ it('highlights only the active tab', () => {
+ render( , { wrapper: MemoryRouter });
+
+ expect(screen.getByRole('link', { name: 'Progress' })).toHaveClass('active');
+ expect(screen.getByRole('link', { name: 'Home' })).not.toHaveClass('active');
+ expect(screen.getByRole('link', { name: 'Achievements' })).not.toHaveClass('active');
+ });
+
+ it('marks only the active tab as the current page', () => {
+ render( , { wrapper: MemoryRouter });
+
+ expect(screen.getByRole('link', { name: 'Progress' })).toHaveAttribute('aria-current', 'page');
+ expect(screen.getByRole('link', { name: 'Home' })).not.toHaveAttribute('aria-current');
+ expect(screen.getByRole('link', { name: 'Achievements' })).not.toHaveAttribute('aria-current');
+ });
+});
diff --git a/src/pathways/pathway-tabs/PathwayTabLinksList.tsx b/src/pathways/pathway-tabs/PathwayTabLinksList.tsx
new file mode 100644
index 0000000000..395a29b5e6
--- /dev/null
+++ b/src/pathways/pathway-tabs/PathwayTabLinksList.tsx
@@ -0,0 +1,21 @@
+import { PathwayTabLink } from './PathwayTabLink';
+import type { PathwayTabMetadata } from './types';
+
+interface PathwayTabLinksListProps {
+ tabs: PathwayTabMetadata[];
+ activeTabSlug?: string;
+}
+
+export const PathwayTabLinksList = ({ tabs, activeTabSlug }: PathwayTabLinksListProps) => (
+ <>
+ {tabs.map(({ url, title, tabId }) => (
+
+ ))}
+ >
+);
diff --git a/src/pathways/pathway-tabs/PathwayTabsNavigation.test.tsx b/src/pathways/pathway-tabs/PathwayTabsNavigation.test.tsx
new file mode 100644
index 0000000000..819fbab277
--- /dev/null
+++ b/src/pathways/pathway-tabs/PathwayTabsNavigation.test.tsx
@@ -0,0 +1,28 @@
+import { render, screen } from '@testing-library/react';
+import { IntlProvider } from '@openedx/frontend-base';
+import { MemoryRouter } from 'react-router-dom';
+
+import { PathwayTabsNavigation } from './PathwayTabsNavigation';
+
+const tabs = [
+ { tabId: 'home', title: 'Home', url: '/pathway/pathway-1/home' },
+ { tabId: 'progress', title: 'Progress', url: '/pathway/pathway-1/progress' },
+];
+
+const renderComponent = (activeTabSlug?: string) => render(
+
+
+
+
+ ,
+);
+
+describe('PathwayTabsNavigation', () => {
+ it('renders the tab links inside a labelled navigation', () => {
+ renderComponent('home');
+
+ const navigation = screen.getByRole('navigation', { name: 'Pathway Material' });
+ expect(navigation).toContainElement(screen.getByRole('link', { name: 'Home' }));
+ expect(navigation).toContainElement(screen.getByRole('link', { name: 'Progress' }));
+ });
+});
diff --git a/src/pathways/pathway-tabs/PathwayTabsNavigation.tsx b/src/pathways/pathway-tabs/PathwayTabsNavigation.tsx
new file mode 100644
index 0000000000..d75c1b1994
--- /dev/null
+++ b/src/pathways/pathway-tabs/PathwayTabsNavigation.tsx
@@ -0,0 +1,28 @@
+import { useIntl } from '@openedx/frontend-base';
+import { Container } from '@openedx/paragon';
+
+import PathwayTabLinksSlot from '@src/slots/PathwayTabLinksSlot';
+import type { PathwayTabMetadata } from './types';
+import messages from './messages';
+
+export interface PathwayTabsNavigationProps {
+ tabs: PathwayTabMetadata[];
+ activeTabSlug?: string;
+}
+
+export const PathwayTabsNavigation = ({ tabs, activeTabSlug }: PathwayTabsNavigationProps) => {
+ const intl = useIntl();
+
+ return (
+
+
+
+
+
+ );
+};
diff --git a/src/pathways/pathway-tabs/constants.ts b/src/pathways/pathway-tabs/constants.ts
new file mode 100644
index 0000000000..9cdfdb56d2
--- /dev/null
+++ b/src/pathways/pathway-tabs/constants.ts
@@ -0,0 +1,5 @@
+export const PATHWAY_TAB_SLUGS = {
+ OUTLINE: 'outline',
+ PROGRESS: 'progress',
+ ACHIEVEMENTS: 'achievements',
+} as const;
diff --git a/src/pathways/pathway-tabs/hooks.test.tsx b/src/pathways/pathway-tabs/hooks.test.tsx
new file mode 100644
index 0000000000..bbfeb575e1
--- /dev/null
+++ b/src/pathways/pathway-tabs/hooks.test.tsx
@@ -0,0 +1,24 @@
+import { renderHook } from '@testing-library/react';
+import { IntlProvider } from '@openedx/frontend-base';
+
+import { usePathwayTabs } from './hooks';
+
+const wrapper = ({ children }) => {children} ;
+
+describe('usePathwayTabs', () => {
+ it('returns the pathway tabs with their URLs', () => {
+ const { result } = renderHook(() => usePathwayTabs('pathway-1'), { wrapper });
+
+ expect(result.current).toEqual([
+ { tabId: 'outline', title: 'Outline', url: '/learning/pathway/pathway-1/outline' },
+ { tabId: 'progress', title: 'Progress', url: '/learning/pathway/pathway-1/progress' },
+ { tabId: 'achievements', title: 'Achievements', url: '/learning/pathway/pathway-1/achievements' },
+ ]);
+ });
+
+ it('returns no tabs without a pathway', () => {
+ const { result } = renderHook(() => usePathwayTabs(undefined), { wrapper });
+
+ expect(result.current).toEqual([]);
+ });
+});
diff --git a/src/pathways/pathway-tabs/hooks.ts b/src/pathways/pathway-tabs/hooks.ts
new file mode 100644
index 0000000000..c67cfa20b2
--- /dev/null
+++ b/src/pathways/pathway-tabs/hooks.ts
@@ -0,0 +1,28 @@
+import { useMemo } from 'react';
+import { useIntl } from '@openedx/frontend-base';
+
+import { getPathwayTabUrl } from '../urls';
+import { PATHWAY_TAB_SLUGS } from './constants';
+import type { PathwayTabMetadata } from './types';
+import messages from './messages';
+
+const PATHWAY_TABS = [
+ // TODO: The Outline Tab title must be the category label
+ { tabId: PATHWAY_TAB_SLUGS.OUTLINE, message: messages.home },
+ { tabId: PATHWAY_TAB_SLUGS.PROGRESS, message: messages.progress },
+ { tabId: PATHWAY_TAB_SLUGS.ACHIEVEMENTS, message: messages.achievements },
+];
+
+export const usePathwayTabs = (pathwayId?: string): PathwayTabMetadata[] => {
+ const intl = useIntl();
+ return useMemo(() => {
+ if (!pathwayId) {
+ return [];
+ }
+ return PATHWAY_TABS.map(({ tabId, message }) => ({
+ tabId,
+ title: intl.formatMessage(message),
+ url: getPathwayTabUrl(pathwayId, tabId),
+ }));
+ }, [intl, pathwayId]);
+};
diff --git a/src/pathways/pathway-tabs/messages.ts b/src/pathways/pathway-tabs/messages.ts
new file mode 100644
index 0000000000..00b94ab1ff
--- /dev/null
+++ b/src/pathways/pathway-tabs/messages.ts
@@ -0,0 +1,26 @@
+import { defineMessages } from '@openedx/frontend-base';
+
+const messages = defineMessages({
+ pathwayMaterial: {
+ id: 'learning.pathways.tabs.navigation.label',
+ defaultMessage: 'Pathway Material',
+ description: 'The accessible label for pathway tabs navigation',
+ },
+ home: {
+ id: 'learning.pathways.tabs.home',
+ defaultMessage: 'Outline',
+ description: 'Title of the pathway tab that shows the pathway outline',
+ },
+ progress: {
+ id: 'learning.pathways.tabs.progress',
+ defaultMessage: 'Progress',
+ description: 'Title of the pathway tab that shows the learner progress in the pathway',
+ },
+ achievements: {
+ id: 'learning.pathways.tabs.achievements',
+ defaultMessage: 'Achievements',
+ description: 'Title of the pathway tab that shows the learner achievements in the pathway',
+ },
+});
+
+export default messages;
diff --git a/src/pathways/pathway-tabs/types.ts b/src/pathways/pathway-tabs/types.ts
new file mode 100644
index 0000000000..759fbf01df
--- /dev/null
+++ b/src/pathways/pathway-tabs/types.ts
@@ -0,0 +1,5 @@
+export interface PathwayTabMetadata {
+ tabId: string;
+ title: string;
+ url: string;
+}
diff --git a/src/pathways/pathways-achievements/CertificateCard.test.tsx b/src/pathways/pathways-achievements/CertificateCard.test.tsx
new file mode 100644
index 0000000000..05159ff121
--- /dev/null
+++ b/src/pathways/pathways-achievements/CertificateCard.test.tsx
@@ -0,0 +1,39 @@
+import { render, screen } from '@testing-library/react';
+import { IntlProvider } from '@openedx/frontend-base';
+
+import { dataEngineeringAchievements } from '@src/pathways/data/__fixtures__/pathways';
+
+import { CertificateCard } from './CertificateCard';
+
+const [pathwayCertificate, itemCertificate] = dataEngineeringAchievements;
+
+const renderComponent = (achievement: typeof pathwayCertificate) => render(
+
+
+ ,
+);
+
+describe('CertificateCard', () => {
+ it('shows the certificate details', () => {
+ renderComponent(itemCertificate);
+
+ expect(screen.getByText(itemCertificate.displayName)).toBeInTheDocument();
+ expect(screen.getByText(itemCertificate.providerName)).toBeInTheDocument();
+ expect(screen.getByText('Completed on Jul 2, 2026')).toBeInTheDocument();
+ expect(screen.getByText(itemCertificate.credentialId)).toBeInTheDocument();
+ expect(screen.getByRole('button', { name: 'View certificate' })).toBeInTheDocument();
+ });
+
+ it('names the pathway category in the certificate of the pathway itself', () => {
+ renderComponent(pathwayCertificate);
+
+ expect(screen.getByText('Bootcamp certificate')).toBeInTheDocument();
+ });
+
+ it('shows a generic label in the certificate of an item', () => {
+ renderComponent(itemCertificate);
+
+ expect(screen.getByText('Certificate')).toBeInTheDocument();
+ expect(screen.queryByText('Bootcamp certificate')).not.toBeInTheDocument();
+ });
+});
diff --git a/src/pathways/pathways-achievements/CertificateCard.tsx b/src/pathways/pathways-achievements/CertificateCard.tsx
new file mode 100644
index 0000000000..384012614a
--- /dev/null
+++ b/src/pathways/pathways-achievements/CertificateCard.tsx
@@ -0,0 +1,80 @@
+import classNames from 'classnames';
+import { Button, Icon, Stack } from '@openedx/paragon';
+import { Article } from '@openedx/paragon/icons';
+import { FormattedDate, FormattedMessage } from '@openedx/frontend-base';
+
+import type { PathwayAchievementData } from '@src/pathways/data/types';
+
+import messages from './messages';
+
+export interface CertificateCardProps extends PathwayAchievementData {
+ categoryLabel: string;
+}
+
+export const CertificateCard = ({
+ credentialId,
+ displayName,
+ providerName,
+ completedOn,
+ isOverarching,
+ categoryLabel,
+}: CertificateCardProps) => {
+ const subtitle = isOverarching ? messages.pathwayCertificate : messages.itemCertificate;
+
+ return (
+
+
+
+
+
+
+
+
+
+
+ {displayName}
+
+
+
+
+ {providerName}
+
+
+
+ ),
+ }}
+ />
+
+
+
+
+
+
+
+
+
+
+ {credentialId}
+
+
+
+
+ );
+};
diff --git a/src/pathways/pathways-achievements/PathwayAchievements.test.tsx b/src/pathways/pathways-achievements/PathwayAchievements.test.tsx
new file mode 100644
index 0000000000..3bac15f3b5
--- /dev/null
+++ b/src/pathways/pathways-achievements/PathwayAchievements.test.tsx
@@ -0,0 +1,48 @@
+import { IntlProvider } from '@openedx/frontend-base';
+import { render, screen } from '@testing-library/react';
+
+import { dataEngineeringAchievements } from '../data/__fixtures__/pathways';
+import { CertificateCard } from './CertificateCard';
+import { PathwayAchievements } from './PathwayAchievements';
+
+jest.mock('./CertificateCard', () => ({
+ CertificateCard: jest.fn(({ displayName }) => {displayName}
),
+}));
+
+const renderComponent = (achievements = dataEngineeringAchievements) => render(
+
+
+ ,
+);
+
+describe('PathwayAchievements', () => {
+ beforeEach(() => {
+ jest.clearAllMocks();
+ });
+
+ it('renders a card for each achievement, with the category label of the pathway', () => {
+ renderComponent();
+
+ dataEngineeringAchievements.forEach((achievement) => {
+ expect(screen.getByText(achievement.displayName)).toBeInTheDocument();
+ expect(CertificateCard).toHaveBeenCalledWith({ ...achievement, categoryLabel: 'Tutorial' }, expect.anything());
+ });
+ expect(screen.queryByText('No achievements earned yet.')).not.toBeInTheDocument();
+ });
+
+ it.each([
+ ['with achievements', dataEngineeringAchievements],
+ ['without achievements', []],
+ ])('shows the tab heading %s', (_, achievements) => {
+ renderComponent(achievements);
+
+ expect(screen.getByRole('heading', { level: 1, name: 'Your achievements' })).toBeInTheDocument();
+ });
+
+ it('tells the learner they have no achievements yet, instead of the cards, without achievements', () => {
+ renderComponent([]);
+
+ expect(screen.getByText('No achievements earned yet.')).toBeInTheDocument();
+ expect(CertificateCard).not.toHaveBeenCalled();
+ });
+});
diff --git a/src/pathways/pathways-achievements/PathwayAchievements.tsx b/src/pathways/pathways-achievements/PathwayAchievements.tsx
new file mode 100644
index 0000000000..44b034a670
--- /dev/null
+++ b/src/pathways/pathways-achievements/PathwayAchievements.tsx
@@ -0,0 +1,43 @@
+import { FormattedMessage } from '@openedx/frontend-base';
+import { CardGrid, Icon } from '@openedx/paragon';
+import { CardMembership } from '@openedx/paragon/icons';
+
+import type { PathwayAchievementData } from '../data/types';
+import { CertificateCard } from './CertificateCard';
+import messages from './messages';
+
+export interface PathwayAchievementsProps {
+ achievements: PathwayAchievementData[];
+ categoryLabel: string;
+}
+
+const NoAchievements = () => (
+
+);
+
+export const PathwayAchievements = ({ achievements, categoryLabel }: PathwayAchievementsProps) => (
+ <>
+
+
+
+ {achievements.length ? (
+
+ {achievements.map((achievement) => (
+
+ ))}
+
+ ) : }
+ >
+);
diff --git a/src/pathways/pathways-achievements/messages.ts b/src/pathways/pathways-achievements/messages.ts
new file mode 100644
index 0000000000..6241f1f3db
--- /dev/null
+++ b/src/pathways/pathways-achievements/messages.ts
@@ -0,0 +1,41 @@
+import { defineMessages } from '@openedx/frontend-base';
+
+const messages = defineMessages({
+ pathwayCertificate: {
+ id: 'learning.pathways.certificate-card.pathway-certificate',
+ defaultMessage: '{categoryLabel} certificate',
+ description: 'Subtitle of the Pathway certificate',
+ },
+ itemCertificate: {
+ id: 'learning.pathways.certificate-card.item-certificate',
+ defaultMessage: 'Certificate',
+ description: 'Subtitle of the Item certificate',
+ },
+ completed: {
+ id: 'learning.pathways.certificate-card.completed',
+ defaultMessage: 'Completed on {date}',
+ description: 'Completion date for the course',
+ },
+ viewCertificateButton: {
+ id: 'learning.pathways.certificate-card.view-certificate',
+ defaultMessage: 'View certificate',
+ description: 'Label for the View certificate button',
+ },
+ heading: {
+ id: 'learning.pathways.achievements.heading',
+ defaultMessage: 'Your achievements',
+ description: 'Heading of the achievements tab of a pathway',
+ },
+ noAchievements: {
+ id: 'learning.pathways.achievements.no-achievements',
+ defaultMessage: 'No achievements earned yet.',
+ description: 'Shown on the achievements tab of a pathway when the learner has not earned any certificate in it yet',
+ },
+ credentialId: {
+ id: 'learning.pathways.certificate-card.credential-id',
+ defaultMessage: 'Credential ID',
+ description: 'Credential ID label of a pathway/item certificate',
+ },
+});
+
+export default messages;
diff --git a/src/pathways/pathways-strip/CoursePathwaysStrip.scss b/src/pathways/pathways-strip/CoursePathwaysStrip.scss
new file mode 100644
index 0000000000..a463376a66
--- /dev/null
+++ b/src/pathways/pathways-strip/CoursePathwaysStrip.scss
@@ -0,0 +1,59 @@
+.course-pathways-strip {
+ .course-pathways-strip-container {
+ position: relative;
+ flex: 1;
+ min-width: 0;
+ overflow: hidden;
+ }
+
+ .course-pathways-strip-label {
+ flex-shrink: 0;
+ white-space: nowrap;
+
+ &:hover,
+ &:focus {
+ text-decoration: underline;
+ }
+
+ // Labels are separated by a vertical line
+ & + .course-pathways-strip-label {
+ margin-inline-start: 0.75rem;
+ padding-inline-start: 0.75rem;
+ border-inline-start: 1px solid var(--pgn-color-light-700);
+ }
+ }
+
+ // "+N" trigger, right after the last visible label and separated from it by a vertical line
+ .course-pathways-strip-trigger {
+ flex-shrink: 0;
+ margin-inline-start: 0.75rem;
+ padding-top: 0;
+ padding-bottom: 0;
+ border-inline-start: 1px solid var(--pgn-color-light-700);
+ border-radius: 0;
+
+ .badge {
+ display: inline-flex;
+ align-items: center;
+ justify-content: center;
+ min-width: 1.25rem;
+ height: 1.25rem;
+ padding: 0;
+ margin-inline-start: 0.5rem;
+ }
+
+ .btn-icon-after {
+ margin-inline-start: 0;
+ }
+ }
+
+ // Hidden copy of every label, only used to measure their natural width
+ .course-pathways-strip-measure {
+ position: absolute;
+ top: 0;
+ left: 0;
+ width: max-content;
+ visibility: hidden;
+ pointer-events: none;
+ }
+}
diff --git a/src/pathways/pathways-strip/CoursePathwaysStrip.test.tsx b/src/pathways/pathways-strip/CoursePathwaysStrip.test.tsx
new file mode 100644
index 0000000000..426b2ff185
--- /dev/null
+++ b/src/pathways/pathways-strip/CoursePathwaysStrip.test.tsx
@@ -0,0 +1,129 @@
+import { render, screen } from '@testing-library/react';
+import { IntlProvider } from '@openedx/frontend-base';
+import { MemoryRouter } from 'react-router-dom';
+
+import { useCoursePathways } from '../data/apiHooks';
+import type { PathwayData } from '../data/types';
+import {
+ courseIdWithPathways, dataEngineering, loremIpsum, machineLearning,
+} from '../data/__fixtures__/pathways';
+import { useVisiblePathways } from './hooks';
+import { MorePathwaysPopover } from './MorePathwaysPopover';
+import { CoursePathwaysStrip } from './CoursePathwaysStrip';
+
+jest.mock('../data/apiHooks', () => ({
+ useCoursePathways: jest.fn(),
+}));
+
+jest.mock('./hooks', () => ({
+ useVisiblePathways: jest.fn(),
+}));
+
+jest.mock('./MorePathwaysPopover', () => ({
+ MorePathwaysPopover: jest.fn(() => MorePathwaysPopover
),
+}));
+
+const mockUseCoursePathways = useCoursePathways as jest.Mock;
+const mockUseVisiblePathways = useVisiblePathways as jest.MockedFunction;
+
+const pathways = [dataEngineering, machineLearning, loremIpsum];
+
+const mockPathways = (data?: PathwayData[]) => {
+ mockUseCoursePathways.mockReturnValue({ data });
+};
+
+const mockSplit = (visiblePathways: PathwayData[], hiddenPathways: PathwayData[]) => {
+ mockUseVisiblePathways.mockReturnValue({
+ containerRef: { current: null },
+ measureRef: { current: null },
+ visiblePathways,
+ hiddenPathways,
+ });
+};
+
+const renderComponent = () => render(
+
+
+
+
+ ,
+);
+
+// The labels shown in the strip, leaving out the hidden copies used for measuring
+const getVisibleLabels = (container: HTMLElement) => Array.from(
+ container.querySelectorAll('.course-pathways-strip-container > .course-pathways-strip-label'),
+);
+
+describe('CoursePathwaysStrip', () => {
+ beforeEach(() => {
+ jest.clearAllMocks();
+ mockPathways(pathways);
+ mockSplit(pathways, []);
+ });
+
+ it('renders nothing when the course has no pathways', () => {
+ mockPathways([]);
+ mockSplit([], []);
+ const { container } = renderComponent();
+ expect(container).toBeEmptyDOMElement();
+ });
+
+ it('renders nothing while the pathways are loading', () => {
+ mockPathways(undefined);
+ mockSplit([], []);
+ const { container } = renderComponent();
+ expect(container).toBeEmptyDOMElement();
+ });
+
+ it('gets the pathways of the course', () => {
+ renderComponent();
+ expect(mockUseCoursePathways).toHaveBeenCalledWith(courseIdWithPathways);
+ expect(mockUseVisiblePathways).toHaveBeenCalledWith(pathways);
+ });
+
+ it('renders the "Course included in" label and every visible pathway', () => {
+ const { container } = renderComponent();
+ expect(screen.getByText('Course included in')).toBeInTheDocument();
+ expect(getVisibleLabels(container).map((label) => label.textContent)).toEqual([
+ 'Data Engineering Fundamentals',
+ 'Introduction to Machine Learning',
+ 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod',
+ ]);
+ });
+
+ it('links every visible pathway to its outline', () => {
+ const { container } = renderComponent();
+ expect(getVisibleLabels(container).map((label) => label.getAttribute('href'))).toEqual(
+ pathways.map((pathway) => `/learning/pathway/${pathway.pathway.id}/outline`),
+ );
+ });
+
+ it('does not render the popover when every pathway fits', () => {
+ renderComponent();
+ expect(MorePathwaysPopover).not.toHaveBeenCalled();
+ });
+
+ it('renders only the visible pathways and passes the hidden ones to the popover', () => {
+ mockSplit([dataEngineering, machineLearning], [loremIpsum]);
+ const { container } = renderComponent();
+
+ expect(getVisibleLabels(container).map((label) => label.textContent)).toEqual([
+ 'Data Engineering Fundamentals',
+ 'Introduction to Machine Learning',
+ ]);
+
+ expect(screen.getByText('MorePathwaysPopover')).toBeInTheDocument();
+ expect(MorePathwaysPopover).toHaveBeenCalledWith({ pathways: [loremIpsum] }, expect.anything());
+ });
+
+ it('renders every pathway in the hidden row used for measuring', () => {
+ mockSplit([dataEngineering], [machineLearning, loremIpsum]);
+ const { container } = renderComponent();
+ const measureRow = container.querySelector('.course-pathways-strip-measure');
+ expect(measureRow).toHaveAttribute('aria-hidden');
+ expect(measureRow?.children).toHaveLength(pathways.length);
+ Array.from(measureRow?.children ?? []).forEach((label) => {
+ expect(label).toHaveAttribute('tabindex', '-1');
+ });
+ });
+});
diff --git a/src/pathways/pathways-strip/CoursePathwaysStrip.tsx b/src/pathways/pathways-strip/CoursePathwaysStrip.tsx
new file mode 100644
index 0000000000..1c5e98f4a9
--- /dev/null
+++ b/src/pathways/pathways-strip/CoursePathwaysStrip.tsx
@@ -0,0 +1,65 @@
+import { FormattedMessage } from '@openedx/frontend-base';
+import { Container } from '@openedx/paragon';
+import { Link } from 'react-router-dom';
+
+import { useCoursePathways } from '../data/apiHooks';
+import type { PathwayData } from '../data/types';
+import { PATHWAY_TAB_SLUGS } from '../pathway-tabs/constants';
+import { getPathwayTabUrl } from '../urls';
+import { MorePathwaysPopover } from './MorePathwaysPopover';
+import { useVisiblePathways } from './hooks';
+import messages from './messages';
+
+interface PathwayLabelProps {
+ pathway: PathwayData;
+ isMeasure?: boolean;
+}
+
+export interface CoursePathwaysStripProps {
+ courseId?: string;
+}
+
+const PathwayLabel = ({ pathway, isMeasure = false }: PathwayLabelProps) => (
+
+ {pathway.pathway.content.displayName}
+
+);
+
+export const CoursePathwaysStrip = ({ courseId }: CoursePathwaysStripProps) => {
+ const { data: pathways = [] } = useCoursePathways(courseId);
+ const {
+ containerRef,
+ measureRef,
+ visiblePathways,
+ hiddenPathways,
+ } = useVisiblePathways(pathways);
+
+ if (!pathways.length) {
+ return null;
+ }
+
+ return (
+
+
+
+
+
+
+ {visiblePathways.map((pathway) => (
+
+ ))}
+ {hiddenPathways.length > 0 &&
}
+
+ {pathways.map((pathway) => (
+
+ ))}
+
+
+
+
+ );
+};
diff --git a/src/pathways/pathways-strip/MorePathwaysPopover.test.tsx b/src/pathways/pathways-strip/MorePathwaysPopover.test.tsx
new file mode 100644
index 0000000000..f54ec9e0a6
--- /dev/null
+++ b/src/pathways/pathways-strip/MorePathwaysPopover.test.tsx
@@ -0,0 +1,53 @@
+import { render, screen } from '@testing-library/react';
+import userEvent from '@testing-library/user-event';
+import { IntlProvider } from '@openedx/frontend-base';
+import { MemoryRouter } from 'react-router-dom';
+
+import type { PathwayData } from '../data/types';
+import { dataEngineering, machineLearning } from '../data/__fixtures__/pathways';
+import { MorePathwaysPopover } from './MorePathwaysPopover';
+
+const renderComponent = (pathways: PathwayData[] = [dataEngineering, machineLearning]) => render(
+
+
+
+
+ ,
+);
+
+describe('MorePathwaysPopover', () => {
+ it('renders the trigger with the number of pathways and an accessible label', async () => {
+ renderComponent();
+ const trigger = await screen.findByRole('button', { name: 'Show 2 more pathways' });
+ expect(trigger).toHaveTextContent('2');
+ });
+
+ it('uses the singular accessible label for a single pathway', async () => {
+ renderComponent([dataEngineering]);
+ expect(await screen.findByRole('button', { name: 'Show 1 more pathway' })).toBeInTheDocument();
+ });
+
+ it('does not show the pathways until the trigger is clicked', async () => {
+ renderComponent();
+ await screen.findByRole('button', { name: 'Show 2 more pathways' });
+ expect(screen.queryByText('Data Engineering Fundamentals')).not.toBeInTheDocument();
+ });
+
+ it('shows the pathways when the trigger is clicked', async () => {
+ const user = userEvent.setup();
+ renderComponent();
+ await user.click(screen.getByRole('button', { name: 'Show 2 more pathways' }));
+ expect(screen.getByRole('link', { name: 'Data Engineering Fundamentals' }))
+ .toHaveAttribute('href', `/learning/pathway/${dataEngineering.pathway.id}/outline`);
+ expect(screen.getByRole('link', { name: 'Introduction to Machine Learning' }))
+ .toHaveAttribute('href', `/learning/pathway/${machineLearning.pathway.id}/outline`);
+ });
+
+ it('closes the pathways list on Escape', async () => {
+ const user = userEvent.setup();
+ renderComponent();
+ await user.click(screen.getByRole('button', { name: 'Show 2 more pathways' }));
+ await user.keyboard('{Escape}');
+ expect(screen.queryByText('Data Engineering Fundamentals')).not.toBeInTheDocument();
+ });
+});
diff --git a/src/pathways/pathways-strip/MorePathwaysPopover.tsx b/src/pathways/pathways-strip/MorePathwaysPopover.tsx
new file mode 100644
index 0000000000..1660491c53
--- /dev/null
+++ b/src/pathways/pathways-strip/MorePathwaysPopover.tsx
@@ -0,0 +1,53 @@
+import { useState } from 'react';
+import { useIntl } from '@openedx/frontend-base';
+import {
+ Badge, Button, ModalPopup, useToggle,
+} from '@openedx/paragon';
+import { ArrowDropDown } from '@openedx/paragon/icons';
+import { Link } from 'react-router-dom';
+
+import type { PathwayData } from '../data/types';
+import { PATHWAY_TAB_SLUGS } from '../pathway-tabs/constants';
+import { getPathwayTabUrl } from '../urls';
+import messages from './messages';
+
+export const MorePathwaysPopover = ({ pathways }: { pathways: PathwayData[] }) => {
+ const { formatMessage } = useIntl();
+ const [isOpen, open, close] = useToggle(false);
+ const [target, setTarget] = useState(null);
+
+ return (
+ <>
+
+ {pathways.length}
+
+
+
+
+ {pathways.map((pathway) => (
+
+
+ {pathway.pathway.content.displayName}
+
+
+ ))}
+
+
+
+ >
+ );
+};
diff --git a/src/pathways/pathways-strip/hooks.test.tsx b/src/pathways/pathways-strip/hooks.test.tsx
new file mode 100644
index 0000000000..f4c412d062
--- /dev/null
+++ b/src/pathways/pathways-strip/hooks.test.tsx
@@ -0,0 +1,203 @@
+import { act, render, screen } from '@testing-library/react';
+
+import type { PathwayData } from '../data/types';
+import { useVisiblePathways } from './hooks';
+
+const buildPathway = (id: string): PathwayData => ({
+ pathway: {
+ id,
+ content: { displayName: `Pathway ${id}` },
+ itemCount: 3,
+ category: 'bootcamp',
+ categoryLabel: 'Bootcamp',
+ },
+});
+
+const pathways = ['1', '2', '3'].map(buildPathway);
+
+// jsdom has no layout, so the sizes the hook reads are taken from data attributes
+const mockLayoutProperty = (property: 'clientWidth' | 'offsetWidth' | 'offsetLeft') => (
+ jest.spyOn(HTMLElement.prototype, property, 'get').mockImplementation(function getSize(this: HTMLElement) {
+ return Number(this.dataset[property] ?? 0);
+ })
+);
+
+let resizeCallback: () => void;
+const disconnect = jest.fn();
+
+const observe = jest.fn();
+
+class MockResizeObserver {
+ constructor(callback: () => void) {
+ resizeCallback = callback;
+ }
+
+ observe = observe;
+
+ disconnect = disconnect;
+}
+
+interface HarnessProps {
+ items?: PathwayData[];
+ containerWidth: number;
+ labelOffsets: number[];
+ labelWidths?: number[];
+ labelsWidth: number;
+}
+
+const Harness = ({
+ items = pathways, containerWidth, labelOffsets, labelWidths = [], labelsWidth,
+}: HarnessProps) => {
+ const {
+ containerRef, measureRef, visiblePathways, hiddenPathways,
+ } = useVisiblePathways(items);
+ return (
+ <>
+
+
+ {labelOffsets.map((offset, index) => (
+
+ ))}
+
+ {visiblePathways.map(({ pathway }) => pathway.id).join(',')}
+ {hiddenPathways.map(({ pathway }) => pathway.id).join(',')}
+ >
+ );
+};
+
+const renderComponent = (props: HarnessProps) => render( );
+
+// A row wider than the strips used below: labels 400, 500 and 400 wide, ending at 400, 900 and 1300
+const overflowingRow = {
+ labelsWidth: 1300,
+ labelOffsets: [0, 400, 900],
+ labelWidths: [400, 500, 400],
+};
+
+describe('useVisiblePathways', () => {
+ const originalResizeObserver = globalThis.ResizeObserver;
+
+ beforeEach(() => {
+ jest.clearAllMocks();
+ globalThis.ResizeObserver = MockResizeObserver as unknown as typeof ResizeObserver;
+ mockLayoutProperty('clientWidth');
+ mockLayoutProperty('offsetWidth');
+ mockLayoutProperty('offsetLeft');
+ });
+
+ afterEach(() => {
+ globalThis.ResizeObserver = originalResizeObserver;
+ jest.restoreAllMocks();
+ });
+
+ it('shows every pathway when all the labels fit', () => {
+ renderComponent({ containerWidth: 1000, labelsWidth: 900, labelOffsets: [0, 300, 600] });
+ expect(screen.getByTestId('visible')).toHaveTextContent('1,2,3');
+ expect(screen.getByTestId('hidden')).toBeEmptyDOMElement();
+ });
+
+ it('moves the labels that do not fit to the hidden pathways', () => {
+ renderComponent({ ...overflowingRow, containerWidth: 1000 });
+ expect(screen.getByTestId('visible')).toHaveTextContent('1,2');
+ expect(screen.getByTestId('hidden')).toHaveTextContent('3');
+ });
+
+ it('moves a label that would be cut to the hidden pathways instead of truncating it', () => {
+ // The third label starts within the strip but ends after the space kept for the "+N" trigger
+ renderComponent({
+ containerWidth: 1000,
+ labelsWidth: 1300,
+ labelOffsets: [0, 400, 800],
+ labelWidths: [400, 400, 500],
+ });
+ expect(screen.getByTestId('visible')).toHaveTextContent('1,2');
+ expect(screen.getByTestId('hidden')).toHaveTextContent('3');
+ });
+
+ it('moves every label to the hidden pathways when not even the first one fits', () => {
+ renderComponent({
+ containerWidth: 500,
+ labelsWidth: 1300,
+ labelOffsets: [0, 600, 900],
+ labelWidths: [600, 300, 400],
+ });
+ expect(screen.getByTestId('visible')).toBeEmptyDOMElement();
+ expect(screen.getByTestId('hidden')).toHaveTextContent('1,2,3');
+ });
+
+ it('measures the labels from the right edge in RTL', () => {
+ // jsdom does not compute the direction
+ jest.spyOn(window, 'getComputedStyle').mockReturnValue({ direction: 'rtl' } as CSSStyleDeclaration);
+ // The same row as [0, 720, 840] in LTR, mirrored: labels 700, 100 and 100 wide in a 940 wide row
+ renderComponent({
+ containerWidth: 800,
+ labelsWidth: 940,
+ labelOffsets: [240, 120, 0],
+ labelWidths: [700, 100, 100],
+ });
+ expect(screen.getByTestId('visible')).toHaveTextContent(/^1$/);
+ expect(screen.getByTestId('hidden')).toHaveTextContent('2,3');
+ });
+
+ it('recalculates the split when the container is resized', () => {
+ renderComponent({ ...overflowingRow, containerWidth: 1000 });
+ expect(screen.getByTestId('visible')).toHaveTextContent('1,2');
+
+ screen.getByTestId('container').dataset.clientWidth = '500';
+ act(() => resizeCallback());
+
+ expect(screen.getByTestId('visible')).toHaveTextContent('1');
+ expect(screen.getByTestId('hidden')).toHaveTextContent('2,3');
+ });
+
+ it('recalculates the split when the labels are resized', () => {
+ renderComponent({ containerWidth: 1000, labelsWidth: 900, labelOffsets: [0, 300, 600] });
+ expect(observe).toHaveBeenCalledWith(screen.getByTestId('measure'));
+ expect(screen.getByTestId('visible')).toHaveTextContent('1,2,3');
+
+ // e.g. the web font loads and every label gets wider
+ const measure = screen.getByTestId('measure');
+ measure.dataset.offsetWidth = '1300';
+ const labels = Array.from(measure.children) as HTMLElement[];
+ overflowingRow.labelOffsets.forEach((offset, index) => {
+ labels[index].dataset.offsetLeft = String(offset);
+ labels[index].dataset.offsetWidth = String(overflowingRow.labelWidths[index]);
+ });
+ act(() => resizeCallback());
+
+ expect(screen.getByTestId('visible')).toHaveTextContent('1,2');
+ expect(screen.getByTestId('hidden')).toHaveTextContent('3');
+ });
+
+ it('recalculates the split when the pathways change but not their count', () => {
+ const props = { containerWidth: 1000, labelsWidth: 900, labelOffsets: [0, 300, 600] };
+ const { rerender } = renderComponent(props);
+ expect(screen.getByTestId('visible')).toHaveTextContent('1,2,3');
+
+ // Same count, but longer names
+ rerender(
+ ,
+ );
+
+ expect(screen.getByTestId('visible')).toHaveTextContent('4,5');
+ expect(screen.getByTestId('hidden')).toHaveTextContent('6');
+ });
+
+ it('shows every pathway when ResizeObserver is not available', () => {
+ // @ts-expect-error ResizeObserver is removed to emulate an environment without it
+ delete globalThis.ResizeObserver;
+ renderComponent({ ...overflowingRow, containerWidth: 1000 });
+ expect(screen.getByTestId('visible')).toHaveTextContent('1,2,3');
+ expect(screen.getByTestId('hidden')).toBeEmptyDOMElement();
+ });
+
+ it('disconnects the observer on unmount', () => {
+ const { unmount } = renderComponent({ containerWidth: 1000, labelsWidth: 900, labelOffsets: [0, 300, 600] });
+ unmount();
+ expect(disconnect).toHaveBeenCalled();
+ });
+});
diff --git a/src/pathways/pathways-strip/hooks.ts b/src/pathways/pathways-strip/hooks.ts
new file mode 100644
index 0000000000..c30986b0b2
--- /dev/null
+++ b/src/pathways/pathways-strip/hooks.ts
@@ -0,0 +1,60 @@
+import { useLayoutEffect, useRef, useState } from 'react';
+
+import type { PathwayData } from '../data/types';
+
+// Width kept free after the last visible label for the "+N" popover trigger, including its
+// 0.75rem (12px) start margin
+const COUNTER_RESERVED_WIDTH = 86;
+
+/**
+ * Splits the course pathways into the ones that fit in the strip and the ones that go to the
+ * "+N" popover. Only the labels that fit entirely are shown, so a label that would be cut goes to
+ * the popover, even if it is the first one. The split is recalculated whenever the strip resizes.
+ */
+export const useVisiblePathways = (pathways: PathwayData[]) => {
+ // Goes on the element whose width is available for the labels and the trigger
+ const containerRef = useRef(null);
+ // Goes on a hidden row that renders every label at its natural width
+ const measureRef = useRef(null);
+ const [visibleCount, setVisibleCount] = useState(pathways.length);
+
+ useLayoutEffect(() => {
+ const container = containerRef.current;
+ const measure = measureRef.current;
+ if (!container || !measure || typeof ResizeObserver === 'undefined') {
+ setVisibleCount(pathways.length);
+ return undefined;
+ }
+
+ const calculate = () => {
+ const available = container.clientWidth;
+ if (measure.offsetWidth <= available) {
+ setVisibleCount(pathways.length);
+ return;
+ }
+ // A label is visible if it ends before the space kept for the "+N" trigger
+ const limit = available - COUNTER_RESERVED_WIDTH;
+ const labels = Array.from(measure.children) as HTMLElement[];
+ // In RTL the labels start at the right edge, so their start is measured from there
+ const isRtl = getComputedStyle(measure).direction === 'rtl';
+ const endOf = (label: HTMLElement) => (
+ isRtl ? measure.offsetWidth - label.offsetLeft : label.offsetLeft + label.offsetWidth
+ );
+ setVisibleCount(labels.filter((label) => endOf(label) <= limit).length);
+ };
+
+ calculate();
+ const observer = new ResizeObserver(calculate);
+ observer.observe(container);
+ // The labels change width without resizing the container, e.g. when the web font loads
+ observer.observe(measure);
+ return () => observer.disconnect();
+ }, [pathways]);
+
+ return {
+ containerRef,
+ measureRef,
+ visiblePathways: pathways.slice(0, visibleCount),
+ hiddenPathways: pathways.slice(visibleCount),
+ };
+};
diff --git a/src/pathways/pathways-strip/messages.ts b/src/pathways/pathways-strip/messages.ts
new file mode 100644
index 0000000000..eaf51e9721
--- /dev/null
+++ b/src/pathways/pathways-strip/messages.ts
@@ -0,0 +1,16 @@
+import { defineMessages } from '@openedx/frontend-base';
+
+const messages = defineMessages({
+ includedIn: {
+ id: 'learning.coursePathways.includedIn',
+ defaultMessage: 'Course included in',
+ description: 'Label that precedes the pathways, in which the learner is enrolled, that include this course',
+ },
+ morePathways: {
+ id: 'learning.coursePathways.morePathways',
+ defaultMessage: 'Show {count, plural, one {# more pathway} other {# more pathways}}',
+ description: 'Accessible label of the button that shows the pathways that do not fit in the course header',
+ },
+});
+
+export default messages;
diff --git a/src/pathways/tab-page/TabPage.test.tsx b/src/pathways/tab-page/TabPage.test.tsx
new file mode 100644
index 0000000000..4f4a7a7cf4
--- /dev/null
+++ b/src/pathways/tab-page/TabPage.test.tsx
@@ -0,0 +1,53 @@
+import { render, screen } from '@testing-library/react';
+import { IntlProvider } from '@openedx/frontend-base';
+import { MemoryRouter } from 'react-router-dom';
+import type { UseQueryResult } from '@tanstack/react-query';
+
+import { dataEngineering } from '../data/__fixtures__/pathways';
+import type { PathwayData } from '../data/types';
+import { TabPage } from './TabPage';
+
+const buildQuery = (query: Partial>) => ({
+ isPending: false,
+ isError: false,
+ data: undefined,
+ error: null,
+ ...query,
+}) as UseQueryResult;
+
+const renderComponent = (metadataQuery: UseQueryResult) => render(
+
+
+
+ Tab content
+
+
+ ,
+);
+
+describe('Pathway TabPage', () => {
+ it('shows the loading state while the pathway is loading', () => {
+ renderComponent(buildQuery({ isPending: true }));
+ expect(screen.getByText('Loading pathway page…')).toBeInTheDocument();
+ expect(screen.queryByText('Tab content')).not.toBeInTheDocument();
+ });
+
+ it('shows an error when the pathway fails to load', () => {
+ renderComponent(buildQuery({ isError: true, error: new Error('network error') }));
+ expect(screen.getByText('There was an error loading this pathway.')).toBeInTheDocument();
+ expect(screen.queryByText('Tab content')).not.toBeInTheDocument();
+ });
+
+ it('renders the tabs and the tab content once the pathway is loaded', () => {
+ renderComponent(buildQuery({ data: dataEngineering }));
+
+ const navigation = screen.getByRole('navigation', { name: 'Pathway Material' });
+ expect(navigation).toContainElement(screen.getByRole('link', { name: 'Outline' }));
+ expect(screen.getByRole('link', { name: 'Progress' })).toHaveClass('active');
+ expect(screen.getByText('Tab content')).toBeInTheDocument();
+ });
+});
diff --git a/src/pathways/tab-page/TabPage.tsx b/src/pathways/tab-page/TabPage.tsx
new file mode 100644
index 0000000000..bef7caf3ad
--- /dev/null
+++ b/src/pathways/tab-page/TabPage.tsx
@@ -0,0 +1,83 @@
+import { type ReactNode } from 'react';
+import { Helmet } from 'react-helmet';
+
+import { getSiteConfig, useIntl } from '@openedx/frontend-base';
+import { Container } from '@openedx/paragon';
+
+import { deriveView, type TabStatus } from '@src/tab-page/utils';
+import PageLoading from '@src/generic/PageLoading';
+
+import messages from './messages';
+import type { PathwayData } from '../data/types';
+import { usePathwayTabs } from '../pathway-tabs/hooks';
+import { PathwayTabsNavigation } from '../pathway-tabs/PathwayTabsNavigation';
+
+export type PathwayStatus = TabStatus;
+
+export interface TabPageProps {
+ activeTabSlug: string;
+ pathwayId?: string;
+ pathwayStatus: PathwayStatus;
+ children?: ReactNode;
+}
+
+export const TabPage = ({
+ activeTabSlug,
+ pathwayId,
+ pathwayStatus,
+ children,
+}: TabPageProps) => {
+ const intl = useIntl();
+ const { pathway } = pathwayStatus.metadataQuery.data ?? {};
+ const title = pathway?.content.displayName ?? '';
+ const tabs = usePathwayTabs(pathwayId);
+ const activeTabTitle = tabs.find((tab) => tab.tabId === activeTabSlug)?.title;
+
+ const {
+ isPending, isError, isDenied, errorDetails,
+ } = deriveView(pathwayStatus);
+
+ if (isDenied) {
+ // TODO: For now, `isDenied` is always `false`.
+ // We need to wait for the backend to see how `isDenied`
+ // is determined—whether it’s based on a response code
+ // or a field in the returned data.
+ }
+
+ const shouldRenderContent = !isPending && !isError;
+
+ const renderLoading = () => (
+
+ );
+
+ const renderError = () => {
+ const errorMessages = errorDetails?.length ? errorDetails : [intl.formatMessage(messages.failure)];
+ return (
+
+ {errorMessages.map((errorMessage) =>
{errorMessage}
)}
+
+ );
+ };
+
+ const renderLoadedTabPage = () => (
+ <>
+
+ {`${activeTabTitle ? `${activeTabTitle} | ` : ''}${title} | ${getSiteConfig().siteName}`}
+
+
+ >
+ );
+
+ return (
+ <>
+ {isPending && renderLoading()}
+ {shouldRenderContent && renderLoadedTabPage()}
+ {isError && renderError()}
+ >
+ );
+};
diff --git a/src/pathways/tab-page/messages.ts b/src/pathways/tab-page/messages.ts
new file mode 100644
index 0000000000..0a32351623
--- /dev/null
+++ b/src/pathways/tab-page/messages.ts
@@ -0,0 +1,16 @@
+import { defineMessages } from '@openedx/frontend-base';
+
+const messages = defineMessages({
+ failure: {
+ id: 'learning.pathways.loading.failure',
+ defaultMessage: 'There was an error loading this pathway.',
+ description: 'Can be because internet connection or any technical other reason',
+ },
+ loading: {
+ id: 'learning.pathways.loading',
+ defaultMessage: 'Loading pathway page…',
+ description: 'When content of a pathway is still loading',
+ },
+});
+
+export default messages;
diff --git a/src/pathways/urls.test.ts b/src/pathways/urls.test.ts
new file mode 100644
index 0000000000..6bcb0f2ae7
--- /dev/null
+++ b/src/pathways/urls.test.ts
@@ -0,0 +1,7 @@
+import { getPathwayTabUrl } from './urls';
+
+describe('getPathwayTabUrl', () => {
+ it("builds the URL of the pathway's tab under Learning's pathway route", () => {
+ expect(getPathwayTabUrl('pathway-1', 'outline')).toBe('/learning/pathway/pathway-1/outline');
+ });
+});
diff --git a/src/pathways/urls.ts b/src/pathways/urls.ts
new file mode 100644
index 0000000000..ee66bc3416
--- /dev/null
+++ b/src/pathways/urls.ts
@@ -0,0 +1,9 @@
+import { getUrlByRouteRole } from '@openedx/frontend-base';
+import { generatePath } from 'react-router-dom';
+
+import { pathwayRole } from '@src/constants';
+
+// The URL of one of a pathway's tabs, under the pathway route wherever the site mounts Learning.
+export const getPathwayTabUrl = (pathwayId: string, tabSlug: string) => (
+ generatePath(`${getUrlByRouteRole(pathwayRole)}/${tabSlug}`, { pathwayId })
+);
diff --git a/src/routes.test.tsx b/src/routes.test.tsx
index ffa0f590a8..ef7dcaa0fc 100644
--- a/src/routes.test.tsx
+++ b/src/routes.test.tsx
@@ -17,6 +17,13 @@ describe('routes', () => {
expect(await screen.findByText('status=404')).toBeInTheDocument();
});
+ describe('pathway', () => {
+ it('throws a 404 response at pathway/:pathwayId, which has no page of its own', async () => {
+ renderRoutes([{ errorElement: , children: routes }], '/learning/pathway/pathway-1');
+ expect(await screen.findByText('status=404')).toBeInTheDocument();
+ });
+ });
+
describe('courseware', () => {
it('throws a 404 response at preview/course/:courseId, which the shell renders as not found', async () => {
renderRoutes([{ errorElement: , children: routes }], `/learning/preview/course/${courseId}`);
diff --git a/src/routes.tsx b/src/routes.tsx
index 344a3e4168..5bc194de99 100644
--- a/src/routes.tsx
+++ b/src/routes.tsx
@@ -8,6 +8,7 @@ import {
coursewareRole,
learningCourseRole,
learningRole,
+ pathwayRole,
} from './constants';
import discussionRedirectLoader from './course-home/discussion-tab/discussionRedirectLoader';
import {
@@ -177,6 +178,47 @@ const courseRoutes: RoleRouteObject[] = [
},
];
+const pathwayRoutes: RoleRouteObject[] = [
+ {
+ id: 'org.openedx.frontend.route.learning.pathway',
+ path: 'pathway/:pathwayId',
+ handle: { roles: [pathwayRole] },
+ children: [
+ {
+ index: true,
+ element: null,
+ loader: () => {
+ throw new Response(null, { status: 404 });
+ },
+ },
+ {
+ id: 'org.openedx.frontend.route.learning.pathwayOutline',
+ path: 'outline',
+ async lazy() {
+ const module = await import(/* webpackChunkName: "learning-pathway" */ './pages/PathwayOutlinePage');
+ return { Component: module.default };
+ },
+ },
+ {
+ id: 'org.openedx.frontend.route.learning.pathwayProgress',
+ path: 'progress',
+ async lazy() {
+ const module = await import(/* webpackChunkName: "learning-pathway" */ './pages/PathwayProgressPage');
+ return { Component: module.default };
+ },
+ },
+ {
+ id: 'org.openedx.frontend.route.learning.pathwayAchievements',
+ path: 'achievements',
+ async lazy() {
+ const module = await import(/* webpackChunkName: "learning-pathway" */ './pages/PathwayAchievementsPage');
+ return { Component: module.default };
+ },
+ },
+ ],
+ },
+];
+
const goalUnsubscribeRoutes: RoleRouteObject[] = [
{
id: 'org.openedx.frontend.route.learning.goalUnsubscribe',
@@ -228,6 +270,7 @@ const routes: RoleRouteObject[] = [
element: ,
children: [
...courseRoutes,
+ ...pathwayRoutes,
...goalUnsubscribeRoutes,
...redirectRoutes,
...preferencesUnsubscribeRoutes,
diff --git a/src/slots.tsx b/src/slots.tsx
index 8983d021a3..7461bb9b48 100644
--- a/src/slots.tsx
+++ b/src/slots.tsx
@@ -1,5 +1,6 @@
import { SlotOperation } from '@openedx/frontend-base';
+import { courseInfoStripApp } from './widgets/CourseInfoStrip';
import { coursewareSearchApp } from './widgets/CoursewareSearch';
import { coursewareTabApp } from './widgets/CoursewareTab';
import { datesTabApp } from './widgets/DatesTab';
@@ -11,6 +12,7 @@ import { progressTabApp } from './widgets/ProgressTab';
const slots: SlotOperation[] = [
...(learningHeaderApp.slots ?? []),
+ ...(courseInfoStripApp.slots ?? []),
...(coursewareSearchApp.slots ?? []),
...(discussionsSidebarApp.slots ?? []),
...(outlineTabApp.slots ?? []),
diff --git a/src/slots/CourseInfoStripSlot/README.md b/src/slots/CourseInfoStripSlot/README.md
new file mode 100644
index 0000000000..dfbdc655f7
--- /dev/null
+++ b/src/slots/CourseInfoStripSlot/README.md
@@ -0,0 +1,66 @@
+# Course Info Strip Slot
+
+### Slot ID: `org.openedx.frontend.slot.learning.courseInfoStrip.v1`
+
+### Slot Props
+
+* `courseId?: string` - the ID of the current course.
+
+## Description
+
+This slot renders a strip between the header and the course tabs of every course page, with information about the current course. For example, it can be used to tell the learner that their trial access to the course ends soon, or that they are viewing an archived run of the course. Learning's [Course Info Strip widget](../../widgets/CourseInfoStrip/README.md) places it in the shell's header.
+
+By default, it lists the pathways that include the current course and in which the learner is enrolled. When the pathways do not fit in the strip, the remaining ones are shown in a "+N" popover. The default strip is not rendered when the course is not included in any of the learner's pathways.
+
+## Examples
+
+### Default content
+
+
+
+### Replaced with a custom strip
+
+
+
+Add the following to your site config to replace the default strip with a custom one. The diff below is against this package's `site.config.dev.tsx`.
+
+```diff
+-import { EnvironmentTypes, SiteConfig, footerApp, headerApp, shellApp } from '@openedx/frontend-base';
++import {
++ EnvironmentTypes, SiteConfig, WidgetOperationTypes, footerApp, headerApp, shellApp,
++} from '@openedx/frontend-base';
+
+ import { learningApp } from './src';
+
+ import '@openedx/frontend-base/shell/style';
+
++const TrialStrip = () => (
++
++ Your trial access to this course ends in 6 days.
++
++);
++
+ const siteConfig: SiteConfig = {
+ // ...
+ apps: [
+ shellApp,
+ headerApp,
+ footerApp,
+ learningApp,
++ {
++ appId: 'org.example.app.myPlugin',
++ slots: [
++ {
++ slotId: 'org.openedx.frontend.slot.learning.courseInfoStrip.v1',
++ id: 'org.example.widget.trialStrip',
++ op: WidgetOperationTypes.REPLACE,
++ relatedId: 'defaultContent',
++ component: TrialStrip,
++ },
++ ],
++ },
+ ],
+ };
+```
+
+To hide the strip, use `WidgetOperationTypes.REMOVE` with `relatedId: 'defaultContent'`.
diff --git a/src/slots/CourseInfoStripSlot/images/screenshot_custom.png b/src/slots/CourseInfoStripSlot/images/screenshot_custom.png
new file mode 100644
index 0000000000..976013821b
Binary files /dev/null and b/src/slots/CourseInfoStripSlot/images/screenshot_custom.png differ
diff --git a/src/slots/CourseInfoStripSlot/images/screenshot_default.png b/src/slots/CourseInfoStripSlot/images/screenshot_default.png
new file mode 100644
index 0000000000..95c73b3521
Binary files /dev/null and b/src/slots/CourseInfoStripSlot/images/screenshot_default.png differ
diff --git a/src/slots/CourseInfoStripSlot/index.test.tsx b/src/slots/CourseInfoStripSlot/index.test.tsx
new file mode 100644
index 0000000000..f778897c49
--- /dev/null
+++ b/src/slots/CourseInfoStripSlot/index.test.tsx
@@ -0,0 +1,37 @@
+import { WidgetOperationTypes } from '@openedx/frontend-base';
+import { screen } from '@testing-library/react';
+
+import { render } from '@src/tests/render';
+import { addSlotOperations } from '@src/tests/slots';
+
+import CourseInfoStripSlot, { courseInfoStripSlotId } from '.';
+
+jest.mock('@src/pathways/pathways-strip/CoursePathwaysStrip', () => ({
+ CoursePathwaysStrip: ({ courseId }: { courseId?: string }) => `Course pathways strip: ${courseId}`,
+}));
+
+describe('CourseInfoStripSlot', () => {
+ const courseId = 'course-v1:edX+DemoX+Demo_Course';
+
+ it('renders the course pathways strip by default', () => {
+ render( );
+
+ expect(screen.getByText(`Course pathways strip: ${courseId}`)).toBeInTheDocument();
+ });
+
+ it('passes its props to a widget that replaces the default content', () => {
+ const Widget = jest.fn(() => null);
+ addSlotOperations([{
+ slotId: courseInfoStripSlotId,
+ id: 'org.example.widget',
+ op: WidgetOperationTypes.REPLACE,
+ relatedId: 'defaultContent',
+ component: Widget,
+ }]);
+
+ render( );
+
+ expect(screen.queryByText(`Course pathways strip: ${courseId}`)).not.toBeInTheDocument();
+ expect(Widget.mock.calls[0][0]).toEqual({ courseId });
+ });
+});
diff --git a/src/slots/CourseInfoStripSlot/index.tsx b/src/slots/CourseInfoStripSlot/index.tsx
new file mode 100644
index 0000000000..5d4207127c
--- /dev/null
+++ b/src/slots/CourseInfoStripSlot/index.tsx
@@ -0,0 +1,17 @@
+import { Slot } from '@openedx/frontend-base';
+
+import { CoursePathwaysStrip } from '@src/pathways/pathways-strip/CoursePathwaysStrip';
+
+export const courseInfoStripSlotId = 'org.openedx.frontend.slot.learning.courseInfoStrip.v1';
+
+export interface CourseInfoStripSlotProps {
+ courseId?: string;
+}
+
+const CourseInfoStripSlot = ({ courseId }: CourseInfoStripSlotProps) => (
+
+
+
+);
+
+export default CourseInfoStripSlot;
diff --git a/src/slots/PathwayTabLinksSlot/README.md b/src/slots/PathwayTabLinksSlot/README.md
new file mode 100644
index 0000000000..7daea97286
--- /dev/null
+++ b/src/slots/PathwayTabLinksSlot/README.md
@@ -0,0 +1,65 @@
+# Pathway Tab Links Slot
+
+### Slot ID: `org.openedx.frontend.slot.learning.pathwayTabLinks.v1`
+
+### Slot Props
+
+* `tabs: PathwayTabMetadata[]` - the tabs of the pathway, each with its `tabId`, `title` and `url`.
+* `activeTabSlug?: string` - the `tabId` of the tab being shown.
+
+## Description
+
+This slot renders the links in the tab navigation of the pathway pages. Its default content is a link to each of the pathway's tabs, with the active one highlighted.
+
+To add a tab that looks like the others, render `PathwayTabLink`, which the package exports.
+
+## Examples
+
+### Default content
+
+
+
+### A custom tab added after the default ones
+
+
+
+Add the following to your site config to add a tab called "Custom Tab". The diff below is against this package's `site.config.dev.tsx`.
+
+```diff
+-import { EnvironmentTypes, SiteConfig, footerApp, headerApp, shellApp } from '@openedx/frontend-base';
++import {
++ EnvironmentTypes, SiteConfig, WidgetOperationTypes, footerApp, headerApp, shellApp,
++} from '@openedx/frontend-base';
+
+-import { learningApp } from './src';
++import { learningApp, PathwayTabLink, type PathwayTabLinksSlotProps } from './src';
+
+ import '@openedx/frontend-base/shell/style';
+
++const CustomTab = ({ activeTabSlug }: PathwayTabLinksSlotProps) => (
++
++);
++
+ const siteConfig: SiteConfig = {
+ // ...
+ apps: [
+ shellApp,
+ headerApp,
+ footerApp,
+ learningApp,
++ {
++ appId: 'org.example.app.myPlugin',
++ slots: [
++ {
++ slotId: 'org.openedx.frontend.slot.learning.pathwayTabLinks.v1',
++ id: 'org.example.widget.customTab',
++ op: WidgetOperationTypes.APPEND,
++ component: CustomTab,
++ },
++ ],
++ },
+ ],
+ };
+```
+
+To hide the default links, use `WidgetOperationTypes.REMOVE` with `relatedId: 'defaultContent'`.
diff --git a/src/slots/PathwayTabLinksSlot/images/screenshot_custom.png b/src/slots/PathwayTabLinksSlot/images/screenshot_custom.png
new file mode 100644
index 0000000000..53e809a351
Binary files /dev/null and b/src/slots/PathwayTabLinksSlot/images/screenshot_custom.png differ
diff --git a/src/slots/PathwayTabLinksSlot/images/screenshot_default.png b/src/slots/PathwayTabLinksSlot/images/screenshot_default.png
new file mode 100644
index 0000000000..dd01f51503
Binary files /dev/null and b/src/slots/PathwayTabLinksSlot/images/screenshot_default.png differ
diff --git a/src/slots/PathwayTabLinksSlot/index.test.tsx b/src/slots/PathwayTabLinksSlot/index.test.tsx
new file mode 100644
index 0000000000..b7a25b0b4f
--- /dev/null
+++ b/src/slots/PathwayTabLinksSlot/index.test.tsx
@@ -0,0 +1,37 @@
+import { WidgetOperationTypes } from '@openedx/frontend-base';
+import { screen } from '@testing-library/react';
+
+import { render } from '@src/tests/render';
+import { addSlotOperations } from '@src/tests/slots';
+
+import PathwayTabLinksSlot, { pathwayTabLinksSlotId } from '.';
+
+describe('PathwayTabLinksSlot', () => {
+ const tabs = [
+ { tabId: 'outline', title: 'Outline', url: '/learning/pathway/pathway-1/outline' },
+ { tabId: 'progress', title: 'Progress', url: '/learning/pathway/pathway-1/progress' },
+ ];
+
+ it('renders a link to each tab and highlights the active one by default', () => {
+ render( , { wrapWithRouter: true });
+
+ expect(screen.getByRole('link', { name: 'Outline' })).toHaveAttribute('href', '/learning/pathway/pathway-1/outline');
+ expect(screen.getByRole('link', { name: 'Outline' })).not.toHaveClass('active');
+ expect(screen.getByRole('link', { name: 'Progress' })).toHaveClass('active');
+ });
+
+ it('passes its props to an appended widget', () => {
+ const Widget = jest.fn(() => null);
+ addSlotOperations([{
+ slotId: pathwayTabLinksSlotId,
+ id: 'org.example.widget',
+ op: WidgetOperationTypes.APPEND,
+ component: Widget,
+ }]);
+
+ render( , { wrapWithRouter: true });
+
+ expect(screen.getByRole('link', { name: 'Outline' })).toBeInTheDocument();
+ expect(Widget.mock.calls[0][0]).toEqual({ tabs, activeTabSlug: 'progress' });
+ });
+});
diff --git a/src/slots/PathwayTabLinksSlot/index.tsx b/src/slots/PathwayTabLinksSlot/index.tsx
new file mode 100644
index 0000000000..73f6f4116a
--- /dev/null
+++ b/src/slots/PathwayTabLinksSlot/index.tsx
@@ -0,0 +1,19 @@
+import { Slot } from '@openedx/frontend-base';
+
+import { PathwayTabLinksList } from '@src/pathways/pathway-tabs/PathwayTabLinksList';
+import type { PathwayTabMetadata } from '@src/pathways/pathway-tabs/types';
+
+export const pathwayTabLinksSlotId = 'org.openedx.frontend.slot.learning.pathwayTabLinks.v1';
+
+export interface PathwayTabLinksSlotProps {
+ tabs: PathwayTabMetadata[];
+ activeTabSlug?: string;
+}
+
+const PathwayTabLinksSlot = ({ tabs, activeTabSlug }: PathwayTabLinksSlotProps) => (
+
+
+
+);
+
+export default PathwayTabLinksSlot;
diff --git a/src/slots/README.md b/src/slots/README.md
index 26fcae63c8..c61c45aeb0 100644
--- a/src/slots/README.md
+++ b/src/slots/README.md
@@ -14,6 +14,14 @@ Each tab's section starts with the slot that holds the whole tab (`outlineTab`,
For the operations Learning applies to other apps' slots (the shell's header and course bar), see `src/slots.tsx` and the [widgets](../widgets/README.md). See frontend-base's [ADR 0009](https://github.com/openedx/frontend-base/blob/main/docs/decisions/0009-slot-naming-and-lifecycle.rst) for slot naming and lifecycle.
+## All course pages
+
+This slot sits in the shell's header, inside Learning's [Course Info Strip widget](../widgets/CourseInfoStrip/README.md).
+
+| Slot | ID | Constant |
+|---|---|---|
+| [Course Info Strip](./CourseInfoStripSlot/README.md) | `courseInfoStrip` | `courseInfoStripSlotId` |
+
## Course Outline tab
| Slot | ID | Constant |
@@ -97,3 +105,9 @@ All three are documented in one [README](./CourseExitSlots/README.md).
| [Course Exit View Courses](./CourseExitSlots/README.md#course-exit-view-courses-slot) | `courseExitViewCourses` | `courseExitViewCoursesSlotId` |
| [Course Recommendations](./CourseExitSlots/README.md#course-recommendations-slot) | `courseRecommendations` | `courseRecommendationsSlotId` |
| [Course Exit Dashboard Footnote Link](./CourseExitSlots/README.md#course-exit-dashboard-footnote-link-slot) | `courseExitDashboardFootnoteLink` | `courseExitDashboardFootnoteLinkSlotId` |
+
+## Pathway pages
+
+| Slot | ID | Constant |
+|---|---|---|
+| [Pathway Tab Links](./PathwayTabLinksSlot/README.md) | `pathwayTabLinks` | `pathwayTabLinksSlotId` |
diff --git a/src/slots/index.ts b/src/slots/index.ts
index 4674d483c4..05cc40b262 100644
--- a/src/slots/index.ts
+++ b/src/slots/index.ts
@@ -23,6 +23,7 @@ export {
courseHomeSectionOutlineSlotId,
type CourseHomeSectionOutlineSlotProps,
} from './CourseHomeSectionOutlineSlot';
+export { courseInfoStripSlotId, type CourseInfoStripSlotProps } from './CourseInfoStripSlot';
export {
courseOutlineMobileSidebarTriggerSlotId,
type CourseOutlineMobileSidebarTriggerSlotProps,
@@ -52,6 +53,7 @@ export { learnerToolsSlotId, type LearnerToolsSlotProps } from './LearnerToolsSl
export { liveTabSlotId, type LiveTabSlotProps } from './LiveTabSlot';
export { nextUnitTopNavTriggerSlotId, type NextUnitTopNavTriggerSlotProps } from './NextUnitTopNavTriggerSlot';
export { outlineTabSlotId, type OutlineTabSlotProps } from './OutlineTabSlot';
+export { pathwayTabLinksSlotId, type PathwayTabLinksSlotProps } from './PathwayTabLinksSlot';
export {
progressCertificateStatusSlotId,
type ProgressCertificateStatusSlotProps,
diff --git a/src/style.scss b/src/style.scss
index 056c863666..dea96c46b9 100644
--- a/src/style.scss
+++ b/src/style.scss
@@ -12,6 +12,9 @@
@use "./courseware/course/course-exit/CourseRecommendations";
@use "./courseware/course/sidebar/common/SidebarBase";
@use "./courseware/course/sidebar/sidebars/course-outline/CourseOutlineTray";
+@use "./pathways/pathway-progress/pathway-completion/PathwayProgressDonut";
+@use "./pathways/pathway-progress/progress-ring/PathwayProgressRing";
+@use "./pathways/pathways-strip/CoursePathwaysStrip";
@use "./product-tours/newUserCourseHomeTour/NewUserCourseHomeTourModal";
@use "./shared/streak-celebration/StreakCelebrationModal";
@use "./widgets/DiscussionsSidebar/Discussions";
diff --git a/src/tab-page/TabPage.tsx b/src/tab-page/TabPage.tsx
index ee965b1894..7f38870fae 100644
--- a/src/tab-page/TabPage.tsx
+++ b/src/tab-page/TabPage.tsx
@@ -1,9 +1,7 @@
import React, { type ReactNode } from 'react';
import { useIntl } from '@openedx/frontend-base';
-import type { UseQueryResult } from '@tanstack/react-query';
import { Toast } from '@openedx/paragon';
-import { getErrorDetail } from '@src/data/http-error';
import PageLoading from '../generic/PageLoading';
import type { CourseHomeMeta } from '../course-home/data/api';
import { useToast } from '../generic/ToastContext';
@@ -11,15 +9,9 @@ import { useToast } from '../generic/ToastContext';
import genericMessages from '../generic/messages';
import messages from './messages';
import LoadedTabPage, { type FrameContentProps } from './LoadedTabPage';
+import { deriveView, type TabStatus } from './utils';
-// A tab hands TabPage its metadata + tab-data queries and lets TabPage derive the view; a tab
-// whose data comes from more than one query passes them as `tabDataQueries`.
-export type CourseStatus = {
- metadataQuery: UseQueryResult;
-} & (
- | { tabDataQuery?: UseQueryResult; tabDataQueries?: never }
- | { tabDataQuery?: never; tabDataQueries: UseQueryResult[] }
-);
+export type CourseStatus = TabStatus;
export interface TabPageProps extends FrameContentProps {
courseId?: string;
@@ -33,46 +25,6 @@ export interface TabPageProps extends FrameContentProps {
children?: ReactNode;
}
-interface TabView {
- isLoading: boolean;
- isError: boolean;
- isDenied: boolean;
- errorDetails?: string[];
-}
-
-const getErrorDetails = (queries: { error: unknown }[]): string[] => {
- const details = queries.flatMap((query) => getErrorDetail(query.error) || []);
- return [...new Set(details)];
-};
-
-const deriveView = (courseStatus: CourseStatus): TabView => {
- const view = { isLoading: false, isError: false, isDenied: false };
-
- // Access is read from the metadata query, resolved before tabData is considered.
- const {
- metadataQuery,
- tabDataQuery,
- tabDataQueries = tabDataQuery ? [tabDataQuery] : [],
- } = courseStatus;
- if (metadataQuery.isError) {
- return { ...view, isError: true, errorDetails: getErrorDetails([metadataQuery]) };
- }
- if (metadataQuery.isPending) {
- return { ...view, isLoading: true };
- }
- if (tabDataQueries.some((query) => query.isPending)) {
- return { ...view, isLoading: true };
- }
- if (!metadataQuery.data?.courseAccess?.hasAccess) {
- return { ...view, isDenied: true };
- }
- const failedQueries = tabDataQueries.filter((query) => query.isError);
- if (failedQueries.length > 0) {
- return { ...view, isError: true, errorDetails: getErrorDetails(failedQueries) };
- }
- return view;
-};
-
const TabPage = ({
courseId,
courseStatus,
@@ -85,8 +37,8 @@ const TabPage = ({
const { toastContent, isToastOpen, closeToast } = useToast();
const {
- isLoading, isError, isDenied, errorDetails,
- } = deriveView(courseStatus);
+ isPending, isError, isDenied, errorDetails,
+ } = deriveView(courseStatus, (metadata) => !!metadata.courseAccess?.hasAccess);
// The tab can see the course metadata before the page above it does, so a denied learner may reach the frame
// before the page has redirected them: render nothing for them, as the redirect did here before.
@@ -96,7 +48,7 @@ const TabPage = ({
// The page renders once metadata resolves without error, and for a denied learner (a failed tab-data query
// notwithstanding) when the tab shows itself to them.
- const shouldRenderContent = !isLoading && !isError;
+ const shouldRenderContent = !isPending && !isError;
const renderToast = () => (
{shouldRenderContent && renderToast()}
{shouldRenderContent && aboveContent}
- {isLoading && renderLoading()}
+ {isPending && renderLoading()}
{shouldRenderContent && renderLoadedTabPage()}
{isError && renderError()}
>
diff --git a/src/tab-page/utils.ts b/src/tab-page/utils.ts
new file mode 100644
index 0000000000..aae5c762c3
--- /dev/null
+++ b/src/tab-page/utils.ts
@@ -0,0 +1,57 @@
+import type { UseQueryResult } from '@tanstack/react-query';
+
+import { getErrorDetail } from '@src/data/http-error';
+
+// A tab hands TabPage its metadata + tab-data queries and lets TabPage derive the view; a tab
+// whose data comes from more than one query passes them as `tabDataQueries`.
+export type TabStatus = {
+ metadataQuery: UseQueryResult;
+} & (
+ | { tabDataQuery?: UseQueryResult; tabDataQueries?: never }
+ | { tabDataQuery?: never; tabDataQueries: UseQueryResult[] }
+);
+
+export interface TabView {
+ isPending: boolean;
+ isError: boolean;
+ isDenied: boolean;
+ errorDetails?: string[];
+}
+
+const getErrorDetails = (queries: { error: unknown }[]): string[] => {
+ const details = queries.flatMap((query) => getErrorDetail(query.error) || []);
+ return [...new Set(details)];
+};
+
+// `hasAccess` tells whether the resolved metadata grants access; pages without an access
+// check omit it.
+export const deriveView = (
+ status: TabStatus,
+ hasAccess: (metadata: TMetadata) => boolean = () => true,
+): TabView => {
+ const view = { isPending: false, isError: false, isDenied: false };
+
+ // Access is read from the metadata query, resolved before tabData is considered.
+ const {
+ metadataQuery,
+ tabDataQuery,
+ tabDataQueries = tabDataQuery ? [tabDataQuery] : [],
+ } = status;
+ if (metadataQuery.isError) {
+ return { ...view, isError: true, errorDetails: getErrorDetails([metadataQuery]) };
+ }
+ if (metadataQuery.isPending) {
+ return { ...view, isPending: true };
+ }
+ if (tabDataQueries.some((query) => query.isPending)) {
+ return { ...view, isPending: true };
+ }
+ if (!metadataQuery.data || !hasAccess(metadataQuery.data)) {
+ return { ...view, isDenied: true };
+ }
+ const failedQueries = tabDataQueries.filter((query) => query.isError);
+ if (failedQueries.length > 0) {
+ return { ...view, isError: true, errorDetails: getErrorDetails(failedQueries) };
+ }
+ return view;
+};
diff --git a/src/tests/readmeTypes.ts b/src/tests/readmeTypes.ts
index 2c21fe64b4..0a0a146106 100644
--- a/src/tests/readmeTypes.ts
+++ b/src/tests/readmeTypes.ts
@@ -20,6 +20,7 @@ import type {
LiveTabSlotProps,
NextUnitTopNavTriggerSlotProps,
OutlineTabSlotProps,
+ PathwayTabLinksSlotProps,
ProgressCertificateStatusSlotProps,
ProgressTabCertificateStatusMainBodySlotProps,
ProgressTabCertificateStatusSidePanelSlotProps,
@@ -54,6 +55,7 @@ export type ReadmeTypes = [
LiveTabSlotProps,
NextUnitTopNavTriggerSlotProps,
OutlineTabSlotProps,
+ PathwayTabLinksSlotProps,
ProgressCertificateStatusSlotProps,
ProgressTabCertificateStatusMainBodySlotProps,
ProgressTabCertificateStatusSidePanelSlotProps,
diff --git a/src/widgets/CourseInfoStrip/CourseInfoStripWidget.test.tsx b/src/widgets/CourseInfoStrip/CourseInfoStripWidget.test.tsx
new file mode 100644
index 0000000000..c66460208e
--- /dev/null
+++ b/src/widgets/CourseInfoStrip/CourseInfoStripWidget.test.tsx
@@ -0,0 +1,65 @@
+import { QueryClientProvider } from '@tanstack/react-query';
+import { render, screen } from '@testing-library/react';
+import { type ComponentType } from 'react';
+import { MemoryRouter, Outlet, Route, Routes } from 'react-router-dom';
+
+import { courseHomeMetaQuery } from '@src/course-home/data/apiHooks';
+import { createTestQueryClient, seedQueryData } from '@src/tests/queryClient';
+
+import { LazyCourseInfoStripWidget } from './app';
+import CourseInfoStripWidget from './CourseInfoStripWidget';
+
+jest.mock('@src/slots/CourseInfoStripSlot', () => ({ courseId }: { courseId?: string }) => (
+ `Course info strip slot: ${courseId}`
+));
+
+const courseId = 'course-v1:edX+DemoX+Demo_Course';
+
+// The widget renders in the shell's header: a layout route above the page, not inside it.
+const renderInHeader = (
+ { metadata, Widget = CourseInfoStripWidget }: { metadata?: Record; Widget?: ComponentType } = {},
+) => {
+ const queryClient = createTestQueryClient();
+ if (metadata) {
+ seedQueryData(queryClient, courseHomeMetaQuery(courseId).queryKey, metadata);
+ }
+ const result = render(
+
+
+
+ >}>
+ } />
+
+
+
+ ,
+ );
+ return { ...result, queryClient };
+};
+
+describe('CourseInfoStripWidget', () => {
+ it('renders the course info strip slot for the course in the page route', () => {
+ renderInHeader({ metadata: { courseAccess: { hasAccess: true } } });
+
+ expect(screen.getByText(`Course info strip slot: ${courseId}`)).toBeInTheDocument();
+ });
+
+ it('renders nothing and requests nothing while the frame has not loaded the metadata', () => {
+ const { container, queryClient } = renderInHeader();
+
+ expect(container.querySelector('header')).toBeEmptyDOMElement();
+ expect(queryClient.getQueryState(courseHomeMetaQuery(courseId).queryKey)?.fetchStatus).toBe('idle');
+ });
+
+ it('renders nothing for a learner without access to the course', () => {
+ const { container } = renderInHeader({ metadata: { courseAccess: { hasAccess: false } } });
+
+ expect(container.querySelector('header')).toBeEmptyDOMElement();
+ });
+
+ it('loads its code on first render', async () => {
+ renderInHeader({ metadata: { courseAccess: { hasAccess: true } }, Widget: LazyCourseInfoStripWidget });
+
+ expect(await screen.findByText(`Course info strip slot: ${courseId}`)).toBeInTheDocument();
+ });
+});
diff --git a/src/widgets/CourseInfoStrip/CourseInfoStripWidget.tsx b/src/widgets/CourseInfoStrip/CourseInfoStripWidget.tsx
new file mode 100644
index 0000000000..3bc8cfb8b5
--- /dev/null
+++ b/src/widgets/CourseInfoStrip/CourseInfoStripWidget.tsx
@@ -0,0 +1,17 @@
+import { useParams } from 'react-router-dom';
+
+import { useCourseHomeMeta } from '@src/course-home/data/apiHooks';
+import CourseInfoStripSlot from '@src/slots/CourseInfoStripSlot';
+
+const CourseInfoStripWidget = () => {
+ const { courseId } = useParams();
+ const { data } = useCourseHomeMeta(courseId, { enabled: false });
+
+ if (!data?.courseAccess?.hasAccess) {
+ return null;
+ }
+
+ return ;
+};
+
+export default CourseInfoStripWidget;
diff --git a/src/widgets/CourseInfoStrip/README.md b/src/widgets/CourseInfoStrip/README.md
new file mode 100644
index 0000000000..703d2af3fe
--- /dev/null
+++ b/src/widgets/CourseInfoStrip/README.md
@@ -0,0 +1,54 @@
+# Course Info Strip Widget
+
+### Widget ID: `org.openedx.frontend.widget.learning.courseInfoStrip.v1`
+
+### Slot ID (owned by the shell): `org.openedx.frontend.slot.header.masqueradeBar.v1`
+
+### Props: none
+
+## Description
+
+The strip with information about the current course, between the shell's header and its course bar: above the masquerade bar when it shows, and above the course tabs. The widget renders Learning's [Course Info Strip slot](../../slots/CourseInfoStripSlot/README.md), whose default content lists the learner's pathways that include the course. Learning inserts it on its course routes only (condition: `org.openedx.frontend.role.learningCourse` active).
+
+The widget renders nothing until the course page has loaded the course's metadata, and nothing for a learner without access to the course.
+
+The widget takes the course ID from the URL. Its code loads on first render, in a chunk of its own.
+
+To change what the strip shows, use the [Course Info Strip slot](../../slots/CourseInfoStripSlot/README.md). To remove the strip altogether, remove this widget.
+
+## Examples
+
+### Remove the widget
+
+The diff below is against this package's `site.config.dev.tsx`.
+
+```diff
+-import { EnvironmentTypes, SiteConfig, footerApp, headerApp, shellApp } from '@openedx/frontend-base';
++import {
++ EnvironmentTypes, SiteConfig, WidgetOperationTypes, footerApp, headerApp, shellApp,
++} from '@openedx/frontend-base';
+
+ import { learningApp } from './src';
+
+ import '@openedx/frontend-base/shell/style';
+
+ const siteConfig: SiteConfig = {
+ // ...
+ apps: [
+ shellApp,
+ headerApp,
+ footerApp,
+ learningApp,
++ {
++ appId: 'org.example.app.myPlugin',
++ slots: [
++ {
++ slotId: 'org.openedx.frontend.slot.header.masqueradeBar.v1',
++ op: WidgetOperationTypes.REMOVE,
++ relatedId: 'org.openedx.frontend.widget.learning.courseInfoStrip.v1',
++ },
++ ],
++ },
+ ],
+ };
+```
diff --git a/src/widgets/CourseInfoStrip/app.test.tsx b/src/widgets/CourseInfoStrip/app.test.tsx
new file mode 100644
index 0000000000..25e3b86fec
--- /dev/null
+++ b/src/widgets/CourseInfoStrip/app.test.tsx
@@ -0,0 +1,22 @@
+import { WidgetOperationTypes } from '@openedx/frontend-base';
+
+import { learningCourseRole } from '@src/constants';
+import slots from '@src/slots';
+
+import courseInfoStripApp, { courseInfoStripWidgetId, LazyCourseInfoStripWidget } from './app';
+
+describe('courseInfoStripApp', () => {
+ it("prepends the strip to the shell's masquerade bar on Learning course routes", () => {
+ expect(courseInfoStripApp.slots).toEqual([{
+ slotId: 'org.openedx.frontend.slot.header.masqueradeBar.v1',
+ id: courseInfoStripWidgetId,
+ op: WidgetOperationTypes.PREPEND,
+ component: LazyCourseInfoStripWidget,
+ condition: { active: [learningCourseRole] },
+ }]);
+ });
+
+ it("is part of Learning's slot operations", () => {
+ expect(slots).toEqual(expect.arrayContaining(courseInfoStripApp.slots ?? []));
+ });
+});
diff --git a/src/widgets/CourseInfoStrip/app.tsx b/src/widgets/CourseInfoStrip/app.tsx
new file mode 100644
index 0000000000..a88bd450be
--- /dev/null
+++ b/src/widgets/CourseInfoStrip/app.tsx
@@ -0,0 +1,29 @@
+import { App, WidgetOperationTypes } from '@openedx/frontend-base';
+import { lazy, Suspense } from 'react';
+
+import { learningCourseRole } from '@src/constants';
+
+export const courseInfoStripWidgetId = 'org.openedx.frontend.widget.learning.courseInfoStrip.v1';
+
+const CourseInfoStripWidget = lazy(() => import(/* webpackChunkName: "learning-course-info-strip" */ './CourseInfoStripWidget'));
+
+export const LazyCourseInfoStripWidget = () => (
+
+
+
+);
+
+const app: App = {
+ appId: 'org.openedx.frontend.app.learning.courseInfoStrip',
+ slots: [
+ {
+ slotId: 'org.openedx.frontend.slot.header.masqueradeBar.v1',
+ id: courseInfoStripWidgetId,
+ op: WidgetOperationTypes.PREPEND,
+ component: LazyCourseInfoStripWidget,
+ condition: { active: [learningCourseRole] },
+ },
+ ],
+};
+
+export default app;
diff --git a/src/widgets/CourseInfoStrip/index.ts b/src/widgets/CourseInfoStrip/index.ts
new file mode 100644
index 0000000000..35e2260572
--- /dev/null
+++ b/src/widgets/CourseInfoStrip/index.ts
@@ -0,0 +1 @@
+export { default as courseInfoStripApp, courseInfoStripWidgetId } from './app';
diff --git a/src/widgets/LearningHeader/PathwayInfo.test.tsx b/src/widgets/LearningHeader/PathwayInfo.test.tsx
new file mode 100644
index 0000000000..550c28e092
--- /dev/null
+++ b/src/widgets/LearningHeader/PathwayInfo.test.tsx
@@ -0,0 +1,55 @@
+import { QueryClientProvider } from '@tanstack/react-query';
+import { render, screen } from '@testing-library/react';
+import { MemoryRouter, Outlet, Route, Routes } from 'react-router-dom';
+
+import { dataEngineering } from '@src/pathways/data/__fixtures__/pathways';
+import { pathwayQueryKeys } from '@src/pathways/data/apiHooks';
+import type { PathwayData } from '@src/pathways/data/types';
+import { createTestQueryClient, seedQueryData } from '@src/tests/queryClient';
+
+import PathwayInfo from './PathwayInfo';
+
+const pathwayId = dataEngineering.pathway.id;
+
+// The widget renders in the shell's header: a layout route above the page, not inside it.
+const renderInHeader = (pathway?: PathwayData) => {
+ const queryClient = createTestQueryClient();
+ if (pathway) {
+ seedQueryData(queryClient, pathwayQueryKeys.pathway(pathwayId), pathway);
+ }
+ const result = render(
+
+
+
+ >}>
+ } />
+
+
+
+ ,
+ );
+ return { ...result, queryClient };
+};
+
+describe('PathwayInfo', () => {
+ it('shows the provider on one line and the pathway title beneath, from the pathway in the page route', () => {
+ renderInHeader(dataEngineering);
+
+ expect(screen.getByText(dataEngineering.provider!.name)).toHaveClass('d-block', 'small');
+ expect(screen.getByText(dataEngineering.pathway.content.displayName)).toHaveClass('d-block', 'font-weight-bold');
+ });
+
+ it('shows only the title of a pathway without a provider', () => {
+ const { container } = renderInHeader({ ...dataEngineering, provider: undefined });
+
+ expect(container.querySelectorAll('header span')).toHaveLength(1);
+ expect(screen.getByText(dataEngineering.pathway.content.displayName)).toBeInTheDocument();
+ });
+
+ it('renders nothing and requests nothing while the page has not loaded the pathway', () => {
+ const { container, queryClient } = renderInHeader();
+
+ expect(container.querySelector('header')).toBeEmptyDOMElement();
+ expect(queryClient.getQueryState(pathwayQueryKeys.pathway(pathwayId))?.fetchStatus).toBe('idle');
+ });
+});
diff --git a/src/widgets/LearningHeader/PathwayInfo.tsx b/src/widgets/LearningHeader/PathwayInfo.tsx
new file mode 100644
index 0000000000..6ad9baec98
--- /dev/null
+++ b/src/widgets/LearningHeader/PathwayInfo.tsx
@@ -0,0 +1,24 @@
+import { useParams } from 'react-router-dom';
+
+import { usePathway } from '@src/pathways/data/apiHooks';
+
+// The pathway counterpart of CourseInfo: the shell header renders outside the matched route's element, but
+// useParams() still returns the pathway ID of the page below it.
+const PathwayInfo = () => {
+ const { pathwayId } = useParams();
+ // A reader of the pathway the pathway page loads: it never fetches.
+ const { data } = usePathway(pathwayId, { enabled: false });
+
+ if (!data) {
+ return null;
+ }
+
+ return (
+
+ {data.provider && {data.provider.name} }
+ {data.pathway.content.displayName}
+
+ );
+};
+
+export default PathwayInfo;
diff --git a/src/widgets/LearningHeader/README.md b/src/widgets/LearningHeader/README.md
index 9e3835b10f..9b10a5cffa 100644
--- a/src/widgets/LearningHeader/README.md
+++ b/src/widgets/LearningHeader/README.md
@@ -14,6 +14,18 @@ Renders the current course's organization and number on one line and its title b
The widget takes the course ID from the URL and reads the course metadata the course page has already loaded: it never fetches, and renders nothing until that metadata is there.
+## Pathway Info
+
+### Widget ID: `org.openedx.frontend.widget.learning.pathwayInfo.v1`
+
+### Slot ID (owned by the shell): `org.openedx.frontend.slot.header.primaryLinks.v1`
+
+### Props: none
+
+The pathway counterpart of the course info: renders the current pathway's provider on one line and its title beneath, next to the site logo. It shows on Learning's pathway routes only (condition: `org.openedx.frontend.role.pathway` active).
+
+The widget takes the pathway ID from the URL and reads the pathway the pathway page has already loaded: it never fetches, and renders nothing until that pathway is there.
+
## Help
### Widget ID: `org.openedx.frontend.widget.header.help.v1`
diff --git a/src/widgets/LearningHeader/app.test.tsx b/src/widgets/LearningHeader/app.test.tsx
index 08f389a609..5b0af49feb 100644
--- a/src/widgets/LearningHeader/app.test.tsx
+++ b/src/widgets/LearningHeader/app.test.tsx
@@ -5,12 +5,13 @@ import { screen } from '@testing-library/react';
import { type ReactElement } from 'react';
import {
- appId, dashboardRole, learningCourseRole, learningRole,
+ appId, dashboardRole, learningCourseRole, learningRole, pathwayRole,
} from '@src/constants';
import { render } from '@src/tests/render';
import CourseInfo from './CourseInfo';
-import learningHeaderApp, { courseInfoWidgetId, dashboardLinkWidgetId } from './app';
+import PathwayInfo from './PathwayInfo';
+import learningHeaderApp, { courseInfoWidgetId, dashboardLinkWidgetId, pathwayInfoWidgetId } from './app';
const siteConfig = getSiteConfig();
@@ -35,6 +36,16 @@ describe('learningHeaderApp', () => {
});
});
+ it('appends the pathway info widget to the primary links on pathway routes', () => {
+ expect(operation(pathwayInfoWidgetId)).toEqual({
+ slotId: 'org.openedx.frontend.slot.header.primaryLinks.v1',
+ id: pathwayInfoWidgetId,
+ op: WidgetOperationTypes.APPEND,
+ component: PathwayInfo,
+ condition: { active: [pathwayRole] },
+ });
+ });
+
it('adds the help button on Learning routes', () => {
expect(operation(helpWidgetId)).toMatchObject({
slotId: 'org.openedx.frontend.slot.header.secondaryLinks.v1',
diff --git a/src/widgets/LearningHeader/app.tsx b/src/widgets/LearningHeader/app.tsx
index b6daf18d5c..e9d39990f1 100644
--- a/src/widgets/LearningHeader/app.tsx
+++ b/src/widgets/LearningHeader/app.tsx
@@ -3,13 +3,15 @@ import {
} from '@openedx/frontend-base';
import {
- appId, dashboardRole, learningCourseRole, learningRole,
+ appId, dashboardRole, learningCourseRole, learningRole, pathwayRole,
} from '@src/constants';
import CourseInfo from './CourseInfo';
+import PathwayInfo from './PathwayInfo';
import messages from './messages';
export const courseInfoWidgetId = 'org.openedx.frontend.widget.learning.courseInfo.v1';
+export const pathwayInfoWidgetId = 'org.openedx.frontend.widget.learning.pathwayInfo.v1';
export const dashboardLinkWidgetId = 'org.openedx.frontend.widget.learning.headerLinkDashboard.v1';
const app: App = {
@@ -23,6 +25,13 @@ const app: App = {
// The query cache can still hold a Learning course after the learner moves to another app's course page.
condition: { active: [learningCourseRole] },
},
+ {
+ slotId: 'org.openedx.frontend.slot.header.primaryLinks.v1',
+ id: pathwayInfoWidgetId,
+ op: WidgetOperationTypes.APPEND,
+ component: PathwayInfo,
+ condition: { active: [pathwayRole] },
+ },
helpButtonSlotOperation({ appId, role: learningRole }),
{
slotId: 'org.openedx.frontend.slot.header.authenticatedMenu.v1',
diff --git a/src/widgets/LearningHeader/index.ts b/src/widgets/LearningHeader/index.ts
index 7242778d47..9b41f650ed 100644
--- a/src/widgets/LearningHeader/index.ts
+++ b/src/widgets/LearningHeader/index.ts
@@ -1 +1,3 @@
-export { default as learningHeaderApp, courseInfoWidgetId, dashboardLinkWidgetId } from './app';
+export {
+ default as learningHeaderApp, courseInfoWidgetId, dashboardLinkWidgetId, pathwayInfoWidgetId,
+} from './app';
diff --git a/src/widgets/README.md b/src/widgets/README.md
index a6e15d515b..16426532fd 100644
--- a/src/widgets/README.md
+++ b/src/widgets/README.md
@@ -11,8 +11,10 @@ Learning's app declares these in its `slots` (see `src/slots.tsx`), so every sit
| Widget | ID | Slot |
|---|---|---|
| [Course info](./LearningHeader/README.md#course-info) | `courseInfo` | the shell's header, `org.openedx.frontend.slot.header.primaryLinks.v1` |
+| [Pathway info](./LearningHeader/README.md#pathway-info) | `pathwayInfo` | the shell's header, `org.openedx.frontend.slot.header.primaryLinks.v1` |
| [Help](./LearningHeader/README.md#help) | `org.openedx.frontend.widget.header.help.v1` | the shell's header, `org.openedx.frontend.slot.header.secondaryLinks.v1` |
| [Dashboard menu item](./LearningHeader/README.md#dashboard) | `headerLinkDashboard` | the shell's header, `org.openedx.frontend.slot.header.authenticatedMenu.v1` |
+| [Course info strip](./CourseInfoStrip/README.md) | `courseInfoStrip` | the shell's header, `org.openedx.frontend.slot.header.masqueradeBar.v1` |
| [Courseware search](./CoursewareSearch/README.md) | `coursewareSearch` | the shell's course bar, `org.openedx.frontend.slot.header.courseNavigationBar.extraContent.v1` |
| [Discussions sidebar](./DiscussionsSidebar/README.md) | `discussionsSidebar` (exported as `discussionsSidebarWidgetId`) | Learning's [auxiliary sidebar](../slots/AuxiliarySidebarSlot/README.md) and [its trigger slot](../slots/AuxiliarySidebarTriggerSlot/README.md) |