refactor: refs #8621 update RouteDescriptor and RouteList components; enhance route tests
gitea/salix-front/pipeline/pr-dev There was a failure building this commit Details

This commit is contained in:
Jose Antonio Tubau 2025-03-12 11:51:18 +01:00
commit f255963ef0
4 changed files with 56 additions and 32 deletions

View File

@ -2,11 +2,11 @@
import { ref, computed, onMounted } from 'vue'; import { ref, computed, onMounted } from 'vue';
import { useRoute } from 'vue-router'; import { useRoute } from 'vue-router';
import CardDescriptor from 'components/ui/CardDescriptor.vue'; import CardDescriptor from 'components/ui/CardDescriptor.vue';
import useCardDescription from 'composables/useCardDescription';
import VnLv from 'components/ui/VnLv.vue'; import VnLv from 'components/ui/VnLv.vue';
import { dashIfEmpty, toDate } from 'src/filters'; import { dashIfEmpty, toDate } from 'src/filters';
import RouteDescriptorMenu from 'pages/Route/Card/RouteDescriptorMenu.vue'; import RouteDescriptorMenu from 'pages/Route/Card/RouteDescriptorMenu.vue';
import filter from './RouteFilter.js'; import filter from './RouteFilter.js';
import useCardDescription from 'src/composables/useCardDescription';
import axios from 'axios'; import axios from 'axios';
const $props = defineProps({ const $props = defineProps({

View File

@ -160,7 +160,6 @@ const columns = computed(() => [
:data-key :data-key
ref="tableRef" ref="tableRef"
:columns="columns" :columns="columns"
ref="tableRef"
:right-search="false" :right-search="false"
redirect="route" redirect="route"
:create="{ :create="{
@ -180,4 +179,4 @@ const columns = computed(() => [
</VnTable> </VnTable>
</template> </template>
</VnSection> </VnSection>
</template> </template>

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 getSelector = (colField) => `tr:last-child > [data-col-field="${colField}"]`;
const selectors = { const selectors = {
@ -120,7 +120,7 @@ describe.skip('Route extended list', () => {
it('Should clone selected route', () => { it('Should clone selected route', () => {
cy.get(selectors.lastRowSelectCheckBox).click(); cy.get(selectors.lastRowSelectCheckBox).click();
cy.get(selectors.cloneBtn).click(); cy.get(selectors.cloneBtn).click();
cy.dataCy('route.Starting date_inputDate').type('10-05-2001').click(); cy.dataCy('route.Starting date_inputDate').type('10-05-2001');
cy.get('.q-card__actions > .q-btn--standard > .q-btn__content').click(); cy.get('.q-card__actions > .q-btn--standard > .q-btn__content').click();
cy.validateContent(selectors.date, '05/10/2001'); cy.validateContent(selectors.date, '05/10/2001');
}); });
@ -153,7 +153,7 @@ describe.skip('Route extended list', () => {
}); });
it('Should add ticket to route', () => { it('Should add ticket to route', () => {
cy.dataCy('tableAction-0').last().click(); cy.dataCy('tableAction-0').first().click();
cy.get(selectors.firstTicketsRowSelectCheckBox).click(); cy.get(selectors.firstTicketsRowSelectCheckBox).click();
cy.get('.q-card__actions > .q-btn--standard > .q-btn__content').click(); cy.get('.q-card__actions > .q-btn--standard > .q-btn__content').click();
cy.checkNotification(dataSaved); cy.checkNotification(dataSaved);

View File

@ -1,37 +1,62 @@
describe('Route', () => { describe('Route', () => {
const selectors = {
worker: 'tr:last-child > [data-col-field="workerFk"]',
workerLink: 'tr:last-child > [data-col-field="workerFk"] > .no-padding > .link',
rowSummaryBtn: 'tableAction-0',
};
const summaryUrl = '/summary';
beforeEach(() => { beforeEach(() => {
cy.viewport(1920, 1080); cy.viewport(1920, 1080);
cy.login('developer'); cy.login('developer');
cy.visit(`/#/route/extended-list`); cy.visit(`/#/route/list`);
cy.typeSearchbar('{enter}');
}); });
it('Route list create route', () => { it('Should list routes', () => {
cy.get('.q-table')
.children()
.should('be.visible')
.should('have.length.greaterThan', 0);
});
it('Should create new route', () => {
cy.addBtnClick(); cy.addBtnClick();
cy.get('.q-card input[name="description"]').type('routeTestOne{enter}');
cy.get('.q-notification__message').should('have.text', 'Data created'); const data = {
cy.url().should('include', '/summary'); Worker: { val: 'logistic', type: 'select' },
Agency: { val: 'Walking', type: 'select' },
Vehicle: { val: '3333-BAT', type: 'select' },
Description: { val: 'routeTest' },
};
cy.fillInForm(data);
cy.dataCy('FormModelPopup_save').should('be.visible').click();
cy.checkNotification('Data created');
cy.url().should('include', summaryUrl);
}); });
it('Route list search and edit', () => { it('Should open summary by clicking a route', () => {
cy.get('#searchbar input').type('{enter}'); cy.get(selectors.worker).should('be.visible').click();
cy.get('[data-col-field="description"][data-row-index="0"]') cy.url().should('include', summaryUrl);
.click() });
.type('routeTestOne{enter}');
cy.get('.q-table tr') it('Should open the route summary pop-up', () => {
.its('length') cy.dataCy(selectors.rowSummaryBtn).last().should('be.visible').click();
.then((rowCount) => { cy.get('.summaryHeader > :nth-child(2').should('contain', 'routeTest');
expect(rowCount).to.be.greaterThan(0); cy.validateContent(':nth-child(2) > :nth-child(3) > .value > span', '3333-BAT');
}); });
cy.get('[data-col-field="workerFk"][data-row-index="0"]')
.click() it('Should redirect to the summary from the route summary pop-up', () => {
.type('{downArrow}{enter}'); cy.dataCy(selectors.rowSummaryBtn).last().should('be.visible').click();
cy.get('[data-col-field="agencyModeFk"][data-row-index="0"]') cy.get('.header > .q-icon').should('be.visible').click();
.click() cy.url().should('include', summaryUrl);
.type('{downArrow}{enter}'); });
cy.get('[data-col-field="vehicleFk"][data-row-index="0"]')
.click() it('Should open the worker summary pop-up', () => {
.type('{downArrow}{enter}'); cy.get(selectors.workerLink).click();
cy.get('button[title="Save"]').click(); cy.get(':nth-child(1) > .value > span').should('contain', 'logistic');
cy.get('.q-notification__message').should('have.text', 'Data saved');
}); });
}); });