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

User Profile Replacement/Removal #9382

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from

Conversation

Jacobjeevan
Copy link
Contributor

@Jacobjeevan Jacobjeevan commented Dec 11, 2024

Proposed Changes

image

@ohcnetwork/care-fe-code-reviewers

Merge Checklist

  • Add specs that demonstrate bug / test a new feature.
  • Update product documentation.
  • Ensure that UI text is kept in I18n files.
  • Prep screenshot or demo video for changelog entry, and attach it to issue.
  • Request for Peer Reviews
  • Completion of QA

Summary by CodeRabbit

  • New Features

    • Introduced a new component for managing software updates.
    • Enhanced user interface with a software update section in the summary tab.
  • Bug Fixes

    • Removed redundant checks related to user profile updates and skills.
  • Refactor

    • Simplified test cases for user profile management and user creation.
    • Improved routing for user profile access.
    • Streamlined the ManageUsers component by removing user facilities management logic.
    • Consolidated user profile editing functionalities into more focused test cases.
  • Chores

    • Removed unused imports and functions related to user facilities management.
    • Updated localization file with new and modified entries.

Copy link
Contributor

coderabbitai bot commented Dec 11, 2024

Walkthrough

The changes in this pull request involve significant modifications to the user management test suite and related components. The UsersCreation.cy.ts file has had user profile update tests removed, while new test cases have been added to focus on user creation and error handling. The ManageUserPage has been updated with new methods for handling working hours and video links. The UserProfile component has been deleted, and a new UserSoftwareUpdate component has been introduced. Routing has also changed to streamline user profile access through a tab-based approach.

Changes

File Path Change Summary
cypress/e2e/users_spec/UsersCreation.cy.ts Removed user profile update tests, associated error handling, and variables.
cypress/e2e/users_spec/UsersManage.cy.ts Modified tests for user skills and working hours; added and removed assertions.
cypress/e2e/users_spec/UsersProfile.cy.ts Restructured test cases for editing user information; added new test cases.
cypress/pageobject/Users/ManageUserPage.ts Added methods for editing and verifying working hours and video connect links.
cypress/pageobject/Users/UserProfilePage.ts Removed multiple methods related to user profile management; added clickSubmit.
src/Routers/routes/UserRoutes.tsx Removed "/user/profile" route; added "/user/:tab" route for user home.
src/components/Users/ManageUsers.tsx Removed UserFacilities function and related imports.
src/components/Users/UserHome.tsx Introduced logic for determining URL prefix based on logged-in user status.
src/components/Users/UserProfile.tsx Deleted the UserProfile component entirely.
src/components/Users/UserSoftwareUpdate.tsx Added a new component for managing software updates.
src/components/Users/UserSummary.tsx Updated to include UserSoftwareUpdate component in the UI.
public/locale/en.json Added new localization key for "Unassign" and updated "volunteer_update".

Assessment against linked issues

Objective Addressed Explanation
Redirect Profile Page to User Details, Remove Profile Component (#9364)

Possibly related PRs

Suggested labels

tested

Suggested reviewers

  • rithviknishad
  • nihal467

🐰 In the code, we hop and play,
Removing old tests, come what may.
With features new, we streamline the way,
User profiles shine bright, day by day!
A software update, oh what a treat,
In our rabbit hole, we can’t be beat! 🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 58368e3 and 3254c9e.

📒 Files selected for processing (2)
  • src/components/Users/ManageUsers.tsx (0 hunks)
  • src/components/Users/UserHome.tsx (3 hunks)
💤 Files with no reviewable changes (1)
  • src/components/Users/ManageUsers.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/components/Users/UserHome.tsx

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Experiment)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

netlify bot commented Dec 11, 2024

Deploy Preview for care-ohc ready!

Name Link
🔨 Latest commit 3254c9e
🔍 Latest deploy log https://app.netlify.com/sites/care-ohc/deploys/675a9f79dc4ea30008754933
😎 Deploy Preview https://deploy-preview-9382--care-ohc.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

- Removed logic to test profile in user creation (already done elsewhere)
- Removed ununsed logic in UserProfilePage
	- Makes uses of logic in ManageUsers instead since it's the same page
- Removed UserFacilities (logic related to sidebar for managing facilities/no longer used)
@Jacobjeevan Jacobjeevan marked this pull request as ready for review December 11, 2024 13:55
@Jacobjeevan Jacobjeevan requested a review from a team as a code owner December 11, 2024 13:55
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 5

