refactor: streamline visibility checks in monitor tests and update login role

This commit is contained in:
Javier Segarra 2025-04-09 20:57:26 +02:00
parent e7bb829bf5
commit 5f2e2421a8
3 changed files with 21 additions and 19 deletions

View File

@ -1,4 +1,5 @@
const clientFk = `[data-cy="recentOrderActions"] [data-cy="column-filter-clientFk"]`;
describe('Monitor Clients actions', () => {
beforeEach(() => {
cy.login('salesPerson');
@ -13,20 +14,22 @@ describe('Monitor Clients actions', () => {
cy.dataCy('recentOrderActions').within(() => {
cy.getRowCol('clientFk').find('span').should('have.class', 'link').click();
});
cy.dataCy('CustomerDescriptor').should('exist').and('be.visible');
cy.dataCy('vnDescriptor').should('exist').and('be.visible');
// cy.checkVisibleDescriptor('Customer');
cy.dataCy('recentOrderActions').within(() => {
cy.getRowCol('departmentFk', 2)
.find('span')
.should('have.class', 'link')
.click();
});
cy.dataCy('DepartmentDescriptor').should('exist');
cy.dataCy('vnDescriptor').should('exist').and('be.visible');
cy.checkVisibleDescriptor('Department');
cy.dataCy('clientsOnWebsite')
.find('.q-ml-md')
.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')
.find('.q-ml-md')
.should('have.text', 'Recent order actions');

View File

@ -1,7 +1,7 @@
describe('Monitor Tickets Table', () => {
beforeEach(() => {
cy.viewport(1920, 1080);
cy.login('developer');
cy.login('salesPerson');
cy.visit('/#/monitor/tickets');
cy.waitForElement('.q-page');
cy.intercept('GET', '**/SalesMonitors/salesFilter*').as('filterRequest');
@ -21,7 +21,7 @@ describe('Monitor Tickets Table', () => {
cy.intercept('GET', '**/SalesMonitors/salesFilter*').as('filterRequest');
cy.dataCy('column-filter-id').find('[data-cy="_input"]').type('13');
cy.dataCy('column-filter-id').find(' .q-icon').click();
cy.dataCy('column-filter-id').find('.q-icon').click();
cy.openRightMenu();
cy.dataCy('column-filter-clientFk').find('[data-cy="_select"]').type('1101');
cy.intercept('GET', '**/Clients*').as('filterClient');
@ -34,24 +34,24 @@ describe('Monitor Tickets Table', () => {
cy.getRowCol('totalProblems');
cy.getRowCol('id').find('span').should('have.class', 'link').click();
cy.dataCy('TicketDescriptor').should('exist');
cy.checkVisibleDescriptor('Ticket');
cy.getRowCol('zoneFk').find('span').should('have.class', 'link').click();
cy.dataCy('ZoneDescriptor').should('exist');
cy.checkVisibleDescriptor('Zone');
cy.getRowCol('clientFk').find('span').should('have.class', 'link').click();
cy.dataCy('CustomerDescriptor').should('exist');
cy.checkVisibleDescriptor('Customer');
cy.getRowCol('departmentFk').find('span').should('have.class', 'link').click();
cy.dataCy('DepartmentDescriptor').should('exist');
cy.getRowCol('shippedDate').find('.q-badge');
cy.checkVisibleDescriptor('Department');
cy.getRowCol('shippedDate').find('.q-badge');
cy.tableActions().click({ ctrlKey: true });
cy.tableActions(1).click();
cy.get('.summaryHeader').should('exist');
});
it('clear scopeDays', function () {
it('clear scopeDays', () => {
cy.get('[data-cy="Days onward_input"]').clear().type('2');
cy.searchInFilterPanel();
cy.get('.q-chip__content > span').should('have.text', '"2"');
@ -79,10 +79,3 @@ function checkScopeDays(scopeDays) {
);
});
}
function interceptSalesFilter() {
cy.intercept('GET', '**/SalesMonitors/salesFilter*').as('salesRequest');
}
function waitRequest() {
cy.wait('@salesRequest');
}

View File

@ -0,0 +1,6 @@
Cypress.Commands.add('checkVisibleDescriptor', (alias) =>
cy
.get(`[data-cy="${alias}Descriptor"] [data-cy="vnDescriptor"] > .header`)
.should('exist')
.and('be.visible'),
);