+
2) {
if (title != '') title += ': ';
- const pageTitle = t(`${moduleName}.pageTitles.${childPageTitle}`);
+ const moduleLocale = `${moduleName}.pageTitles.${childPageTitle}`;
+ const pageTitle = te(moduleLocale)
+ ? t(moduleLocale)
+ : t(`globals.pageTitles.${childPageTitle}`);
const idParam = to.params && to.params.id;
const idPageTitle = `${idParam} - ${pageTitle}`;
const builtTitle = idParam ? idPageTitle : pageTitle;
diff --git a/src/router/modules/index.js b/src/router/modules/index.js
index 076605f24..302ba7fe0 100644
--- a/src/router/modules/index.js
+++ b/src/router/modules/index.js
@@ -13,7 +13,8 @@ import Travel from './travel';
import Order from './order';
import Department from './department';
import Entry from './entry';
-import roadmap from "./roadmap";
+import roadmap from './roadmap';
+import Parking from './parking';
export default [
Item,
@@ -31,5 +32,6 @@ export default [
invoiceIn,
Department,
Entry,
- roadmap
+ roadmap,
+ Parking,
];
diff --git a/src/router/modules/parking.js b/src/router/modules/parking.js
new file mode 100644
index 000000000..51ea200c6
--- /dev/null
+++ b/src/router/modules/parking.js
@@ -0,0 +1,54 @@
+import { RouterView } from 'vue-router';
+
+export default {
+ path: '/parking',
+ name: 'Parking',
+ meta: {
+ title: 'parking',
+ icon: 'garage_home',
+ moduleName: 'Parking',
+ },
+ component: RouterView,
+ redirect: { name: 'ParkingCard' },
+ menus: {
+ main: [],
+ card: ['ParkingBasicData', 'ParkingLog'],
+ },
+ children: [
+ {
+ path: '/parking/:id',
+ name: 'ParkingCard',
+ component: () => import('src/pages/Parking/Card/ParkingCard.vue'),
+ redirect: { name: 'ParkingSummary' },
+ children: [
+ {
+ name: 'ParkingSummary',
+ path: 'summary',
+ meta: {
+ title: 'summary',
+ icon: 'view_list',
+ },
+ component: () => import('src/pages/Parking/Card/ParkingSummary.vue'),
+ },
+ {
+ name: 'ParkingBasicData',
+ path: 'basic-data',
+ meta: {
+ title: 'basicData',
+ icon: 'vn:settings',
+ },
+ component: () => import('pages/Parking/Card/ParkingBasicData.vue'),
+ },
+ {
+ name: 'ParkingLog',
+ path: 'log',
+ meta: {
+ title: 'log',
+ icon: 'history',
+ },
+ component: () => import('src/pages/Parking/Card/ParkingLog.vue'),
+ },
+ ],
+ },
+ ],
+};
diff --git a/src/router/modules/shelving.js b/src/router/modules/shelving.js
index d32c7d9f3..b881ca020 100644
--- a/src/router/modules/shelving.js
+++ b/src/router/modules/shelving.js
@@ -11,7 +11,7 @@ export default {
component: RouterView,
redirect: { name: 'ShelvingMain' },
menus: {
- main: ['ShelvingList'],
+ main: ['ShelvingList', 'ParkingList'],
card: ['ShelvingBasicData', 'ShelvingLog'],
},
children: [
@@ -38,6 +38,21 @@ export default {
},
component: () => import('src/pages/Shelving/Card/ShelvingForm.vue'),
},
+ {
+ path: '/parking',
+ redirect: { name: 'ParkingList' },
+ children: [
+ {
+ path: 'list',
+ name: 'ParkingList',
+ meta: {
+ title: 'parkingList',
+ icon: 'view_list',
+ },
+ component: () => import('src/pages/Parking/ParkingList.vue'),
+ },
+ ],
+ },
],
},
{
diff --git a/src/router/modules/worker.js b/src/router/modules/worker.js
index 8d7891b40..b3166587e 100644
--- a/src/router/modules/worker.js
+++ b/src/router/modules/worker.js
@@ -12,7 +12,12 @@ export default {
redirect: { name: 'WorkerMain' },
menus: {
main: ['WorkerList', 'WorkerDepartment'],
- card: ['WorkerNotificationsManager', 'WorkerPda', 'WorkerTimeControl'],
+ card: [
+ 'WorkerNotificationsManager',
+ 'WorkerPda',
+ 'WorkerTimeControl',
+ 'WorkerLog',
+ ],
departmentCard: ['BasicData'],
},
children: [
@@ -95,6 +100,15 @@ export default {
component: () =>
import('src/pages/Worker/Card/WorkerTimeControl.vue'),
},
+ {
+ name: 'WorkerLog',
+ path: 'log',
+ meta: {
+ title: 'log',
+ icon: 'vn:History',
+ },
+ component: () => import('src/pages/Worker/Card/WorkerLog.vue'),
+ },
],
},
],
diff --git a/src/router/routes.js b/src/router/routes.js
index 32f43965f..51e726a62 100644
--- a/src/router/routes.js
+++ b/src/router/routes.js
@@ -13,7 +13,8 @@ import department from './modules/department';
import shelving from 'src/router/modules/shelving';
import order from 'src/router/modules/order';
import entry from 'src/router/modules/entry';
-import roadmap from "src/router/modules/roadmap";
+import roadmap from 'src/router/modules/roadmap';
+import parking from 'src/router/modules/parking';
const routes = [
{
@@ -69,6 +70,7 @@ const routes = [
department,
roadmap,
entry,
+ parking,
{
path: '/:catchAll(.*)*',
name: 'NotFound',
diff --git a/test/cypress/integration/parking/parkingBasicData.spec.js b/test/cypress/integration/parking/parkingBasicData.spec.js
new file mode 100644
index 000000000..b5633992c
--- /dev/null
+++ b/test/cypress/integration/parking/parkingBasicData.spec.js
@@ -0,0 +1,23 @@
+///
+describe('ParkingBasicData', () => {
+ const codeInput = 'form .q-card .q-input input';
+ const sectorSelect = 'form .q-card .q-select input';
+ const sectorOpt = '.q-menu .q-item';
+ beforeEach(() => {
+ cy.login('developer');
+ cy.visit(`/#/parking/1/basic-data`);
+ });
+
+ it('should edit the code and sector', () => {
+ cy.get(sectorSelect).type('Second');
+ cy.get(sectorOpt).click();
+
+ cy.get(codeInput).eq(0).clear();
+ cy.get(codeInput).eq(0).type(123);
+
+ cy.saveCard();
+
+ cy.get(sectorSelect).should('have.value', 'Second sector');
+ cy.get(codeInput).should('have.value', 123);
+ });
+});
diff --git a/test/cypress/integration/parking/parkingList.spec.js b/test/cypress/integration/parking/parkingList.spec.js
new file mode 100644
index 000000000..3ac46f8cd
--- /dev/null
+++ b/test/cypress/integration/parking/parkingList.spec.js
@@ -0,0 +1,30 @@
+///
+describe('ParkingList', () => {
+ const firstCard = '.q-card:nth-child(1)';
+ const firstChipId =
+ ':nth-child(1) > :nth-child(1) > .justify-between > .flex > .q-chip > .q-chip__content';
+ const firstDetailBtn =
+ ':nth-child(1) > :nth-child(1) > .card-list-body > .actions > .q-btn';
+ const summaryHeader = '.summaryBody .header';
+
+ beforeEach(() => {
+ cy.login('developer');
+ cy.visit(`/#/parking/list`);
+ cy.closeSideMenu();
+ });
+
+ it('should redirect on clicking a parking', () => {
+ cy.get(firstChipId)
+ .invoke('text')
+ .then((content) => {
+ const id = content.substring(4);
+ cy.get(firstCard).click();
+ cy.url().should('include', `/parking/${id}/summary`);
+ });
+ });
+
+ it('should open the details', () => {
+ cy.get(firstDetailBtn).click();
+ cy.get(summaryHeader).contains('Basic data');
+ });
+});
diff --git a/test/cypress/integration/ticket/ticketDescriptor.spec.js b/test/cypress/integration/ticket/ticketDescriptor.spec.js
new file mode 100644
index 000000000..c212d3b4a
--- /dev/null
+++ b/test/cypress/integration/ticket/ticketDescriptor.spec.js
@@ -0,0 +1,27 @@
+///
+describe('Ticket descriptor', () => {
+ const toCloneOpt = '.q-list > :nth-child(5)';
+ const warehouseValue = '.summaryBody > :nth-child(2) > :nth-child(6) > .value > span';
+ const summaryHeader = '.summaryHeader > div';
+
+ beforeEach(() => {
+ const ticketId = 1;
+
+ cy.login('developer');
+ cy.visit(`/#/ticket/${ticketId}/summary`);
+ });
+
+ it('should clone the ticket without warehouse', () => {
+ cy.openLeftMenu();
+ cy.openActionsDescriptor();
+ cy.get(toCloneOpt).click();
+ cy.clickConfirm();
+ cy.get(warehouseValue).contains('-');
+ cy.get(summaryHeader)
+ .invoke('text')
+ .then((text) => {
+ const [, owner] = text.split('-');
+ cy.wrap(owner.trim()).should('eq', 'Bruce Wayne (1101)');
+ });
+ });
+});
diff --git a/test/cypress/integration/vnSearchBar.spec.js b/test/cypress/integration/vnSearchBar.spec.js
index d6dea0780..3db789773 100644
--- a/test/cypress/integration/vnSearchBar.spec.js
+++ b/test/cypress/integration/vnSearchBar.spec.js
@@ -1,19 +1,42 @@
///
describe('VnSearchBar', () => {
+ const employeeId = ' #1';
+ const salesPersonId = ' #18';
+ const idGap = '.q-item > .q-item__label';
+ const cardList = '.vn-card-list';
+
+ let url;
beforeEach(() => {
cy.login('developer');
- cy.visit('/');
+ cy.visit('#/customer/list');
+ cy.url().then((currentUrl) => (url = currentUrl));
});
- it('should redirect to new customer', () => {
- cy.visit('#/customer/1112/basic-data')
- cy.openLeftMenu();
- cy.get('.q-item > .q-item__label').should('have.text',' #1112')
- cy.closeLeftMenu();
- cy.clearSearchbar();
- cy.writeSearchbar('1{enter}');
- cy.openLeftMenu();
- cy.get('.q-item > .q-item__label').should('have.text',' #1')
- cy.closeLeftMenu();
+ it('should redirect to customer summary page', () => {
+ searchAndCheck('1', employeeId);
+ searchAndCheck('salesPerson', salesPersonId);
+ });
+
+ it('should stay on the list page if there are several results or none', () => {
+ cy.writeSearchbar('salesA{enter}');
+ checkCardListAndUrl(2);
+
+ cy.clearSearchbar();
+
+ cy.writeSearchbar('0{enter}');
+ checkCardListAndUrl(0);
+ });
+
+ const searchAndCheck = (searchTerm, expectedText) => {
+ cy.clearSearchbar();
+ cy.writeSearchbar(`${searchTerm}{enter}`);
+ cy.get(idGap).should('have.text', expectedText);
+ };
+
+ const checkCardListAndUrl = (expectedLength) => {
+ cy.get(cardList).then(($cardList) => {
+ expect($cardList.find('.q-card').length).to.equal(expectedLength);
+ cy.url().then((currentUrl) => expect(currentUrl).to.equal(url));
});
+ };
});
diff --git a/test/cypress/support/commands.js b/test/cypress/support/commands.js
index f075d500f..544e7e6b5 100755
--- a/test/cypress/support/commands.js
+++ b/test/cypress/support/commands.js
@@ -52,16 +52,18 @@ Cypress.Commands.add('getValue', (selector) => {
}
// Si es un QSelect
if ($el.find('.q-select__dropdown-icon').length) {
- return cy.get(
- selector +
- '> .q-field > .q-field__inner > .q-field__control > .q-field__control-container > .q-field__native > input'
- ).invoke('val')
+ return cy
+ .get(
+ selector +
+ '> .q-field > .q-field__inner > .q-field__control > .q-field__control-container > .q-field__native > input'
+ )
+ .invoke('val');
}
// Si es un QSelect
if ($el.find('span').length) {
- return cy.get(
- selector + ' span'
- ).then(($span) => { return $span[0].innerText })
+ return cy.get(selector + ' span').then(($span) => {
+ return $span[0].innerText;
+ });
}
// Puedes añadir un log o lanzar un error si el elemento no es reconocido
cy.log('Elemento no soportado');
@@ -132,13 +134,13 @@ Cypress.Commands.add('validateRow', (rowSelector, expectedValues) => {
cy.get(rowSelector).within(() => {
for (const [index, value] of expectedValues.entries()) {
cy.log('CHECKING ', index, value);
- if(value === undefined) continue
+ if (value === undefined) continue;
if (typeof value == 'boolean') {
const prefix = value ? '' : 'not.';
cy.getValue(`:nth-child(${index + 1})`).should(`${prefix}be.checked`);
continue;
}
- cy.getValue(`:nth-child(${index + 1})`).should('equal', value)
+ cy.getValue(`:nth-child(${index + 1})`).should('equal', value);
}
});
});
@@ -174,9 +176,9 @@ Cypress.Commands.add('openLeftMenu', (element) => {
if (element) cy.waitForElement(element);
cy.get('.q-toolbar > .q-btn--round.q-btn--dense > .q-btn__content > .q-icon').click();
});
-Cypress.Commands.add('closeLeftMenu', (element) => {
+Cypress.Commands.add('closeSideMenu', (element) => {
if (element) cy.waitForElement(element);
- cy.get('.fullscreen').click();
+ cy.get('.fullscreen.q-drawer__backdrop:not(.hidden)').click();
});
Cypress.Commands.add('clearSearchbar', (element) => {
diff --git a/test/vitest/__tests__/components/common/VnSearchBar.spec.js b/test/vitest/__tests__/components/common/VnSearchBar.spec.js
index fd0a026ef..0938ae9c0 100644
--- a/test/vitest/__tests__/components/common/VnSearchBar.spec.js
+++ b/test/vitest/__tests__/components/common/VnSearchBar.spec.js
@@ -1,11 +1,11 @@
-import { vi, describe, expect, it, beforeAll, beforeEach, afterEach } from 'vitest';
-import { createWrapper, axios } from 'app/test/vitest/helper';
+import { vi, describe, expect, it, beforeAll, afterEach, beforeEach } from 'vitest';
+import { createWrapper } from 'app/test/vitest/helper';
import VnSearchbar from 'components/ui/VnSearchbar.vue';
-
-
+// Probar a importar como plugin vue-router en archivo helper
describe('VnSearchBar', () => {
let vm;
let wrapper;
+ let pushSpy;
beforeAll(() => {
wrapper = createWrapper(VnSearchbar, {
@@ -16,7 +16,7 @@ describe('VnSearchBar', () => {
},
});
vm = wrapper.vm;
- vm.route.matched = [
+ vm.router.currentRoute.value.matched = [
{
path: '/',
},
@@ -30,24 +30,33 @@ describe('VnSearchBar', () => {
path: '/customer/:id/basic-data',
},
];
+
+ pushSpy = vi.spyOn(vm.router, 'push');
+ vi.spyOn(vm.arrayData, 'applyFilter');
});
- afterEach(() => {
- vi.clearAllMocks();
- });
+ beforeEach(() => (vm.store.data = [{ id: 1112, name: 'Trash' }]));
+ afterEach(() => vi.clearAllMocks());
+
it('should be defined', async () => {
expect(vm.searchText).toBeDefined();
expect(vm.searchText).toEqual('');
});
- it('should redirect', async () => {
- vi.spyOn(vm.router,'push');
- vm.searchText = '1';
+
+ it('should redirect to list page if there are several results', async () => {
+ vm.store.data.push({ id: 1, name: 'employee' });
await vm.search();
- expect(vm.router.push).toHaveBeenCalledWith('/customer/1/basic-data');
- vm.searchText = '1112';
- expect(vm.searchText).toEqual('1112');
- vi.spyOn(vm.router,'push');
+ expect(pushSpy).toHaveBeenCalledWith({ path: '/customer/list' });
+ });
+
+ it('should redirect to list page if there is no results', async () => {
+ vm.store.data.pop();
await vm.search();
- expect(vm.router.push).toHaveBeenCalledWith('/customer/1112/basic-data');
- });
+ expect(pushSpy).toHaveBeenCalledWith({ path: '/customer/list' });
+ });
+
+ it('should redirect to basic-data page if there is only one result', async () => {
+ await vm.search();
+ expect(pushSpy).toHaveBeenCalledWith({ path: '/customer/1112/basic-data' });
+ });
});