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

db-object-widget is not well supported #184

Open
inromualdo opened this issue Nov 17, 2022 · 3 comments
Open

db-object-widget is not well supported #184

inromualdo opened this issue Nov 17, 2022 · 3 comments
Assignees

Comments

@inromualdo
Copy link

Describe the bug
When you fill a form using harness.fillForm the user role is not coming in user data as the form inputs.

To Reproduce
Steps to reproduce the behavior:

  1. Fill a form containing user data (contact_id, name, role) in inputs
  2. Verify the form result

What happened?
contact_id and name have the id and name in harness.defaults.json. But role is not filled

What did you expect?
role should be filled with user role. It is used in the form to check the connected user role (ex: chw or oca) and display field according to it.

Screenshots
Screenshot 2022-11-17 at 10 15 01
Screenshot 2022-11-17 at 10 16 58

@kennsippell
Copy link
Member

Does the data bind properly through the CHT and only fails to bind when testing via the harness?

Ensure you're familiar with the difference between the CHT user's contact doc and the CouchDB's user document or this user-settings representation in CHT.

A user's role at the CHT level is not set through the user's contact document, but rather through the user's userSettings document. Recommend you're familiar with the following interfaces:

gl debugging and let me know if you have questions as you untangle this. The CHT's logic with users, user-settings, user's contacts (etc) is pretty complex and so some shortcuts were taken when building the harness. Welcome any suggestions or improvements you can bring.

@inromualdo inromualdo self-assigned this Feb 8, 2023
@kennsippell kennsippell self-assigned this Feb 10, 2023
@kennsippell
Copy link
Member

kennsippell commented Feb 19, 2023

This is what's happening in the CHT:

  1. The CHT binds the user's user-settings doc to the user object in the XForm. The contact_id attribute is set during this binding. The role attribute is not set at this time.
  2. The contact_id element in the XForm is of type db:person or "db-object-widget". This looks up all attributes of the user's contact-doc and binds the data to its siblings. The role attribute is set by the "db-object-widget".

The bug report above infers that the role should be set directly by the user's contact doc - but that is not what happens in the CHT.

This scenario is broken in the harness because the CHTCore.Select2Search is not implemented.

Proposed workaround is to use harness.userSettingsDoc.role = 'oca';. This will allow you to test this scenario but this is not actually how the CHT moves the data. This is a valid bug representing a gap between the CHT and harness.

@kennsippell kennsippell changed the title User role is not coming into form inputs db-object-widget is not supported in Harness@3 Feb 19, 2023
@kennsippell kennsippell changed the title db-object-widget is not supported in Harness@3 db-object-widget is not well supported Feb 19, 2023
@kennsippell
Copy link
Member

#233 is a PR which attempts proper support for db-object-widget. I'm proceeding with #232 which disables the widget to work around #210.

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

No branches or pull requests

2 participants