🧹 Outside diff range and nitpick comments (8)
cypress/e2e/users_spec/UsersProfile.cy.ts (4)

Line range hint 33-33: Update hardcoded URL in beforeEach

The cy.awaitUrl("/user/profile") still references the old profile route which has been removed.

-    cy.awaitUrl("/user/profile");
+    cy.awaitUrl("/user/details");

37-44: Extract test data to constants or fixtures

Consider extracting test data like "Devo", "Doctoro", and date formats to constants or fixtures for better maintainability.

const TEST_DATA = {
  firstName: "Devo",
  lastName: "Doctoro",
  dateFormat: "M/D/YYYY"
};

55-91: Improve test organization and readability

This test case handles multiple concerns (qualifications, working hours, video link). Consider:

  1. Breaking it into smaller, focused test cases
  2. Using test data builders or fixtures
  3. Extracting repeated patterns into custom commands

Example refactor:

describe('Professional Information', () => {
  it('should update qualification details', () => {
    // qualification specific test
  });
  
  it('should update working hours', () => {
    // working hours specific test
  });
  
  it('should update video connect link', () => {
    // video link specific test
  });
});

70-71: Consider moving date formatting logic to a helper

The date manipulation logic should be extracted to a helper function for reusability and easier testing.

// utils/dateHelpers.ts
export const calculateExperienceDate = (yearsOfExperience: string): string => {
  const date = dayjs().subtract(parseInt(yearsOfExperience), "year");
  return date.format("YYYY-MM-DD");
};
src/components/Users/UserSoftwareUpdate.tsx (2)

12-17: Add TypeScript types for better type safety

Consider adding TypeScript interface for the update status state.

