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

feat(ui) Add new prop 'option-data-id' to QSelect #17499

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from

Conversation

lucashenkes
Copy link

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Documentation
  • Code style update
  • Refactor
  • Build-related changes
  • Other, please describe:

Does this PR introduce a breaking change?

  • Yes
  • No

The PR fulfills these requirements:

  • It's submitted to the dev branch (or v[X] branch)
  • When resolving a specific issue, it's referenced in the PR's title (e.g. fix: #xxx[,#xxx], where "xxx" is the issue number)
  • It's been tested on a Cordova (iOS, Android) app
  • It's been tested on an Electron app
  • Any necessary documentation has been added or updated in the docs or explained in the PR's description.

If adding a new feature, the PR's description includes:

  • A convincing reason for adding this feature (to avoid wasting your time, it's best to start a new feature discussion first and wait for approval before working on it)

Other information:

Currently, there is no easy way to find a specific option (e.g. using querySelector / in automated tests).
This PR adds the option to set a custom data-id attribute to the option-elements, making them easy to query.

@lucashenkes lucashenkes marked this pull request as ready for review September 9, 2024 12:01
@lucashenkes lucashenkes changed the title Add new prop 'option-data-id' to QSelect feat(ui) Add new prop 'option-data-id' to QSelect Oct 8, 2024
@peter-schunk-ion2s
Copy link

@rstoenescu would be nice if we could get feedback on this small addition. It's a blocker for test automation and would really help us and probably others.
Thanks and regards

@rstoenescu rstoenescu self-requested a review October 18, 2024 13:29
@rstoenescu
Copy link
Member

Would something like this suffice for you instead? It's a Vitest example, but I guess there are alternatives for other testing environments. It points to the actual content of the QDialog/QMenu/QTooltip.

// Quasar supplies this for some time now already
wrapper.findComponent({ name: 'QPortal' })
            .get('.q-dialog__inner')

@peter-schunk-ion2s
Copy link

Thanks for the answer, @rstoenescu . This sure would work but it has some drawbacks.
Using the right option in the test framework (Cypress in our case) needs the selectors to go deep down all the way to the label to have its content (string-) compared to make sure the correct option will be selected. This is due to the fact that we cannot guarantee that the order and amount of available selections is always the same. Otherwise we could select it by index, sure.
Also it should be somewhat future proof and if the (HTML) structure of Quasar differs those tests would fail.
All in all we feel like using an optional option-data-id attribute would be less flaky and more consistent.

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