Skip to content

Conversation

@zawan-ila
Copy link
Contributor

PROD-4319

This PR makes the following changes:-

  1. Update the Learner Information Page to append lms_user_id in the query params even in the case when the search is through a username or email.
  2. Update the Program Inspector page to append the edx_user_id in the query params instead of the edx_user, org_key and external_user_key params.

These changes are intended to remove PII like emails and usernames from the urls.

@codecov
Copy link

codecov bot commented Mar 24, 2025

Codecov Report

Attention: Patch coverage is 96.55172% with 1 line in your changes missing coverage. Please review.

Project coverage is 85.91%. Comparing base (c2ebf7b) to head (29d81ca).
Report is 2 commits behind head on master.

Files with missing lines Patch % Lines
src/users/UserPage.jsx 83.33% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #452      +/-   ##
==========================================
+ Coverage   84.93%   85.91%   +0.97%     
==========================================
  Files         185      185              
  Lines        3862     3868       +6     
  Branches      962      956       -6     
==========================================
+ Hits         3280     3323      +43     
+ Misses        564      527      -37     
  Partials       18       18              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@zawan-ila zawan-ila requested a review from DawoudSheraz March 27, 2025 11:32
Copy link
Contributor

@Ali-D-Akbar Ali-D-Akbar left a comment

Choose a reason for hiding this comment

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

Bunch of comments here n there. Looks good otherwise.

setSsoRecords([]);
navigate('/programs');
} else {
const newLink = `/programs?edx_user=${
Copy link
Contributor

Choose a reason for hiding this comment

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

Why did we remove /programs again?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Earlier, we would navigate to this url. Now, we are only using it to store the "query" (backend api call) that we should make. I have refactored it a little. Hopefully it's clearer now. I also removed the ClickEvent state, as it wasn't being used anywhere.

})
.catch(err => {
console.error(err);
setError('An error occured while fetching user id');
Copy link
Contributor

Choose a reason for hiding this comment

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

spell: occurred

Copy link
Contributor

Choose a reason for hiding this comment

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

Please update in all places.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

jest.spyOn(ssoAndUserApi, 'getEnrollments').mockImplementation(() => Promise.resolve(enrollmentsData));
jest.spyOn(ssoAndUserApi, 'getEnterpriseCustomerUsers').mockImplementation(() => Promise.resolve(enterpriseCustomerUsersData));

jest.clearAllMocks();
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't we have this in afterEach?

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 feel like it is fine in both afterEach and beforeEach. Most tests add it in beforeEach too.

jest.spyOn(ssoAndUserApi, 'getSsoRecords').mockImplementation(() => Promise.resolve(ssoRecordsData));
jest.spyOn(ssoAndUserApi, 'getLicense').mockImplementation(() => Promise.resolve(licensesData));
jest.spyOn(ssoAndUserApi, 'getEntitlements').mockImplementation(() => Promise.resolve(entitlementsData));
jest.spyOn(ssoAndUserApi, 'getEnrollments').mockImplementation(() => Promise.resolve(enrollmentsData));
Copy link
Contributor

Choose a reason for hiding this comment

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

We got a duplicate line here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Which one?

Copy link
Contributor

Choose a reason for hiding this comment

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

This line is written twice.

jest.spyOn(ssoAndUserApi, 'getEnrollments').mockImplementation(() => Promise.resolve(enrollmentsData));

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed

wrapper = mount(<UserPageWrapper />);
wrapper.find(
"input[name='userIdentifier']",
).instance().value = 'ANonyMouse';
Copy link
Contributor

Choose a reason for hiding this comment

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

This may not trigger input change if I'm not wrong... 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Probably, yes. But we don't need a change event anyways.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Additionally, when I tried a simulate('onchange'...), the value of the input wasn't changing for some reason, and hence the test was failing. Thus, I took this approach.

Comment on lines +59 to +62
await waitFor(() => {
expect(mockedNavigator).toHaveBeenCalledWith(
`/learner_information/?lms_user_id=${UserSummaryData.userData.id}`,
);
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we add some assertions to check if the API was called?

Copy link
Contributor

Choose a reason for hiding this comment

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

I believe this should call getAllUserData if I'm not wrong 😵‍💫

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@zawan-ila zawan-ila requested a review from Ali-D-Akbar April 3, 2025 11:44
@zawan-ila zawan-ila merged commit 99bcbb0 into master Apr 4, 2025
6 checks passed
@zawan-ila zawan-ila deleted the anawaz/prod-4319 branch April 4, 2025 18:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants