-
Notifications
You must be signed in to change notification settings - Fork 3
course/program enrollment dialog #2797
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
base: main
Are you sure you want to change the base?
Changes from all commits
dc3c1b8
c75f5c4
48c4c01
0b7cec5
c5bc45b
7996ff7
ca82e0c
7204584
121f97c
b864dc4
a48beda
f273300
3679dc6
aa0c33b
ca8ded0
7aee9f5
9cf3435
f25ebe7
6c2eff6
ad206a8
671f623
7ac4d8e
a0c69f0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,7 +18,9 @@ const countries = { | |
| } | ||
|
|
||
| const enrollment = { | ||
| enrollmentsList: () => `${API_BASE_URL}/api/v1/enrollments/`, | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We weren't using this; I removed the mock from some tests and they all still passed. |
||
| /** | ||
| * @deprecated | ||
| */ | ||
| courseEnrollment: (id?: number) => | ||
| `${API_BASE_URL}/api/v1/enrollments/${id ? `${id}/` : ""}`, | ||
| enrollmentsListV2: () => `${API_BASE_URL}/api/v2/enrollments/`, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -29,7 +29,6 @@ const makeGrade = factories.enrollment.grade | |
|
|
||
| describe("OrganizationContent", () => { | ||
| beforeEach(() => { | ||
| setMockResponse.get(urls.enrollment.enrollmentsList(), []) | ||
| setMockResponse.get(urls.enrollment.enrollmentsListV2(), []) | ||
| setMockResponse.get(urls.programEnrollments.enrollmentsList(), []) | ||
| setMockResponse.get(urls.programEnrollments.enrollmentsListV2(), []) | ||
|
|
@@ -145,7 +144,6 @@ describe("OrganizationContent", () => { | |
| }), | ||
| ] | ||
| // Override the default empty enrollments for this test | ||
| setMockResponse.get(urls.enrollment.enrollmentsList(), enrollments) | ||
| setMockResponse.get(urls.enrollment.enrollmentsListV2(), enrollments) | ||
|
|
||
| renderWithProviders(<OrganizationContent orgSlug={orgX.slug} />) | ||
|
|
@@ -170,11 +168,11 @@ describe("OrganizationContent", () => { | |
|
|
||
| // Check based on the actual enrollment status, not array position | ||
| if (course.enrollment?.status === EnrollmentStatus.Enrolled) { | ||
| expect(indicator).toHaveTextContent("Enrolled") | ||
| expect(indicator).toHaveTextContent(/^Enrolled$/) | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As originally written, a bunch of tests in this file passed irrespective of whether the text was "Enrolled" or "Not Enrolled". |
||
| } else if (course.enrollment?.status === EnrollmentStatus.Completed) { | ||
| expect(indicator).toHaveTextContent("Completed") | ||
| expect(indicator).toHaveTextContent(/^Completed$/) | ||
| } else { | ||
| expect(indicator).toHaveTextContent("Not Enrolled") | ||
| expect(indicator).toHaveTextContent(/^Not Enrolled$/) | ||
| } | ||
| }) | ||
| }) | ||
|
|
@@ -754,9 +752,25 @@ describe("OrganizationContent", () => { | |
| )?.id, | ||
| course: { id: courses[0].id, title: courses[0].title }, | ||
| }, | ||
| grades: [], // No grades = enrolled but not completed | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Notes:
|
||
| b2b_contract_id: contracts[0].id, | ||
| b2b_organization_id: contracts[0].organization, | ||
| certificate: { uuid: faker.string.uuid(), link: faker.internet.url() }, | ||
| }), | ||
| factories.enrollment.courseEnrollment({ | ||
| run: { | ||
| id: courses[1].courseruns.find( | ||
| (r) => r.b2b_contract === contractIds[0], | ||
| )?.id, | ||
| course: { id: courses[1].id, title: courses[1].title }, | ||
| }, | ||
| b2b_contract_id: contracts[0].id, | ||
| b2b_organization_id: contracts[0].organization, | ||
| certificate: null, | ||
| grades: [], | ||
| }), | ||
| ] | ||
| // Override enrollments for this test | ||
| setMockResponse.get(urls.enrollment.enrollmentsListV2(), enrollments) | ||
|
|
||
| const program = factories.programs.program({ | ||
| courses: courses.map((c) => c.id), | ||
|
|
@@ -771,24 +785,22 @@ describe("OrganizationContent", () => { | |
| contracts, | ||
| ) | ||
|
|
||
| // Override enrollments for this test | ||
| setMockResponse.get(urls.enrollment.enrollmentsList(), enrollments) | ||
|
Comment on lines
-774
to
-775
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On
|
||
|
|
||
| renderWithProviders(<OrganizationContent orgSlug={orgX.slug} />) | ||
|
|
||
| const cards = await within( | ||
| await screen.findByTestId("org-program-root"), | ||
| ).findAllByTestId("enrollment-card-desktop") | ||
|
|
||
| expect(cards.length).toBe(3) | ||
| // First card should show enrolled status | ||
| const firstCardStatus = within(cards[0]).getByTestId("enrollment-status") | ||
| expect(firstCardStatus).toHaveTextContent("Enrolled") | ||
| const cardStatus0 = within(cards[0]).getByTestId("enrollment-status") | ||
| expect(cardStatus0).toHaveTextContent(/^Completed$/) | ||
|
|
||
| // Remaining cards should show not enrolled | ||
| for (let i = 1; i < cards.length; i++) { | ||
| const cardStatus = within(cards[i]).getByTestId("enrollment-status") | ||
| expect(cardStatus).toHaveTextContent("Not Enrolled") | ||
| } | ||
| const cardStatus1 = within(cards[1]).getByTestId("enrollment-status") | ||
| expect(cardStatus1).toHaveTextContent(/^Enrolled$/) | ||
|
|
||
| const cardStatus2 = within(cards[2]).getByTestId("enrollment-status") | ||
| expect(cardStatus2).toHaveTextContent(/^Not Enrolled$/) | ||
| }) | ||
|
|
||
| test("shows the not found screen if the organization is not found by orgSlug", async () => { | ||
|
|
@@ -987,7 +999,6 @@ describe("OrganizationContent", () => { | |
| contracts, | ||
| ) | ||
|
|
||
| setMockResponse.get(urls.enrollment.enrollmentsList(), [enrollment]) | ||
| setMockResponse.get(urls.enrollment.enrollmentsListV2(), [enrollment]) | ||
|
|
||
| renderWithProviders(<OrganizationContent orgSlug={orgX.slug} />) | ||
|
|
||
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.
With the original version of this factory, it was impossible to specify null
next_run_id, even thought that is possible via the api.