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

Select: add support for typeahead select #51

Merged
merged 1 commit into from
Feb 26, 2024

Conversation

jrusz
Copy link
Contributor

@jrusz jrusz commented Feb 19, 2024

When there is an item selected it would click on the clear button instead of the toggle button when trying to access items or calling open(), this fixes that.

Copy link

codecov bot commented Feb 19, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.82%. Comparing base (4d67bc9) to head (f15be8c).
Report is 3 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main      #51   +/-   ##
=======================================
  Coverage   99.82%   99.82%           
=======================================
  Files          43       43           
  Lines        1677     1706   +29     
=======================================
+ Hits         1674     1703   +29     
  Misses          3        3           
Flag Coverage Δ
unittests 99.82% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@jrusz jrusz force-pushed the update-select branch 2 times, most recently from 2ad416a to ce0013f Compare February 19, 2024 15:33
@jrusz
Copy link
Contributor Author

jrusz commented Feb 19, 2024

@digitronik Hi, can you review please?

Also there were some seemingly random failures during the test runs, I had to force push a few times before it all passed, they were tests for other widgets, unrelated to my change though, should we be concerned about that?

@jrusz
Copy link
Contributor Author

jrusz commented Feb 19, 2024

Also this is not urgent, just something I've noticed when working. I wanted to get the items from a select which had a default item selected and when I called .items it would click on the clear button instead of the toggle button and fail. I don't need it in the actual test now so don't need a release right away :)

@jrusz jrusz marked this pull request as draft February 19, 2024 20:21
@jrusz
Copy link
Contributor Author

jrusz commented Feb 19, 2024

I've actually found some issues with this. Need to update it.

@jrusz
Copy link
Contributor Author

jrusz commented Feb 20, 2024

This should work now, also I've found out that I need it for the fill method, it doesn't work without this. I think it's the "Typeahead" select which causes these issues for me with a default value preselected (but the same would happen if you were to select something twice) ... I'll add some tests for this as it seems that select type is not covered.

@jrusz
Copy link
Contributor Author

jrusz commented Feb 20, 2024

I ended up adding a new class for the select as the read method didn't work, the selected value is a in separate input element instead of underneath the button, the rest seems to be fine.

@jrusz jrusz marked this pull request as ready for review February 20, 2024 08:50
@jrusz jrusz force-pushed the update-select branch 4 times, most recently from ee8a7c2 to 8d99323 Compare February 20, 2024 15:52
@jrusz
Copy link
Contributor Author

jrusz commented Feb 20, 2024

Ok I think I'm finished with this one, can you review please @digitronik ? :)

Copy link
Member

@digitronik digitronik left a comment

Choose a reason for hiding this comment

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

Nice PR 👍

Some suggestions
As we are introducing new widget better to maintain it in README as well.

Special thanks for covering unit tests. I will take a look on more time after changes.

Comment on lines 192 to 196
class BaseTypeaheadSelect(BaseSelect):
text = TextInput(locator=".//input")

def read(self):
return self.browser.get_attribute("value", self.text)
Copy link
Member

Choose a reason for hiding this comment

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

Lets make this part of widget directly only single method.
Better to use input as name of child widget.

input = TextInput(locator=".//input")

@@ -19,7 +20,11 @@ class BaseSelect:
https://www.patternfly.org/components/menus/select
"""

BUTTON_LOCATOR = ".//button"
BUTTON_LOCATOR = (
Copy link
Member

Choose a reason for hiding this comment

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

Better to overwrite in widget itself. Those limitation can break usage. Not tested against console dot so.

@jrusz
Copy link
Contributor Author

jrusz commented Feb 20, 2024

@digitronik Is this what you meant?

@jrusz jrusz changed the title Select: Make button locator more speciffic Select: add support for typeahead select Feb 20, 2024
@jrusz jrusz marked this pull request as draft February 21, 2024 13:57
@jrusz
Copy link
Contributor Author

jrusz commented Feb 21, 2024

I'm not sure why, but the ouia component doesn't work if I don't use the Base component type, is it ok like this?

@jrusz jrusz marked this pull request as ready for review February 21, 2024 14:08
@digitronik
Copy link
Member

@jrusz I'm good with it can you please check jobs

@jrusz
Copy link
Contributor Author

jrusz commented Feb 21, 2024

@jrusz I'm good with it can you please check jobs

Thank you. I don't know why the jobs fail, like I said in a comment above they fail seemingly randomly. I don't have permissions to restart them, I'd have to force push, can you try restarting them please?

BUTTON_LOCATOR = (
".//button[(contains(@class, '-c-select__toggle') "
"or contains(@class, '-c-menu-toggle')) "
"and not(contains(@class, '-c-select__toggle-clear'))]"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Consider creating a separate locator for the clear button, and a function to click it.

@mshriver mshriver merged commit e0cae05 into RedHatQE:main Feb 26, 2024
9 checks passed
@jrusz jrusz deleted the update-select branch February 28, 2024 06:29
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