Skip to content

Commit

Permalink
test: test for entrance exam failed
Browse files Browse the repository at this point in the history
- Introduces a test case each for scenarios where the entrance exam
status is failed and pass

Signed-off by: Ishan Masdekar <[email protected]>
  • Loading branch information
imasdekar committed Sep 23, 2024
1 parent 1d401bb commit c98da6d
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/courseware/course/course-exit/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,11 @@ function GetCourseExitNavigation(courseId, intl) {
entranceExamPassed,
);

// exitActive is used to enable/disable the exit i.e. next buttons.
// COURSE_EXIT_MODES denote the current status of the course.
// Available COURSE_EXIT_MODES: disabled, celebration, nonPassing, inProgress, entranceExamFail
// If the user fails the entrance exam,
// access to further course sections should not be allowed i.e. disable the next buttons.
/** exitActive is used to enable/disable the exit i.e. next buttons.
COURSE_EXIT_MODES denote the current status of the course.
Available COURSE_EXIT_MODES: disabled, celebration, nonPassing, inProgress, entranceExamFail
If the user fails the entrance exam,
access to further course sections should not be allowed i.e. disable the next buttons. */
const exitActive = ((exitMode !== COURSE_EXIT_MODES.disabled) && (exitMode !== COURSE_EXIT_MODES.entranceExamFail));

let exitText;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,50 @@ describe('Unit Navigation', () => {
expect(screen.getByRole('button', { name: /next/i })).toBeDisabled();
});

it('has the "Next" button disabled for entrance exam failed', async () => {
const testCourseMetadata = {
...courseMetadata,
certificate_data: { cert_status: 'bogus_status' },
enrollment: { is_active: true },
entrance_exam_data: {
entrance_exam_current_score: 0, entrance_exam_enabled: true, entrance_exam_id: '1', entrance_exam_minimum_score_pct: 0.65, entrance_exam_passed: false,
},
};
const testStore = await initializeTestStore({ courseMetadata: testCourseMetadata, unitBlocks }, false);
// Have to refetch the sequenceId since the new store generates new sequences
const { courseware } = testStore.getState();
const testData = { ...mockData, sequenceId: courseware.sequenceId };

render(
<UnitNavigation {...testData} unitId={unitBlocks[0].id} />,
{ store: testStore, wrapWithRouter: true },
);

expect(screen.getByRole('button', { name: /next/i })).toBeDisabled();
});

it('has the "Next" button enabled for entrance exam pass', async () => {
const testCourseMetadata = {
...courseMetadata,
certificate_data: { cert_status: 'bogus_status' },
enrollment: { is_active: true },
entrance_exam_data: {
entrance_exam_current_score: 1.0, entrance_exam_enabled: true, entrance_exam_id: '1', entrance_exam_minimum_score_pct: 0.65, entrance_exam_passed: true,
},
};
const testStore = await initializeTestStore({ courseMetadata: testCourseMetadata, unitBlocks }, false);
// Have to refetch the sequenceId since the new store generates new sequences
const { courseware } = testStore.getState();
const testData = { ...mockData, sequenceId: courseware.sequenceId };

render(
<UnitNavigation {...testData} unitId={unitBlocks[0].id} />,
{ store: testStore, wrapWithRouter: true },
);

expect(screen.getByRole('link', { name: /next/i })).toBeEnabled();
});

it('displays end of course message instead of the "Next" button as needed', async () => {
const testCourseMetadata = { ...courseMetadata, certificate_data: { cert_status: 'notpassing' }, enrollment: { is_active: true } };
const testStore = await initializeTestStore({ courseMetadata: testCourseMetadata, unitBlocks }, false);
Expand Down

0 comments on commit c98da6d

Please sign in to comment.