+interface UpdateStatus {
+  isChecking: boolean;
+  isUpdateAvailable: boolean;
+}

 export default function UserSoftwareUpdate() {
-  const [updateStatus, setUpdateStatus] = useState({
+  const [updateStatus, setUpdateStatus] = useState<UpdateStatus>({
     isChecking: false,
     isUpdateAvailable: false,
   });

38-71: Enhance accessibility for update status buttons

The buttons need ARIA labels and roles for better accessibility.

-        <Button disabled>
+        <Button 
+          disabled
+          aria-label={t("checking_for_update")}
+          role="status"
+        >
           <div className="flex items-center gap-4">
             <CareIcon icon="l-sync" className="text-2xl animate-spin" />
             {t("checking_for_update")}
           </div>
         </Button>

-        <Button disabled>
+        <Button 
+          disabled
+          aria-label={t("update_available")}
+          role="alert"
+        >
           <div className="flex items-center gap-4">
             <CareIcon
               icon="l-exclamation"
               className="text-2xl text-warning"
             />
             {t("update_available")}
           </div>
         </Button>

-        <Button variant="primary" onClick={checkUpdates}>
+        <Button 
+          variant="primary" 
+          onClick={checkUpdates}
+          aria-label={t("check_for_update")}
+        >
cypress/e2e/users_spec/UsersCreation.cy.ts (2)

Line range hint 89-127: Consider adding test coverage for new user details page integration.

While the user creation test is comprehensive, consider adding assertions to verify:

  1. Successful redirection to the new user details page after creation
  2. Proper tab selection in the new interface
 userCreationPage.clickSaveUserButton();
 cy.wait("@createUser").its("response.statusCode").should("eq", 201);
 cy.verifyNotification("User added successfully");
+// Verify redirection to user details page
+cy.url().should('include', '/user/details');
+// Verify active tab
+cy.get('[data-testid="user-details-tab"]').should('have.class', 'active');

Line range hint 129-134: Consider expanding mandatory field validation test.

The current test only verifies error messages. Consider adding positive validation cases to ensure the error messages clear correctly when valid data is entered.

 userCreationPage.clickSaveUserButton();
 cy.get(".error-text", { timeout: 10000 }).should("be.visible");
 cy.verifyErrorMessages(EXPECTED_ERROR_MESSAGES);
+// Add validation for error message clearance
+userCreationPage.typeUserName(username);
+cy.contains("Please enter the username").should("not.exist");
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between e89530d and 6f26109.

📒 Files selected for processing (11)
  • cypress/e2e/users_spec/UsersCreation.cy.ts (1 hunks)
  • cypress/e2e/users_spec/UsersManage.cy.ts (0 hunks)
  • cypress/e2e/users_spec/UsersProfile.cy.ts (2 hunks)
  • cypress/pageobject/Users/ManageUserPage.ts (3 hunks)
  • cypress/pageobject/Users/UserProfilePage.ts (1 hunks)
  • src/Routers/routes/UserRoutes.tsx (1 hunks)
  • src/components/Users/ManageUsers.tsx (0 hunks)
  • src/components/Users/UserHome.tsx (3 hunks)
  • src/components/Users/UserProfile.tsx (0 hunks)
  • src/components/Users/UserSoftwareUpdate.tsx (1 hunks)
  • src/components/Users/UserSummary.tsx (2 hunks)
💤 Files with no reviewable changes (3)
  • cypress/e2e/users_spec/UsersManage.cy.ts
  • src/components/Users/UserProfile.tsx
  • src/components/Users/ManageUsers.tsx
🔇 Additional comments (7)
src/components/Users/UserHome.tsx (1)

41-42: LGTM! Clean implementation of user-aware navigation.

The changes effectively handle URL construction and breadcrumb display based on whether the user is viewing their own profile or another user's profile.

Also applies to: 101-105, 132-132

cypress/pageobject/Users/ManageUserPage.ts (1)

153-162: LGTM! Well-structured test helper methods.

The new methods follow best practices:

  • Proper scrolling before interactions
  • Consistent verification approach
  • Clear separation of edit and verify operations

Also applies to: 184-197, 222-226

src/components/Users/UserSoftwareUpdate.tsx (1)

1-10: Verify UpdatableApp integration and implementation

The component relies on UpdatableApp and checkForUpdate from Common components. Let's verify their implementation to ensure proper integration.

✅ Verification successful

Let me gather more information about the UpdatableApp component since the previous command only showed the checkForUpdate function.


Let me try a different approach to find the UpdatableApp component implementation.


UpdatableApp integration looks properly implemented

The verification shows that both UpdatableApp and checkForUpdate are properly implemented in the Common components:

  • checkForUpdate is a well-structured async function that handles version checking and update detection
  • UpdatableApp is a React component that manages update state and integrates with the check functionality
  • The implementation includes proper error handling, version management via localStorage, and UI feedback
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check implementation of UpdatableApp and checkForUpdate
ast-grep --pattern 'export const checkForUpdate = $_' 
ast-grep --pattern 'export default function UpdatableApp($_) {
  $$$
}'

Length of output: 2300


Script:

#!/bin/bash
# Search for UpdatableApp component implementation and its usage
rg -A 10 "function UpdatableApp" src/components/Common/UpdatableApp.tsx

Length of output: 73


Script:

#!/bin/bash
# Search for UpdatableApp component using different patterns
rg -A 20 "export default.*UpdatableApp" src/components/Common/UpdatableApp.tsx
rg -A 20 "const UpdatableApp" src/components/Common/UpdatableApp.tsx

Length of output: 1230

src/components/Users/UserSummary.tsx (1)

211-216: Verify scope of software update feature

The addition of the software update feature appears to be outside the scope of the PR objectives, which focus on profile page redirection and removal. Please clarify if this is an intentional addition or should be moved to a separate PR.

cypress/e2e/users_spec/UsersCreation.cy.ts (3)

9-9: LGTM! Import changes align with profile removal.

The simplified imports reflect the removal of profile-related functionality while maintaining necessary utilities for user creation.


Line range hint 136-147: Verify facility page redirection with new user details page.

The facility page user redirection test should be updated to verify proper navigation to the new user details page interface.


Line range hint 11-57: Verify test data constants against new user details page.

The test data constants and error messages should be verified to ensure they match the new user details page implementation.

✅ Verification successful

Error messages in test suite match the actual form validation

Based on the search results, the error messages defined in the test suite (EXPECTED_ERROR_MESSAGES) match the actual form validation messages used in the codebase:

  • The user form validation messages are defined in src/components/Users/UserFormValidations.tsx and src/components/Users/UserAddEditForm.tsx
  • The error messages cover all required fields:
    • User type selection
    • Phone number validation
    • Username validation
    • Date format validation
    • Password requirements
    • First/Last name validation
    • Email validation
    • Gender selection
    • State/District/Local body selection

The test data constants accurately reflect the validation messages shown to users when form fields are invalid or missing.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for field validations in the new user details component
ast-grep --pattern 'const EXPECTED_ERROR_MESSAGES = [
  $$$
]'

# Search for form field definitions
rg -A 5 'interface.*FormValues|type.*FormValues'

Length of output: 1297


Script:

#!/bin/bash
# Search for form validation messages in component files
rg -A 1 "Please select the User Type|Please enter valid phone number|Please enter the username|Please enter date in DD/MM/YYYY format|Password is required|Confirm password is required|First Name is required|Last Name is required|Please enter a valid email address|Please select the Gender|Please select the state|Please select the district|Please select the local body" --type ts --type tsx

# Search for form field validation logic
ast-grep --pattern 'const validate = {
  $$$
}'

