Closed dbranley closed 4 months ago
Thanks @mturoci for all your great feedback! I've responded to each of your observations and pushed another commit with the changes. Let me know what you think!
And for reference, here's the updated Cypress test snipit with video:
from h2o_wave import cypress
@cypress('Remove picker selections')
def test_picker(cy):
cy.visit('/demo')
cy.locate('remove_picker').should('exist').first().click()
cy.locate('remove_picker').should('exist').first().click()
cy.locate('remove_picker').should('not.exist')
cy.locate('picker').type('Ham').type('{enter}')
cy.locate('remove_picker').should('exist')
https://github.com/h2oai/wave/assets/61979454/26780351-3f65-4af1-8a9e-6e47b889c2de
Closes #273
The PR fulfills these requirements: (check all the apply)
main
branch.feat: Add a button #xxx
, where "xxx" is the issue number).Closes #xxx
, where "xxx" is the issue number.ui
folder, unit tests (make test
) still pass.As explained in the issue, the picker
data-test
attribute is missing from the DOM once themax_choices
defined for the FluentUI TagPicker component is reached. With the change in this PR, a newdata-test
attribute is added to the remove button for the choices selected in the picker. This allows a Cypress test to locate the picker remove button with thedata-test
attribute and click it. Since themax_choices
is no longer satisfied, theinput
element with the pickerdata-test
attribute is added back to the DOM.This was accomplished by using
removeButtonIconProps
onTagPicker
to add a newdata_test
attribute that includes the picker name prefixed withremove_
. The code inui/src/picker.tsx
looks like this:There are 2 new test cases in
picker.test.tsx
. First is to confirm that the pickerdata-test
attribute is unavailable whenmax_choices
is met. The other is to confirm that the newdata-test
attribute for the remove button can be located and clicked, which returns the original pickerdata-test
attribute back in DOM.I ran all the ui tests and confirmed they passed. Here is a screen shot for that:![wave_ui_test_issue_273](https://github.com/h2oai/wave/assets/61979454/f5cdd3eb-1582-4ffe-8ef5-8b957998af5e)
Lastly, I also created a new Cypress test to confirm this would work. To support this, I modified the
picker_selection.py
example so that it defined amax_choices
of 3. This allows the Cypress test to use an existing example. I noticed that there are no Python test definitions for Cypress in the repository, so I wasn't sure what to do with the test. Here is the test, you can see it is very simple:Here is video showing the Cypress test in action: https://github.com/h2oai/wave/assets/61979454/6cf63b01-1b8e-461d-a1b6-4b019c65e4cf