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

Ensure backward compatibility of facility_id in Admin app #9203

Closed
Benmuiruri opened this issue Jun 24, 2024 · 3 comments · Fixed by #9204
Closed

Ensure backward compatibility of facility_id in Admin app #9203

Benmuiruri opened this issue Jun 24, 2024 · 3 comments · Fixed by #9204
Assignees
Labels
Type: Bug Fix something that isn't working as intended
Milestone

Comments

@Benmuiruri
Copy link
Contributor

Benmuiruri commented Jun 24, 2024

Describe the bug

For existing offline users, the request body to get the list of facilities for the multiselect in the admin app queries directly to couchdb and not through api which enforces the typecasting of previous string facility_id to Array

To Reproduce
Steps to reproduce the behavior:

  1. If you have a DB with user's who have string values for facility_id
  2. Login as admin, go to "App Management"
  3. Click on 'Users' on the left side pane
  4. Select a user to bring up the edit user form
  5. The user's place will fail to load

Screenshot 2024-06-24 at 10 24 28 PM

Expected behavior

  • When you click the user edit form, it should auto populate the user's place correctly
Screenshot 2024-06-24 at 22 24 05

Logs

Screenshot 2024-06-24 at 10 39 24 PM

{"error":"bad_request","reason":"keys body member must be an array."}

Screenshots

Environment

  • Instance: localhost
  • Browser: Chrome
  • Client platform: MacOS
  • App: Admin
  • Version: 4.8.0

Additional context

@Benmuiruri Benmuiruri added the Type: Bug Fix something that isn't working as intended label Jun 24, 2024
@Benmuiruri Benmuiruri self-assigned this Jun 24, 2024
@Benmuiruri Benmuiruri added this to the 4.9.0 milestone Jun 24, 2024
Benmuiruri added a commit that referenced this issue Jun 25, 2024
Co-authored-by: latin-panda <66472237+latin-panda@users.noreply.github.com>
@Benmuiruri
Copy link
Contributor Author

Although this issue is closed and the bug identified has been fixed. The Care Teams is conducting further testing to find whether there may be other bugs introduced by switching facility_id from a string to an Array.

From my testing this is what I found

Testing Admin app
  • User type: [admin]
  • Config: [Default]
  • App: [Admin]
- Can click on existing user and load edit user form 
- Can update existing user role
- Can assign multi facility to user
- when you delete facility from multi facility user, on edit the multifacility does not appear
- All validations on the edit form work as expected. 
- When supervisor deletes area with no children, the admin no longer sees the place for the CHW on the edit form.
Testing Webapp as Supervisor
  • User type: [online - Supervisor]
  • Config: [Default]
  • App: [Webapp]
- User cannot delete facility they belong to even if it has no children
- With Permission, user cannot delete Area with children
- With Permission, user can delete Area with no children
- With permission, user can delete Area with no children even if it is assigned to a CHW - Expected behavior ? 
Testing Webapp as CHW
  • User type: [offline - CHW]
  • Config: [Default]
  • App: [Webapp]
- When assigned multifacility, they only see the two places on the LHS
- User cannot delete area they belong to, even if the area has no children
- When supervisor deletes area with no children, it is removed from the CHW's places and they see their original place with its descendants.

Summary

From my testing, I did not encounter any unexpected behavior but I have one suggestion

  • In contacts-content we have a check that we should updated to handle Arrays with !this.userSettings?.facility_id.includes(this.selectedContact?.doc?._id)

@ralfudx
Copy link

ralfudx commented Jun 25, 2024

I completed the testing for this and didn't find anything unusual

Post-testing notes:

  • Admin app ✅
    create new user
    update existing user
    assign multi facility
    cannot assign multi facility to roles without the permission
    delete one facility
    can delete all facilities for a CHW user - expected behaviour???
    cannot delete all facilities for a Supervisor user

  • WebApp CHW (online) ✅
    cannot delete own area
    only areas listed on LHS when assigned multi facility
    cannot delete other area with household
    cannot delete associated households
    can delete associated people
    can edit own area and associated households and people

  • WebApp Supervisor (offline) ✅
    cannot delete own facility
    only facilities listed on LHS when assigned multi facility
    facility and associated areas listed on LHS when assigned only one facility
    cannot delete associated areas and households
    can delete associated people
    cannot edit own facility
    can edit associated areas, households and people

@latin-panda
Copy link
Contributor

My tests, no problems found:

User: Admin
Config: Default
App: Webapp
Facility_id: none

App: Webapp

  • Navigation through all pages
  • Send sms in the Report tab
  • Export messages, reports, and contacts.
  • Report
    • Open existing report
    • Open form: expected error shows: Your user does not have an associated contact, or does not have access to the associated contact.
    • Filter by form, place, date, and status
    • Delete single, delete multiple reports.
    • Search by term
  • Messages
    • Open conversation
    • Send and delete message
  • Contact
    • Navigate down the hierarchy
    • Delete option disabled when the facility has descendants
    • Create, edit, and delete contacts

App: Admin

  • Navigation through all pages
  • Set roles and permissions
  • Create, edit and delete users - user is saved with facility_id as array
  • Can assign multiple facilities and remove facilities

User: Offline
Config: Default
App: Webapp
Facility_id: string

  • Navigation through all pages
  • Messages
    • send bulk SMS, send single SMS
    • open conversation and delete the conversation
  • Tasks
    • load list and complete task - doc in the db looks normal
  • Reports
    • load list and search by text
    • filter by place, form, status, date
    • Open, edit and delete the report
    • Open submit form
    • Review and change review
  • Contacts
    • load list and search by text
    • created patient and doc is saved with correct user info
    • Open edit and delete contact type person
    • Created a report for pregnant woman, and contact summary cards are updated correctly
  • Targets
    • calculated successfully

User: Online
Config: Default
App: Webapp
Facility_id: array 2 facility

  • Navigation to everywhere is fine. Breadcrumbs now display the home facility
    - Telemetry is created with first facility assigned
  • Messages
    • send bulk SMS, send single SMS
    • open conversation and delete the conversation
  • Tasks
    • load list and complete task - doc in the db looks normal
  • Reports
    • load list and search by text
    • filter by place, form, status, date
    • Open, edit and delete the report
    • Open submit form
    • Review and change review
  • Contacts
    • Load list and search by text
    • Created patient and doc is saved with correct user info, picks the first facility from the 2 assigned.
    • Open edit and delete contact type person
    • Created a report for pregnant woman, and contact summary cards are updated correctly
    • Cannot edit nor delete home-places.
  • Targets
    • calculated successfully
    • Target aggregates are hidden even when permission is enabled

User: Online
Config: Default
App: Webapp
Facility_id: array 1 facility

  • Navigation to everywhere is fine. Breadcrumbs doesnt display the home facility
  • Messages
    • send bulk SMS, send single SMS
    • open conversation and delete the conversation
  • Tasks
    • load list and complete task - doc in the db looks normal
  • Reports
    • load list and search by text
    • filter by place, form, status, date
    • Open, edit and delete the report
    • Open submit form
    • Review and change review
  • Contacts
    • Load list and search by text
    • Created patient and doc is saved with correct user info, picks the first facility from the 2 assigned.
    • Open edit and delete contact type person
    • Created a report for pregnant woman, and contact summary cards are updated correctly
    • Cannot edit nor delete home-places.
  • Targets
    • calculated successfully
    • Target aggregates are enabled

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Fix something that isn't working as intended
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants