salix-front/test/cypress/integration/ticket/negative/TicketLackDetail.spec.js

174 lines
7.2 KiB
JavaScript

/// <reference types="cypress" />
const firstRow = 'tr.cursor-pointer > :nth-child(1)';
const ticketId = 1000000;
const findTr = (index) => `tbody > tr > :nth-child(${index}) > div`;
const clickNotificationAction = () => {
const notification = '.q-notification';
cy.waitForElement(notification);
cy.get(notification).should('be.visible');
cy.get(notification).find('.q-btn').click();
cy.get(notification).should('not.be.visible');
};
describe('Ticket Lack detail', () => {
beforeEach(() => {
cy.viewport(1280, 720);
cy.login('developer');
cy.intercept('GET', /\/api\/Tickets\/itemLack\/88.*$/).as('getItemLack');
cy.visit('/#/ticket/negative/88');
cy.wait('@getItemLack').then((interception) => {
const { query } = interception.request;
const filter = JSON.parse(query.filter);
expect(filter).to.have.property('where');
expect(filter.where).to.have.property('alertLevelCode', 'FREE');
});
cy.domContentLoad();
cy.waitForElement('.q-table');
});
describe('Table detail', () => {
it('should open descriptors', () => {
cy.get('.q-table').should('be.visible');
cy.colField('zoneName').click();
cy.dataCy('zoneDescriptorProxy').should('be.visible');
cy.get('.q-item > .q-item__label').should('have.text', ' #1');
cy.colField('ticketFk').click();
cy.dataCy('ticketDescriptorProxy').should('be.visible');
cy.get('.q-item > .q-item__label').should('have.text', ` #${ticketId}`);
cy.colField('nickname').find('.link').click();
cy.waitForElement('[data-cy="customerDescriptorProxy"]');
cy.dataCy('customerDescriptorProxy').should('be.visible');
cy.get('.q-item > .q-item__label').should('have.text', ' #1');
});
it('should display only one row in the lack list', () => {
cy.dataCy('changeItem').should('be.disabled');
cy.dataCy('changeState').should('be.disabled');
cy.dataCy('changeQuantity').should('be.disabled');
cy.dataCy('itemProposal').should('be.disabled');
cy.dataCy('transferLines').should('be.disabled');
cy.get('tr.cursor-pointer > :nth-child(1)').click();
cy.dataCy('changeItem').should('be.enabled');
cy.dataCy('changeState').should('be.enabled');
cy.dataCy('changeQuantity').should('be.enabled');
cy.dataCy('itemProposal').should('be.enabled');
cy.dataCy('transferLines').should('be.enabled');
});
});
describe('Split', () => {
beforeEach(() => {
cy.get(firstRow).click();
cy.dataCy('transferLines').click();
});
it('Split', () => {
cy.dataCy('ticketTransferPopup').find('.flex > .q-btn').click();
clickNotificationAction();
cy.dataCy('HandleLackDialog').should('be.visible');
cy.dataCy('HandleLackDialog').find('tbody > tr > :nth-child(1) > .q-icon');
cy.dataCy('HandleLackDialog').find(findTr(2)).should('have.class', 'link');
cy.dataCy('HandleLackDialog')
.find(`${findTr(2)}.link > div > span`)
.should('have.text', `${ticketId} `);
cy.dataCy('HandleLackDialog').find(findTr(3)).should('have.text', 'noSplit');
});
});
describe('Change Item', () => {
beforeEach(() => {
cy.get(firstRow).click();
cy.dataCy('changeItem').click();
});
it('Change failed', () => {
cy.dataCy('New item_select').should('be.visible').click();
cy.get('.q-item').contains('Palito rojo').click();
cy.get('.q-btn--unelevated > .q-btn__content > .block').click();
clickNotificationAction();
cy.dataCy('HandleLackDialog').should('be.visible');
cy.dataCy('HandleLackDialog').find('tbody > tr > :nth-child(1) > .q-icon');
cy.dataCy('HandleLackDialog').find(findTr(2)).should('have.class', 'link');
cy.dataCy('HandleLackDialog')
.find(`${findTr(2)}.link > span`)
.should('have.text', `${ticketId}`);
cy.dataCy('HandleLackDialog')
.find(findTr(3))
.should('have.text', 'price retrieval failed');
});
});
describe('Change state', () => {
beforeEach(() => {
cy.get(firstRow).click();
cy.dataCy('changeState').click();
});
it('Change success', () => {
cy.dataCy('New state_select').should('be.visible').click();
cy.get('.q-item').contains('OK').click();
cy.get('.q-btn--unelevated > .q-btn__content > .block').click();
clickNotificationAction();
cy.dataCy('HandleLackDialog')
.should('be.visible')
.find('tbody > tr > :nth-child(1) > .q-icon');
cy.dataCy('HandleLackDialog').find(findTr(2)).should('have.class', 'link');
cy.dataCy('HandleLackDialog')
.find(`${findTr(2)}.link > div > span`)
.should('have.text', `${ticketId} `);
cy.dataCy('HandleLackDialog').find(findTr(3)).should('have.text', 'OK');
});
});
describe('change quantity', () => {
beforeEach(() => {
cy.get(firstRow).click();
cy.dataCy('changeQuantity').click();
});
it('Change success', () => {
cy.dataCy('New quantity_input').type(10);
cy.get('.q-btn--unelevated > .q-btn__content > .block').click();
clickNotificationAction();
cy.dataCy('HandleLackDialog')
.should('be.visible')
.find('tbody > tr > :nth-child(1) > .q-icon');
cy.dataCy('HandleLackDialog').find(findTr(2)).should('have.class', 'link');
cy.dataCy('HandleLackDialog')
.find(`${findTr(2)}.link > div > span`)
.should('have.text', `${ticketId} `);
cy.dataCy('HandleLackDialog').find(findTr(3)).should('have.text', '10');
});
});
describe('Item proposal', () => {
beforeEach(() => {
cy.get(firstRow).click();
cy.dataCy('itemProposal').click();
});
describe('Replace item if', () => {
it.skip('Quantity is less than available', () => {
cy.get(':nth-child(1) > .text-right > .q-btn').click();
});
it('item proposal cells', () => {
cy.get('[data-col-field="longName"] .link').first().click();
cy.dataCy('itemDescriptorProxy').should('be.visible');
cy.colField('longName', 2)
.find('.no-padding > .q-td > .middle')
.should('have.class', 'proposal-primary');
cy.colField('tag5', 2)
.find('.no-padding > .match')
.should('have.class', 'match');
cy.colField('tag6', 2)
.find('.no-padding > .match')
.should('have.class', 'match');
cy.colField('tag7', 2).click();
});
});
});
});