From 44f11fddf13a2ae767fce54b88ea8713d68f0c02 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Thu, 6 Mar 2025 01:15:31 +0100 Subject: [PATCH] test: fix test --- src/pages/Order/OrderList.vue | 6 +-- .../integration/client/clientList.spec.js | 11 ++++- .../integration/order/orderList.spec.js | 42 ++++++++++++++++++- .../ticket/negative/TicketLackDetail.spec.js | 2 +- .../integration/ticket/ticketList.spec.js | 6 +-- 5 files changed, 57 insertions(+), 10 deletions(-) diff --git a/src/pages/Order/OrderList.vue b/src/pages/Order/OrderList.vue index e4457fa38..a066bf914 100644 --- a/src/pages/Order/OrderList.vue +++ b/src/pages/Order/OrderList.vue @@ -158,11 +158,11 @@ onMounted(async () => { if (route.query?.createForm) { const query = JSON.parse(route.query?.createForm); formInitialData.value = query; - await onClientSelected({ ...formInitialData.value, clientId: query?.clientFk }); + await onClientSelected({ ...formInitialData.value, clientFk: query?.clientFk }); } else if (route.query?.table) { const query = JSON.parse(route.query?.table); - const clientId = query?.clientFk; - if (clientId) await onClientSelected({ clientId }); + const clientFk = query?.clientFk; + if (clientFk) await onClientSelected({ clientFk }); } if (tableRef.value) tableRef.value.create.formInitialData = formInitialData.value; }); diff --git a/test/cypress/integration/client/clientList.spec.js b/test/cypress/integration/client/clientList.spec.js index f2e3671ba..879a50f7a 100644 --- a/test/cypress/integration/client/clientList.spec.js +++ b/test/cypress/integration/client/clientList.spec.js @@ -58,13 +58,22 @@ describe('Client list', () => { cy.waitForElement('.q-form'); cy.checkValueForm(1, search); cy.checkValueForm(2, search); + cy.dataCy('Customer_select').should('have.value', search); + cy.dataCy('Address_select').should('have.value', search); }); it('Client founded create order', () => { const search = 'Jessica Jones'; - cy.searchByLabel('Name', search); + + cy.intercept('GET', /\/api\/Clients\/1110\/summary/).as('customer'); + cy.dataCy('Name_input').type(`${search}{enter}`); + cy.wait('@customer'); + cy.get('.actions > .q-card__actions').should('exist'); cy.clickButtonWith('icon', 'icon-basketadd'); + cy.url().should('include', `/customer/1110/summary`); cy.waitForElement('#formModel'); cy.waitForElement('.q-form'); cy.checkValueForm(1, search); + cy.dataCy('Client_select').should('have.value', search); + cy.dataCy('Address_select').should('have.value', search); }); }); diff --git a/test/cypress/integration/order/orderList.spec.js b/test/cypress/integration/order/orderList.spec.js index bece338a7..b88f3c7fa 100644 --- a/test/cypress/integration/order/orderList.spec.js +++ b/test/cypress/integration/order/orderList.spec.js @@ -8,7 +8,6 @@ describe('OrderList', () => { }); it('create order', () => { - /* ==== Generated with Cypress Studio ==== */ cy.get('[data-cy="vnTableCreateBtn"]').click(); cy.get('[data-cy="Client_select"]').type('1101'); cy.get('.q-menu').contains('Bruce Wayne').click(); @@ -29,4 +28,45 @@ describe('OrderList', () => { }); cy.url().should('include', `/order`); }); + + it('filter list and create order', () => { + cy.dataCy('Customer ID_input').type('1101{enter}'); + cy.dataCy('vnTableCreateBtn').click(); + cy.dataCy('landedDate').find('input').type('06/01/2001'); + cy.get('.q-card [data-cy="Agency_select"]').click(); + cy.get('.q-menu > div> .q-item:nth-child(1)').click(); + cy.intercept('GET', /\/api\/Orders\/\d/).as('orderSale'); + cy.get('[data-cy="FormModelPopup_save"] > .q-btn__content > .block').click(); + cy.wait('@orderSale'); + cy.get('.q-item > .q-item__label.subtitle').then((text) => { + const id = text.text().trim().split('#')[1]; + cy.get('.q-item > .q-item__label').should('have.text', ` #${id}`); + }); + cy.url().should('include', `/order`); + }); + + it('create order from customer summary', function () { + const clientId = 1101; + cy.dataCy('Customer ID_input').type(`${clientId}{enter}`); + cy.get( + ':nth-child(1) > [data-col-field="clientFk"] > .no-padding > .link', + ).click(); + cy.get( + `[href="#/order/list?createForm={%22clientFk%22:${clientId},%22addressId%22:1}"] > .q-btn__content > .q-icon`, + ).click(); + cy.dataCy('vnTableCreateBtn').click(); + cy.get('[data-cy="Client_select"]').should('have.value', 'Bruce Wayne'); + cy.get('[data-cy="Address_select"]').should('have.value', 'Bruce Wayne'); + cy.dataCy('landedDate').find('input').type('06/01/2001'); + cy.get('.q-card [data-cy="Agency_select"]').click(); + cy.get('.q-menu > div> .q-item:nth-child(1)').click(); + cy.intercept('GET', /\/api\/Orders\/\d/).as('orderSale'); + cy.get('[data-cy="FormModelPopup_save"] > .q-btn__content > .block').click(); + cy.wait('@orderSale'); + cy.get('.q-item > .q-item__label.subtitle').then((text) => { + const id = text.text().trim().split('#')[1]; + cy.get('.q-item > .q-item__label').should('have.text', ` #${id}`); + }); + cy.url().should('include', `/order`); + }); }); diff --git a/test/cypress/integration/ticket/negative/TicketLackDetail.spec.js b/test/cypress/integration/ticket/negative/TicketLackDetail.spec.js index 9ea1cff63..a6d1a1982 100644 --- a/test/cypress/integration/ticket/negative/TicketLackDetail.spec.js +++ b/test/cypress/integration/ticket/negative/TicketLackDetail.spec.js @@ -139,7 +139,7 @@ describe('Ticket Lack detail', () => { cy.wait('@getItemGetSimilar'); }); describe('Replace item if', () => { - it.only('Quantity is less than available', () => { + it('Quantity is less than available', () => { cy.get(':nth-child(1) > .text-right > .q-btn').click(); }); }); diff --git a/test/cypress/integration/ticket/ticketList.spec.js b/test/cypress/integration/ticket/ticketList.spec.js index 598a065a6..527d194cf 100644 --- a/test/cypress/integration/ticket/ticketList.spec.js +++ b/test/cypress/integration/ticket/ticketList.spec.js @@ -1,5 +1,5 @@ /// -describe.only('TicketList', () => { +describe('TicketList', () => { const firstRow = 'tbody.q-virtual-scroll__content tr:nth-child(1)'; beforeEach(() => { @@ -12,12 +12,10 @@ describe.only('TicketList', () => { const searchResults = (search) => { if (search) cy.typeSearchbar().type(search); cy.dataCy('vn-searchbar').find('input').type('{enter}'); - // cy.dataCy('ticketListTable').should('exist'); cy.get(firstRow).should('exist'); }; it('should search results', () => { - // cy.dataCy('ticketListTable').should('not.exist'); cy.get('.q-field__control').should('exist'); searchResults(); }); @@ -53,7 +51,7 @@ describe.only('TicketList', () => { cy.getOption().click(); cy.dataCy('Address_select').should('have.value', 'Bruce Wayne'); }); - it('Client list create new client', () => { + it('Client list create new ticket', () => { cy.dataCy('vnTableCreateBtn').should('exist'); cy.dataCy('vnTableCreateBtn').click(); const data = {