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

Ops 441 update user details #2671

Merged
merged 23 commits into from
Aug 13, 2024
Merged

Ops 441 update user details #2671

merged 23 commits into from
Aug 13, 2024

Conversation

johndeange
Copy link
Contributor

@johndeange johndeange commented Aug 12, 2024

What changed

  • Implement USER_ADMIN role changing User details.
  • Deactivate all UserSession when changing UserStatus to INACTIVE/LOCKED

Issue

#441

How to test

  1. Login as Budget Team Member
  2. Navigate to the User Admin page.
  3. Search for and select User Demo user
  4. Update division, roles and set User Demo status to LOCKED
  5. Log out and Log in with User Demo (Basic) user.
  6. Log in should fail and an event should be created in the DB for a failed login.
  7. Log in as Budget Team Member
  8. Set User Demo status to ACTIVE
  9. Log out and you should be able to log in with User Demo (Basic) now.

Screenshots

image

Definition of Done Checklist

  • OESA: Code refactored for clarity
  • OESA: Dependency rules followed
  • Automated unit tests updated and passed
  • Automated integration tests updated and passed
  • Automated quality tests updated and passed
  • Automated load tests updated and passed
  • Automated a11y tests updated and passed
  • Automated security tests updated and passed
  • 90%+ Code coverage achieved
  • Form validations updated

@johndeange johndeange marked this pull request as ready for review August 12, 2024 21:54
Copy link
Contributor

@fpigeonjr fpigeonjr left a comment

Choose a reason for hiding this comment

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

🥇 looks good @johndeange, made some non-blocking suggestions. Would be nice to add some UX like confirmation Alert (if changes were applied)and Cancel/Save buttons to allow user to back out of changes.

* @returns {JSX.Element} - The rendered component.
*/
function UserEmailComboBox({ selectedUsers, setSelectedUsers }) {
// const [selectedUsers, setSelectedUsers] = React.useState([]);
Copy link
Contributor

Choose a reason for hiding this comment

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

pls remove commented code

@@ -16,6 +23,7 @@ const UserInfo = ({ user, isEditable }) => {

const { data: divisions, error: errorDivisions, isLoading: isLoadingDivisions } = useGetDivisionsQuery();
const { data: roles, error: errorRoles, isLoading: isLoadingRoles } = useGetRolesQuery();
const [updateUser, updateUserResult] = useUpdateUserMutation();
Copy link
Contributor

Choose a reason for hiding this comment

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

⭐ thx for sharing this pattern for handling result from the api call


console.log("isEditable: ", isEditable);
if (updateUserResult.isError) {
return <div>Oops, an error occurred</div>;
Copy link
Contributor

Choose a reason for hiding this comment

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

wonder if we can render this on the page somewhere?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is - the div is displayed in the case of an API error

Copy link
Contributor

Choose a reason for hiding this comment

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

ok I guess I was envisioning an error Alert with a message to try again or the div to be displayed above the User card.

// eslint-disable-next-line testing-library/no-node-access
const divisionInput = divisionComboBox.querySelector("input");

fireEvent.keyDown(divisionInput, { key: "ArrowDown", code: 40 });
Copy link
Contributor

Choose a reason for hiding this comment

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

learned that the [userEvent](https://testing-library.com/docs/user-event/intro/) is now the preferred method of handling user interactions

Copy link
Contributor

Choose a reason for hiding this comment

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

I have been adding the extension of jsx to unit-test files since they render a React component.

@@ -1,26 +1,37 @@
import App from "../../../App";
import UserEmailComboBox from "../../../components/Users/UserEmailComboBox/index.js";
import { useGetDivisionsQuery } from "../../../api/opsAPI.js";
import React from "react";
import UserInfo from "../../../components/Users/UserInfo/UserInfo.jsx";
Copy link
Contributor

Choose a reason for hiding this comment

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

don't need the double UserInfo on the import

../../../components/Users/UserInfo"

url: `/users/${id}`,
method: "PUT",
method: "PATCH",
Copy link
Contributor

Choose a reason for hiding this comment

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

🤔 does the openAPI spec need to be updated to match?

Copy link
Contributor

@maiyerlee maiyerlee left a comment

Choose a reason for hiding this comment

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

I followed the 'How to Test' steps, and the changes worked as expected.

Signed-off-by: John DeAngelis <[email protected]>
Signed-off-by: John DeAngelis <[email protected]>
Signed-off-by: John DeAngelis <[email protected]>
Signed-off-by: John DeAngelis <[email protected]>
Signed-off-by: John DeAngelis <[email protected]>
Signed-off-by: John DeAngelis <[email protected]>
Signed-off-by: John DeAngelis <[email protected]>
@johndeange johndeange merged commit 26d3ddb into main Aug 13, 2024
40 checks passed
@johndeange johndeange deleted the OPS-441-update-user-details branch August 13, 2024 20:16
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.

3 participants