fix: render issue date on certificate pages - #3390
Conversation
OpenAPI ChangesNo changes detected Unexpected changes? Ensure your branch is up-to-date with |
There was a problem hiding this comment.
Pull request overview
This PR updates certificate rendering (both the on-screen certificate page and the generated PDF route) to display a certificate’s issue date from the API (issue_date) instead of relying on verifiable_credential_json.validFrom, which is not consistently present in responses.
Changes:
- Replace usage of
verifiable_credential_json.validFromwithissue_datewhen rendering certificate dates. - Update the PDF certificate route to render the issue date when present.
- Update
CertificatePagetests to assert against the issue date field.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| frontends/main/src/app/(site)/certificate/[certificateType]/[uuid]/pdf/route.tsx | Switch PDF date rendering from validFrom to issueDate sourced from issue_date. |
| frontends/main/src/app-pages/CertificatePage/CertificatePage.tsx | Switch UI date rendering from validFrom to issueDate sourced from issue_date. |
| frontends/main/src/app-pages/CertificatePage/CertificatePage.test.tsx | Update assertions to check the rendered issue date instead of validFrom. |
| await screen.findAllByText( | ||
| moment(certificate.verifiable_credential_json.validFrom).format( | ||
| "MMM D, YYYY", | ||
| ), | ||
| moment(certificate.issue_date).format("MMM D, YYYY"), | ||
| ) |
| await screen.findAllByText( | ||
| moment(certificate.verifiable_credential_json.validFrom).format( | ||
| "MMM D, YYYY", | ||
| ), | ||
| moment(certificate.issue_date).format("MMM D, YYYY"), | ||
| ) |
861e0e8 to
9d03919
Compare
| const { displayType } = getCertificateInfo() | ||
| const signatories = certificate.certificate_page.signatory_items | ||
| const validFrom = certificate?.verifiable_credential_json?.validFrom | ||
| const issueDate = certificate?.issue_date |
There was a problem hiding this comment.
What if there is no certificate.issue_date are we okay with this being blank?
There was a problem hiding this comment.
IMO there won't be any case where the issue date will be blank because this PR tells us that issue date will be there.
mitodl/mitxonline#3587
7ff2f9b to
b842a0b
Compare

What are the relevant tickets?
https://github.com/mitodl/hq/issues/10711#issuecomment-4481397774
Description (What does it do?)
Screenshots (if appropriate):
How can this be tested?
If you have mitxonline running locally and certificates set up, navigate to http://open.odl.local:8062/certificate/<"course"|"program">/<certificate_id>/pdf
If not, grab a response from e.g. https://api.mitxonline.mit.edu/api/v2/course_certificates/19d376df-63e3-4924-81ad-722fc8638c57/ and return it in the certificateQueries.courseCertificatesRetrieve() hook queryFn and load http://open.odl.local:8062/certificate/course/19d376df-63e3-4924-81ad-722fc8638c57/
Additional Context