Skip to content

Commit d61cfda

Browse files
Product Page Instructor Section (#2964)
* instructor display first pass * add bleed options to carouselv2 * fix scroll initial enabled/disabled detection * spacing tweaks * instructor section styling pass 2 * remove builtin outer margin * fix heading * minor fixes * make consumer responsible for track padding
1 parent 8f02234 commit d61cfda

9 files changed

Lines changed: 326 additions & 202 deletions

File tree

frontends/main/next.config.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ validateEnv()
66
const NEXT_PUBLIC_OPTIMIZE_IMAGES = Boolean(
77
(process.env.NEXT_PUBLIC_OPTIMIZE_IMAGES ?? "true") === "true",
88
)
9+
const IS_LOCAL_DEV = process.env.NODE_ENV === "development"
910

1011
const processFeatureFlags = () => {
1112
const featureFlagPrefix =
@@ -107,6 +108,7 @@ const nextConfig = {
107108

108109
images: {
109110
unoptimized: !NEXT_PUBLIC_OPTIMIZE_IMAGES,
111+
dangerouslyAllowLocalIP: IS_LOCAL_DEV,
110112
remotePatterns: [
111113
{
112114
hostname: "**",

frontends/main/src/app-pages/HomePage/VideoShortsSection.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ const Header = styled.div(({ theme }) => ({
2828
}))
2929

3030
const StyledCarouselV2 = styled(CarouselV2)(({ theme }) => ({
31+
margin: "24px 0",
32+
".MitCarousel-track": {
33+
paddingBottom: "4px",
34+
},
3135
[theme.breakpoints.down("sm")]: {
3236
padding: "0 16px",
3337
},

frontends/main/src/app-pages/ProductPages/CoursePage.test.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ describe("CoursePage", () => {
9090
test("Page has expected headings", async () => {
9191
const course = makeCourse()
9292
const page = makePage({ course_details: course })
93+
invariant(page.faculty.length > 0)
9394
setupApis({ course, page })
9495
renderWithProviders(<CoursePage readableId={course.readable_id} />)
9596

@@ -102,6 +103,7 @@ describe("CoursePage", () => {
102103
{ level: 2, name: "How you'll learn" },
103104
{ level: 2, name: "Prerequisites" },
104105
{ level: 2, name: "Meet your instructors" },
106+
{ level: 3, name: page.faculty[0].instructor_name },
105107
{ level: 2, name: "Who can take this Course?" },
106108
])
107109
})
@@ -162,7 +164,7 @@ describe("CoursePage", () => {
162164
expectRawContent(section, page.what_you_learn)
163165
})
164166

165-
// Dialog tested in InstructorsSection.test.tsx
167+
// Interaction and active content are tested in InstructorsSection.test.tsx
166168
test("Instructors section has expected content", async () => {
167169
const course = makeCourse()
168170
const page = makePage({ course_details: course })
@@ -173,8 +175,10 @@ describe("CoursePage", () => {
173175
const section = await screen.findByRole("region", {
174176
name: "Meet your instructors",
175177
})
176-
const items = within(section).getAllByRole("listitem")
177-
expect(items.length).toBe(page.faculty.length)
178+
const buttons = page.faculty.map((faculty) =>
179+
within(section).getByRole("button", { name: faculty.instructor_name }),
180+
)
181+
expect(buttons.length).toBe(page.faculty.length)
178182
})
179183

180184
test("Prerequisites section has expected content", async () => {
Lines changed: 18 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,7 @@
11
import React from "react"
22
import { factories } from "api/mitxonline-test-utils"
33

4-
import {
5-
renderWithProviders,
6-
waitFor,
7-
screen,
8-
within,
9-
user,
10-
} from "@/test-utils"
4+
import { renderWithProviders, screen, within, user } from "@/test-utils"
115

126
import { getByImageSrc } from "ol-test-utilities"
137

@@ -30,18 +24,22 @@ test("Renders each instructor", async () => {
3024
name: "Meet your instructors",
3125
})
3226

33-
const items = within(section).getAllByRole("listitem")
34-
3527
expect(instructors.length).toBe(3)
36-
instructors.forEach((instructor, index) => {
37-
const item = items[index]
38-
within(item).getByRole("button", { name: instructor.instructor_name })
39-
within(item).getByText(instructor.instructor_title)
40-
getByImageSrc(item, instructor.feature_image_src)
28+
instructors.forEach((instructor) => {
29+
const button = within(section).getByRole("button", {
30+
name: instructor.instructor_name,
31+
})
32+
getByImageSrc(button, instructor.feature_image_src)
33+
})
34+
35+
const defaultInstructor = instructors[0]
36+
within(section).getByRole("heading", {
37+
name: defaultInstructor.instructor_name,
4138
})
39+
expectRawContent(section, defaultInstructor.instructor_bio_long)
4240
})
4341

44-
test("Opens and closes instructor dialog", async () => {
42+
test("Changes active instructor content on portrait click", async () => {
4543
const instructors = Array.from({ length: 3 }, () => makeFaculty())
4644
renderWithProviders(<InstructorsSection instructors={instructors} />)
4745

@@ -51,18 +49,13 @@ test("Opens and closes instructor dialog", async () => {
5149
})
5250
await user.click(button)
5351

54-
const dialog = await screen.findByRole("dialog", {
55-
name: `${instructor.instructor_name}`,
52+
const section = await screen.findByRole("region", {
53+
name: "Meet your instructors",
5654
})
57-
within(dialog).getByRole("heading", {
58-
level: 2,
55+
within(section).getByRole("heading", {
5956
name: instructor.instructor_name,
6057
})
61-
expectRawContent(dialog, instructor.instructor_bio_long)
58+
expectRawContent(section, instructor.instructor_bio_long)
6259

63-
const closeButton = within(dialog).getByRole("button", { name: "Close" })
64-
await user.click(closeButton)
65-
await waitFor(() => {
66-
expect(dialog).not.toBeInTheDocument()
67-
})
60+
expect(screen.queryByRole("dialog")).not.toBeInTheDocument()
6861
})

0 commit comments

Comments
 (0)