test: add test
gitea/salix-front/pipeline/pr-test There was a failure building this commit Details

This commit is contained in:
Javier Segarra 2025-02-16 00:46:20 +01:00
parent 70fe95661a
commit b998aab6dd
3 changed files with 38 additions and 5 deletions

View File

@ -432,7 +432,7 @@ watch(
(newValue) => {
if (newValue) {
const clientId = +JSON.parse(newValue)?.clientFk;
if (!clientFk) return;
if (!clientId) return;
formInitialData.value = {
clientId,
};

View File

@ -1,16 +1,16 @@
/// <reference types="cypress" />
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();

View File

@ -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();
});