test: perf clientList descriptor action

This commit is contained in:
Javier Segarra 2024-11-25 23:49:24 +01:00
parent 6c6144864f
commit 4e5754ccb5
2 changed files with 23 additions and 6 deletions

View File

@ -6,7 +6,11 @@ describe('Client list', () => {
cy.visit('/#/customer/list', { cy.visit('/#/customer/list', {
timeout: 5000, timeout: 5000,
onBeforeLoad(win) { onBeforeLoad(win) {
cy.stub(win, 'open'); cy.stub(win, 'open')
.callsFake((url) => {
return win.open.wrappedMethod.call(win, url, '_self');
})
.as('Open');
}, },
}); });
}); });
@ -47,17 +51,20 @@ describe('Client list', () => {
it('Client founded create ticket', () => { it('Client founded create ticket', () => {
const search = 'Jessica Jones'; const search = 'Jessica Jones';
cy.searchByLabel('Name', search); cy.searchByLabel('Name', search);
cy.clickButtonsDescriptor(2); cy.openActionDescriptor('Create ticket');
cy.waitForElement('#formModel'); cy.waitForElement('#formModel');
cy.waitForElement('.q-form'); cy.waitForElement('.q-form', { timeout: 5000 });
cy.checkValueForm(1, search);
cy.get('.grid-create >:nth-child(1)').find('input').should('have.value', search);
cy.get('.grid-create >:nth-child(2)').find('input').should('have.value', search);
}); });
it('Client founded create order', () => { it('Client founded create order', () => {
const search = 'Jessica Jones'; const search = 'Jessica Jones';
cy.searchByLabel('Name', search); cy.searchByLabel('Name', search);
cy.clickButtonsDescriptor(4); cy.openActionDescriptor('New order');
cy.waitForElement('#formModel'); cy.waitForElement('#formModel');
cy.waitForElement('.q-form'); cy.waitForElement('.q-form');
cy.checkValueForm(2, search); cy.get('.grid-create >:nth-child(2)').find('input').should('have.value', search);
cy.get('.grid-create >:nth-child(4)').find('input').should('have.value', search);
}); });
}); });

View File

@ -249,6 +249,7 @@ Cypress.Commands.add('writeSearchbar', (value) => {
value value
); );
}); });
Cypress.Commands.add('validateContent', (selector, expectedValue) => { Cypress.Commands.add('validateContent', (selector, expectedValue) => {
cy.get(selector).should('have.text', expectedValue); cy.get(selector).should('have.text', expectedValue);
}); });
@ -256,6 +257,14 @@ Cypress.Commands.add('validateContent', (selector, expectedValue) => {
Cypress.Commands.add('openActionsDescriptor', () => { Cypress.Commands.add('openActionsDescriptor', () => {
cy.get('.header > :nth-child(3) > .q-btn__content > .q-icon').click(); cy.get('.header > :nth-child(3) > .q-btn__content > .q-icon').click();
}); });
Cypress.Commands.add('openActionDescriptor', (opt) => {
cy.openActionsDescriptor();
const listItem = '[role="menu"] .q-list .q-item';
cy.contains(listItem, opt).click();
1;
});
Cypress.Commands.add('clickButtonsDescriptor', (id) => { Cypress.Commands.add('clickButtonsDescriptor', (id) => {
cy.get(`.actions > .q-card__actions> .q-btn:nth-child(${id})`) cy.get(`.actions > .q-card__actions> .q-btn:nth-child(${id})`)
.invoke('removeAttr', 'target') .invoke('removeAttr', 'target')
@ -267,6 +276,7 @@ Cypress.Commands.add('openUserPanel', () => {
'.column > .q-avatar > .q-avatar__content > .q-img > .q-img__container > .q-img__image' '.column > .q-avatar > .q-avatar__content > .q-img > .q-img__container > .q-img__image'
).click(); ).click();
}); });
Cypress.Commands.add('checkNotification', (text) => { Cypress.Commands.add('checkNotification', (text) => {
cy.get('.q-notification') cy.get('.q-notification')
.should('be.visible') .should('be.visible')