70 lines
2.6 KiB
JavaScript
70 lines
2.6 KiB
JavaScript
/// <reference types="cypress" />
|
|
describe('Monitor Tickets Table', () => {
|
|
beforeEach(() => {
|
|
cy.viewport(1920, 1080);
|
|
cy.login('salesPerson');
|
|
cy.visit('/#/monitor/tickets');
|
|
cy.waitForElement('.q-page');
|
|
cy.intercept('GET', '**/SalesMonitors/salesFilter*').as('filterRequest');
|
|
cy.openRightMenu();
|
|
});
|
|
it('should open new tab when ctrl+click on client link', () => {
|
|
cy.intercept('GET', '**/SalesMonitors/salesFilter*').as('filterRequest');
|
|
|
|
cy.window().then((win) => {
|
|
cy.stub(win, 'open').as('windowOpen');
|
|
});
|
|
|
|
cy.getRowCol('provinceFk').click({ ctrlKey: true });
|
|
cy.get('@windowOpen').should('be.calledWithMatch', /\/ticket\/\d+\/sale/);
|
|
});
|
|
it('should open the descriptorProxy and SummaryPopup', () => {
|
|
cy.getRowCol('totalProblems');
|
|
|
|
cy.getRowCol('id').find('span').should('have.class', 'link').click();
|
|
cy.checkVisibleDescriptor('Ticket');
|
|
|
|
cy.getRowCol('zoneFk').find('span').should('have.class', 'link').click();
|
|
cy.checkVisibleDescriptor('Zone');
|
|
|
|
cy.getRowCol('clientFk').find('span').should('have.class', 'link').click();
|
|
cy.checkVisibleDescriptor('Customer');
|
|
|
|
cy.getRowCol('departmentFk').find('span').should('have.class', 'link').click();
|
|
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', () => {
|
|
cy.get('[data-cy="Days onward_input"]').clear().type('2');
|
|
cy.searchInFilterPanel();
|
|
cy.get('.q-chip__content > span').should('have.text', '"2"');
|
|
cy.waitSpinner();
|
|
checkScopeDays(2);
|
|
cy.get('[data-cy="Days onward_input"]').clear();
|
|
cy.searchInFilterPanel();
|
|
cy.get('.q-chip__content > span').should('have.text', '"0"');
|
|
cy.waitSpinner();
|
|
checkScopeDays(0);
|
|
});
|
|
});
|
|
|
|
function checkScopeDays(scopeDays) {
|
|
cy.url().then((url) => {
|
|
const urlParams = new URLSearchParams(url.split('?')[1]);
|
|
const saleMonitorTickets = JSON.parse(
|
|
decodeURIComponent(urlParams.get('saleMonitorTickets')),
|
|
);
|
|
expect(saleMonitorTickets.scopeDays).to.equal(scopeDays);
|
|
const fromDate = new Date(saleMonitorTickets.from);
|
|
const toDate = new Date(saleMonitorTickets.to);
|
|
expect(toDate.getDate() - fromDate.getDate()).to.equal(
|
|
saleMonitorTickets.scopeDays,
|
|
);
|
|
});
|
|
}
|