test: enhance monitor client actions and ticket tests with Cypress intercepts

This commit is contained in:
Javier Segarra 2025-04-09 22:38:30 +02:00
parent 5f2e2421a8
commit 80fb1eaf6a
2 changed files with 15 additions and 6 deletions

View File

@ -1,20 +1,30 @@
const clientFk = `[data-cy="recentOrderActions"] [data-cy="column-filter-clientFk"]`; /// <reference types="cypress" />
describe('Monitor Clients actions', () => { describe('Monitor Clients actions', () => {
beforeEach(() => { beforeEach(() => {
cy.login('salesPerson'); cy.login('salesPerson');
cy.intercept('GET', '**/Departments**').as('departments');
cy.visit('/#/monitor/clients-actions'); cy.visit('/#/monitor/clients-actions');
cy.waitForElement('.q-page'); cy.waitForElement('.q-page');
cy.wait('@departments').then((xhr) => {
cy.window().then((win) => {
const user = JSON.parse(win.sessionStorage.getItem('user'));
const { where } = JSON.parse(xhr.request.query.filter);
expect(where.id.like).to.include(user.departmentFk.toString());
});
});
cy.intercept('GET', '**/SalesMonitors/ordersFilter*').as('ordersFilter'); cy.intercept('GET', '**/SalesMonitors/ordersFilter*').as('ordersFilter');
cy.intercept('GET', '**/SalesMonitors/clientsFilter*').as('clientsFilter'); cy.intercept('GET', '**/SalesMonitors/clientsFilter*').as('clientsFilter');
}); });
it('Should filter by field', () => { it('Should filter by field', () => {
cy.get('.q-page').should('be.visible'); cy.get('.q-page').should('be.visible');
cy.dataCy('clientsOnWebsite')
.find('[data-cy="column-filter-departmentFk"] [data-cy="_select"]')
.click();
cy.dataCy('recentOrderActions').within(() => { cy.dataCy('recentOrderActions').within(() => {
cy.getRowCol('clientFk').find('span').should('have.class', 'link').click(); cy.getRowCol('clientFk').find('span').should('have.class', 'link').click();
}); });
// cy.checkVisibleDescriptor('Customer'); cy.checkVisibleDescriptor('Customer');
cy.dataCy('recentOrderActions').within(() => { cy.dataCy('recentOrderActions').within(() => {
cy.getRowCol('departmentFk', 2) cy.getRowCol('departmentFk', 2)
@ -22,14 +32,12 @@ describe('Monitor Clients actions', () => {
.should('have.class', 'link') .should('have.class', 'link')
.click(); .click();
}); });
cy.checkVisibleDescriptor('Department'); cy.checkVisibleDescriptor('Department');
cy.dataCy('clientsOnWebsite') cy.dataCy('clientsOnWebsite')
.find('.q-ml-md') .find('.q-ml-md')
.should('have.text', 'Clients on website'); .should('have.text', 'Clients on website');
cy.dataCy('clientsOnWebsite')
.find('[data-cy="column-filter-departmentFk"] [data-cy="_select"]')
.should('have.value', 'EQUIPO ESPAÑA VIP');
cy.dataCy('recentOrderActions') cy.dataCy('recentOrderActions')
.find('.q-ml-md') .find('.q-ml-md')
.should('have.text', 'Recent order actions'); .should('have.text', 'Recent order actions');

View File

@ -1,3 +1,4 @@
/// <reference types="cypress" />
describe('Monitor Tickets Table', () => { describe('Monitor Tickets Table', () => {
beforeEach(() => { beforeEach(() => {
cy.viewport(1920, 1080); cy.viewport(1920, 1080);