diff --git a/src/pages/Ticket/TicketList.vue b/src/pages/Ticket/TicketList.vue index d8eb91fc9..ed2aad37c 100644 --- a/src/pages/Ticket/TicketList.vue +++ b/src/pages/Ticket/TicketList.vue @@ -432,7 +432,7 @@ watch( (newValue) => { if (newValue) { const clientId = +JSON.parse(newValue)?.clientFk; - if (!clientFk) return; + if (!clientId) return; formInitialData.value = { clientId, }; diff --git a/test/cypress/integration/ticket/ticketList.spec.js b/test/cypress/integration/ticket/ticketList.spec.js index 2984a4ee4..8c03462da 100644 --- a/test/cypress/integration/ticket/ticketList.spec.js +++ b/test/cypress/integration/ticket/ticketList.spec.js @@ -1,16 +1,16 @@ /// describe('TicketList', () => { - const firstRow = 'tbody > :nth-child(1)'; + const firstRow = 'tbody.q-virtual-scroll__content tr:nth-child(1)'; beforeEach(() => { cy.login('developer'); cy.viewport(1920, 1080); cy.visit('/#/ticket/list'); + cy.domContentLoad(); }); const searchResults = (search) => { - cy.dataCy('vn-searchbar').find('input').focus(); - if (search) cy.dataCy('vn-searchbar').find('input').type(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'); @@ -27,7 +27,7 @@ describe('TicketList', () => { cy.window().then((win) => { cy.stub(win, 'open').as('windowOpen'); }); - cy.get(firstRow).find('.q-btn:first').click(); + cy.get(firstRow).should('be.visible').find('.q-btn:first').click(); cy.get('@windowOpen').should('be.calledWithMatch', /\/ticket\/\d+\/sale/); }); @@ -38,6 +38,36 @@ describe('TicketList', () => { cy.get('.summaryBody').should('exist'); }); + it.only('Filter client and create ticket', () => { + cy.intercept('GET', /\/api\/Tickets\/filter/).as('ticketSearchbar'); + searchResults(); + cy.wait('@ticketSearchbar').then((interception) => { + const { query } = interception.request; + cy.log('Request query:', query); + expect(query).to.have.property('from'); + expect(query).to.have.property('to'); + expect(query).to.not.have.property('clientFk'); + }); + cy.intercept('GET', /\/api\/Tickets\/filter/).as('ticketFilter'); + cy.get('[data-cy="Customer ID_input"]').clear('1'); + cy.get('[data-cy="Customer ID_input"]').type('1101{enter}'); + cy.wait('@ticketFilter').then((interception) => { + const { query } = interception.request; + cy.log('Request query:', query); + expect(query).to.not.have.property('from'); + expect(query).to.not.have.property('to'); + expect(query).to.have.property('clientFk'); + }); + cy.get('[data-cy="vnTableCreateBtn"] > .q-btn__content > .q-icon').click(); + cy.get('[data-cy="Customer_select"]').should('have.value', 'Bruce Wayne'); + cy.get('[data-cy="Address_select"]').click(); + + cy.selectOptionBeta().click(); + cy.get('[data-cy="Address_select"]').should('have.value', 'Bruce Wayne'); + // cy.get('[role="listbox"] .q-item:nth-child(1)>.q-item__section--avatar > i') + // .should('have.text', 'star') + // .click(); + }); it('Client list create new client', () => { cy.dataCy('vnTableCreateBtn').should('exist'); cy.dataCy('vnTableCreateBtn').click(); diff --git a/test/cypress/support/commands.js b/test/cypress/support/commands.js index 2c93fbf84..c4e2c29ca 100755 --- a/test/cypress/support/commands.js +++ b/test/cypress/support/commands.js @@ -365,3 +365,6 @@ Cypress.Commands.add('clickButtonWithIcon', (iconClass) => { Cypress.Commands.add('clickButtonWithText', (buttonText) => { cy.get('.q-btn').contains(buttonText).click(); }); +Cypress.Commands.add('selectOptionBeta', (index = 1) => { + cy.get(`[role="listbox"] .q-item:nth-child(${index})`).click(); +});