Skip to content

Commit e9a546c

Browse files
authored
more dashboard CTA adjustments (#2701)
* adjust CTA buttons to new width of 124px, set new button text and end icon logic * update tests to reflect new logic * fix one more test
1 parent 923bcb7 commit e9a546c

File tree

4 files changed

+35
-24
lines changed

4 files changed

+35
-24
lines changed

frontends/main/src/app-pages/DashboardPage/CoursewareDisplay/DashboardCard.test.tsx

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -179,21 +179,21 @@ describe.each([
179179
course: pastDashboardCourse({
180180
enrollment: { status: EnrollmentStatus.Enrolled },
181181
}),
182-
expected: { labelPrefix: "View" },
182+
expected: { label: "View", usesCourseNoun: true },
183183
case: "past",
184184
},
185185
{
186186
course: currentDashboardCourse({
187187
enrollment: { status: EnrollmentStatus.Enrolled },
188188
}),
189-
expected: { labelPrefix: "Continue" },
189+
expected: { label: "Continue", usesCourseNoun: false },
190190
case: "current",
191191
},
192192
{
193193
course: futureDashboardCourse({
194194
enrollment: { status: EnrollmentStatus.Enrolled },
195195
}),
196-
expected: { labelPrefix: "Continue" },
196+
expected: { label: "Continue", usesCourseNoun: false },
197197
label: "future",
198198
},
199199
])(
@@ -211,10 +211,10 @@ describe.each([
211211
!course.enrollment
212212
) {
213213
expect(coursewareCTA).toHaveTextContent("Start Course")
214+
} else if (expected.usesCourseNoun) {
215+
expect(coursewareCTA).toHaveTextContent(`${expected.label} Course`)
214216
} else {
215-
expect(coursewareCTA).toHaveTextContent(
216-
`${expected.labelPrefix} Course`,
217-
)
217+
expect(coursewareCTA).toHaveTextContent(expected.label)
218218
}
219219

220220
const courseNoun = faker.word.noun()
@@ -231,10 +231,13 @@ describe.each([
231231
!course.enrollment
232232
) {
233233
expect(coursewareCTA).toHaveTextContent(`Start ${courseNoun}`)
234-
} else {
234+
} else if (expected.usesCourseNoun) {
235235
expect(coursewareCTA).toHaveTextContent(
236-
`${expected.labelPrefix} ${courseNoun}`,
236+
`${expected.label} ${courseNoun}`,
237237
)
238+
} else {
239+
// "Continue" doesn't use courseNoun
240+
expect(coursewareCTA).toHaveTextContent(expected.label)
238241
}
239242
},
240243
)
@@ -522,7 +525,7 @@ describe.each([
522525

523526
test.each([
524527
{ status: EnrollmentStatus.Completed, expectedText: "View Course" },
525-
{ status: EnrollmentStatus.Enrolled, expectedText: "Continue Course" },
528+
{ status: EnrollmentStatus.Enrolled, expectedText: "Continue" },
526529
{ status: EnrollmentStatus.NotEnrolled, expectedText: "Start Course" },
527530
])(
528531
"CoursewareButton shows correct text based on enrollment status ($status)",

frontends/main/src/app-pages/DashboardPage/CoursewareDisplay/DashboardCard.tsx

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,8 @@ type CoursewareButtonProps = {
158158
courseNoun: string
159159
"data-testid"?: string
160160
}
161-
const getCoursewareText = ({
161+
162+
const getCoursewareTextAndIcon = ({
162163
endDate,
163164
enrollmentStatus,
164165
courseNoun,
@@ -168,16 +169,17 @@ const getCoursewareText = ({
168169
courseNoun: string
169170
}) => {
170171
if (!enrollmentStatus || enrollmentStatus === EnrollmentStatus.NotEnrolled) {
171-
return `Start ${courseNoun}`
172+
return { text: `Start ${courseNoun}`, endIcon: null }
172173
}
173174
if (
174175
(endDate && isInPast(endDate)) ||
175176
enrollmentStatus === EnrollmentStatus.Completed
176177
) {
177-
return `View ${courseNoun}`
178+
return { text: `View ${courseNoun}`, endIcon: null }
178179
}
179-
return `Continue ${courseNoun}`
180+
return { text: "Continue", endIcon: <RiArrowRightLine /> }
180181
}
182+
181183
const CoursewareButton = styled(
182184
({
183185
coursewareId,
@@ -189,7 +191,7 @@ const CoursewareButton = styled(
189191
courseNoun,
190192
...others
191193
}: CoursewareButtonProps) => {
192-
const coursewareText = getCoursewareText({
194+
const coursewareText = getCoursewareTextAndIcon({
193195
endDate,
194196
courseNoun,
195197
enrollmentStatus,
@@ -222,20 +224,20 @@ const CoursewareButton = styled(
222224
}
223225
{...others}
224226
>
225-
{coursewareText}
227+
{coursewareText.text}
226228
</Button>
227229
)
228230
} else if (hasStarted && href /* Link to course */) {
229231
return (
230232
<ButtonLink
231233
size="small"
232234
variant="primary"
233-
endIcon={<RiArrowRightLine />}
235+
endIcon={coursewareText.endIcon}
234236
href={href}
235237
className={className}
236238
{...others}
237239
>
238-
{coursewareText}
240+
{coursewareText.text}
239241
</ButtonLink>
240242
)
241243
}
@@ -249,11 +251,11 @@ const CoursewareButton = styled(
249251
className={className}
250252
{...others}
251253
>
252-
{coursewareText}
254+
{coursewareText.text}
253255
</Button>
254256
)
255257
},
256-
)({ width: "142px" })
258+
)({ width: "124px" })
257259

258260
const formatUpgradeTime = (daysFloat: number) => {
259261
if (daysFloat < 0) return ""

frontends/main/src/app-pages/DashboardPage/CoursewareDisplay/OrganizationCards.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { mitxUserQueries } from "api/mitxonline-hooks/user"
88
import { ButtonLink } from "@mitodl/smoot-design"
99
import { organizationView } from "@/common/urls"
1010
import { OrganizationPage } from "@mitodl/mitxonline-api-axios/v2"
11+
import { RiArrowRightLine } from "@remixicon/react"
1112

1213
const Wrapper = styled.div(({ theme }) => ({
1314
display: "flex",
@@ -88,6 +89,12 @@ const Title = styled.div(({ theme }) => ({
8889
},
8990
}))
9091

92+
const CardButton = styled(ButtonLink)({
93+
width: "124px",
94+
minWidth: "124px",
95+
flexShrink: 0,
96+
})
97+
9198
interface OrganizationContractsProps {
9299
org: OrganizationPage
93100
}
@@ -103,9 +110,9 @@ const OrganizationContracts: React.FC<OrganizationContractsProps> = ({
103110
<TitleLink size="medium" color="black" href={href}>
104111
{contract.name}
105112
</TitleLink>
106-
<ButtonLink size="small" href={href}>
113+
<CardButton size="small" href={href} endIcon={<RiArrowRightLine />}>
107114
Continue
108-
</ButtonLink>
115+
</CardButton>
109116
</CardContent>
110117
)
111118
}) ?? null

frontends/main/src/app-pages/DashboardPage/OrganizationContent.test.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -530,9 +530,8 @@ describe("OrganizationContent", () => {
530530
// Check that the card displays information from the correct course run
531531
const coursewareButton = within(card).getByTestId("courseware-button")
532532

533-
// The courseware button shows different text based on course type and enrollment status
534-
// For enrolled users in started courses, it shows "Continue Course" or "Continue Module"
535-
expect(coursewareButton).toHaveTextContent(/Continue (Course|Module)/i)
533+
// The courseware button shows "Continue" for enrolled users in started courses
534+
expect(coursewareButton).toHaveTextContent("Continue")
536535

537536
// Verify the courseware button has the correct href from the contract run
538537
// Only check href if the course has started and user is enrolled

0 commit comments

Comments
 (0)