test: refs #7356 clean commands

This commit is contained in:
Javier Segarra 2025-03-28 00:25:27 +01:00
parent 9492c71128
commit bdfc1fa309
15 changed files with 107 additions and 109 deletions

View File

@ -9,7 +9,7 @@ describe('TicketBasicData', () => {
it('Should redirect to customer basic data', () => {
cy.get('.q-page').should('be.visible');
cy.get(':nth-child(2) > div > .text-primary').click();
cy.get('[data-cy="Address_select"]').click();
cy.dataCy('Address_select').click();
cy.get('.q-btn-group > [data-v-d4506789=""] > .q-btn__content > .q-icon').click();
cy.get(
'[data-cy="CustomerBasicData-menu-item"] > .q-item__section--main',
@ -25,16 +25,16 @@ describe('TicketBasicData', () => {
cy.get('tr:nth-child(1)>:nth-child(1)>span').should('have.class', 'link').click();
cy.dataCy('ItemDescriptor').should('exist');
cy.get('.q-drawer__content > :nth-child(1) > :nth-child(2) > span').should(
'have.text',
'Price: €34.40',
'contain.text',
'Price: €',
);
cy.get('.q-drawer__content > :nth-child(1) > :nth-child(3) > span').should(
'have.text',
'New price: €34.20',
'contain.text',
'New price: €',
);
cy.get('.q-drawer__content > :nth-child(1) > :nth-child(4) > span').should(
'have.text',
'Difference: €0.20',
'contain.text',
'Difference: €',
);
cy.get(
':nth-child(3) > .q-radio > .q-radio__inner > .q-radio__bg > .q-radio__check',

View File

@ -1,4 +1,5 @@
/// <reference types="cypress" />
describe('TicketComponents', () => {
beforeEach(() => {
cy.login('developer');
@ -7,61 +8,23 @@ describe('TicketComponents', () => {
});
it('Should load layout', () => {
cy.get('.q-page').should('be.visible');
/* ==== Generated with Cypress Studio ==== */
cy.get('.q-scrollarea__content > :nth-child(2) > :nth-child(2)').should(
'have.text',
'Base to commission: €799.20',
);
cy.get('.q-scrollarea__content > :nth-child(2) > :nth-child(3)').should(
'have.text',
'Total without VAT: €807.20',
);
cy.get('.q-scrollarea__content > :nth-child(3) > :nth-child(2)').should(
'have.text',
'valor de compra: €425.000',
);
cy.get('.q-scrollarea__content > :nth-child(3) > :nth-child(4)').should(
'have.text',
'maná auto: €7.998',
);
cy.get('.q-scrollarea__content > :nth-child(4) > :nth-child(2)').should(
'have.text',
'Price: €5.00',
);
cy.get('.q-scrollarea__content > :nth-child(4) > :nth-child(3)').should(
'have.text',
'Bonus: €1.00',
);
cy.get('.q-scrollarea__content > :nth-child(4) > :nth-child(5)').should(
'have.text',
'Packages: 6',
);
cy.get('.q-scrollarea__content > :nth-child(4) > :nth-child(4)').should(
'have.text',
'Zone: Zone pickup A ',
);
cy.get('.q-scrollarea__content > :nth-child(5) > :nth-child(2)').should(
'have.text',
'Total price: €16.00',
);
cy.validateScrollContent([
{ row: 2, col: 2, text: 'Base to commission: €799.20' },
{ row: 2, col: 3, text: 'Total without VAT: €807.20' },
{ row: 3, col: 2, text: 'valor de compra: €425.000' },
{ row: 3, col: 4, text: 'maná auto: €7.998' },
{ row: 4, col: 2, text: 'Price: €5.00' },
{ row: 4, col: 3, text: 'Bonus: €1.00' },
{ row: 4, col: 5, text: 'Packages: 6' },
{ row: 4, col: 4, text: 'Zone: Zone pickup A ' },
{ row: 5, col: 2, text: 'Total price: €16.00' },
]);
cy.get(':nth-child(4) > .link').click();
cy.dataCy('ZoneDescriptor').should('exist');
cy.get(':nth-child(1) > [data-col-field="total"]').should(
'have.text',
'€250.000€247.000€4.970',
);
cy.get(':nth-child(1) > [data-col-field="import"]').should(
'have.text',
'€50.000€49.400€0.994',
);
cy.get(':nth-child(1) > [data-col-field="components"]').should(
'have.text',
'valor de compramargenmaná auto',
);
cy.get(':nth-child(1) > [data-col-field="serie"]').should(
'have.text',
'costeempresacartera_comercial',
);
cy.getRowCol('total').should('have.text', '€250.000€247.000€4.970');
cy.getRowCol('import').should('have.text', '€50.000€49.400€0.994');
cy.getRowCol('components').should('have.text', 'valor de compramargenmaná auto');
cy.getRowCol('serie').should('have.text', 'costeempresacartera_comercial');
});
});

View File

@ -1,7 +1,5 @@
/// <reference types="cypress" />
describe('TicketList', () => {
const firstRow = 'tbody.q-virtual-scroll__content tr:nth-child(1)';
beforeEach(() => {
cy.login('developer');
cy.viewport(1920, 1080);
@ -11,7 +9,7 @@ describe('TicketList', () => {
const searchResults = (search) => {
if (search) cy.typeSearchbar().type(search);
cy.dataCy('vn-searchbar').find('input').type('{enter}');
cy.get(firstRow).should('exist');
cy.getRow().should('exist');
};
it('should search results', () => {
@ -24,13 +22,13 @@ describe('TicketList', () => {
cy.window().then((win) => {
cy.stub(win, 'open').as('windowOpen');
});
cy.get(firstRow).should('be.visible').find('.q-btn:first').click();
cy.getRow().should('be.visible').find('.q-btn:first').click();
cy.get('@windowOpen').should('be.calledWithMatch', /\/ticket\/\d+\/sale/);
});
it('should open ticket summary', () => {
searchResults();
cy.get(firstRow).find('.q-btn:last').click();
cy.getRow().find('.q-btn:last').click();
cy.get('.summaryHeader').should('exist');
cy.get('.summaryBody').should('exist');
});
@ -44,7 +42,7 @@ describe('TicketList', () => {
cy.dataCy('Customer ID_input').type('1101{enter}');
cy.intercept('GET', /\/api\/Clients\?filter/).as('clientFilter');
cy.get('[data-cy="vnTableCreateBtn"] > .q-btn__content > .q-icon').click();
cy.vnTableCreateBtn();
cy.wait('@clientFilter');
cy.dataCy('Customer_select').should('have.value', 'Bruce Wayne');
cy.dataCy('Address_select').click();
@ -53,8 +51,7 @@ describe('TicketList', () => {
cy.dataCy('Address_select').should('have.value', 'Bruce Wayne');
});
it('Client list create new ticket', () => {
cy.dataCy('vnTableCreateBtn').should('exist');
cy.dataCy('vnTableCreateBtn').click();
cy.vnTableCreateBtn();
const data = {
Customer: { val: 1, type: 'select' },
Warehouse: { val: 'Warehouse One', type: 'select' },

View File

@ -19,7 +19,7 @@ describe('TicketNotes', () => {
cy.checkNotification('Data saved');
cy.dataCy('ticketNotesRemoveNoteBtn').should('exist');
cy.dataCy('ticketNotesRemoveNoteBtn').click();
cy.dataCy('VnConfirm_confirm').click();
cy.confirmVnConfirm();
cy.checkNotification('Data saved');
});
});

View File

@ -9,14 +9,13 @@ describe('TicketPackages', () => {
it('Should load layout', () => {
cy.get('.q-page').should('be.visible');
cy.get('.vn-row > .q-btn > .q-btn__content > .q-icon').click();
cy.get('[data-cy="Package_select"]').click();
cy.dataCy('Package_select').click();
cy.get('.q-menu :nth-child(1) >.q-item__section').click();
cy.get('[data-cy="Quantity_input"]').clear();
cy.get('[data-cy="Quantity_input"]').type('5');
cy.get('[data-cy="crudModelDefaultSaveBtn"] > .q-btn__content').click();
cy.dataCy('Quantity_input').clear().type('5');
cy.saveCrudModel();
cy.checkNotification('Data saved');
cy.get('.q-mb-md > .text-primary').click();
cy.get('[data-cy="VnConfirm_confirm"] > .q-btn__content > .block').click();
cy.confirmVnConfirm();
cy.checkNotification('Data saved');
});
});

View File

@ -9,9 +9,9 @@ describe('TicketPictures', () => {
cy.get(':nth-child(1) > .q-card > .content').should('be.visible');
cy.get('.content > .link').should('be.visible').click();
cy.dataCy('ItemDescriptor').should('exist');
cy.get('[data-cy="vnLvColor:"]').should('be.visible');
cy.get('[data-cy="vnLvColor:"]').should('be.visible');
cy.get('[data-cy="vnLvTallos:"]').should('be.visible');
cy.dataCy('vnLvColor:');
cy.dataCy('vnLvColor:');
cy.dataCy('vnLvTallos:');
cy.get('.q-mt-md').should('be.visible');
cy.get(':nth-child(1) > .q-card > .img-wrapper').should('be.visible');
});

View File

@ -7,8 +7,7 @@ describe('TicketRequest', () => {
});
it('Creates a new request', () => {
cy.dataCy('vnTableCreateBtn').should('exist');
cy.dataCy('vnTableCreateBtn').click();
cy.vnTableCreateBtn();
const data = {
Description: { val: 'Purchase description' },
Atender: { val: 'buyerNick', type: 'select' },

View File

@ -16,9 +16,11 @@ describe('TicketSale', () => {
cy.waitForElement('[data-cy="ticketEditManaProxy"]');
cy.dataCy('ticketEditManaProxy').should('exist');
cy.waitForElement('[data-cy="Price_input"]');
cy.dataCy('Price_input').clear();
cy.dataCy('Price_input').type(price);
cy.dataCy('Price_input').clear().type(price);
cy.intercept('POST', '**/api').as('saveMana');
cy.dataCy('saveManaBtn').click();
cy.wait('@saveMana').its('response.statusCode').should('eq', 200);
handleVnConfirm();
cy.get('[data-col-field="price"]')
@ -34,7 +36,10 @@ describe('TicketSale', () => {
cy.waitForElement('[data-cy="Disc_input"]');
cy.dataCy('Disc_input').clear();
cy.dataCy('Disc_input').type(discount);
cy.intercept('POST', '**/api').as('saveMana');
cy.dataCy('saveManaBtn').click();
cy.wait('@saveMana').its('response.statusCode').should('eq', 200);
handleVnConfirm();
cy.get('[data-col-field="discount"]')
@ -82,12 +87,12 @@ describe('TicketSale', () => {
selectFirstRow();
cy.dataCy('ticketSaleMoreActionsDropdown').click();
cy.dataCy('createClaimItem').click();
cy.dataCy('VnConfirm_confirm').click();
cy.confirmVnConfirm();
cy.url().should('contain', 'claim/');
// Delete created claim to avoid cluttering the database
cy.dataCy('descriptor-more-opts').click();
cy.dataCy('deleteClaim').click();
cy.dataCy('VnConfirm_confirm').click();
cy.confirmVnConfirm();
});
});
describe('Free ticket #31', () => {
@ -138,8 +143,10 @@ describe('TicketSale', () => {
cy.waitForElement('[data-cy="ticketSaleDiscountInput"]');
cy.dataCy('ticketSaleDiscountInput').find('input').focus();
cy.dataCy('ticketSaleDiscountInput').find('input').type('10');
cy.intercept('POST', '**/api').as('saveMana');
cy.dataCy('saveManaBtn').click();
cy.waitForElement('.q-notification__message');
cy.wait('@saveMana').its('response.statusCode').should('eq', 200);
cy.checkNotification('Data saved');
cy.dataCy('ticketSaleMoreActionsDropdown').should('be.disabled');
});
@ -148,7 +155,7 @@ describe('TicketSale', () => {
selectFirstRow();
cy.dataCy('ticketSaleMoreActionsDropdown').click();
cy.dataCy('createClaimItem').click();
cy.dataCy('VnConfirm_confirm').click();
cy.confirmVnConfirm();
cy.checkNotification('Future ticket date not allowed');
});
@ -194,9 +201,6 @@ function selectFirstRow() {
cy.get(firstRow).find('.q-checkbox__inner').click();
}
function handleVnConfirm() {
cy.get('[data-cy="VnConfirm_confirm"]').click();
cy.waitForElement('.q-notification__message');
cy.get('.q-notification__message').should('be.visible');
cy.confirmVnConfirm();
cy.checkNotification('Data saved');
}

View File

@ -9,17 +9,14 @@ describe('TicketService', () => {
it('Add and remove service', () => {
cy.get('.q-page').should('be.visible');
cy.addBtnClick();
cy.get('[data-cy="Description_icon"]').click();
cy.get('[data-cy="Description_input"]').clear();
cy.get('[data-cy="Description_input"]').type('test');
cy.get('[data-cy="FormModelPopup_save"] > .q-btn__content > .block').click();
cy.dataCy('Description_icon').click();
cy.dataCy('Description_input').clear().type('test');
cy.saveFormModel();
cy.selectOption('[data-cy="Description_select"]', 'test');
cy.get('[data-cy="Quantity_input"]').clear('1');
cy.get('[data-cy="Quantity_input"]').type('1');
cy.get('[data-cy="Price_input"]').clear('2');
cy.get('[data-cy="Price_input"]').type('2');
cy.get('[data-cy="crudModelDefaultSaveBtn"] > .q-btn__content > .block').click();
cy.dataCy('Quantity_input').clear().type('1');
cy.dataCy('Price_input').clear().type('2');
cy.saveCrudModel();
cy.checkNotification('Data saved');
cy.get(':nth-child(5) > .q-icon').click();
});

View File

@ -9,11 +9,11 @@ describe('Ticket tracking', () => {
it('Add new tracking', () => {
cy.get('.q-page').should('be.visible');
cy.firstRow('worker').find('span').should('have.class', 'link').click();
cy.getRowCol('worker').find('span').should('have.class', 'link').click();
cy.dataCy('WorkerDescriptor').should('exist');
cy.get('[data-cy="vnTableCreateBtn"] > .q-btn__content > .q-icon').click();
cy.vnTableCreateBtn();
cy.selectOption('.q-field--float [data-cy="State_select"]', 'OK').click();
cy.get('[data-cy="FormModelPopup_save"] > .q-btn__content > .block').click();
cy.saveFormModel();
cy.get(
':last-child > [data-col-field="state"] > [data-cy="vnTableCell_state"]',
).should('have.text', 'OK');

View File

@ -0,0 +1,3 @@
Cypress.Commands.add('saveCrudModel', () =>
cy.dataCy('crudModelDefaultSaveBtn').should('exist').click(),
);

View File

@ -0,0 +1,3 @@
Cypress.Commands.add('saveFormModel', () =>
cy.dataCy('FormModelPopup_save').should('exist').click(),
);

View File

@ -0,0 +1,3 @@
Cypress.Commands.add('confirmVnConfirm', () =>
cy.dataCy('VnConfirm_confirm').should('exist').click(),
);

View File

@ -1,3 +1,16 @@
Cypress.Commands.add('firstRow', (field, index = 1) =>
cy.get(`:nth-child(${index}) > [data-col-field="${field}"]`),
Cypress.Commands.add('getRow', (index = 1) =>
cy.get(`.vnTable .q-virtual-scroll__content tr:nth-child(${index})`),
);
Cypress.Commands.add('getRowCol', (field, index = 1) =>
cy.get(
`.vnTable .q-virtual-scroll__content > :nth-child(${index}) > [data-col-field="${field}"]`,
),
);
Cypress.Commands.add('vnTableCreateBtn', () =>
cy.dataCy('vnTableCreateBtn').should('exist').click(),
);
Cypress.Commands.add('waitTableScrollLoad', () =>
cy.waitForElement('[data-q-vs-anchor]'),
);

View File

@ -429,8 +429,29 @@ Cypress.Commands.add('searchByLabel', (label, value) => {
cy.get(`[label="${label}"] > .q-field > .q-field__inner`).type(`${value}{enter}`);
});
Cypress.Commands.add('dataCy', (tag, attr = 'data-cy') => {
return cy.get(`[${attr}="${tag}"]`);
Cypress.Commands.add('dataCy', (tag, attr = 'data-cy', options = {}) => {
let chain = cy.get(`[${attr}="${tag}"]`).should('be.visible');
// Procesar cada opción y encadenar los comandos correspondientes
Object.entries(options).forEach(([key, value]) => {
switch (key) {
case 'click':
if (value) chain = chain.click();
break;
case 'type':
chain = chain.type(value);
break;
case 'clear':
if (value) chain = chain.clear();
break;
case 'should':
chain = chain.should(value);
break;
// Puedes añadir más casos según necesites
}
});
return chain;
});
Cypress.Commands.add('addBtnClick', () => {
@ -610,7 +631,3 @@ Cypress.Commands.add('checkQueryParams', (expectedParams = {}) => {
}
});
});
Cypress.Commands.add('waitTableScrollLoad', () =>
cy.waitForElement('[data-q-vs-anchor]'),
);