97 lines
3.6 KiB
JavaScript
97 lines
3.6 KiB
JavaScript
/// <reference types="cypress" />
|
|
describe('TicketList', () => {
|
|
const firstRow = 'tbody.q-virtual-scroll__content tr:nth-child(1)';
|
|
|
|
beforeEach(() => {
|
|
cy.login('developer');
|
|
cy.viewport(1920, 1080);
|
|
cy.visit('/#/ticket/list');
|
|
cy.domContentLoad();
|
|
});
|
|
|
|
const searchResults = (search) => {
|
|
if (search) cy.typeSearchbar().type(search);
|
|
cy.dataCy('vn-searchbar').find('input').type('{enter}');
|
|
// cy.dataCy('ticketListTable').should('exist');
|
|
cy.get(firstRow).should('exist');
|
|
};
|
|
|
|
it('should search results', () => {
|
|
// cy.dataCy('ticketListTable').should('not.exist');
|
|
cy.get('.q-field__control').should('exist');
|
|
searchResults();
|
|
});
|
|
|
|
it('should open ticket sales', () => {
|
|
searchResults();
|
|
cy.window().then((win) => {
|
|
cy.stub(win, 'open').as('windowOpen');
|
|
});
|
|
cy.get(firstRow).should('be.visible').find('.q-btn:first').click();
|
|
cy.get('@windowOpen').should('be.calledWithMatch', /\/ticket\/\d+\/sale/);
|
|
});
|
|
|
|
it('should open ticket summary', () => {
|
|
searchResults();
|
|
cy.get(firstRow).find('.q-btn:last').click();
|
|
cy.get('.summaryHeader').should('exist');
|
|
cy.get('.summaryBody').should('exist');
|
|
});
|
|
|
|
it('filter client and create ticket', () => {
|
|
cy.intercept('GET', /\/api\/Tickets\/filter/).as('ticketSearchbar');
|
|
searchResults();
|
|
|
|
cy.intercept('GET', /\/api\/Tickets\/filter/).as('ticketFilter');
|
|
cy.dataCy('Customer ID_input').clear('1');
|
|
cy.dataCy('Customer ID_input').type('1101{enter}');
|
|
|
|
cy.get('[data-cy="vnTableCreateBtn"] > .q-btn__content > .q-icon').click();
|
|
cy.dataCy('Customer_select').should('have.value', 'Bruce Wayne');
|
|
cy.dataCy('Address_select').click();
|
|
|
|
cy.getOption().click();
|
|
cy.dataCy('Address_select').should('have.value', 'Bruce Wayne');
|
|
});
|
|
it('Client list create new client', () => {
|
|
cy.dataCy('vnTableCreateBtn').should('exist');
|
|
cy.dataCy('vnTableCreateBtn').click();
|
|
const data = {
|
|
Customer: { val: 1, type: 'select' },
|
|
Warehouse: { val: 'Warehouse One', type: 'select' },
|
|
Address: { val: 'employee', type: 'select' },
|
|
Landed: { val: '01-01-2024', type: 'date' },
|
|
Agency: { val: 'Other agency', type: 'select' },
|
|
};
|
|
cy.fillInForm(data);
|
|
cy.dataCy('FormModelPopup_save').click();
|
|
cy.checkNotification('Data created');
|
|
cy.url().should('match', /\/ticket\/\d+\/summary/);
|
|
});
|
|
|
|
it('should show the corerct problems', () => {
|
|
cy.intercept('GET', '**/api/Tickets/filter*', (req) => {
|
|
req.headers['cache-control'] = 'no-cache';
|
|
req.headers['pragma'] = 'no-cache';
|
|
req.headers['expires'] = '0';
|
|
|
|
req.on('response', (res) => {
|
|
delete res.headers['if-none-match'];
|
|
delete res.headers['if-modified-since'];
|
|
});
|
|
}).as('ticket');
|
|
|
|
cy.get('[data-cy="Warehouse_select"]').type('Warehouse Five');
|
|
cy.get('.q-menu .q-item').contains('Warehouse Five').click();
|
|
cy.wait('@ticket').then((interception) => {
|
|
const data = interception.response.body[1];
|
|
expect(data.hasComponentLack).to.equal(1);
|
|
expect(data.isTooLittle).to.equal(1);
|
|
expect(data.hasItemShortage).to.equal(1);
|
|
});
|
|
cy.get('.icon-components').should('exist');
|
|
cy.get('.icon-unavailable').should('exist');
|
|
cy.get('.icon-isTooLittle').should('exist');
|
|
});
|
|
});
|