@@ -132,11 +125,3 @@ const exprBuilder = (param, value) => {
-
-
-es:
- New item type: Nueva familia
- Name: Nombre
- Search item type: Buscar familia
- Search itemType by id, name or code: Buscar familia por id, nombre o código
-
diff --git a/src/pages/Item/locale/en.yml b/src/pages/Item/locale/en.yml
index c08c71f48..99dbeb9fd 100644
--- a/src/pages/Item/locale/en.yml
+++ b/src/pages/Item/locale/en.yml
@@ -78,3 +78,6 @@ itemTags:
tag: Tag
value: Value
relevancy: Relevancy
+searchbar:
+ label: Search item
+ info: Search by item id
diff --git a/src/pages/Item/locale/es.yml b/src/pages/Item/locale/es.yml
index 9b6a51b8a..60e589932 100644
--- a/src/pages/Item/locale/es.yml
+++ b/src/pages/Item/locale/es.yml
@@ -78,3 +78,6 @@ itemTags:
tag: Etiqueta
value: Valor
relevancy: Relevancia
+searchbar:
+ label: Buscar artículo
+ info: Buscar por id de artículo
diff --git a/src/pages/ItemType/Card/ItemTypeCard.vue b/src/pages/ItemType/Card/ItemTypeCard.vue
index cb8adf7f6..9daec7921 100644
--- a/src/pages/ItemType/Card/ItemTypeCard.vue
+++ b/src/pages/ItemType/Card/ItemTypeCard.vue
@@ -1,12 +1,20 @@
+ :filter-panel="ItemTypeFilter"
+ search-data-key="ItemTypeList"
+ search-url="ItemTypes"
+ >
+
+
+
+
diff --git a/src/pages/ItemType/ItemTypeSearchbar.vue b/src/pages/ItemType/ItemTypeSearchbar.vue
new file mode 100644
index 000000000..749033d43
--- /dev/null
+++ b/src/pages/ItemType/ItemTypeSearchbar.vue
@@ -0,0 +1,19 @@
+
+
+
+
+
+
+es:
+ Search item type: Buscar familia
+ Search itemType by id, name or code: Buscar familia por id, nombre o código
+
diff --git a/src/pages/Order/Card/OrderCard.vue b/src/pages/Order/Card/OrderCard.vue
index ef7b30d86..5b6896656 100644
--- a/src/pages/Order/Card/OrderCard.vue
+++ b/src/pages/Order/Card/OrderCard.vue
@@ -1,7 +1,19 @@
-
+
+
+
+
+
diff --git a/src/pages/Order/Card/OrderSummary.vue b/src/pages/Order/Card/OrderSummary.vue
index 6e06be9bf..a674a20d0 100644
--- a/src/pages/Order/Card/OrderSummary.vue
+++ b/src/pages/Order/Card/OrderSummary.vue
@@ -7,7 +7,6 @@ import { dashIfEmpty, toCurrency, toDateHourMinSec } from 'src/filters';
import VnLv from 'components/ui/VnLv.vue';
import CardSummary from 'components/ui/CardSummary.vue';
import CustomerDescriptorProxy from 'pages/Customer/Card/CustomerDescriptorProxy.vue';
-import OrderSearchbar from 'pages/Order/Card/OrderSearchbar.vue';
import FetchedTags from 'components/ui/FetchedTags.vue';
const { t } = useI18n();
@@ -53,10 +52,6 @@ const detailsColumns = ref([
-
-
-
-
@@ -158,11 +153,7 @@ const detailsColumns = ref([
-
+
{{ t('order.summary.item') }}
diff --git a/src/pages/Order/OrderList.vue b/src/pages/Order/OrderList.vue
index 203eaccd1..6d36d8b31 100644
--- a/src/pages/Order/OrderList.vue
+++ b/src/pages/Order/OrderList.vue
@@ -61,6 +61,7 @@ function navigate(id) {
:limit="20"
:order="['landed DESC', 'clientFk', 'id DESC']"
:user-params="{ showEmpty: false }"
+ :keep-opts="['userParams']"
auto-load
>
diff --git a/src/pages/Parking/Card/ParkingBasicData.vue b/src/pages/Parking/Card/ParkingBasicData.vue
index c1a9dcee8..8e3433a5b 100644
--- a/src/pages/Parking/Card/ParkingBasicData.vue
+++ b/src/pages/Parking/Card/ParkingBasicData.vue
@@ -1,5 +1,5 @@
-
+
+
+
+
+
diff --git a/src/pages/Route/Card/RouteSearchbar.vue b/src/pages/Route/Card/RouteSearchbar.vue
index e3833d13c..924280580 100644
--- a/src/pages/Route/Card/RouteSearchbar.vue
+++ b/src/pages/Route/Card/RouteSearchbar.vue
@@ -1,6 +1,6 @@
diff --git a/src/pages/Route/Card/RouteSummary.vue b/src/pages/Route/Card/RouteSummary.vue
index 220f93f30..ac03a8231 100644
--- a/src/pages/Route/Card/RouteSummary.vue
+++ b/src/pages/Route/Card/RouteSummary.vue
@@ -10,7 +10,6 @@ import { dashIfEmpty, toCurrency, toDate, toHour } from 'src/filters';
import WorkerDescriptorProxy from 'pages/Worker/Card/WorkerDescriptorProxy.vue';
import CustomerDescriptorProxy from 'pages/Customer/Card/CustomerDescriptorProxy.vue';
import TicketDescriptorProxy from 'pages/Ticket/Card/TicketDescriptorProxy.vue';
-import RouteSearchbar from 'pages/Route/Card/RouteSearchbar.vue';
import { openBuscaman } from 'src/utils/buscaman';
const $props = defineProps({
@@ -118,11 +117,6 @@ const ticketColumns = ref([
-
-
-
-
-
import VnCard from 'components/common/VnCard.vue';
import ShelvingDescriptor from 'pages/Shelving/Card/ShelvingDescriptor.vue';
+import ShelvingFilter from './ShelvingFilter.vue';
+import ShelvingSearchbar from './ShelvingSearchbar.vue';
-
+
+
+
+
+
diff --git a/src/pages/Supplier/Card/SupplierCard.vue b/src/pages/Supplier/Card/SupplierCard.vue
index c8c503056..adf0315da 100644
--- a/src/pages/Supplier/Card/SupplierCard.vue
+++ b/src/pages/Supplier/Card/SupplierCard.vue
@@ -1,14 +1,16 @@
diff --git a/src/pages/Ticket/Card/TicketCard.vue b/src/pages/Ticket/Card/TicketCard.vue
index 471bfe490..04363b506 100644
--- a/src/pages/Ticket/Card/TicketCard.vue
+++ b/src/pages/Ticket/Card/TicketCard.vue
@@ -1,14 +1,16 @@
diff --git a/src/pages/Worker/Card/WorkerCard.vue b/src/pages/Worker/Card/WorkerCard.vue
index d76ef6f59..fb9ab9666 100644
--- a/src/pages/Worker/Card/WorkerCard.vue
+++ b/src/pages/Worker/Card/WorkerCard.vue
@@ -1,14 +1,16 @@
diff --git a/src/pages/Zone/Card/ZoneBasicData.vue b/src/pages/Zone/Card/ZoneBasicData.vue
index 5d57b920e..7a2c505fa 100644
--- a/src/pages/Zone/Card/ZoneBasicData.vue
+++ b/src/pages/Zone/Card/ZoneBasicData.vue
@@ -1,34 +1,24 @@
@@ -36,58 +26,90 @@ const agencyFilter = {
:filter="agencyFilter"
@on-fetch="(data) => (agencyOptions = data)"
auto-load
- url="agencies"
- />
- (zoneOptions = data)"
- auto-load
- url="zones"
+ url="AgencyModes/isActive"
/>
-
-
+
+
-
+
-
-
-
+
+
+
-
-
-
-
-
-
+
-
+
+
+
+
+
+
-
+
es:
Name: Nombre
diff --git a/src/pages/Zone/Card/ZoneDescriptor.vue b/src/pages/Zone/Card/ZoneDescriptor.vue
index 8f0aa9e07..b3a55bbe0 100644
--- a/src/pages/Zone/Card/ZoneDescriptor.vue
+++ b/src/pages/Zone/Card/ZoneDescriptor.vue
@@ -9,6 +9,7 @@ import { toTimeFormat } from 'src/filters/date';
import { toCurrency } from 'filters/index';
import useCardDescription from 'src/composables/useCardDescription';
+import ZoneDescriptorMenuItems from './ZoneDescriptorMenuItems.vue';
const $props = defineProps({
id: {
@@ -59,7 +60,7 @@ const setData = (entity) => {
flat
dense
size="md"
- icon="preview"
+ icon="vn:zone"
color="white"
class="link"
:to="{ name: 'ZoneList' }"
@@ -69,11 +70,10 @@ const setData = (entity) => {
-
+
- {{ console.log('entity', entity) }}
diff --git a/src/pages/Zone/Card/ZoneSummary.vue b/src/pages/Zone/Card/ZoneSummary.vue
index b39d2aaab..d46282c10 100644
--- a/src/pages/Zone/Card/ZoneSummary.vue
+++ b/src/pages/Zone/Card/ZoneSummary.vue
@@ -32,7 +32,7 @@ const filter = computed(() => {
fields: ['name'],
},
where: {
- id: route.params.id,
+ id: entityId,
},
};
return filter;
diff --git a/src/pages/Zone/ZoneCreate.vue b/src/pages/Zone/ZoneCreate.vue
index c287bce42..e25ccae3a 100644
--- a/src/pages/Zone/ZoneCreate.vue
+++ b/src/pages/Zone/ZoneCreate.vue
@@ -1,184 +1,114 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- {{ t('zone.warnings.noData') }}
-
-
-
-
-
-
-
-
-
-
-
-
+ (warehousesOptions = data)"
+ auto-load
+ />
+ (agencyOptions = data)"
+ auto-load
+ />
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
diff --git a/src/pages/Zone/locale/en.yml b/src/pages/Zone/locale/en.yml
index d0a22ebcd..746d3f2e7 100644
--- a/src/pages/Zone/locale/en.yml
+++ b/src/pages/Zone/locale/en.yml
@@ -2,6 +2,7 @@ zone:
pageTitles:
zones: Zone
zonesList: Zones
+ zoneCreate: Create zone
deliveryList: Delivery days
upcomingList: Upcoming deliveries
list:
@@ -13,18 +14,19 @@ list:
price: Price
create: Create zone
openSummary: Details
- confirmCloneTitle: All it's properties will be copied
- confirmCloneSubtitle: Do you want to clone this zone?
searchZone: Search zones
searchInfo: Search zone by id or name
+ confirmCloneTitle: All it's properties will be copied
+ confirmCloneSubtitle: Do you want to clone this zone?
create:
name: Name
+ warehouse: Warehouse
agency: Agency
- close: Close
+ travelingDays: Traveling days
+ closingHour: Closing hour
price: Price
-type:
- submit: Save
- reset: Reset
+ bonus: Bonus
+ volumetric: Volumetric
summary:
agency: Agency
price: Price
diff --git a/src/pages/Zone/locale/es.yml b/src/pages/Zone/locale/es.yml
index ad740d5f7..d9266b150 100644
--- a/src/pages/Zone/locale/es.yml
+++ b/src/pages/Zone/locale/es.yml
@@ -2,6 +2,7 @@ zone:
pageTitles:
zones: Zonas
zonesList: Zonas
+ zoneCreate: Nueva zona
deliveryList: Días de entrega
upcomingList: Próximos repartos
list:
@@ -13,18 +14,19 @@ list:
price: Precio
create: Crear zona
openSummary: Detalles
- confirmCloneTitle: Todas sus propiedades serán copiadas
- confirmCloneSubtitle: ¿Seguro que quieres clonar esta zona?
searchZone: Buscar zonas
searchInfo: Buscar zonas por identificador o nombre
+ confirmCloneTitle: Todas sus propiedades serán copiadas
+ confirmCloneSubtitle: ¿Seguro que quieres clonar esta zona?
create:
name: Nombre
+ warehouse: Almacén
agency: Agencia
- close: Cierre
+ travelingDays: Días de viaje
+ closingHour: Hora de cierre
price: Precio
-type:
- submit: Guardar
- reset: Reiniciar
+ bonus: Bonificación
+ volumetric: Volumétrico
summary:
agency: Agencia
price: Precio
@@ -38,5 +40,3 @@ summary:
filterPanel:
name: Nombre
agencyModeFk: Agencia
-Search zones: Buscar zonas
-You can search by zone reference: Puedes buscar por referencia de la zona
diff --git a/src/router/modules/zone.js b/src/router/modules/zone.js
index d39ed82d0..9c917c301 100644
--- a/src/router/modules/zone.js
+++ b/src/router/modules/zone.js
@@ -12,7 +12,7 @@ export default {
redirect: { name: 'ZoneMain' },
menus: {
main: ['ZoneList', 'ZoneDeliveryList', 'ZoneUpcomingList'],
- card: ['ZoneBasicData'],
+ card: ['ZoneBasicData', 'ZoneHistory', 'ZoneLocations'],
},
children: [
{
@@ -48,15 +48,15 @@ export default {
},
component: () => import('src/pages/Zone/ZoneCreate.vue'),
},
- {
- path: 'counter',
- name: 'ZoneCounter',
- meta: {
- title: 'zoneCounter',
- icon: 'add_circle',
- },
- component: () => import('src/pages/Zone/ZoneCounter.vue'),
- },
+ // {
+ // path: 'counter',
+ // name: 'ZoneCounter',
+ // meta: {
+ // title: 'zoneCounter',
+ // icon: 'add_circle',
+ // },
+ // component: () => import('src/pages/Zone/ZoneCounter.vue'),
+ // },
],
},
{
@@ -74,6 +74,15 @@ export default {
},
component: () => import('src/pages/Zone/Card/ZoneSummary.vue'),
},
+ {
+ name: 'ZoneLocations',
+ path: 'location',
+ meta: {
+ title: 'locations',
+ icon: 'vn:greuge',
+ },
+ component: () => import('src/pages/Zone/Card/ZoneLocations.vue'),
+ },
{
name: 'ZoneBasicData',
path: 'basic-data',
@@ -83,6 +92,16 @@ export default {
},
component: () => import('src/pages/Zone/Card/ZoneBasicData.vue'),
},
+ {
+ name: 'ZoneHistory',
+ path: 'history',
+ meta: {
+ title: 'log',
+ icon: 'history',
+ },
+ component: () => import('src/pages/Zone/Card/ZoneLog.vue'),
+ },
+
// {
// path: '/zone/delivery',
// name: 'ZoneDeliveryMain',
diff --git a/test/cypress/integration/VnLocation.spec.js b/test/cypress/integration/VnLocation.spec.js
index f373bad8a..d1cddd0e7 100644
--- a/test/cypress/integration/VnLocation.spec.js
+++ b/test/cypress/integration/VnLocation.spec.js
@@ -1,13 +1,13 @@
const locationOptions = '[role="listbox"] > div.q-virtual-scroll__content > .q-item';
describe('VnLocation', () => {
const dialogInputs = '.q-dialog label input';
- describe('Create', () => {
+ describe('Worker Create', () => {
const inputLocation =
- '.q-form .q-card> :nth-child(3) > :nth-child(1) > .q-field > .q-field__inner > .q-field__control';
+ '.q-form .q-card > :nth-child(3) > .q-field > .q-field__inner > .q-field__control > .q-field__control-container';
beforeEach(() => {
cy.viewport(1280, 720);
cy.login('developer');
- cy.visit('/#/worker/create');
+ cy.visit('/#/worker/create', { timeout: 5000 });
cy.waitForElement('.q-card');
});
it('Show all options', function () {
@@ -25,34 +25,35 @@ describe('VnLocation', () => {
cy.get(inputLocation).clear();
cy.get(inputLocation).type('ecuador');
cy.get(locationOptions).should('have.length.at.least', 1);
- cy.get(`${locationOptions}:nth-child(1)`).click();
- cy.get(inputLocation + '> :nth-child(2) > .q-icon').click();
+ cy.get(
+ '.q-form .q-card > :nth-child(3) > .q-field > .q-field__inner > .q-field__control > :nth-child(3) > .q-icon'
+ ).click();
});
});
describe('Fiscal-data', () => {
beforeEach(() => {
cy.viewport(1280, 720);
cy.login('developer');
- cy.visit('/#/supplier/567/fiscal-data', { timeout: 2000 });
- cy.waitForElement('.q-card');
+ cy.visit('/#/supplier/567/fiscal-data', { timeout: 7000 });
+ cy.waitForElement('.q-form');
});
it('Create postCode', function () {
cy.get(
- ':nth-child(6) > :nth-child(1) > .q-field > .q-field__inner > .q-field__control > :nth-child(3) > .q-icon'
+ ':nth-child(6) > .q-field > .q-field__inner > .q-field__control > :nth-child(3) > .q-icon'
).click();
cy.get('.q-card > h1').should('have.text', 'New postcode');
cy.get(dialogInputs).eq(0).clear('12');
cy.get(dialogInputs).eq(0).type('1234453');
cy.selectOption(
- '.q-dialog__inner > .column > #formModel > .q-card > :nth-child(4) > :nth-child(2) > .q-field > .q-field__inner > .q-field__control ',
+ '.q-dialog__inner > .column > #formModel > .q-card > :nth-child(4) > .q-select > .q-field__inner > .q-field__control ',
'Valencia'
);
cy.selectOption(
- '.q-dialog__inner > .column > #formModel > .q-card > :nth-child(5) > :nth-child(1) > .q-field > .q-field__inner > .q-field__control ',
+ '.q-dialog__inner > .column > #formModel > .q-card > :nth-child(5) > .q-select > .q-field__inner > .q-field__control ',
'Province one'
);
cy.selectOption(
- '.q-dialog__inner > .column > #formModel > .q-card > :nth-child(5) > :nth-child(2) > .q-field > .q-field__inner > .q-field__control ',
+ '.q-dialog__inner > .column > #formModel > .q-card > :nth-child(6) > .q-select > .q-field__inner > .q-field__control ',
'España'
);
cy.get('.q-mt-lg > .q-btn--standard').click();
diff --git a/test/cypress/integration/invoiceIn/invoiceInBasicData.spec.js b/test/cypress/integration/invoiceIn/invoiceInBasicData.spec.js
index fc989d6c5..963dda3e2 100644
--- a/test/cypress/integration/invoiceIn/invoiceInBasicData.spec.js
+++ b/test/cypress/integration/invoiceIn/invoiceInBasicData.spec.js
@@ -1,7 +1,8 @@
///
describe('InvoiceInBasicData', () => {
- const selects = '.q-form .q-card>:nth-child(1) > :nth-child(1) > .q-field';
- const appendBtns = 'label button';
+ const formInputs = '.q-form > .q-card input';
+ const firstFormSelect = '.q-card > .vn-row:nth-child(1) > .q-select';
+ const appendBtns = '.q-form label button';
const dialogAppendBtns = '.q-dialog label button';
const dialogInputs = '.q-dialog input';
const dialogActionBtns = '.q-card__actions button';
@@ -12,15 +13,14 @@ describe('InvoiceInBasicData', () => {
});
it('should edit the provideer and supplier ref', () => {
- cy.selectOption(selects, 'Bros');
-
+ cy.selectOption(firstFormSelect, 'Bros');
cy.get('[title="Reset"]').click();
cy.get(appendBtns).eq(0).click();
- cy.get('input').eq(2).type(4739);
+ cy.get(formInputs).eq(1).type(4739);
cy.saveCard();
- cy.get(`${selects} input`).eq(0).invoke('val').should('eq', 'Plants nick');
- cy.get('input').eq(2).invoke('val').should('eq', '4739');
+ cy.get(`${firstFormSelect} input`).invoke('val').should('eq', 'Plants nick');
+ cy.get(formInputs).eq(1).invoke('val').should('eq', '4739');
});
it('should edit the dms data', () => {
diff --git a/test/cypress/integration/invoiceIn/invoiceInDueDay.spec.js b/test/cypress/integration/invoiceIn/invoiceInDueDay.spec.js
index f39c80809..124b60c34 100644
--- a/test/cypress/integration/invoiceIn/invoiceInDueDay.spec.js
+++ b/test/cypress/integration/invoiceIn/invoiceInDueDay.spec.js
@@ -1,6 +1,6 @@
///
describe('InvoiceInDueDay', () => {
- const inputs = 'label input';
+ const amountInput = 'tbody > tr:nth-child(1) td:nth-child(4)';
const addBtn = '.q-page-sticky > div > .q-btn > .q-btn__content';
beforeEach(() => {
@@ -9,7 +9,7 @@ describe('InvoiceInDueDay', () => {
});
it('should update the amount', () => {
- cy.get(inputs).eq(3).type(23);
+ cy.get(amountInput).type('{selectall}{backspace}23');
cy.saveCard();
cy.get('.q-notification__message').should('have.text', 'Data saved');
});
diff --git a/test/cypress/integration/invoiceIn/invoiceInIntrastat.spec.js b/test/cypress/integration/invoiceIn/invoiceInIntrastat.spec.js
index 306c0b8c0..c87fd4315 100644
--- a/test/cypress/integration/invoiceIn/invoiceInIntrastat.spec.js
+++ b/test/cypress/integration/invoiceIn/invoiceInIntrastat.spec.js
@@ -17,10 +17,7 @@ describe('InvoiceInIntrastat', () => {
cy.saveCard();
cy.visit(`/#/invoice-in/1/intrastat`);
- cy.getValue(firstLineCode).should(
- 'equal',
- 'Plantas vivas: Esqueje/injerto, Vid'
- );
+ cy.getValue(firstLineCode).should('equal', 'Plantas vivas: Esqueje/injerto, Vid');
});
it('should add a new row', () => {
@@ -33,6 +30,6 @@ describe('InvoiceInIntrastat', () => {
});
it('should remove the first line', () => {
- cy.removeRow(1);
+ cy.removeRow(2);
});
});
diff --git a/test/cypress/integration/invoiceIn/invoiceInVat.spec.js b/test/cypress/integration/invoiceIn/invoiceInVat.spec.js
index ff891399b..389be671c 100644
--- a/test/cypress/integration/invoiceIn/invoiceInVat.spec.js
+++ b/test/cypress/integration/invoiceIn/invoiceInVat.spec.js
@@ -29,7 +29,7 @@ describe('InvoiceInVat', () => {
});
it('should remove the first line', () => {
- cy.removeRow(1);
+ cy.removeRow(2);
});
it('should throw an error if there are fields undefined', () => {
diff --git a/test/cypress/integration/ticket/ticketDescriptor.spec.js b/test/cypress/integration/ticket/ticketDescriptor.spec.js
index 22401f0b4..fc920f346 100644
--- a/test/cypress/integration/ticket/ticketDescriptor.spec.js
+++ b/test/cypress/integration/ticket/ticketDescriptor.spec.js
@@ -1,6 +1,6 @@
///
describe('Ticket descriptor', () => {
- const toCloneOpt = '.q-list > :nth-child(5)';
+ const toCloneOpt = '[role="menu"] .q-list > :nth-child(5)';
const warehouseValue = ':nth-child(1) > :nth-child(6) > .value > span';
const summaryHeader = '.summaryHeader > div';
diff --git a/test/cypress/integration/worker/workerLocker.spec.js b/test/cypress/integration/worker/workerLocker.spec.js
index 8c1886438..01e74760b 100644
--- a/test/cypress/integration/worker/workerLocker.spec.js
+++ b/test/cypress/integration/worker/workerLocker.spec.js
@@ -1,6 +1,6 @@
describe('WorkerList', () => {
- const workerId = 1110;
- const lockerCode = '200A';
+ const workerId = 1109;
+ const lockerCode = '201A';
const input = '.q-card input';
const firstOpt = '[role="listbox"] .q-item:nth-child(1)';
beforeEach(() => {
diff --git a/test/vitest/__tests__/components/common/VnSearchBar.spec.js b/test/vitest/__tests__/components/common/VnSearchBar.spec.js
deleted file mode 100644
index 0938ae9c0..000000000
--- a/test/vitest/__tests__/components/common/VnSearchBar.spec.js
+++ /dev/null
@@ -1,62 +0,0 @@
-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, {
- propsData: {
- dataKey: 'CustomerList',
- label: 'Search customer',
- info: 'Info customer',
- },
- });
- vm = wrapper.vm;
- vm.router.currentRoute.value.matched = [
- {
- path: '/',
- },
- {
- path: '/customer',
- },
- {
- path: '/customer/:id',
- },
- {
- path: '/customer/:id/basic-data',
- },
- ];
-
- pushSpy = vi.spyOn(vm.router, 'push');
- vi.spyOn(vm.arrayData, 'applyFilter');
- });
-
- 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 to list page if there are several results', async () => {
- vm.store.data.push({ id: 1, name: 'employee' });
- await vm.search();
- 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(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' });
- });
-});
diff --git a/test/vitest/__tests__/composables/useRedirect.spec.js b/test/vitest/__tests__/composables/useRedirect.spec.js
new file mode 100644
index 000000000..ce56189b9
--- /dev/null
+++ b/test/vitest/__tests__/composables/useRedirect.spec.js
@@ -0,0 +1,52 @@
+import { vi, describe, expect, it, beforeEach, beforeAll } from 'vitest';
+import useRedirect from 'src/composables/useRedirect';
+import { useRouter } from 'vue-router';
+
+vi.mock('vue-router');
+
+describe('useRedirect', () => {
+ useRouter.mockReturnValue({
+ push: vi.fn(),
+ currentRoute: {
+ value: {
+ matched: [
+ { path: '/' },
+ { path: '/customer' },
+ { path: '/customer/:id' },
+ { path: '/customer/:id/basic-data' },
+ ],
+ },
+ },
+ });
+ const data = [];
+ let navigate;
+ let spy;
+
+ beforeAll(() => {
+ const { navigate: navigateFn } = useRedirect();
+ navigate = navigateFn;
+ spy = useRouter().push;
+ });
+
+ beforeEach(() => {
+ data.length = 0;
+ spy.mockReset();
+ });
+
+ it('should redirect to list page if there are several results', async () => {
+ data.push({ id: 1, name: 'employee' }, { id: 2, name: 'boss' });
+ navigate(data, {});
+ expect(spy).toHaveBeenCalledWith({ path: '/customer/' });
+ });
+
+ it('should redirect to list page if there is no results', async () => {
+ navigate(data, {});
+ expect(spy).toHaveBeenCalledWith({ path: '/customer/' });
+ });
+
+ it('should redirect to basic-data page if there is only one result', async () => {
+ data.push({ id: 1, name: 'employee' });
+ navigate(data, {});
+ expect(spy).toHaveBeenCalledWith({ path: '/customer/1/basic-data' });
+ });
+});