Skip to content
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: update proctoring info panel api call #1579

Merged
merged 1 commit into from
Jan 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions src/course-home/data/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -289,9 +289,17 @@
}

export async function getProctoringInfoData(courseId, username) {
let url = `${getConfig().LMS_BASE_URL}/api/edx_proctoring/v1/user_onboarding/status?is_learning_mfe=true&course_id=${encodeURIComponent(courseId)}`;
if (username) {
url += `&username=${encodeURIComponent(username)}`;
let url;
if (!getConfig().EXAMS_BASE_URL) {
url = `${getConfig().LMS_BASE_URL}/api/edx_proctoring/v1/user_onboarding/status?is_learning_mfe=true&course_id=${encodeURIComponent(courseId)}`;

Check warning on line 294 in src/course-home/data/api.js

View check run for this annotation

Codecov / codecov/patch

src/course-home/data/api.js#L294

Added line #L294 was not covered by tests
if (username) {
url += `&username=${encodeURIComponent(username)}`;

Check warning on line 296 in src/course-home/data/api.js

View check run for this annotation

Codecov / codecov/patch

src/course-home/data/api.js#L296

Added line #L296 was not covered by tests
}
} else {
url = `${getConfig().EXAMS_BASE_URL}/api/v1/student/course_id/${encodeURIComponent(courseId)}/onboarding`;
if (username) {
url += `?username=${encodeURIComponent(username)}`;
}
}
try {
const { data } = await getAuthenticatedHttpClient().get(url);
Expand Down
2 changes: 1 addition & 1 deletion src/course-home/outline-tab/OutlineTab.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ describe('Outline Tab', () => {
const goalUrl = `${getConfig().LMS_BASE_URL}/api/course_home/save_course_goal`;
const masqueradeUrl = `${getConfig().LMS_BASE_URL}/courses/${courseId}/masquerade`;
const outlineUrl = `${getConfig().LMS_BASE_URL}/api/course_home/outline/${courseId}`;
const proctoringInfoUrl = `${getConfig().LMS_BASE_URL}/api/edx_proctoring/v1/user_onboarding/status?is_learning_mfe=true&course_id=${encodeURIComponent(courseId)}&username=MockUser`;
const proctoringInfoUrl = `${getConfig().EXAMS_BASE_URL}/api/v1/student/course_id/${encodeURIComponent(courseId)}/onboarding?username=MockUser`;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I spent a while trying to figure out how to mock out getConfig to try adding a test for the legacy endpoint, but wasn't able to mock it successfully. I've updated the URL in the tests to match what is being called by the getProctoringInfoData in the case where EXAMS_BASE_URL is truthy, because that setting has a truthy value for the test environment.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes sense! I think it's sufficient/okay to not have testing for the legacy endpoint here. That being said, is it possible to test locally instead? Also okay with leaving as is, but just figured it could be a nice check.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I did test locally as well!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just leaving a comment: Is this example useful to mock the getConfig values?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rijuma that's what I tried to do for the mock, but it wasn't actually mocking the correct thing.


const store = initializeStore();
const defaultMetadata = Factory.build('courseHomeMetadata');
Expand Down