Skip to content

Commit

Permalink
Updated broken links (openedx#346)
Browse files Browse the repository at this point in the history
updated tests

added test
  • Loading branch information
alangsto authored Jan 21, 2021
1 parent 68c8d31 commit 293dc9f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/course-home/data/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ export async function getProgressTabData(courseId) {
}

export async function getProctoringInfoData(courseId) {
const url = `${getConfig().LMS_BASE_URL}/api/edx_proctoring/v1/user_onboarding/status?course_id=${courseId}`;
const url = `${getConfig().LMS_BASE_URL}/api/edx_proctoring/v1/user_onboarding/status?course_id=${encodeURIComponent(courseId)}`;
try {
const { data } = await getAuthenticatedHttpClient().get(url);
return data;
Expand Down
10 changes: 9 additions & 1 deletion src/course-home/outline-tab/OutlineTab.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ describe('Outline Tab', () => {
const enrollmentUrl = `${getConfig().LMS_BASE_URL}/api/enrollment/v1/enrollment`;
const goalUrl = `${getConfig().LMS_BASE_URL}/api/course_home/v1/save_course_goal`;
const outlineUrl = `${getConfig().LMS_BASE_URL}/api/course_home/v1/outline/${courseId}`;
const proctoringInfoUrl = `${getConfig().LMS_BASE_URL}/api/edx_proctoring/v1/user_onboarding/status?course_id=${courseId}`;
const proctoringInfoUrl = `${getConfig().LMS_BASE_URL}/api/edx_proctoring/v1/user_onboarding/status?course_id=${encodeURIComponent(courseId)}`;

const store = initializeStore();
const defaultMetadata = Factory.build('courseHomeMetadata', { courseId });
Expand Down Expand Up @@ -499,6 +499,14 @@ describe('Outline Tab', () => {
expect(screen.queryByRole('link', { name: 'Review instructions and system requirements' })).toBeInTheDocument();
});

it('appears for no status', async () => {
axiosMock.onGet(proctoringInfoUrl).reply(200, { onboarding_status: '', onboarding_link: 'test' });
await fetchAndRender();
await screen.findByText('This course contains proctored exams');
expect(screen.queryByRole('link', { name: 'Complete Onboarding' })).toBeInTheDocument();
expect(screen.queryByRole('link', { name: 'Review instructions and system requirements' })).toBeInTheDocument();
});

it('does not appear for 404', async () => {
axiosMock.onGet(proctoringInfoUrl).reply(404);
expect(screen.queryByRole('link', { name: 'Review instructions and system requirements' })).not.toBeInTheDocument();
Expand Down
5 changes: 3 additions & 2 deletions src/course-home/outline-tab/widgets/ProctoringInfoPanel.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { useState, useEffect } from 'react';
import PropTypes from 'prop-types';

import { getConfig } from '@edx/frontend-platform';
import { injectIntl, intlShape } from '@edx/frontend-platform/i18n';
import { Button } from '@edx/paragon';

Expand Down Expand Up @@ -56,7 +57,7 @@ function ProctoringInfoPanel({ courseId, intl }) {

return (
<>
{ status && (
{ link && (
<section className={`mb-4 p-3 outline-sidebar-proctoring-panel ${getBorderClass(status)}`}>
<h2 className="h4" id="outline-sidebar-upgrade-header">{intl.formatMessage(messages.proctoringInfoPanel)}</h2>
<div>
Expand All @@ -77,7 +78,7 @@ function ProctoringInfoPanel({ courseId, intl }) {
</>
)}
{showExamLink(status) && (
<Button variant="primary" block href={link}>
<Button variant="primary" block href={`${getConfig().LMS_BASE_URL}${link}`}>
{intl.formatMessage(messages.proctoringOnboardingButton)}
</Button>
)}
Expand Down

0 comments on commit 293dc9f

Please sign in to comment.