MST-342 Hide all other fields if enableProctoredExam is false (#21)
This commit is contained in:
@@ -125,7 +125,7 @@ function ExamSettings(props) {
|
||||
function renderContent() {
|
||||
return (
|
||||
<Form>
|
||||
{proctortrackEscalationEmailError
|
||||
{proctortrackEscalationEmailError && enableProctoredExams
|
||||
&& (
|
||||
// tabIndex="-1" to make non-focusable element focusable
|
||||
<Alert
|
||||
@@ -153,7 +153,7 @@ function ExamSettings(props) {
|
||||
</Form.Group>
|
||||
|
||||
{/* ALLOW OPTING OUT OF PROCTORED EXAMS */}
|
||||
{ isEdxStaff && (
|
||||
{ isEdxStaff && enableProctoredExams && (
|
||||
<fieldset aria-describedby="allowOptingOutHelpText">
|
||||
<Form.Group controlId="formAllowingOptingOut">
|
||||
<Form.Label as="legend">Allow Opting Out of Proctored Exams</Form.Label>
|
||||
@@ -186,21 +186,23 @@ function ExamSettings(props) {
|
||||
</fieldset>
|
||||
)}
|
||||
|
||||
{/* PROCTORING PROVIDER */}
|
||||
<Form.Group controlId="formProctoringProvider">
|
||||
<Form.Label>Proctoring Provider</Form.Label>
|
||||
<Form.Control
|
||||
as="select"
|
||||
value={proctoringProvider}
|
||||
onChange={onProctoringProviderChange}
|
||||
>
|
||||
{getProctoringProviderOptions(availableProctoringProviders)}
|
||||
</Form.Control>
|
||||
<Form.Text>{cannotEditProctoringProvider() ? ('Proctoring provider cannot be modified after course start date.') : ('Select the proctoring provider you want to use for this course run.')}</Form.Text>
|
||||
</Form.Group>
|
||||
{enableProctoredExams && (
|
||||
<Form.Group controlId="formProctoringProvider">
|
||||
{/* PROCTORING PROVIDER */}
|
||||
<Form.Label>Proctoring Provider</Form.Label>
|
||||
<Form.Control
|
||||
as="select"
|
||||
value={proctoringProvider}
|
||||
onChange={onProctoringProviderChange}
|
||||
>
|
||||
{getProctoringProviderOptions(availableProctoringProviders)}
|
||||
</Form.Control>
|
||||
<Form.Text>{cannotEditProctoringProvider() ? ('Proctoring provider cannot be modified after course start date.') : ('Select the proctoring provider you want to use for this course run.')}</Form.Text>
|
||||
</Form.Group>
|
||||
)}
|
||||
|
||||
{/* PROCTORTRACK ESCALATION EMAIL */}
|
||||
{showProctortrackEscalationEmail && (
|
||||
{showProctortrackEscalationEmail && enableProctoredExams && (
|
||||
<Form.Group controlId="formProctortrackEscalationEmail">
|
||||
<Form.Label>Proctortrack Escalation Email</Form.Label>
|
||||
<Form.Control
|
||||
@@ -220,7 +222,7 @@ function ExamSettings(props) {
|
||||
)}
|
||||
|
||||
{/* CREATE ZENDESK TICKETS */}
|
||||
{ isEdxStaff && (
|
||||
{ isEdxStaff && enableProctoredExams && (
|
||||
<fieldset aria-describedby="createZendeskTicketsText">
|
||||
<Form.Group controlId="formCreateZendeskTickets">
|
||||
<Form.Label as="legend">Create Zendesk Tickets for Suspicious Proctored Exam Attempts</Form.Label>
|
||||
|
||||
@@ -10,7 +10,7 @@ const defaultProps = {
|
||||
courseId: 'course-v1%3AedX%2BDemoX%2BDemo_Course',
|
||||
};
|
||||
|
||||
describe('ProctoredExamSettings check default on create zendesk ticket field tests', () => {
|
||||
describe('ProctoredExamSettings field dependency tests', () => {
|
||||
beforeEach(async () => {
|
||||
auth.getAuthenticatedHttpClient = jest.fn(() => ({
|
||||
get: async () => ({
|
||||
@@ -25,7 +25,6 @@ describe('ProctoredExamSettings check default on create zendesk ticket field tes
|
||||
available_proctoring_providers: ['software_secure', 'proctortrack', 'mockproc'],
|
||||
course_start_date: '2070-01-01T00:00:00Z',
|
||||
},
|
||||
catch: () => {},
|
||||
}),
|
||||
}));
|
||||
|
||||
@@ -72,6 +71,61 @@ describe('ProctoredExamSettings check default on create zendesk ticket field tes
|
||||
const zendeskTicketInput = screen.getByTestId('createZendeskTicketsYes');
|
||||
expect(zendeskTicketInput.checked).toEqual(true);
|
||||
});
|
||||
|
||||
it('Hides all other fields when enabledProctorExam is false when first loaded', async () => {
|
||||
cleanup();
|
||||
auth.getAuthenticatedHttpClient = jest.fn(() => ({
|
||||
get: async () => ({
|
||||
data: {
|
||||
proctored_exam_settings: {
|
||||
enable_proctored_exams: false,
|
||||
allow_proctoring_opt_out: false,
|
||||
proctoring_provider: 'mockproc',
|
||||
proctoring_escalation_email: 'test@example.com',
|
||||
create_zendesk_tickets: true,
|
||||
},
|
||||
available_proctoring_providers: ['software_secure', 'proctortrack', 'mockproc'],
|
||||
course_start_date: '2070-01-01T00:00:00Z',
|
||||
},
|
||||
}),
|
||||
}));
|
||||
|
||||
await act(async () => render(<ProctoredExamSettings {...defaultProps} />));
|
||||
await waitFor(() => {
|
||||
screen.getByLabelText('Enable Proctored Exams');
|
||||
});
|
||||
const enabledProctoredExamCheck = screen.getByLabelText('Enable Proctored Exams');
|
||||
expect(enabledProctoredExamCheck.checked).toEqual(false);
|
||||
expect(screen.queryByText('Allow Opting Out of Proctored Exams')).toBeNull();
|
||||
expect(screen.queryByDisplayValue('mockproc')).toBeNull();
|
||||
expect(screen.queryByTestId('escalationEmail')).toBeNull();
|
||||
expect(screen.queryByTestId('createZendeskTicketsYes')).toBeNull();
|
||||
expect(screen.queryByTestId('createZendeskTicketsNo')).toBeNull();
|
||||
});
|
||||
|
||||
it('Hides all other fields when enableProctoredExams toggled to false', async () => {
|
||||
await waitFor(() => {
|
||||
screen.getByLabelText('Enable Proctored Exams');
|
||||
});
|
||||
expect(screen.queryByText('Allow Opting Out of Proctored Exams')).toBeDefined();
|
||||
expect(screen.queryByDisplayValue('mockproc')).toBeDefined();
|
||||
expect(screen.queryByTestId('escalationEmail')).toBeDefined();
|
||||
expect(screen.queryByTestId('createZendeskTicketsYes')).toBeDefined();
|
||||
expect(screen.queryByTestId('createZendeskTicketsNo')).toBeDefined();
|
||||
|
||||
let enabledProctorExamCheck = screen.getByLabelText('Enable Proctored Exams');
|
||||
expect(enabledProctorExamCheck.checked).toEqual(true);
|
||||
await act(async () => {
|
||||
fireEvent.click(enabledProctorExamCheck, { target: { value: false } });
|
||||
});
|
||||
enabledProctorExamCheck = screen.getByLabelText('Enable Proctored Exams');
|
||||
expect(enabledProctorExamCheck.checked).toEqual(false);
|
||||
expect(screen.queryByText('Allow Opting Out of Proctored Exams')).toBeNull();
|
||||
expect(screen.queryByDisplayValue('mockproc')).toBeNull();
|
||||
expect(screen.queryByTestId('escalationEmail')).toBeNull();
|
||||
expect(screen.queryByTestId('createZendeskTicketsYes')).toBeNull();
|
||||
expect(screen.queryByTestId('createZendeskTicketsNo')).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe('ProctoredExamSettings tests with escalation email', () => {
|
||||
@@ -90,7 +144,7 @@ describe('ProctoredExamSettings tests with escalation email', () => {
|
||||
course_start_date: '2070-01-01T00:00:00Z',
|
||||
},
|
||||
}),
|
||||
post: async () => ({}),
|
||||
post: async () => {},
|
||||
}));
|
||||
|
||||
auth.getAuthenticatedUser = jest.fn(() => ({ userId: 3, administrator: false }));
|
||||
|
||||
Reference in New Issue
Block a user