salix-front/test/cypress/integration/monitor/clientActions.spec.js

54 lines
2.2 KiB
JavaScript

const clientFk = `[data-cy="recentOrderActions"] [data-cy="column-filter-clientFk"]`;
const departmentFk = `[data-cy="recentOrderActions"] [data-cy="column-filter-departmentFk"]`;
describe('Monitor Clients actions', () => {
beforeEach(() => {
cy.login('developer');
cy.visit('/#/monitor/clients-actions');
cy.waitForElement('.q-page');
cy.intercept('GET', '**/SalesMonitors/ordersFilter*').as('ordersFilter');
cy.intercept('GET', '**/SalesMonitors/clientsFilter*').as('clientsFilter');
});
it('Should load layout', () => {
cy.get('.q-page').should('be.visible');
cy.dataCy('recentOrderActions').within(() => {
cy.getRowCol('clientFk').find('span').should('have.class', 'link').click();
});
cy.dataCy('CustomerDescriptor').should('exist');
cy.dataCy('recentOrderActions').within(() => {
cy.getRowCol('departmentFk', 2)
.find('span')
.should('have.class', 'link')
.click();
});
cy.dataCy('DepartmentDescriptor').should('exist');
cy.dataCy('clientsOnWebsite')
.find('.q-ml-md')
.should('have.text', 'Clients on website');
cy.dataCy('recentOrderActions')
.find('.q-ml-md')
.should('have.text', 'Recent order actions');
cy.dataCy('From_inputDate').should('have.value', '01/01/2001');
cy.dataCy('To_inputDate').should('have.value', '01/01/2001');
cy.get(`${clientFk} [data-cy="_select"]`).click();
cy.clickOption();
cy.countTableRows('eq', 0);
cy.get(`${clientFk} .q-field .q-field__control > :nth-child(2)`).click();
cy.get(`${departmentFk} [data-cy="_select"]`).type('VIP').trigger('enter');
cy.intercept('GET', '**/Departments*').as('filterDepartment');
cy.wait('@filterDepartment').then(() => {
cy.clickOption();
cy.countTableRows('eq', 13);
});
cy.get(`${clientFk} [data-cy="_select"]`).type('Bruce Banner');
cy.intercept('GET', '**/Clients*').as('filterClient');
cy.wait('@filterClient').then(() => {
cy.clickOption();
cy.countTableRows('eq', 3);
});
});
});