# Search for form field validation functions
ast-grep --pattern 'function validate$_($$$) {
  $$$
}'

Length of output: 528


Script:

#!/bin/bash
# Search for validation messages in all files, fixing the file type flag
rg -A 1 "Please select the User Type|Please enter valid phone number|Please enter the username|Please enter date in DD/MM/YYYY format|Password is required|Confirm password is required|First Name is required|Last Name is required|Please enter a valid email address|Please select the Gender|Please select the state|Please select the district|Please select the local body" --type typescript

# Search for form validation in component files
rg -A 3 "validation|errorMessage|error message" --type typescript src/

# Look for user creation form component
fd -e ts -e tsx "UserCreation" src/

Length of output: 568


Script:

#!/bin/bash
# First find all TypeScript files that might contain validation messages
fd -e ts -e tsx . | xargs rg -l "validation|error|message"

# Find user creation related components and their validation logic
fd -e ts -e tsx . | xargs rg -A 3 "createUser|UserCreation|addUser"

# Search for form field validation patterns in all TypeScript files
fd -e ts -e tsx . | xargs rg -A 2 "required|invalid|Please"

Length of output: 70818

src/Routers/routes/UserRoutes.tsx Show resolved Hide resolved
cypress/pageobject/Users/UserProfilePage.ts Show resolved Hide resolved
cypress/e2e/users_spec/UsersProfile.cy.ts Show resolved Hide resolved
src/components/Users/UserSoftwareUpdate.tsx Show resolved Hide resolved
Comment on lines +204 to +217
<>
<UserColumns
heading={t("language_selection")}
note={t("set_your_local_language")}
Child={LanguageSelector}
childProps={userColumnsData}
/>
<UserColumns
heading={t("software_update")}
note={t("check_for_available_update")}
Child={UserSoftwareUpdate}
childProps={userColumnsData}
/>
</>
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Codebase verification

Translation keys missing in non-English locales

The software update section's translation keys need to be added to all non-English locale files:

  • software_update key missing in hi.json, kn.json, ml.json, mr.json, ta.json
  • check_for_available_update key missing in hi.json, kn.json, ml.json, mr.json, ta.json
🔗 Analysis chain

Verify translation keys for software update section

The new software update section uses translation keys that need to be verified in the i18n files.


Translation keys are properly defined in English locale but missing in others

The verification shows that both translation keys software_update and check_for_available_update are defined in the English locale file (en.json), but might be missing in other locale files. Let me verify other locales.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if translation keys exist in i18n files
rg -g '*.json' '"software_update":'
rg -g '*.json' '"check_for_available_update":'

Length of output: 232


Script:

#!/bin/bash
# List all locale files
fd -e json -p public/locale/

# Check content of all locale files for these keys
for locale in $(fd -e json -p public/locale/); do
  echo "=== $locale ==="
  jq '.software_update, .check_for_available_update' "$locale"
done

Length of output: 1443

@github-actions github-actions bot added the merge conflict pull requests with merge conflict label Dec 11, 2024
Copy link

👋 Hi, @Jacobjeevan,
Conflicts have been detected against the base branch. Please rebase your branch against the base branch.


This message is automatically generated by prince-chrismc/label-merge-conflicts-action so don't hesitate to report issues/improvements there.

@Jacobjeevan Jacobjeevan added needs testing needs review and removed merge conflict pull requests with merge conflict labels Dec 12, 2024
@github-actions github-actions bot added the merge conflict pull requests with merge conflict label Dec 12, 2024
Copy link

👋 Hi, @Jacobjeevan,
Conflicts have been detected against the base branch. Please rebase your branch against the base branch.


This message is automatically generated by prince-chrismc/label-merge-conflicts-action so don't hesitate to report issues/improvements there.

@github-actions github-actions bot removed the merge conflict pull requests with merge conflict label Dec 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Redirect Profile Page to User Details, Remove Profile Component
1 participant