test: fix selectOption wait to ariaControl is visible
This commit is contained in:
parent
9306f88b99
commit
afb0e912d6
|
@ -6,9 +6,10 @@ describe('Client balance', () => {
|
|||
cy.visit('#/customer/1101/balance');
|
||||
});
|
||||
it('Should create a mandate', () => {
|
||||
cy.waitSpinner();
|
||||
cy.get('.q-page-sticky > div > .q-btn').click();
|
||||
cy.selectOption('[data-cy="paymentBank"]', 2);
|
||||
cy.dataCy('paymentAmount_input').type('100');
|
||||
cy.dataCy('paymentAmount_input').clear().type('100');
|
||||
cy.saveCard();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -92,6 +92,14 @@ Cypress.Commands.add('getValue', (selector) => {
|
|||
});
|
||||
});
|
||||
|
||||
Cypress.Commands.add('waitSpinner', () => {
|
||||
cy.get('body').then(($body) => {
|
||||
if ($body.find('[data-cy="loading-spinner"]').length) {
|
||||
cy.get('[data-cy="loading-spinner"]').should('not.be.visible');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// Fill Inputs
|
||||
Cypress.Commands.add('selectOption', (selector, option, timeout = 2500) => {
|
||||
cy.waitForElement(selector, timeout);
|
||||
|
@ -109,6 +117,7 @@ Cypress.Commands.add('selectOption', (selector, option, timeout = 2500) => {
|
|||
|
||||
function selectItem(selector, option, ariaControl, hasWrite = true) {
|
||||
if (!hasWrite) cy.wait(100);
|
||||
cy.waitSpinner();
|
||||
|
||||
getItems(ariaControl).then((items) => {
|
||||
const matchingItem = items
|
||||
|
@ -128,6 +137,7 @@ function getItems(ariaControl, startTime = Cypress._.now(), timeout = 2500) {
|
|||
.should('exist')
|
||||
.find('.q-item')
|
||||
.should('exist')
|
||||
.should('be.visible')
|
||||
.then(($items) => {
|
||||
if (!$items?.length || $items.first().text().trim() === '') {
|
||||
if (Cypress._.now() - startTime > timeout) {
|
||||
|
|
Loading…
Reference in New Issue