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 { useRoute } from 'vue-router';
import CardDescriptor from 'components/ui/CardDescriptor.vue';
import useCardDescription from 'composables/useCardDescription';
import VnLv from 'components/ui/VnLv.vue';
import { dashIfEmpty, toDate } from 'src/filters';
import RouteDescriptorMenu from 'pages/Route/Card/RouteDescriptorMenu.vue';
import filter from './RouteFilter.js';
import useCardDescription from 'src/composables/useCardDescription';
import axios from 'axios';
const $props = defineProps({

View File

@ -160,7 +160,6 @@ const columns = computed(() => [
:data-key
ref="tableRef"
:columns="columns"
ref="tableRef"
:right-search="false"
redirect="route"
:create="{
@ -180,4 +179,4 @@ const columns = computed(() => [
</VnTable>
</template>
</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 selectors = {
@ -120,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').click();
cy.dataCy('route.Starting date_inputDate').type('10-05-2001');
cy.get('.q-card__actions > .q-btn--standard > .q-btn__content').click();
cy.validateContent(selectors.date, '05/10/2001');
});
@ -153,7 +153,7 @@ describe.skip('Route extended list', () => {
});
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('.q-card__actions > .q-btn--standard > .q-btn__content').click();
cy.checkNotification(dataSaved);

View File

@ -1,37 +1,62 @@
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(() => {
cy.viewport(1920, 1080);
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.get('.q-card input[name="description"]').type('routeTestOne{enter}');
cy.get('.q-notification__message').should('have.text', 'Data created');
cy.url().should('include', '/summary');
const data = {
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', () => {
cy.get('#searchbar input').type('{enter}');
cy.get('[data-col-field="description"][data-row-index="0"]')
.click()
.type('routeTestOne{enter}');
cy.get('.q-table tr')
.its('length')
.then((rowCount) => {
expect(rowCount).to.be.greaterThan(0);
});
cy.get('[data-col-field="workerFk"][data-row-index="0"]')
.click()
.type('{downArrow}{enter}');
cy.get('[data-col-field="agencyModeFk"][data-row-index="0"]')
.click()
.type('{downArrow}{enter}');
cy.get('[data-col-field="vehicleFk"][data-row-index="0"]')
.click()
.type('{downArrow}{enter}');
cy.get('button[title="Save"]').click();
cy.get('.q-notification__message').should('have.text', 'Data saved');
it('Should open summary by clicking a route', () => {
cy.get(selectors.worker).should('be.visible').click();
cy.url().should('include', summaryUrl);
});
it('Should open the route summary pop-up', () => {
cy.dataCy(selectors.rowSummaryBtn).last().should('be.visible').click();
cy.get('.summaryHeader > :nth-child(2').should('contain', 'routeTest');
cy.validateContent(':nth-child(2) > :nth-child(3) > .value > span', '3333-BAT');
});
it('Should redirect to the summary from the route summary pop-up', () => {
cy.dataCy(selectors.rowSummaryBtn).last().should('be.visible').click();
cy.get('.header > .q-icon').should('be.visible').click();
cy.url().should('include', summaryUrl);
});
it('Should open the worker summary pop-up', () => {
cy.get(selectors.workerLink).click();
cy.get(':nth-child(1) > .value > span').should('contain', 'logistic');
});
});