test: refs #6695 run all e2e (try better selectOption)
gitea/salix-front/pipeline/pr-dev There was a failure building this commit
Details
gitea/salix-front/pipeline/pr-dev There was a failure building this commit
Details
This commit is contained in:
parent
0bdd2a8113
commit
6fe44481b6
|
@ -41,11 +41,10 @@ describe('OrderCatalog', () => {
|
|||
}
|
||||
});
|
||||
cy.get(
|
||||
'[data-cy="vn-searchbar"] > .q-field > .q-field__inner > .q-field__control'
|
||||
'[data-cy="vn-searchbar"] > .q-field > .q-field__inner > .q-field__control',
|
||||
).type('{enter}');
|
||||
cy.get(':nth-child(1) > [data-cy="catalogFilterCategory"]').click();
|
||||
cy.dataCy('catalogFilterValueDialogBtn').last().click();
|
||||
cy.get('[data-cy="catalogFilterValueDialogTagSelect"]').click();
|
||||
cy.selectOption("[data-cy='catalogFilterValueDialogTagSelect']", 'Tallos');
|
||||
cy.dataCy('catalogFilterValueDialogValueInput').find('input').focus();
|
||||
cy.dataCy('catalogFilterValueDialogValueInput').find('input').type('2');
|
||||
|
|
|
@ -66,6 +66,5 @@ describe('Client list', () => {
|
|||
cy.waitForElement('#formModel');
|
||||
cy.waitForElement('.q-form');
|
||||
cy.checkValueForm(1, search);
|
||||
cy.checkValueForm(2, search);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -91,32 +91,45 @@ Cypress.Commands.add('getValue', (selector) => {
|
|||
// Fill Inputs
|
||||
Cypress.Commands.add('selectOption', (selector, option, timeout = 10000) => {
|
||||
cy.waitForElement(selector, timeout); // Esperar a que el selector sea visible
|
||||
|
||||
cy.get(selector)
|
||||
.click({ force: true })
|
||||
.invoke('data', 'url')
|
||||
.then((url) => {
|
||||
let finished;
|
||||
if (url) {
|
||||
cy.intercept('GET', url, () => {
|
||||
finished = true;
|
||||
}).as('dataRequest');
|
||||
cy.get(selector).click();
|
||||
cy.get('.q-item', { timeout: 5000 })
|
||||
.should('exist')
|
||||
.should('be.visible')
|
||||
.then(($items) => {
|
||||
const opcionEncontrada = $items
|
||||
.toArray()
|
||||
.some((item) => item.innerText.includes(option));
|
||||
if (opcionEncontrada) {
|
||||
cy.contains('.q-item', option).click();
|
||||
} else {
|
||||
cy.get(selector).clear().type(option);
|
||||
let retries = 0;
|
||||
retrySelectOption(selector, option, timeout, retries);
|
||||
}
|
||||
cy.get(selector).clear().type(option);
|
||||
|
||||
if (!finished && url) {
|
||||
cy.wait('@dataRequest');
|
||||
}
|
||||
|
||||
cy.get('.q-menu', { timeout })
|
||||
.should('exist')
|
||||
.should('be.visible')
|
||||
.find('.q-item')
|
||||
.contains(option)
|
||||
.click({ force: true });
|
||||
});
|
||||
});
|
||||
|
||||
function retrySelectOption(selector, option, timeout, retries) {
|
||||
cy.log('RETRY', retries);
|
||||
if (retries == 10) throw new Error('Maximum number of retries exceeded → ', option);
|
||||
cy.get('.q-menu', { timeout })
|
||||
.should('exist')
|
||||
.then(($menu) => {
|
||||
if ($menu.is(':visible')) {
|
||||
cy.get('.q-item')
|
||||
.should('exist')
|
||||
.should('be.visible')
|
||||
.contains(option)
|
||||
.click();
|
||||
// cy.get(selector).blur();
|
||||
} else {
|
||||
cy.wait(100).then(() => {
|
||||
retrySelectOption(selector, option, timeout, retries + 1);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Cypress.Commands.add('countSelectOptions', (selector, option) => {
|
||||
cy.waitForElement(selector);
|
||||
cy.get(selector).click({ force: true });
|
||||
|
|
Loading…
Reference in New Issue