Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions RELEASE.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
Release Notes
=============

Version 0.56.10
---------------

- Avoid unnecessary task calls for contentfiles if none exist (#3017)
- add ocw learning materials to search (#3018)

Version 0.56.9 (Released March 09, 2026)
--------------

Expand Down
18 changes: 12 additions & 6 deletions frontends/api/src/generated/v0/api.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

205 changes: 182 additions & 23 deletions frontends/api/src/generated/v1/api.ts

Large diffs are not rendered by default.

26 changes: 26 additions & 0 deletions frontends/api/src/test-utils/factories/learningResources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import type { Factory, PartialFactory } from "ol-test-utilities"
import { UniqueEnforcer } from "enforce-unique"
import { makePaginatedFactory, mergeOverrides } from "ol-test-utilities"
import type {
ContentFile,
CourseNumber,
CourseResource,
LearningPathRelationship,
Expand Down Expand Up @@ -41,6 +42,7 @@ import {
LearningResourceRunLevelInnerCodeEnum,
PlatformEnum,
CourseResourceCertificationTypeCodeEnum,
ContentTypeEnum,
} from "api"

const uniqueEnforcerId = new UniqueEnforcer()
Expand Down Expand Up @@ -234,6 +236,29 @@ const learningResourceRun: Factory<LearningResourceRun> = (overrides = {}) => {
return run
}

const contentFile: Factory<ContentFile> = (overrides = {}) => {
return {
id: uniqueEnforcerId.enforce(() => faker.number.int()),
departments: repeat(learningResourceDepartment, { min: 0, max: 3 }),
topics: repeat(learningResourceTopic, { min: 0, max: 3 }),
require_summaries: faker.datatype.boolean(),
content_feature_type: repeat(faker.lorem.word, { min: 0, max: 3 }),
resource_id: uniqueEnforcerId.enforce(() => faker.number.int()).toString(),
resource_readable_id: faker.string.alphanumeric(32).toLowerCase(),
course_number: repeat(faker.lorem.word, { min: 0, max: 3 }),
offered_by: learningResourceOfferor(),
platform: learningResourcePlatform(),
title: faker.lorem.sentence(),
description: faker.lorem.paragraph(),
key: faker.string.uuid(),
uid: faker.string.uuid(),
url: faker.internet.url(),
content_type: faker.helpers.arrayElement(Object.values(ContentTypeEnum)),
content: faker.lorem.paragraph(),
...overrides,
}
}

const learningResourceTopic: Factory<LearningResourceTopic> = (
overrides = {},
) => {
Expand Down Expand Up @@ -626,6 +651,7 @@ export {
learningResourceSummaries as resourceSummaries,
learningResourceSummary as resourceSummary,
learningResourceRun as run,
contentFile,
learningResourceImage as image,
learningResourceDepartment as department,
departments,
Expand Down
2 changes: 1 addition & 1 deletion frontends/main/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"@emotion/cache": "^11.13.1",
"@emotion/styled": "^11.11.0",
"@floating-ui/react": "^0.27.16",
"@mitodl/course-search-utils": "^3.5.1",
"@mitodl/course-search-utils": "^3.5.2",
"@mitodl/mitxonline-api-axios": "^2026.3.5",
"@mitodl/smoot-design": "^6.24.0",
"@mui/material": "^6.4.5",
Expand Down
19 changes: 10 additions & 9 deletions frontends/main/src/app-pages/SearchPage/SearchPage.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ describe("SearchPage", () => {
"free",
"offered_by",
"professional",
"resource_category",
"resource_type",
"resource_type_group",
"topic",
Expand Down Expand Up @@ -180,7 +181,7 @@ describe("SearchPage", () => {
expect(location.current.search).toBe("?topic=Physics")
})

test("Shows Learning Resource facet only if learning materials tab is selected", async () => {
test("Shows Resource Category facet only if learning materials tab is selected", async () => {
setMockApiResponses({
search: {
count: 700,
Expand All @@ -190,10 +191,10 @@ describe("SearchPage", () => {
{ key: "course", doc_count: 100 },
{ key: "learning_material", doc_count: 200 },
],
resource_type: [
{ key: "course", doc_count: 100 },
{ key: "podcast", doc_count: 100 },
{ key: "video", doc_count: 100 },
resource_category: [
{ key: "Course", doc_count: 100 },
{ key: "Podcast", doc_count: 100 },
{ key: "Video", doc_count: 100 },
],
},
suggestions: [],
Expand All @@ -203,12 +204,12 @@ describe("SearchPage", () => {
renderWithProviders(<SearchPage />)

const facetsContainer = screen.getByTestId("facets-container")
expect(within(facetsContainer).queryByText("Resource Type")).toBeNull()
expect(within(facetsContainer).queryByText("Resource Category")).toBeNull()
const tabLearningMaterial = screen.getByRole("tab", {
name: /Learning Material/,
})
await user.click(tabLearningMaterial)
await within(facetsContainer).findByText("Resource Type")
await within(facetsContainer).findByText("Resource Category")
})

test.each([
Expand Down Expand Up @@ -497,7 +498,7 @@ describe("Search Page Tabs", () => {
expect(params2.get("department")).toBe("8") // should preserve other params
})

test("Switching from learning materials tab clears resource type only", async () => {
test("Switching from learning materials tab clears resource category only", async () => {
setMockApiResponses({
search: {
count: 1000,
Expand All @@ -510,7 +511,7 @@ describe("Search Page Tabs", () => {
},
})
const { location } = renderWithProviders(<SearchPage />, {
url: "?resource_type_group=learning_material&resource_type=video&topic=Biology",
url: "?resource_type_group=learning_material&resource_category=Video&topic=Biology",
})
const tabLM = screen.getByRole("tab", { name: /Learning Materials/ })
const tabCourses = screen.getByRole("tab", { name: /Courses/ })
Expand Down
1 change: 1 addition & 0 deletions frontends/main/src/app-pages/SearchPage/searchRequests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ export const facetNames = [
"offered_by",
"free",
"professional",
"resource_category",
] as UseResourceSearchParamsProps["facets"]
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ describe("LearningResourceDrawer", () => {
const { resource } = setupApis({
resource: {
resource_type: ResourceTypeEnum.Course,
resource_category: "Course",
},
})
renderWithProviders(<LearningResourceDrawer />, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,34 +31,68 @@ const IMG_CONFIG: ImageConfig = {
describe("CallToActionSection", () => {
describe("Resource URL rendering", () => {
it.each([
{ resourceType: ResourceTypeEnum.Course, expectedText: "Learn More" },
{ resourceType: ResourceTypeEnum.Program, expectedText: "Learn More" },
{
resourceType: ResourceTypeEnum.Course,
platform: PlatformEnum.Xpro,
expectedText: "Learn More",
},
{
resourceType: ResourceTypeEnum.Course,
platform: PlatformEnum.Ocw,
expectedText: "Access Course Materials",
},

{
resourceType: ResourceTypeEnum.Program,
platform: PlatformEnum.Xpro,
expectedText: "Learn More",
},
{
resourceType: ResourceTypeEnum.Video,
platform: PlatformEnum.Youtube,
expectedText: "Watch on YouTube",
},
{
resourceType: ResourceTypeEnum.Video,
platform: PlatformEnum.Ocw,
expectedText: "Access Learning Material",
},
{
resourceType: ResourceTypeEnum.VideoPlaylist,
platform: PlatformEnum.Youtube,
expectedText: "Watch on YouTube",
},
{
resourceType: ResourceTypeEnum.Podcast,
expectedText: "Listen to Podcast",
platform: PlatformEnum.Podcast,
},
{
resourceType: ResourceTypeEnum.PodcastEpisode,
expectedText: "Listen to Podcast",
platform: PlatformEnum.Podcast,
},
{
resourceType: ResourceTypeEnum.Article,
expectedText: "View Article",
platform: PlatformEnum.Climate,
},
{ resourceType: ResourceTypeEnum.Article, expectedText: "View Article" },
{
resourceType: ResourceTypeEnum.LearningPath,
resourceType: ResourceTypeEnum.Document,
expectedText: "Access Learning Material",
platform: PlatformEnum.Ocw,
},
{
resourceType: ResourceTypeEnum.Document,
expectedText: "Learn More",
platform: PlatformEnum.Xpro,
},
])(
"renders link with correct text for $resourceType",
({ resourceType, expectedText }) => {
"renders link with correct text for $resourceType and platform $platform",
({ resourceType, expectedText, platform }) => {
const resource = factories.learningResources.resource({
resource_type: resourceType,
platform: { code: platform },
url: "https://example.com/resource",
})

Expand All @@ -74,27 +108,6 @@ describe("CallToActionSection", () => {
expect(link).toBeInTheDocument()
},
)

it("renders 'Access Course Materials' for OCW courses", () => {
const resource = factories.learningResources.resource({
resource_type: ResourceTypeEnum.Course,
platform: { code: PlatformEnum.Ocw },
url: "https://ocw.mit.edu/course",
})

renderWithProviders(
<CallToActionSection
imgConfig={IMG_CONFIG}
resource={resource}
shareUrl="https://learn.mit.edu/test"
/>,
)

const link = screen.getByRole("link", {
name: "Access Course Materials",
})
expect(link).toBeInTheDocument()
})
})

describe("UTM parameters", () => {
Expand Down
Loading
Loading