-
Notifications
You must be signed in to change notification settings - Fork 18
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
feat: add view certificate button #121
Conversation
Codecov Report
@@ Coverage Diff @@
## master #121 +/- ##
==========================================
+ Coverage 76.23% 78.26% +2.03%
==========================================
Files 43 45 +2
Lines 930 1017 +87
Branches 183 199 +16
==========================================
+ Hits 709 796 +87
Misses 210 210
Partials 11 11
Continue to review full report at Codecov.
|
cf35eaa
to
dcebca3
Compare
8222190
to
35f15db
Compare
0eb1f74
to
076d278
Compare
076d278
to
f1e08b6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A handful of queries to be addressed:
- Can you please add a screenshot for regenerate button scenario? Just wanted to confirm that only one of the button is shown
- What does a user see as a verification that an operation was successful? Some sort of a success message or the whole page/component refresh?
src/users/data/api.test.js
Outdated
const certificatesUrl = `${getConfig().LMS_BASE_URL}/certificates/search?user=${testUsername}&course_id=${testCourseId}`; | ||
const generateCertificateUrl = `${getConfig().LMS_BASE_URL}/certificates/generate`; | ||
const regenerateCertificateUrl = `${getConfig().LMS_BASE_URL}/certificates/regenerate`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why're you not using getCertificateUrl, regenerateCertificateUrl and regenerateCertificateUrl from urls.js?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, I will change it
const props = { | ||
username: testUser, | ||
courseId: testCourseId, | ||
closeHandler: jest.fn(() => {}), | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move this in src/users/data/test/certificates.js.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not the exact data. The data is already in cert.js.
await waitForComponentToPaint(wrapper); | ||
generateButton = wrapper.find('button#generate-certificate'); | ||
expect(wrapper.find('h3').length).toEqual(0); | ||
expect(generateButton.prop('disabled')).toBeFalsy(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is the generate-certificate button still not disabled after flow has been successful?
And are we showing some success message on success of certificate generation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because it is still possible to generate/regenerate after one attempt. The backend does not restrict reattempts for generation/regeneration. Ideally, the generate button would change into the regenerate button. But the mock in this current test is returning the generatable certificate data.
|
const { data } = await getAuthenticatedHttpClient().get( | ||
AppUrls.getCertificateUrl(username, courseKey), | ||
); | ||
return Array.isArray(data) && data.length > 0 ? data[0] : data; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In what cases this endpoint will return an array or single item?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If course id is mentioned, then the single item, otherwise a list of certificates. We might not need this check. I added it for cautious purposes(unexpected data on stage/prod). Once the changes are live, I will validate and remove the unnecessary check.
AppUrls.generateCertificateUrl(), | ||
formData, | ||
); | ||
return data; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does data
contain in this case? from here it says its a http response. Are we using it anywhere?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, it is just a response. We are not using it anywhere though. The return value is used only in tests to verify the api behavior.
|
||
export const getCertificateUrl = (username, courseKey) => `${ | ||
LMS_BASE_URL | ||
}/certificates/search?user=${username}&course_id=${courseKey}`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we may need to encode courseKey
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, the backend is running quote_plus on the course key. https://github.com/edx/edx-platform/blob/master/lms/djangoapps/certificates/views/support.py#L109. I will check if the encoding is necessary.
https://docs.python.org/3/library/urllib.parse.html#urllib.parse.quote_plus
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Encoding is not needed. Encoding the courseId results in 404 on backend.
<div className="m-3"> | ||
<h2>Course ID: {certificate.courseKey}</h2> | ||
{status && (<h3>Status: {status} </h3>)} | ||
<table className="table"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a specific reason for not using Table
component?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, the Table component is more suited for listing with headings on top and data listed vertically. In cert case, the headers are on the left and data on right i.e. one header and one piece of data are on the same row. furthermore, the Table component has many other operations not needed in this case.
PROD-2357
Description
Add certificate tool with the following features:
The backend APIs are the same as old support tools, located at https://github.com/edx/edx-platform/blob/master/lms/djangoapps/certificates/views/support.py. The view cert button is added to the enrollment listing, as requested in the ticket.