fix: refs #8618 update route descriptor to handle empty ticket records and adjust test cases #1478

Merged
jtubau merged 11 commits from 8619-fixRouteExtendedListTest into dev 2025-03-07 10:06:46 +00:00
2 changed files with 29 additions and 32 deletions
Showing only changes of commit 6c29a5ed67 - Show all commits

View File

@ -27,12 +27,14 @@ const getZone = async () => {
const filter = {
where: { routeFk: $props.id ? $props.id : route.params.id },
};
const { data } = await axios.get('Tickets/findOne', {
const { data: [firstRecord] = [] } = await axios.get('Tickets/filter', {
jtubau marked this conversation as resolved Outdated

Yo lo simplificaria en data
Ya si después de comprobar si existe data o no, ya desestructuras

Yo lo simplificaria en data Ya si después de comprobar si existe data o no, ya desestructuras

Ok, lo ajusto

Ok, lo ajusto
params: {
filter: JSON.stringify(filter),
},
});
zoneId.value = data.zoneFk;
if (!firstRecord) return;
jtubau marked this conversation as resolved Outdated

if (!data.length) return;

if (!data.length) return;
zoneId.value = firstRecord.zoneFk;
const { data: zoneData } = await axios.get(`Zones/${zoneId.value}`);
zone.value = zoneData.name;
};

View File

@ -1,4 +1,4 @@
describe.skip('Route extended list', () => {
describe('Route extended list', () => {
const getSelector = (colField) => `tr:last-child > [data-col-field="${colField}"]`;
const selectors = {
@ -32,18 +32,18 @@ describe.skip('Route extended list', () => {
const originalFields = [
{ selector: selectors.worker, type: 'select', value: 'logistic' },
{ selector: selectors.agency, type: 'select', value: 'Super-Man delivery' },
{ selector: selectors.agency, type: 'select', value: 'inhouse pickup' },
{ selector: selectors.vehicle, type: 'select', value: '3333-IMK' },
{ selector: selectors.date, type: 'date', value: '01/02/2024' },
{ selector: selectors.date, type: 'date', value: '01/01/2001' },
{ selector: selectors.description, type: 'input', value: 'Test route' },
{ selector: selectors.served, type: 'checkbox', value: checkboxState.uncheck },
];
const updateFields = [
{ selector: selectors.worker, type: 'select', value: 'salesperson' },
{ selector: selectors.agency, type: 'select', value: 'inhouse pickup' },
{ selector: selectors.agency, type: 'select', value: 'Super-Man delivery' },
{ selector: selectors.vehicle, type: 'select', value: '1111-IMK' },
{ selector: selectors.date, type: 'date', value: '01/01/2001' },
{ selector: selectors.date, type: 'date', value: '11/01/2001' },
{ selector: selectors.description, type: 'input', value: 'Description updated' },
{ selector: selectors.served, type: 'checkbox', value: checkboxState.check },
];
@ -57,11 +57,11 @@ describe.skip('Route extended list', () => {
break;
case 'input':
cy.get(selector).should('be.visible').click();
cy.dataCy('null_input').clear().type(`${value}{enter}`);
cy.dataCy('null_input').clear().type(`${value}`);
break;
case 'date':
cy.get(selector).should('be.visible').click();
cy.dataCy('null_inputDate').clear().type(`${value}{enter}`);
cy.dataCy('null_inputDate').clear().type(`${value}`);
break;
case 'checkbox':
cy.get(selector).should('be.visible').click().click();
@ -76,15 +76,6 @@ describe.skip('Route extended list', () => {
cy.typeSearchbar('{enter}');
});
after(() => {
cy.visit(url);
cy.typeSearchbar('{enter}');
cy.get(selectors.lastRowSelectCheckBox).click();
cy.get(selectors.removeBtn).click();
cy.dataCy(selectors.confirmBtn).click();
});
it('Should list routes', () => {
cy.get('.q-table')
.children()
@ -97,9 +88,9 @@ describe.skip('Route extended list', () => {
const data = {
Worker: { val: 'logistic', type: 'select' },
Agency: { val: 'Super-Man delivery', type: 'select' },
Agency: { val: 'inhouse pickup', type: 'select' },
Vehicle: { val: '3333-IMK', type: 'select' },
Date: { val: '02-01-2024', type: 'date' },
Date: { val: '01-01-2001', type: 'date' },
From: { val: '01-01-2024', type: 'date' },
To: { val: '10-01-2024', type: 'date' },
'Km start': { val: 1000 },
@ -129,7 +120,7 @@ describe.skip('Route extended list', () => {
it('Should clone selected route', () => {
cy.get(selectors.lastRowSelectCheckBox).click();
cy.get(selectors.cloneBtn).click();
cy.dataCy('route.Starting date_inputDate').type('10-05-2001{enter}');
cy.dataCy('route.Starting date_inputDate').type('10-05-2001').click();
cy.get('.q-card__actions > .q-btn--standard > .q-btn__content').click();
cy.validateContent(selectors.date, '05/10/2001');
});
@ -143,9 +134,9 @@ describe.skip('Route extended list', () => {
const fileName = 'download.zip';
cy.readFile(`${downloadsFolder}/${fileName}`).should('exist');
cy.task('deleteFile', `${downloadsFolder}/${fileName}`).then((deleted) => {
expect(deleted).to.be.true;
});
// cy.task('deleteFile', `${downloadsFolder}/${fileName}`).then((deleted) => {
jtubau marked this conversation as resolved Outdated

esto lo comentó Juan o tu?

esto lo comentó Juan o tu?

Esto lo comento Juan

Esto lo comento Juan

Okey, elimínalo de todas maneras porque el código ya se queda guardado en git

Okey, elimínalo de todas maneras porque el código ya se queda guardado en git

Perdón, esto lo comenté yo porque Juan comentó la task del cypress.config.js

Perdón, esto lo comenté yo porque Juan comentó la task del cypress.config.js
// expect(deleted).to.be.true;
// });
});
it('Should mark as served the selected route', () => {
@ -165,6 +156,13 @@ describe.skip('Route extended list', () => {
cy.checkNotification(dataSaved);
});
it('Should add ticket to route', () => {
cy.dataCy('tableAction-0').last().click();
cy.get(selectors.firstTicketsRowSelectCheckBox).click();
cy.get('.q-card__actions > .q-btn--standard > .q-btn__content').click();
cy.checkNotification(dataSaved);
});
it('Should save changes in route', () => {
updateFields.forEach(({ selector, type, value }) => {
fillField(selector, type, value);
@ -175,18 +173,15 @@ describe.skip('Route extended list', () => {
cy.typeSearchbar('{enter}');
updateFields.forEach(({ selector, value }) => {
updateFields.forEach(({ selector, value, type }) => {
if (type === 'date') {
const [month, day, year] = value.split('/');
value = `${day}/${month}/${year}`;
}
cy.validateContent(selector, value);
});
});
it('Should add ticket to route', () => {
cy.dataCy('tableAction-0').last().click();
cy.get(selectors.firstTicketsRowSelectCheckBox).click();
cy.get('.q-card__actions > .q-btn--standard > .q-btn__content').click();
cy.checkNotification(dataSaved);
});
it('Should open summary pop-up when click summuary icon', () => {
cy.dataCy('tableAction-1').last().click();
cy.get('.summaryHeader > :nth-child(2').should('contain', updateFields[4].value);