199 lines
7.5 KiB
JavaScript
199 lines
7.5 KiB
JavaScript
describe('Route extended list', () => {
|
|
const worker = 'tr:last-child > [data-col-field="workerFk"]';
|
|
const agency = 'tr:last-child > [data-col-field="agencyModeFk"]';
|
|
const vehicle = 'tr:last-child > [data-col-field="vehicleFk"]';
|
|
const date = 'tr:last-child > [data-col-field="dated"]';
|
|
const description = 'tr:last-child > [data-col-field="description"]';
|
|
const served = 'tr:last-child > [data-col-field="isOk"]';
|
|
|
|
beforeEach(() => {
|
|
cy.viewport(1920, 1080);
|
|
cy.login('developer');
|
|
cy.visit('/#/route/extended-list');
|
|
cy.typeSearchbar('{enter}');
|
|
});
|
|
|
|
after(() => {
|
|
cy.visit('/#/route/extended-list');
|
|
cy.typeSearchbar('{enter}');
|
|
cy.get(
|
|
'tbody > tr:last-child > :nth-child(1) > .q-checkbox > .q-checkbox__inner',
|
|
).click();
|
|
|
|
cy.get('[title="Remove"]').click();
|
|
cy.dataCy('VnConfirm_confirm').click();
|
|
});
|
|
|
|
it('Should list routes', () => {
|
|
cy.get('.q-table')
|
|
.children()
|
|
.should('be.visible')
|
|
.should('have.length.greaterThan', 0);
|
|
});
|
|
|
|
it('Should create new route', () => {
|
|
cy.addBtnClick();
|
|
|
|
const data = {
|
|
Worker: { val: 'logistic', type: 'select' },
|
|
Agency: { val: 'Super-Man delivery', type: 'select' },
|
|
Vehicle: { val: '3333-IMK', type: 'select' },
|
|
Date: { val: '02-01-2024', type: 'date' },
|
|
From: { val: '01-01-2024', type: 'date' },
|
|
To: { val: '10-01-2024', type: 'date' },
|
|
'Km start': { val: 1000 },
|
|
'Km end': { val: 1200 },
|
|
Description: { val: 'Test route' },
|
|
};
|
|
|
|
cy.fillInForm(data);
|
|
|
|
cy.dataCy('FormModelPopup_save').click();
|
|
cy.checkNotification('Data created');
|
|
cy.url().should('include', '/summary');
|
|
});
|
|
|
|
it('Should reset changed values when click reset button', () => {
|
|
cy.get(worker).should('be.visible').click();
|
|
cy.dataCy('null_select').clear().type('salesperson');
|
|
cy.get('.q-item').contains('salesperson').click();
|
|
|
|
cy.get(agency).should('be.visible').click();
|
|
cy.dataCy('null_select').clear().type('inhouse pickup');
|
|
cy.get('.q-item').contains('inhouse pickup').click();
|
|
|
|
cy.get(vehicle).should('be.visible').click();
|
|
cy.dataCy('null_select').clear().type('1111-IMK');
|
|
cy.get('.q-item').contains('1111-IMK').click();
|
|
|
|
cy.get(date).should('be.visible').click();
|
|
cy.dataCy('null_inputDate').clear().type('01-01-2001{enter}');
|
|
|
|
cy.get(description).should('be.visible').click();
|
|
cy.dataCy('null_input').clear().type('DescriptionUpdated{enter}');
|
|
|
|
cy.get(served).should('be.visible').click().click();
|
|
|
|
cy.get('[title="Reset"]').click();
|
|
|
|
cy.validateContent(worker, 'logistic');
|
|
cy.validateContent(agency, 'Super-Man delivery');
|
|
cy.validateContent(vehicle, '3333-IMK');
|
|
cy.validateContent(date, '01/02/2024');
|
|
cy.validateContent(description, 'Test route');
|
|
cy.validateContent(served, 'close');
|
|
});
|
|
|
|
it('Should clone selected route', () => {
|
|
cy.get(
|
|
'tbody > tr:last-child > :nth-child(1) > .q-checkbox > .q-checkbox__inner',
|
|
).click();
|
|
cy.get(
|
|
'#st-actions > .q-btn-group > :nth-child(1) > .q-btn__content > .q-icon',
|
|
).click();
|
|
cy.dataCy('route.Starting date_inputDate').type('10-05-2001{enter}');
|
|
cy.get('.q-card__actions > .q-btn--standard > .q-btn__content').click();
|
|
cy.validateContent('tr:last-child > [data-col-field="dated"]', '05/10/2001');
|
|
});
|
|
|
|
it('Should download selected route', () => {
|
|
const downloadsFolder = Cypress.config('downloadsFolder');
|
|
cy.get(
|
|
'tbody > tr:last-child > :nth-child(1) > .q-checkbox > .q-checkbox__inner',
|
|
).click();
|
|
cy.get(
|
|
'#st-actions > .q-btn-group > :nth-child(2) > .q-btn__content > .q-icon',
|
|
).click();
|
|
cy.wait(5000); //necesario para dar tiempo a que descargue el documento
|
|
|
|
const fileName = 'download.zip';
|
|
cy.readFile(`${downloadsFolder}/${fileName}`).should('exist');
|
|
|
|
cy.task('deleteFile', `${downloadsFolder}/${fileName}`).then((deleted) => {
|
|
expect(deleted).to.be.true;
|
|
});
|
|
});
|
|
|
|
it('Should mark as served the selected route', () => {
|
|
cy.get(
|
|
'tbody > tr:last-child > :nth-child(1) > .q-checkbox > .q-checkbox__inner',
|
|
).click();
|
|
cy.get(
|
|
'#st-actions > .q-btn-group > :nth-child(3) > .q-btn__content > .q-icon',
|
|
).click();
|
|
|
|
cy.typeSearchbar('{enter}');
|
|
cy.validateContent('tr:last-child > [data-col-field="isOk"]', 'check');
|
|
});
|
|
|
|
it('Should delete the selected route', () => {
|
|
cy.get(
|
|
'tbody > tr:last-child > :nth-child(1) > .q-checkbox > .q-checkbox__inner',
|
|
).click();
|
|
|
|
cy.get('[title="Remove"]').click();
|
|
cy.dataCy('VnConfirm_confirm').click();
|
|
|
|
cy.checkNotification('Data saved');
|
|
});
|
|
|
|
it('Should save changes in route', () => {
|
|
cy.get(worker).should('be.visible').click();
|
|
cy.dataCy('null_select').clear().type('salesperson');
|
|
cy.get('.q-item').contains('salesperson').click();
|
|
|
|
cy.get(agency).should('be.visible').click();
|
|
cy.dataCy('null_select').clear().type('inhouse pickup');
|
|
cy.get('.q-item').contains('inhouse pickup').click();
|
|
|
|
cy.get(vehicle).should('be.visible').click();
|
|
cy.dataCy('null_select').clear().type('1111-IMK');
|
|
cy.get('.q-item').contains('1111-IMK').click();
|
|
|
|
cy.get(date).should('be.visible').click();
|
|
cy.dataCy('null_inputDate').clear().type('01-01-2001{enter}');
|
|
|
|
cy.get(description).should('be.visible').click();
|
|
cy.dataCy('null_input').clear().type('DescriptionUpdated{enter}');
|
|
|
|
cy.get(served).should('be.visible').click().click();
|
|
|
|
cy.dataCy('crudModelDefaultSaveBtn').should('not.be.disabled').click();
|
|
cy.checkNotification('Data saved');
|
|
|
|
cy.typeSearchbar('{enter}');
|
|
|
|
cy.validateContent(worker, 'salesperson');
|
|
cy.validateContent(agency, 'inhouse pickup');
|
|
cy.validateContent(vehicle, '1111-IMK');
|
|
cy.validateContent(date, '01/01/2001');
|
|
cy.validateContent(description, 'DescriptionUpdated');
|
|
cy.validateContent(served, 'check');
|
|
});
|
|
|
|
it('Should add ticket to route', () => {
|
|
cy.dataCy('tableAction-0').last().click();
|
|
cy.get(
|
|
'.q-card > :nth-child(2) > .q-table__container > .q-table__middle > .q-table > tbody > :nth-child(1) > .q-table--col-auto-width > .q-checkbox > .q-checkbox__inner > .q-checkbox__bg > .q-checkbox__svg',
|
|
).click();
|
|
cy.get('.q-card__actions > .q-btn--standard > .q-btn__content').click();
|
|
cy.get('.q-notification__message').should('have.text', 'Data saved');
|
|
});
|
|
|
|
it('Should open summary pop-up when click summuary icon', () => {
|
|
cy.dataCy('tableAction-1').last().click();
|
|
cy.get('.summaryHeader > :nth-child(2').should('contain', '- DescriptionUpdated');
|
|
});
|
|
|
|
it('Should redirect to the summary from the route summary pop-up', () => {
|
|
cy.dataCy('tableAction-1').last().click();
|
|
cy.get('.header > .q-icon').should('be.visible').click();
|
|
cy.url().should('include', '/summary');
|
|
});
|
|
|
|
it('Should redirect to the summary when click go to summary icon', () => {
|
|
cy.dataCy('tableAction-2').last().click();
|
|
cy.url().should('include', '/summary');
|
|
});
|
|
});
|