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

Proposal: Improve portal dependent components (e.g. QSelect , QButtonGroup etc) testing experience #371

Open
thevladisss opened this issue Apr 18, 2024 · 0 comments

Comments

@thevladisss
Copy link

thevladisss commented Apr 18, 2024

Issue:
Testing QSelect and other portal dependent components is heavy and time consuming. By portal dependent I mean the components that actually trigger portal based components to appear e.g. Menu, Dialog.

The biggest problem is that portal based components like Menu do not know know who called them and this causes the issue when testing components specifically or during E2E tests. Couple of different menu or dialogs can be open at the same time and withinSelectMenu command might bot be able to handle this scenario.

Solution:
When QSelect triggers mount for QMenu or QDialog, a specific attribute that should be put onto the instantiated portal based component to be able to refer to the caller. In this case custom commands like "withinSelectMenu" can become chainable or can accept a selector be able to query the menu trigerred by selector

Cypress.Commands.add('withinSelectElement', { prevSubject: 'optional' }, (subject, callback, selector) => {
	if (subject && !selector) {
  	/**
    	Assume all menus created by use of QSelect have data-caller="1"
    */
  	selector = ".q-menu" + "[data-caller=" + subject.attr('id') + "]"
  }
  
    	cy.root().closest('html').get(selector).within(callback)
})

cy.dataCy('dropdown-persons').withinSelectElement(() => {})


There is a way however to circumvent it now, it is by passing selector to "popupContentClass" in QSelect element and explicitly querying this element, however I beleive that is not the best solution

IMPORTANT NOTE

This requires updating the QSelect element, and is not only matter of updating this package.

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

1 participant