Skip to content

v2 drawer certification updates #1823

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Nov 15, 2024
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
98 changes: 49 additions & 49 deletions frontends/api/src/generated/v1/api.ts

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ const courses = {
runs: [factories.learningResources.run()],
free: true,
certification: true,
certification_type: {
code: "completion",
name: "Certificate of Completion",
},
resource_prices: [
{ amount: "0", currency: "USD" },
{ amount: "49", currency: "USD" },
Expand All @@ -77,6 +81,10 @@ const courses = {
runs: [factories.learningResources.run()],
free: true,
certification: true,
certification_type: {
code: "completion",
name: "Certificate of Completion",
},
resource_prices: [
{ amount: "0", currency: "USD" },
{ amount: "99", currency: "USD" },
Expand Down Expand Up @@ -125,6 +133,10 @@ const courses = {
runs: [factories.learningResources.run()],
free: false,
certification: true,
certification_type: {
code: "completion",
name: "Certificate of Completion",
},
resource_prices: [],
}),
},
Expand All @@ -141,13 +153,21 @@ const courses = {
runs: [factories.learningResources.run()],
free: false,
certification: true,
certification_type: {
code: "completion",
name: "Certificate of Completion",
},
resource_prices: [{ amount: "49", currency: "USD" }],
}),
withCertificatePriceRange: makeResource({
resource_type: ResourceTypeEnum.Course,
runs: [factories.learningResources.run()],
free: false,
certification: true,
certification_type: {
code: "completion",
name: "Certificate of Completion",
},
resource_prices: [
{ amount: "49", currency: "USD" },
{ amount: "99", currency: "USD" },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,10 @@ describe("Learning resource info section pricing", () => {

screen.getByText("Paid")
expect(screen.queryByText("Free")).toBeNull()
screen.getByText("Certificate included")
screen.getByText("Certificate:")
screen.getByText(
courses.unknownPrice.withCertificate.certification_type.name,
)
})

test("Paid course, no certificate", () => {
Expand All @@ -87,7 +90,8 @@ describe("Learning resource info section pricing", () => {

screen.getByText("$49")
expect(screen.queryByText("Paid")).toBeNull()
screen.getByText("Certificate included")
screen.getByText("Certificate:")
screen.getByText(courses.paid.withCerticateOnePrice.certification_type.name)
})

test("Paid course, with certificate, price range", () => {
Expand All @@ -100,7 +104,10 @@ describe("Learning resource info section pricing", () => {

screen.getByText("$49 – $99")
expect(screen.queryByText("Paid")).toBeNull()
screen.getByText("Certificate included")
screen.getByText("Certificate:")
screen.getByText(
courses.paid.withCertificatePriceRange.certification_type.name,
)
})
})

Expand Down Expand Up @@ -158,13 +165,14 @@ describe("Learning resource info section start date", () => {
})
})

test("If data is different, dates are not shown", () => {
test("If data is different, dates and prices are not shown", () => {
const course = courses.multipleRuns.differentData
render(<InfoSectionV2 resource={course} />, {
wrapper: ThemeProvider,
})
const section = screen.getByTestId("drawer-info-items")
expect(within(section).queryByText("Start Date:")).toBeNull()
expect(within(section).queryByText("Price:")).toBeNull()
})

test("Clicking the show more button should show more dates", async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
RiTranslate2,
RiPresentationLine,
RiAwardFill,
RiAwardLine,
} from "@remixicon/react"
import { LearningResource, ResourceTypeEnum } from "api"
import {
Expand Down Expand Up @@ -128,7 +129,7 @@ const Certificate = styled.div({
height: "16px",
},
[theme.breakpoints.down("sm")]: {
padding: "1px 2px",
padding: "4px 8px",
...theme.typography.subtitle4,
},
})
Expand Down Expand Up @@ -251,22 +252,44 @@ const INFO_ITEMS: InfoItemConfig = [
label: "Price:",
Icon: RiPriceTag3Line,
selector: (resource: LearningResource) => {
const prices = getLearningResourcePrices(resource)
if (allRunsAreIdentical(resource)) {
const prices = getLearningResourcePrices(resource)

return (
<PriceDisplay>
<div>{prices.course.display}</div>
{resource.certification && (
<Certificate>
<RiAwardFill />
{prices.certificate.display
? "Earn a certificate:"
: "Certificate included"}
<span>{prices.certificate.display}</span>
</Certificate>
)}
</PriceDisplay>
)
return (
<PriceDisplay>
<div>{resource.free ? "Free" : prices.course.display}</div>
{resource.certification && resource.free ? (
<>
{prices.certificate.display ? (
<Certificate>
<RiAwardFill />
<span>Earn a certificate:</span>
<span>{prices.certificate.display}</span>
</Certificate>
) : (
<Certificate>
<RiAwardLine />
<span>Certificate</span>
</Certificate>
)}
</>
) : null}
</PriceDisplay>
)
} else return null
},
},
{
label: "Certificate:",
Icon: RiAwardLine,
selector: (resource: LearningResource) => {
return resource.certification_type && !resource.free ? (
<InfoItemValue
label={resource.certification_type.name}
index={1}
total={1}
/>
) : null
},
},
{
Expand Down
2 changes: 1 addition & 1 deletion learning_resources/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ class LearningResourceDelivery(ExtendedEnum):
class CertificationType(ExtendedEnum):
"""Enum for resource certification types"""

micromasters = "Micromasters Credential"
micromasters = "MicroMasters Credential"
professional = "Professional Certificate"
completion = "Certificate of Completion"
none = "No Certificate"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Generated by Django 4.2.16 on 2024-11-13 22:34

from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
("learning_resources", "0075_learningresourcerun_instructors"),
]

operations = [
migrations.AlterField(
model_name="learningresource",
name="certification_type",
field=models.CharField(
choices=[
("micromasters", "MicroMasters Credential"),
("professional", "Professional Certificate"),
("completion", "Certificate of Completion"),
("none", "No Certificate"),
],
default="none",
max_length=24,
),
),
]
44 changes: 22 additions & 22 deletions openapi/specs/v1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,7 @@ paths:
description: |-
The type of certification offered

* `micromasters` - Micromasters Credential
* `micromasters` - MicroMasters Credential
* `professional` - Professional Certificate
* `completion` - Certificate of Completion
* `none` - No Certificate
Expand Down Expand Up @@ -1163,7 +1163,7 @@ paths:
description: |-
The type of certification offered

* `micromasters` - Micromasters Credential
* `micromasters` - MicroMasters Credential
* `professional` - Professional Certificate
* `completion` - Certificate of Completion
* `none` - No Certificate
Expand Down Expand Up @@ -1567,7 +1567,7 @@ paths:
description: |-
The type of certification offered

* `micromasters` - Micromasters Credential
* `micromasters` - MicroMasters Credential
* `professional` - Professional Certificate
* `completion` - Certificate of Completion
* `none` - No Certificate
Expand Down Expand Up @@ -1978,7 +1978,7 @@ paths:
description: |-
The type of certification offered

* `micromasters` - Micromasters Credential
* `micromasters` - MicroMasters Credential
* `professional` - Professional Certificate
* `completion` - Certificate of Completion
* `none` - No Certificate
Expand Down Expand Up @@ -2371,7 +2371,7 @@ paths:
description: |-
The type of certification offered

* `micromasters` - Micromasters Credential
* `micromasters` - MicroMasters Credential
* `professional` - Professional Certificate
* `completion` - Certificate of Completion
* `none` - No Certificate
Expand Down Expand Up @@ -3099,11 +3099,11 @@ paths:
- none
type: string
description: |-
* `micromasters` - Micromasters Credential
* `micromasters` - MicroMasters Credential
* `professional` - Professional Certificate
* `completion` - Certificate of Completion
* `none` - No Certificate
description: "The type of certificate \n\n* `micromasters` - Micromasters\
description: "The type of certificate \n\n* `micromasters` - MicroMasters\
\ Credential\n* `professional` - Professional Certificate\n* `completion`\
\ - Certificate of Completion\n* `none` - No Certificate"
- in: query
Expand Down Expand Up @@ -3597,11 +3597,11 @@ paths:
- none
type: string
description: |-
* `micromasters` - Micromasters Credential
* `micromasters` - MicroMasters Credential
* `professional` - Professional Certificate
* `completion` - Certificate of Completion
* `none` - No Certificate
description: "The type of certificate \n\n* `micromasters` - Micromasters\
description: "The type of certificate \n\n* `micromasters` - MicroMasters\
\ Credential\n* `professional` - Professional Certificate\n* `completion`\
\ - Certificate of Completion\n* `none` - No Certificate"
- in: query
Expand Down Expand Up @@ -4120,11 +4120,11 @@ paths:
- none
type: string
description: |-
* `micromasters` - Micromasters Credential
* `micromasters` - MicroMasters Credential
* `professional` - Professional Certificate
* `completion` - Certificate of Completion
* `none` - No Certificate
description: "The type of certificate \n\n* `micromasters` - Micromasters\
description: "The type of certificate \n\n* `micromasters` - MicroMasters\
\ Credential\n* `professional` - Professional Certificate\n* `completion`\
\ - Certificate of Completion\n* `none` - No Certificate"
- in: query
Expand Down Expand Up @@ -4634,11 +4634,11 @@ paths:
- none
type: string
description: |-
* `micromasters` - Micromasters Credential
* `micromasters` - MicroMasters Credential
* `professional` - Professional Certificate
* `completion` - Certificate of Completion
* `none` - No Certificate
description: "The type of certificate \n\n* `micromasters` - Micromasters\
description: "The type of certificate \n\n* `micromasters` - MicroMasters\
\ Credential\n* `professional` - Professional Certificate\n* `completion`\
\ - Certificate of Completion\n* `none` - No Certificate"
- in: query
Expand Down Expand Up @@ -5122,7 +5122,7 @@ paths:
description: |-
The type of certification offered

* `micromasters` - Micromasters Credential
* `micromasters` - MicroMasters Credential
* `professional` - Professional Certificate
* `completion` - Certificate of Completion
* `none` - No Certificate
Expand Down Expand Up @@ -5866,7 +5866,7 @@ paths:
description: |-
The type of certification offered

* `micromasters` - Micromasters Credential
* `micromasters` - MicroMasters Credential
* `professional` - Professional Certificate
* `completion` - Certificate of Completion
* `none` - No Certificate
Expand Down Expand Up @@ -6270,7 +6270,7 @@ paths:
description: |-
The type of certification offered

* `micromasters` - Micromasters Credential
* `micromasters` - MicroMasters Credential
* `professional` - Professional Certificate
* `completion` - Certificate of Completion
* `none` - No Certificate
Expand Down Expand Up @@ -6761,7 +6761,7 @@ paths:
description: |-
The type of certification offered

* `micromasters` - Micromasters Credential
* `micromasters` - MicroMasters Credential
* `professional` - Professional Certificate
* `completion` - Certificate of Completion
* `none` - No Certificate
Expand Down Expand Up @@ -7571,7 +7571,7 @@ paths:
description: |-
The type of certification offered

* `micromasters` - Micromasters Credential
* `micromasters` - MicroMasters Credential
* `professional` - Professional Certificate
* `completion` - Certificate of Completion
* `none` - No Certificate
Expand Down Expand Up @@ -8041,7 +8041,7 @@ paths:
description: |-
The type of certification offered

* `micromasters` - Micromasters Credential
* `micromasters` - MicroMasters Credential
* `professional` - Professional Certificate
* `completion` - Certificate of Completion
* `none` - No Certificate
Expand Down Expand Up @@ -8515,12 +8515,12 @@ components:
- none
type: string
description: |-
* `micromasters` - Micromasters Credential
* `micromasters` - MicroMasters Credential
* `professional` - Professional Certificate
* `completion` - Certificate of Completion
* `none` - No Certificate
x-enum-descriptions:
- Micromasters Credential
- MicroMasters Credential
- Professional Certificate
- Certificate of Completion
- No Certificate
Expand Down Expand Up @@ -11164,7 +11164,7 @@ components:
items:
$ref: '#/components/schemas/CertificationTypeEnum'
description: "The type of certificate \n\n* `micromasters` -\
\ Micromasters Credential\n* `professional` - Professional Certificate\n\
\ MicroMasters Credential\n* `professional` - Professional Certificate\n\
* `completion` - Certificate of Completion\n* `none` - No Certificate"
department:
type: array
Expand Down