diff --git a/src/pages/Zone/ZoneList.vue b/src/pages/Zone/ZoneList.vue
index 0272292f6..d160ea6b5 100644
--- a/src/pages/Zone/ZoneList.vue
+++ b/src/pages/Zone/ZoneList.vue
@@ -1,74 +1,120 @@
@@ -91,82 +138,72 @@ onMounted(() => (stateStore.rightDrawer = true));
-
+
-
-
-
-
-
-
-
-
-
- {{ t(col.label) }}
- {{
- col.tooltip
- }}
-
-
-
-
-
-
-
- {{ props.value }}
-
-
-
-
-
-
- {{ t('globals.clone') }}
-
-
- {{ t('Preview') }}
-
-
-
-
-
-
-
-
-
-
- {{ t('list.create') }}
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+es:
+ Search zone: Buscar zona
+ You can search zones by id or name: Puedes buscar zonas por id o nombre
+
diff --git a/src/pages/Zone/locale/en.yml b/src/pages/Zone/locale/en.yml
index 31eeb2b7f..2608c071c 100644
--- a/src/pages/Zone/locale/en.yml
+++ b/src/pages/Zone/locale/en.yml
@@ -18,9 +18,16 @@ list:
create: Create zone
openSummary: Details
searchZone: Search zones
+ searchLocation: Search locations
searchInfo: Search zone by id or name
confirmCloneTitle: All it's properties will be copied
confirmCloneSubtitle: Do you want to clone this zone?
+ travelingDays: Traveling days
+ warehouse: Warehouse
+ bonus: Bonus
+ isVolumetric: Volumetric
+ createZone: Create zone
+ zoneSummary: Summary
create:
name: Name
warehouse: Warehouse
@@ -30,6 +37,8 @@ create:
price: Price
bonus: Bonus
volumetric: Volumetric
+ itemMaxSize: Max m³
+ inflation: Inflation
summary:
agency: Agency
price: Price
diff --git a/src/pages/Zone/locale/es.yml b/src/pages/Zone/locale/es.yml
index c670c2c08..dd919a0c5 100644
--- a/src/pages/Zone/locale/es.yml
+++ b/src/pages/Zone/locale/es.yml
@@ -18,9 +18,16 @@ list:
create: Crear zona
openSummary: Detalles
searchZone: Buscar zonas
+ searchLocation: Buscar localizaciones
searchInfo: Buscar zonas por identificador o nombre
confirmCloneTitle: Todas sus propiedades serán copiadas
confirmCloneSubtitle: ¿Seguro que quieres clonar esta zona?
+ travelingDays: Días de viaje
+ warehouse: Almacén
+ bonus: Bonus
+ isVolumetric: Volumétrico
+ createZone: Crear zona
+ zoneSummary: Resumen
create:
name: Nombre
warehouse: Almacén
@@ -30,6 +37,8 @@ create:
price: Precio
bonus: Bonificación
volumetric: Volumétrico
+ itemMaxSize: Medida máxima
+ inflation: Inflación
summary:
agency: Agencia
price: Precio
diff --git a/src/router/index.js b/src/router/index.js
index 686da2dde..18541c0b2 100644
--- a/src/router/index.js
+++ b/src/router/index.js
@@ -60,15 +60,12 @@ export default route(function (/* { store, ssrContext } */) {
await useTokenConfig().fetch();
}
const matches = to.matched;
- const hasRequiredRoles = matches.every((route) => {
+ const hasRequiredAcls = matches.every((route) => {
const meta = route.meta;
- if (meta && meta.roles) return useRole().hasAny(meta.roles);
- return true;
+ if (!meta?.acls) return true;
+ return useAcl().hasAny(meta.acls);
});
-
- if (!hasRequiredRoles) {
- return next({ path: '/' });
- }
+ if (!hasRequiredAcls) return next({ path: '/' });
}
next();
diff --git a/src/router/modules/Supplier.js b/src/router/modules/Supplier.js
index b711066b2..143d7c824 100644
--- a/src/router/modules/Supplier.js
+++ b/src/router/modules/Supplier.js
@@ -7,6 +7,7 @@ export default {
title: 'suppliers',
icon: 'vn:supplier',
moduleName: 'Supplier',
+ keyBinding: 'p',
},
component: RouterView,
redirect: { name: 'SupplierMain' },
diff --git a/src/router/modules/account.js b/src/router/modules/account.js
index cfec2b95d..7200131da 100644
--- a/src/router/modules/account.js
+++ b/src/router/modules/account.js
@@ -7,6 +7,7 @@ export default {
title: 'users',
icon: 'face',
moduleName: 'Account',
+ keyBinding: 'u',
},
component: RouterView,
redirect: { name: 'AccountMain' },
@@ -79,7 +80,7 @@ export default {
meta: {
title: 'accounts',
icon: 'accessibility',
- roles: ['itManagement'],
+ acls: [{ model: 'Account', props: '*', accessType: '*' }],
},
component: () => import('src/pages/Account/AccountAccounts.vue'),
},
@@ -89,7 +90,7 @@ export default {
meta: {
title: 'ldap',
icon: 'account_tree',
- roles: ['itManagement'],
+ acls: [{ model: 'LdapConfig', props: '*', accessType: '*' }],
},
component: () => import('src/pages/Account/AccountLdap.vue'),
},
@@ -99,7 +100,7 @@ export default {
meta: {
title: 'samba',
icon: 'preview',
- roles: ['itManagement'],
+ acls: [{ model: 'SambaConfig', props: '*', accessType: '*' }],
},
component: () => import('src/pages/Account/AccountSamba.vue'),
},
diff --git a/src/router/modules/claim.js b/src/router/modules/claim.js
index cced9e24d..b58a58e8d 100644
--- a/src/router/modules/claim.js
+++ b/src/router/modules/claim.js
@@ -7,6 +7,7 @@ export default {
title: 'claims',
icon: 'vn:claims',
moduleName: 'Claim',
+ keyBinding: 'r',
},
component: RouterView,
redirect: { name: 'ClaimMain' },
@@ -61,7 +62,7 @@ export default {
meta: {
title: 'basicData',
icon: 'vn:settings',
- roles: ['salesPerson'],
+ acls: [{ model: 'Claim', props: 'findById', accessType: 'READ' }],
},
component: () => import('src/pages/Claim/Card/ClaimBasicData.vue'),
},
@@ -98,7 +99,13 @@ export default {
meta: {
title: 'development',
icon: 'vn:traceability',
- roles: ['claimManager'],
+ acls: [
+ {
+ model: 'ClaimDevelopment',
+ props: '*',
+ accessType: 'WRITE',
+ },
+ ],
},
component: () => import('src/pages/Claim/Card/ClaimDevelopment.vue'),
},
diff --git a/src/router/modules/customer.js b/src/router/modules/customer.js
index 684b83b0f..5b73ddc84 100644
--- a/src/router/modules/customer.js
+++ b/src/router/modules/customer.js
@@ -7,6 +7,7 @@ export default {
title: 'customers',
icon: 'vn:client',
moduleName: 'Customer',
+ keyBinding: 'c',
},
component: RouterView,
redirect: { name: 'CustomerMain' },
diff --git a/src/router/modules/entry.js b/src/router/modules/entry.js
index 0d38ed626..365615b87 100644
--- a/src/router/modules/entry.js
+++ b/src/router/modules/entry.js
@@ -7,6 +7,7 @@ export default {
title: 'entries',
icon: 'vn:entry',
moduleName: 'Entry',
+ keyBinding: 'e',
},
component: RouterView,
redirect: { name: 'EntryMain' },
diff --git a/src/router/modules/invoiceIn.js b/src/router/modules/invoiceIn.js
index cd8f7de9c..168d64f37 100644
--- a/src/router/modules/invoiceIn.js
+++ b/src/router/modules/invoiceIn.js
@@ -1,5 +1,5 @@
import { RouterView } from 'vue-router';
-
+import { setRectificative } from 'src/pages/InvoiceIn/composables/setRectificative';
export default {
path: '/invoice-in',
name: 'InvoiceIn',
@@ -11,7 +11,7 @@ export default {
component: RouterView,
redirect: { name: 'InvoiceInMain' },
menus: {
- main: ['InvoiceInList'],
+ main: ['InvoiceInList', 'InvoiceInSerial'],
card: [
'InvoiceInBasicData',
'InvoiceInVat',
@@ -37,6 +37,16 @@ export default {
},
component: () => import('src/pages/InvoiceIn/InvoiceInList.vue'),
},
+ {
+ path: 'serial',
+ name: 'InvoiceInSerial',
+ meta: {
+ title: 'serial',
+ icon: 'view_list',
+ },
+ component: () =>
+ import('src/pages/InvoiceIn/Serial/InvoiceInSerial.vue'),
+ },
{
path: 'create',
name: 'InvoiceInCreare',
@@ -53,6 +63,10 @@ export default {
path: ':id',
component: () => import('src/pages/InvoiceIn/Card/InvoiceInCard.vue'),
redirect: { name: 'InvoiceInSummary' },
+ beforeEnter: async (to, from, next) => {
+ await setRectificative(to);
+ next();
+ },
children: [
{
name: 'InvoiceInSummary',
@@ -70,7 +84,6 @@ export default {
meta: {
title: 'basicData',
icon: 'vn:settings',
- roles: ['salesPerson'],
},
component: () =>
import('src/pages/InvoiceIn/Card/InvoiceInBasicData.vue'),
diff --git a/src/router/modules/item.js b/src/router/modules/item.js
index 4bd5df4e2..48e19dd54 100644
--- a/src/router/modules/item.js
+++ b/src/router/modules/item.js
@@ -7,6 +7,7 @@ export default {
title: 'items',
icon: 'vn:item',
moduleName: 'Item',
+ keyBinding: 'a',
},
component: RouterView,
redirect: { name: 'ItemMain' },
diff --git a/src/router/modules/monitor.js b/src/router/modules/monitor.js
index f0db8d3f3..7342a5904 100644
--- a/src/router/modules/monitor.js
+++ b/src/router/modules/monitor.js
@@ -7,11 +7,12 @@ export default {
title: 'monitors',
icon: 'grid_view',
moduleName: 'Monitor',
+ keyBinding: 'm',
},
component: RouterView,
redirect: { name: 'MonitorMain' },
menus: {
- main: ['MonitorList'],
+ main: ['MonitorTickets', 'MonitorClientsActions'],
card: [],
},
children: [
@@ -19,16 +20,27 @@ export default {
path: '',
name: 'MonitorMain',
component: () => import('src/components/common/VnSectionMain.vue'),
- redirect: { name: 'MonitorList' },
+ redirect: { name: 'MonitorTickets' },
children: [
{
- path: 'list',
- name: 'MonitorList',
+ path: 'tickets',
+ name: 'MonitorTickets',
meta: {
- title: 'list',
- icon: 'grid_view',
+ title: 'ticketsMonitor',
+ icon: 'vn:ticket',
},
- component: () => import('src/pages/Monitor/MonitorList.vue'),
+ component: () =>
+ import('src/pages/Monitor/Ticket/MonitorTickets.vue'),
+ },
+ {
+ path: 'clients-actions',
+ name: 'MonitorClientsActions',
+ meta: {
+ title: 'clientsActionsMonitor',
+ icon: 'vn:client',
+ },
+ component: () =>
+ import('src/pages/Monitor/MonitorClientsActions.vue'),
},
],
},
diff --git a/src/router/modules/order.js b/src/router/modules/order.js
index 9ccdb820b..bfa37fce5 100644
--- a/src/router/modules/order.js
+++ b/src/router/modules/order.js
@@ -7,6 +7,7 @@ export default {
title: 'order',
icon: 'vn:basket',
moduleName: 'Order',
+ keyBinding: 'o',
},
component: RouterView,
redirect: { name: 'OrderMain' },
diff --git a/src/router/modules/shelving.js b/src/router/modules/shelving.js
index 70145dfb4..b7f50a3b6 100644
--- a/src/router/modules/shelving.js
+++ b/src/router/modules/shelving.js
@@ -76,7 +76,6 @@ export default {
meta: {
title: 'basicData',
icon: 'vn:settings',
- roles: ['salesPerson'],
},
component: () => import('pages/Shelving/Card/ShelvingForm.vue'),
},
diff --git a/src/router/modules/ticket.js b/src/router/modules/ticket.js
index 4074f089f..dcc238f95 100644
--- a/src/router/modules/ticket.js
+++ b/src/router/modules/ticket.js
@@ -7,6 +7,7 @@ export default {
title: 'tickets',
icon: 'vn:ticket',
moduleName: 'Ticket',
+ keyBinding: 't',
},
component: RouterView,
redirect: { name: 'TicketMain' },
@@ -53,7 +54,6 @@ export default {
meta: {
title: 'createTicket',
icon: 'vn:ticketAdd',
- roles: ['developer'],
},
component: () => import('src/pages/Ticket/TicketCreate.vue'),
},
diff --git a/src/router/modules/wagon.js b/src/router/modules/wagon.js
index d3d14a888..e25e585eb 100644
--- a/src/router/modules/wagon.js
+++ b/src/router/modules/wagon.js
@@ -11,7 +11,7 @@ export default {
component: RouterView,
redirect: { name: 'WagonMain' },
menus: {
- main: ['WagonList', 'WagonTypeList', 'WagonCounter'],
+ main: ['WagonList', 'WagonTypeList', 'WagonCounter', 'WagonTray'],
card: [],
},
children: [
@@ -81,7 +81,7 @@ export default {
title: 'typeCreate',
icon: 'create',
},
- component: () => import('src/pages/Wagon/Type/WagonTypeCreate.vue'),
+ component: () => import('src/pages/Wagon/Type/WagonTypeList.vue'),
},
{
path: ':id/edit',
@@ -90,7 +90,7 @@ export default {
title: 'typeEdit',
icon: 'edit',
},
- component: () => import('src/pages/Wagon/Type/WagonTypeCreate.vue'),
+ component: () => import('src/pages/Wagon/Type/WagonTypeEdit.vue'),
},
],
},
diff --git a/src/router/modules/worker.js b/src/router/modules/worker.js
index f80df5e06..b2716474b 100644
--- a/src/router/modules/worker.js
+++ b/src/router/modules/worker.js
@@ -7,6 +7,7 @@ export default {
title: 'workers',
icon: 'vn:worker',
moduleName: 'Worker',
+ keyBinding: 'w',
},
component: RouterView,
redirect: { name: 'WorkerMain' },
@@ -25,6 +26,7 @@ export default {
'WorkerLocker',
'WorkerBalance',
'WorkerFormation',
+ 'WorkerMedical',
],
},
children: [
@@ -196,6 +198,15 @@ export default {
},
component: () => import('src/pages/Worker/Card/WorkerFormation.vue'),
},
+ {
+ name: 'WorkerMedical',
+ path: 'medical',
+ meta: {
+ title: 'medical',
+ icon: 'medical_information',
+ },
+ component: () => import('src/pages/Worker/Card/WorkerMedical.vue'),
+ },
],
},
],
diff --git a/src/router/modules/zone.js b/src/router/modules/zone.js
index 889b47464..1f27cc76f 100644
--- a/src/router/modules/zone.js
+++ b/src/router/modules/zone.js
@@ -7,6 +7,7 @@ export default {
title: 'zones',
icon: 'vn:zone',
moduleName: 'Zone',
+ keyBinding: 'z',
},
component: RouterView,
redirect: { name: 'ZoneMain' },
@@ -50,33 +51,6 @@ export default {
},
component: () => import('src/pages/Zone/ZoneDeliveryDays.vue'),
},
- {
- path: 'create',
- name: 'ZoneCreate',
- meta: {
- title: 'zoneCreate',
- icon: 'create',
- },
- component: () => import('src/pages/Zone/ZoneCreate.vue'),
- },
- {
- path: ':id/edit',
- name: 'ZoneEdit',
- meta: {
- title: 'zoneEdit',
- icon: 'edit',
- },
- component: () => import('src/pages/Zone/ZoneCreate.vue'),
- },
- // {
- // path: 'counter',
- // name: 'ZoneCounter',
- // meta: {
- // title: 'zoneCounter',
- // icon: 'add_circle',
- // },
- // component: () => import('src/pages/Zone/ZoneCounter.vue'),
- // },
{
name: 'ZoneUpcomingDeliveries',
path: 'upcoming-deliveries',
diff --git a/src/stores/invoiceOutGlobal.js b/src/stores/invoiceOutGlobal.js
index bb9a3d376..42acac013 100644
--- a/src/stores/invoiceOutGlobal.js
+++ b/src/stores/invoiceOutGlobal.js
@@ -19,6 +19,7 @@ export const useInvoiceOutGlobalStore = defineStore({
maxShipped: null,
clientId: null,
printer: null,
+ serialType: null,
},
addresses: [],
minInvoicingDate: null,
@@ -100,6 +101,7 @@ export const useInvoiceOutGlobalStore = defineStore({
maxShipped: new Date(formData.maxShipped),
clientId: formData.clientId ? formData.clientId : null,
companyFk: formData.companyFk,
+ serialType: formData.serialType,
};
this.validateMakeInvoceParams(params, clientsToInvoice);
@@ -152,7 +154,13 @@ export const useInvoiceOutGlobalStore = defineStore({
);
throw new Error('Invoice date in the future');
}
-
+ if (!params.serialType) {
+ notify(
+ 'invoiceOut.globalInvoices.errors.chooseValidSerialType',
+ 'negative'
+ );
+ throw new Error('Invalid Serial Type');
+ }
if (!params.companyFk) {
notify('invoiceOut.globalInvoices.errors.chooseValidCompany', 'negative');
throw new Error('Invalid company');
@@ -180,6 +188,7 @@ export const useInvoiceOutGlobalStore = defineStore({
invoiceDate: new Date(formData.invoiceDate),
maxShipped: new Date(formData.maxShipped),
companyFk: formData.companyFk,
+ serialType: formData.serialType,
};
this.status = 'invoicing';
@@ -191,12 +200,7 @@ export const useInvoiceOutGlobalStore = defineStore({
this.addressIndex++;
this.isInvoicing = false;
} catch (err) {
- if (
- err &&
- err.response &&
- err.response.status >= 400 &&
- err.response.status < 500
- ) {
+ if (err?.response?.status >= 400 && err?.response?.status < 500) {
this.invoiceClientError(address, err.response?.data?.error?.message);
return;
} else {
@@ -243,7 +247,7 @@ export const useInvoiceOutGlobalStore = defineStore({
params,
});
- if (data.data && data.data.error) throw new Error();
+ if (data?.data?.error) throw new Error();
const status = exportFile('negativeBases.csv', data, {
encoding: 'windows-1252',
diff --git a/src/stores/useNavigationStore.js b/src/stores/useNavigationStore.js
index 961e80377..4a819bf19 100644
--- a/src/stores/useNavigationStore.js
+++ b/src/stores/useNavigationStore.js
@@ -2,7 +2,7 @@ import axios from 'axios';
import { ref } from 'vue';
import { defineStore } from 'pinia';
import { toLowerCamel } from 'src/filters';
-import { useRole } from 'src/composables/useRole';
+import { useAcl } from 'src/composables/useAcl';
import routes from 'src/router/modules';
export const useNavigationStore = defineStore('navigationStore', () => {
@@ -26,7 +26,7 @@ export const useNavigationStore = defineStore('navigationStore', () => {
'zone',
];
const pinnedModules = ref([]);
- const role = useRole();
+ const acl = useAcl();
function getModules() {
const modulesRoutes = ref([]);
@@ -56,6 +56,7 @@ export const useNavigationStore = defineStore('navigationStore', () => {
function addMenuItem(module, route, parent) {
const { meta } = route;
let { menuChildren = null } = meta;
+ if (meta.hidden) return;
if (menuChildren)
menuChildren = menuChildren.map(({ name, title, icon }) => ({
name,
@@ -63,7 +64,7 @@ export const useNavigationStore = defineStore('navigationStore', () => {
title: `globals.pageTitles.${title}`,
}));
- if (meta && meta.roles && role.hasAny(meta.roles) === false) return;
+ if (meta && meta.acls && acl.hasAny(meta.acls) === false) return;
const item = {
name: route.name,
@@ -72,6 +73,7 @@ export const useNavigationStore = defineStore('navigationStore', () => {
if (meta) {
item.title = `globals.pageTitles.${meta.title}`;
item.icon = meta.icon;
+ item.keyBinding = meta.keyBinding;
}
parent.push(item);
diff --git a/test/cypress/integration/claim/claimDevelopment.spec.js b/test/cypress/integration/claim/claimDevelopment.spec.js
index 903f58d4b..3b73a24d9 100755
--- a/test/cypress/integration/claim/claimDevelopment.spec.js
+++ b/test/cypress/integration/claim/claimDevelopment.spec.js
@@ -8,6 +8,8 @@ describe('ClaimDevelopment', () => {
cy.viewport(1920, 1080);
cy.login('developer');
cy.visit(`/#/claim/${claimId}/development`);
+ cy.intercept('GET', /\/api\/Workers\/search/).as('workers');
+ cy.intercept('GET', /\/api\/Workers\/search/).as('workers');
cy.waitForElement('tbody');
});
@@ -32,10 +34,19 @@ describe('ClaimDevelopment', () => {
});
it('should add and remove new line', () => {
+ cy.wait(['@workers', '@workers']);
cy.addCard();
+
cy.get(thirdRow).should('exist');
- const rowData = [false, 'Novato', 'Roces', 'Compradores', 'employeeNick', 'Tour'];
+ const rowData = [
+ false,
+ 'Novato',
+ 'Roces',
+ 'Compradores',
+ 'administrativeNick',
+ 'Tour',
+ ];
cy.fillRow(thirdRow, rowData);
cy.saveCard();
diff --git a/test/cypress/integration/invoiceIn/invoiceInBasicData.spec.js b/test/cypress/integration/invoiceIn/invoiceInBasicData.spec.js
index 77a11969b..e1939fe5a 100644
--- a/test/cypress/integration/invoiceIn/invoiceInBasicData.spec.js
+++ b/test/cypress/integration/invoiceIn/invoiceInBasicData.spec.js
@@ -36,8 +36,7 @@ describe('InvoiceInBasicData', () => {
});
it('should throw an error creating a new dms if a file is not attached', () => {
- cy.get(formInputs).eq(5).click();
- cy.get(formInputs).eq(5).type('{selectall}{backspace}');
+ cy.get(formInputs).eq(7).type('{selectall}{backspace}');
cy.get(documentBtns).eq(0).click();
cy.get(dialogActionBtns).eq(1).click();
cy.get('.q-notification__message').should(
diff --git a/test/cypress/integration/invoiceIn/invoiceInVat.spec.js b/test/cypress/integration/invoiceIn/invoiceInVat.spec.js
index 018ae7a53..b84d743d1 100644
--- a/test/cypress/integration/invoiceIn/invoiceInVat.spec.js
+++ b/test/cypress/integration/invoiceIn/invoiceInVat.spec.js
@@ -3,13 +3,14 @@ describe('InvoiceInVat', () => {
const thirdRow = 'tbody > :nth-child(3)';
const firstLineVat = 'tbody > :nth-child(1) > :nth-child(4)';
const dialogInputs = '.q-dialog label input';
- const dialogBtns = '.q-dialog button';
- const acrossInput = 'tbody tr:nth-child(1) td:nth-child(2) .default-icon';
+ const addBtn = 'tbody tr:nth-child(1) td:nth-child(2) .--add-icon';
const randomInt = Math.floor(Math.random() * 100);
beforeEach(() => {
cy.login('developer');
cy.visit(`/#/invoice-in/1/vat`);
+ cy.intercept('GET', '/api/InvoiceIns/1/getTotals').as('lastCall');
+ cy.wait('@lastCall');
});
it('should edit the sage iva', () => {
@@ -26,22 +27,15 @@ describe('InvoiceInVat', () => {
});
it('should remove the first line', () => {
- cy.removeRow(2);
- });
-
- it('should throw an error if there are fields undefined', () => {
- cy.get(acrossInput).click();
- cy.get(dialogBtns).eq(2).click();
- cy.get('.q-notification__message').should('have.text', "The code can't be empty");
+ cy.removeRow(1);
});
it('should correctly handle expense addition', () => {
- cy.get(acrossInput).click();
+ cy.get(addBtn).click();
cy.get(dialogInputs).eq(0).type(randomInt);
- cy.get(dialogInputs).eq(1).click();
cy.get(dialogInputs).eq(1).type('This is a dummy expense');
- cy.get(dialogBtns).eq(2).click();
- cy.get('.q-notification__message').should('have.text', 'Data saved');
+ cy.get('button[type="submit"]').click();
+ cy.get('.q-notification__message').should('have.text', 'Data created');
});
});
diff --git a/test/cypress/integration/outLogin/login.spec.js b/test/cypress/integration/outLogin/login.spec.js
index f8a9f5c64..3db223cdb 100755
--- a/test/cypress/integration/outLogin/login.spec.js
+++ b/test/cypress/integration/outLogin/login.spec.js
@@ -52,9 +52,9 @@ describe('Login', () => {
cy.url().should('contain', '/login');
});
- it(`should get redirected to dashboard since employee can't create tickets`, () => {
- cy.visit('/#/ticket/create', { failOnStatusCode: false });
- cy.url().should('contain', '/#/login?redirect=/ticket/create');
+ it(`should be redirected to dashboard since the employee is not enabled to see ldap`, () => {
+ cy.visit('/#/account/ldap', { failOnStatusCode: false });
+ cy.url().should('contain', '/#/login?redirect=/account/ldap');
cy.get('input[aria-label="Username"]').type('employee');
cy.get('input[aria-label="Password"]').type('nightmare');
cy.get('button[type="submit"]').click();
diff --git a/test/cypress/integration/route/routeList.spec.js b/test/cypress/integration/route/routeList.spec.js
index afc0fc395..c9d7147c2 100644
--- a/test/cypress/integration/route/routeList.spec.js
+++ b/test/cypress/integration/route/routeList.spec.js
@@ -10,12 +10,13 @@ describe('Route', () => {
it('Route list create route', () => {
cy.get('.q-page-sticky > div > .q-btn > .q-btn__content > .q-icon').click();
- cy.get('input[name="description"]').eq(1).type('routeTestOne{enter}');
+ cy.get('input[name="description"]').type('routeTestOne{enter}');
cy.get('.q-notification__message').should('have.text', 'Data created');
cy.url().should('include', '/summary');
});
it('Route list search and edit', () => {
+ cy.get('#searchbar input').type('{enter}');
cy.get('input[name="description"]').type('routeTestOne{enter}');
cy.get('.q-table tr')
.its('length')
diff --git a/test/cypress/integration/ticket/ticketDescriptor.spec.js b/test/cypress/integration/ticket/ticketDescriptor.spec.js
index fc920f346..516b0f13d 100644
--- a/test/cypress/integration/ticket/ticketDescriptor.spec.js
+++ b/test/cypress/integration/ticket/ticketDescriptor.spec.js
@@ -1,22 +1,22 @@
///
describe('Ticket descriptor', () => {
const toCloneOpt = '[role="menu"] .q-list > :nth-child(5)';
+ const setWeightOpt = '[role="menu"] .q-list > :nth-child(6)';
const warehouseValue = ':nth-child(1) > :nth-child(6) > .value > span';
const summaryHeader = '.summaryHeader > div';
-
+ const weight = 25;
+ const weightValue = ':nth-child(10) > .value > span';
beforeEach(() => {
- const ticketId = 1;
-
cy.login('developer');
- cy.visit(`/#/ticket/${ticketId}/summary`);
+ cy.viewport(1920, 1080);
});
it('should clone the ticket without warehouse', () => {
- cy.openLeftMenu();
+ cy.visit('/#/ticket/1/summary');
cy.openActionsDescriptor();
cy.get(toCloneOpt).click();
cy.clickConfirm();
- cy.get(warehouseValue).contains('-');
+ cy.get(warehouseValue).contains('Warehouse One');
cy.get(summaryHeader)
.invoke('text')
.then((text) => {
@@ -24,4 +24,15 @@ describe('Ticket descriptor', () => {
cy.wrap(owner.trim()).should('eq', 'Bruce Wayne (1101)');
});
});
+
+ it('should set the weight of the ticket', () => {
+ cy.visit('/#/ticket/10/summary');
+ cy.openActionsDescriptor();
+ cy.get(setWeightOpt).click();
+ cy.intercept('POST', /\/api\/Tickets\/\d+\/setWeight/).as('weight');
+ cy.get('.q-dialog input').type(weight);
+ cy.clickConfirm();
+ cy.wait('@weight');
+ cy.get(weightValue).contains(weight);
+ });
});
diff --git a/test/cypress/integration/vnComponent/VnShortcut.spec.js b/test/cypress/integration/vnComponent/VnShortcut.spec.js
new file mode 100644
index 000000000..b49b4e964
--- /dev/null
+++ b/test/cypress/integration/vnComponent/VnShortcut.spec.js
@@ -0,0 +1,33 @@
+///
+
+describe('VnShortcuts', () => {
+ const modules = {
+ item: 'a',
+ customer: 'c',
+ ticket: 't',
+ claim: 'r',
+ worker: 'w',
+ monitor: 'm',
+ order: 'o',
+ supplier: 'p',
+ entry: 'e',
+ zone: 'z',
+ account: 'u',
+ };
+ beforeEach(() => {
+ cy.login('developer');
+ cy.visit('/');
+ });
+
+ for (const [module, shortcut] of Object.entries(modules)) {
+ it(`should visit ${module} module`, () => {
+ cy.get('body').trigger('keydown', {
+ ctrlKey: true,
+ altKey: true,
+ code: `Key${shortcut.toUpperCase()}`,
+ });
+
+ cy.url().should('include', module);
+ });
+ }
+});
diff --git a/test/cypress/integration/wagonType/wagonTypeCreate.spec.js b/test/cypress/integration/wagonType/wagonTypeCreate.spec.js
index bcf7fe841..cd7ffa58f 100644
--- a/test/cypress/integration/wagonType/wagonTypeCreate.spec.js
+++ b/test/cypress/integration/wagonType/wagonTypeCreate.spec.js
@@ -3,52 +3,15 @@ describe('WagonTypeCreate', () => {
cy.viewport(1920, 1080);
cy.login('developer');
cy.visit('/#/wagon/type/create');
+ cy.waitForElement('.q-page', 6000);
});
- function chooseColor(color) {
- cy.get('div.shelving-down').eq(1).click();
- cy.get('div.q-color-picker__cube').eq(color).click();
- cy.get('div.q-card__section').find('button').click();
- }
-
- function addTray(position) {
- cy.get('div.action-button').last().find('button').click();
- cy.focused().type(position);
- cy.focused().blur();
- }
-
- it('should create and delete a new wagon type', () => {
+ it('should create a new wagon type', () => {
+ cy.get('.q-page-sticky > div > .q-btn').click();
cy.get('input').first().type('Example for testing');
- cy.get('div.q-checkbox__bg').click();
- chooseColor(1);
-
- // Insert invalid position (not minimal height)
- addTray(20);
- cy.get('div[role="alert"]').should('exist');
- chooseColor(2);
- addTray(150);
- chooseColor(3);
- addTray(100);
-
- // Insert invalid position (max height reached)
- addTray(210);
- cy.get('div[role="alert"]').should('exist');
-
- // Save
cy.get('button[type="submit"]').click();
-
- // Check data has been saved successfully
- cy.get(':nth-child(1) > :nth-child(1) > .justify-between > .flex > .title')
- .contains('Example for testing')
- .click();
- cy.get('input').first().should('have.value', 'Example for testing');
- cy.get('div.wagon-tray').should('have.length', 4);
- cy.get('div.position').eq(0).find('input').should('have.value', '150');
- cy.get('div.position').eq(1).find('input').should('have.value', '100');
- cy.get('div.position').eq(2).find('input').should('have.value', '50');
-
- // Delete wagon type created
- cy.go('back');
+ });
+ it('delete a wagon type', () => {
cy.get(
':nth-child(2) > :nth-child(1) > .card-list-body > .actions > .q-btn--standard'
).click();
diff --git a/test/cypress/integration/wagonType/wagonTypeEdit.spec.js b/test/cypress/integration/wagonType/wagonTypeEdit.spec.js
new file mode 100644
index 000000000..6e5816e51
--- /dev/null
+++ b/test/cypress/integration/wagonType/wagonTypeEdit.spec.js
@@ -0,0 +1,27 @@
+describe('WagonTypeEdit', () => {
+ const trayColorRow =
+ '.q-select > .q-field__inner > .q-field__control > .q-field__control-container';
+ beforeEach(() => {
+ cy.viewport(1920, 1080);
+ cy.login('developer');
+ cy.visit('/#/wagon/type/2/edit');
+ });
+
+ it('should edit the name and the divisible field of the wagon type', () => {
+ cy.get('.q-card');
+ cy.get('input').first().type(' changed');
+ cy.get('div.q-checkbox__bg').first().click();
+ cy.get('.q-btn--standard').click();
+ });
+
+ it('should create a tray', () => {
+ cy.get('.action-button > .q-btn > .q-btn__content > .q-icon').click();
+ cy.get('input').last().type('150');
+ cy.get(trayColorRow).type('{downArrow}{downArrow}{enter}');
+ });
+
+ it('should delete a tray', () => {
+ cy.get('.action-button > .q-btn > .q-btn__content > .q-icon').first().click();
+ cy.reload();
+ });
+});
diff --git a/test/cypress/integration/worker/workerCreate.spec.js b/test/cypress/integration/worker/workerCreate.spec.js
index c1832ad67..50afe1892 100644
--- a/test/cypress/integration/worker/workerCreate.spec.js
+++ b/test/cypress/integration/worker/workerCreate.spec.js
@@ -2,6 +2,9 @@ describe('WorkerCreate', () => {
const externalRadio = '.q-radio:nth-child(2)';
const notification = '.q-notification__message';
const developerBossId = 120;
+ const payMethodCross =
+ '.grid-create .full-width > :nth-child(9) .q-select .q-field__append:not(.q-anchor--skip)';
+ const saveBtn = '.q-mt-lg > .q-btn--standard';
const internal = {
Fi: { val: '78457139E' },
@@ -36,7 +39,8 @@ describe('WorkerCreate', () => {
it('should throw an error if a pay method has not been selected', () => {
cy.fillInForm(internal);
- cy.get('.q-mt-lg > .q-btn--standard').click();
+ cy.get(payMethodCross).click();
+ cy.get(saveBtn).click();
cy.get(notification).should('contains.text', 'Payment method is required');
});
@@ -45,14 +49,14 @@ describe('WorkerCreate', () => {
...internal,
'Pay method': { val: 'PayMethod one', type: 'select' },
});
- cy.get('.q-mt-lg > .q-btn--standard').click();
+ cy.get(saveBtn).click();
cy.get(notification).should('contains.text', 'Data created');
});
it('should create an external', () => {
cy.get(externalRadio).click();
cy.fillInForm(external);
- cy.get('.q-mt-lg > .q-btn--standard').click();
+ cy.get(saveBtn).click();
cy.get(notification).should('contains.text', 'Data created');
});
});
diff --git a/test/cypress/integration/worker/workerLocker.spec.js b/test/cypress/integration/worker/workerLocker.spec.js
index 9a4066f54..8a169dfb2 100644
--- a/test/cypress/integration/worker/workerLocker.spec.js
+++ b/test/cypress/integration/worker/workerLocker.spec.js
@@ -1,12 +1,12 @@
describe('WorkerLocker', () => {
- const workerId = 1109;
+ const productionId = 49;
const lockerCode = '2F';
const input = '.q-card input';
const thirdOpt = '[role="listbox"] .q-item:nth-child(1)';
beforeEach(() => {
cy.viewport(1280, 720);
cy.login('productionBoss');
- cy.visit(`/#/worker/${workerId}/locker`);
+ cy.visit(`/#/worker/${productionId}/locker`);
});
it('should allocates a locker', () => {
diff --git a/test/cypress/integration/zone/zoneBasicData.spec.js b/test/cypress/integration/zone/zoneBasicData.spec.js
new file mode 100644
index 000000000..c6151a49b
--- /dev/null
+++ b/test/cypress/integration/zone/zoneBasicData.spec.js
@@ -0,0 +1,21 @@
+describe('ZoneBasicData', () => {
+ const notification = '.q-notification__message';
+
+ beforeEach(() => {
+ cy.viewport(1280, 720);
+ cy.login('developer');
+ cy.visit('/#/zone/4/basic-data');
+ });
+
+ it('should throw an error if the name is empty', () => {
+ cy.get('.q-card > :nth-child(1)').clear();
+ cy.get('.q-btn-group > .q-btn--standard').click();
+ cy.get(notification).should('contains.text', "can't be blank");
+ });
+
+ it("should edit the basicData's zone", () => {
+ cy.get('.q-card > :nth-child(1)').type(' modified');
+ cy.get('.q-btn-group > .q-btn--standard').click();
+ cy.get(notification).should('contains.text', 'Data saved');
+ });
+});
diff --git a/test/cypress/integration/zone/zoneCreate.spec.js b/test/cypress/integration/zone/zoneCreate.spec.js
new file mode 100644
index 000000000..9618ea846
--- /dev/null
+++ b/test/cypress/integration/zone/zoneCreate.spec.js
@@ -0,0 +1,38 @@
+describe('ZoneCreate', () => {
+ const notification = '.q-notification__message';
+
+ const data = {
+ Name: { val: 'Zone pickup D' },
+ Price: { val: '3' },
+ Bonus: { val: '0' },
+ 'Traveling days': { val: '0' },
+ Warehouse: { val: 'Algemesi', type: 'select' },
+ Volumetric: { val: 'true', type: 'checkbox' },
+ };
+
+ beforeEach(() => {
+ cy.viewport(1280, 720);
+ cy.login('developer');
+ cy.visit('/#/zone/list');
+ cy.get('.q-page-sticky > div > .q-btn').click();
+ });
+
+ it('should throw an error if an agency has not been selected', () => {
+ cy.fillInForm({
+ ...data,
+ });
+ cy.get('input[aria-label="Close"]').type('10:00');
+ cy.get('.q-mt-lg > .q-btn--standard').click();
+ cy.get(notification).should('contains.text', 'Agency cannot be blank');
+ });
+
+ it('should create a zone', () => {
+ cy.fillInForm({
+ ...data,
+ Agency: { val: 'inhouse pickup', type: 'select' },
+ });
+ cy.get('input[aria-label="Close"]').type('10:00');
+ cy.get('.q-mt-lg > .q-btn--standard').click();
+ cy.get(notification).should('contains.text', 'Data created');
+ });
+});
diff --git a/test/cypress/integration/zone/zoneList.spec.js b/test/cypress/integration/zone/zoneList.spec.js
index f35da7e5f..92c77a2c6 100644
--- a/test/cypress/integration/zone/zoneList.spec.js
+++ b/test/cypress/integration/zone/zoneList.spec.js
@@ -1,15 +1,18 @@
describe('ZoneList', () => {
beforeEach(() => {
- cy.viewport(1920, 1080);
+ cy.viewport(1280, 720);
cy.login('developer');
- cy.visit(`/#/zone/list`);
+ cy.visit('/#/zone/list');
});
- it('should open the details', () => {
- cy.get(':nth-child(1) > .text-right > .material-symbols-outlined').click();
+ it('should filter by agency', () => {
+ cy.get(
+ ':nth-child(1) > .column > .q-field > .q-field__inner > .q-field__control > .q-field__control-container'
+ ).type('{downArrow}{enter}');
});
- it('should redirect to summary', () => {
- cy.waitForElement('.q-page');
- cy.get('tbody > :nth-child(1)').click();
+
+ it('should open the zone summary', () => {
+ cy.get('input[aria-label="Name"]').type('zone refund');
+ cy.get('.q-scrollarea__content > .q-btn--standard > .q-btn__content').click();
});
});
diff --git a/test/cypress/integration/zone/zoneWarehouse.spec.js b/test/cypress/integration/zone/zoneWarehouse.spec.js
new file mode 100644
index 000000000..3ffa3f69d
--- /dev/null
+++ b/test/cypress/integration/zone/zoneWarehouse.spec.js
@@ -0,0 +1,34 @@
+describe('ZoneWarehouse', () => {
+ const data = {
+ Warehouse: { val: 'Algemesi', type: 'select' },
+ };
+ const deviceProductionField =
+ '.vn-row > :nth-child(1) > .q-field > .q-field__inner > .q-field__control > .q-field__control-container';
+ const dataError = "ER_DUP_ENTRY: Duplicate entry '2-2' for key 'zoneFk'";
+
+ beforeEach(() => {
+ cy.viewport(1280, 720);
+ cy.login('developer');
+ cy.visit(`/#/zone/2/warehouses`);
+ });
+
+ it('should throw an error if the warehouse chosen is already put in the zone', () => {
+ cy.get('.q-page-sticky > div > .q-btn > .q-btn__content > .q-icon').click();
+ cy.get(deviceProductionField).click();
+ cy.get(deviceProductionField).type('{upArrow}{enter}');
+ cy.get('.q-notification__message').should('have.text', dataError);
+ });
+
+ it('should create a warehouse', () => {
+ cy.get('.q-page-sticky > div > .q-btn > .q-btn__content > .q-icon').click();
+ cy.get(deviceProductionField).click();
+ cy.fillInForm(data);
+ cy.get('.q-mt-lg > .q-btn--standard').click();
+ });
+
+ it('should delete a warehouse', () => {
+ cy.get('tbody > :nth-child(2) > :nth-child(2) > .q-icon').click();
+ cy.get('.q-card__actions > .q-btn--flat > .q-btn__content').click();
+ cy.reload();
+ });
+});
diff --git a/test/cypress/support/commands.js b/test/cypress/support/commands.js
index 3cf909af5..a9a405313 100755
--- a/test/cypress/support/commands.js
+++ b/test/cypress/support/commands.js
@@ -105,6 +105,12 @@ Cypress.Commands.add('fillInForm', (obj, form = '.q-form > .q-card') => {
case 'date':
cy.wrap(el).type(val.split('-').join(''));
break;
+ case 'time':
+ cy.wrap(el).click();
+ cy.get('.q-time .q-time__clock').contains(val.h).click();
+ cy.get('.q-time .q-time__clock').contains(val.m).click();
+ cy.get('.q-time .q-time__link').contains(val.x).click();
+ break;
default:
cy.wrap(el).type(val);
break;
diff --git a/test/vitest/__tests__/composables/useAcl.spec.js b/test/vitest/__tests__/composables/useAcl.spec.js
index a2b44b5e7..6cb29984c 100644
--- a/test/vitest/__tests__/composables/useAcl.spec.js
+++ b/test/vitest/__tests__/composables/useAcl.spec.js
@@ -48,40 +48,62 @@ describe('useAcl', () => {
describe('hasAny', () => {
it('should return false if no roles matched', async () => {
- expect(acl.hasAny('Worker', 'updateAttributes', 'WRITE')).toBeFalsy();
+ expect(
+ acl.hasAny([
+ { model: 'Worker', props: 'updateAttributes', accessType: 'WRITE' },
+ ])
+ ).toBeFalsy();
});
it('should return false if no roles matched', async () => {
- expect(acl.hasAny('Worker', 'holidays', 'READ')).toBeTruthy();
+ expect(
+ acl.hasAny([{ model: 'Worker', props: 'holidays', accessType: 'READ' }])
+ ).toBeTruthy();
});
describe('*', () => {
it('should return true if an acl matched', async () => {
- expect(acl.hasAny('Address', '*', 'WRITE')).toBeTruthy();
+ expect(
+ acl.hasAny([{ model: 'Address', props: '*', accessType: 'WRITE' }])
+ ).toBeTruthy();
});
it('should return false if no acls matched', async () => {
- expect(acl.hasAny('Worker', '*', 'READ')).toBeFalsy();
+ expect(
+ acl.hasAny([{ model: 'Worker', props: '*', accessType: 'READ' }])
+ ).toBeFalsy();
});
});
describe('$authenticated', () => {
it('should return false if no acls matched', async () => {
- expect(acl.hasAny('Url', 'getByUser', '*')).toBeFalsy();
+ expect(
+ acl.hasAny([{ model: 'Url', props: 'getByUser', accessType: '*' }])
+ ).toBeFalsy();
});
it('should return true if an acl matched', async () => {
- expect(acl.hasAny('Url', 'getByUser', 'READ')).toBeTruthy();
+ expect(
+ acl.hasAny([{ model: 'Url', props: 'getByUser', accessType: 'READ' }])
+ ).toBeTruthy();
});
});
describe('$everyone', () => {
it('should return false if no acls matched', async () => {
- expect(acl.hasAny('TpvTransaction', 'start', 'READ')).toBeFalsy();
+ expect(
+ acl.hasAny([
+ { model: 'TpvTransaction', props: 'start', accessType: 'READ' },
+ ])
+ ).toBeFalsy();
});
it('should return false if an acl matched', async () => {
- expect(acl.hasAny('TpvTransaction', 'start', 'WRITE')).toBeTruthy();
+ expect(
+ acl.hasAny([
+ { model: 'TpvTransaction', props: 'start', accessType: 'WRITE' },
+ ])
+ ).toBeTruthy();
});
});
});
diff --git a/test/vitest/__tests__/pages/Wagons/WagonTypeCreate.spec.js b/test/vitest/__tests__/pages/Wagons/WagonTypeCreate.spec.js
deleted file mode 100644
index 60c199b73..000000000
--- a/test/vitest/__tests__/pages/Wagons/WagonTypeCreate.spec.js
+++ /dev/null
@@ -1,271 +0,0 @@
-import { axios, createWrapper } from 'app/test/vitest/helper';
-import WagonTypeCreate from 'pages/Wagon/Type/WagonTypeCreate.vue';
-import { afterEach, beforeAll, describe, expect, it, vi } from 'vitest';
-
-describe('WagonTypeCreate', () => {
- let vmCreate, vmEdit;
- const entityId = 1;
-
- beforeAll(() => {
- vmEdit = createWrapper(WagonTypeCreate, {propsData: {
- id: entityId,
- }}).vm;
- vmCreate = createWrapper(WagonTypeCreate).vm;
- vmEdit.wagonConfig = vmCreate.wagonConfig = {maxTrays: 2 ,minHeightBetweenTrays: 50, maxWagonHeight: 200 };
- vmEdit.wagonTypeColors = vmCreate.wagonTypeColors = [{id: 1, color:'white', rgb:'#000000'}];
- });
-
- afterEach(() => {
- vi.clearAllMocks();
- });
-
- describe('addTray()', () => {
- it('should throw message if there are uncomplete trays', async () => {
- vi.spyOn(vmEdit.quasar, 'notify');
- vmEdit.wagon = [{
- id: 1,
- position: null,
- color: vmEdit.wagonTypeColors[0]
- }];
-
- await vmEdit.addTray();
-
- expect(vmEdit.quasar.notify).toHaveBeenCalledWith(
- expect.objectContaining({
- type: 'warning',
- })
- );
- });
-
- it('should create a new tray if the limit has not been reached', async () => {
- vmEdit.wagon = [{
- id: 1,
- position: 0,
- color: vmEdit.wagonTypeColors[0]
- }];
-
- await vmEdit.addTray();
- expect(vmEdit.wagon.length).toEqual(2);
- });
-
- it('should throw message if there are uncomplete trays', async () => {
- vi.spyOn(vmEdit.quasar, 'notify');
- vmEdit.wagon = [{
- id: 1,
- position: 0,
- color: vmEdit.wagonTypeColors[0]
- },{
- id: 2,
- position: 50,
- color: vmEdit.wagonTypeColors[0]
- }];
-
- await vmEdit.addTray();
-
- expect(vmEdit.quasar.notify).toHaveBeenCalledWith(
- expect.objectContaining({
- type: 'warning',
- })
- );
- });
- });
-
- describe('deleteTray() reorderIds()', () => {
- it('should delete a tray and reorder the ids', async () => {
- const trayToDelete = {
- id: 1,
- position: 0,
- color: vmEdit.wagonTypeColors[0]
- };
- const trayMaintained = {
- id: 2,
- position: 50,
- color: vmEdit.wagonTypeColors[0]
- };
- vmEdit.wagon = [trayToDelete,trayMaintained];
-
- await vmEdit.deleteTray(trayToDelete);
-
- expect(vmEdit.wagon.length).toEqual(1);
- expect(vmEdit.wagon[0].id).toEqual(0);
- expect(vmEdit.wagon[0].position).toEqual(50);
-
- });
- });
-
- describe('onSubmit()', () => {
- it('should make a patch to editWagonType if have id', async () => {
- vi.spyOn(axios, 'patch').mockResolvedValue({ data: true });
- const wagon = {
- id: entityId,
- name: "Mock name",
- divisible: true,
- trays: [{
- id: 1,
- position: 0,
- color: vmEdit.wagonTypeColors[0]
- }]
- }
- vmEdit.name = wagon.name;
- vmEdit.divisible = wagon.divisible;
- vmEdit.wagon = wagon.trays;
-
- await vmEdit.onSubmit();
-
- expect(axios.patch).toHaveBeenCalledWith(
- `WagonTypes/editWagonType`, wagon
- );
- });
-
- it('should make a patch to createtWagonType if not have id', async () => {
- vi.spyOn(axios, 'patch').mockResolvedValue({ data: true });
- const wagon = {
- name: "Mock name",
- divisible: true,
- trays: [{
- id: 1,
- position: 0,
- color: vmCreate.wagonTypeColors[0]
- }]
- }
- vmCreate.name = wagon.name;
- vmCreate.divisible = wagon.divisible;
- vmCreate.wagon = wagon.trays;
-
- await vmCreate.onSubmit();
-
- expect(axios.patch).toHaveBeenCalledWith(
- `WagonTypes/createWagonType`, wagon
- );
- });
- });
-
- describe('onReset()', () => {
- it('should reset if have id', async () => {
- vmEdit.name = 'Changed name';
- vmEdit.divisible = false;
- vmEdit.wagon = [];
- vmEdit.originalData = {
- name: 'Original name',
- divisible: true,
- trays: [{
- id: 1,
- position: 0,
- color: vmEdit.wagonTypeColors[0]
- },{
- id: 2,
- position: 50,
- color: vmEdit.wagonTypeColors[0]
- }]
- };
-
- vmEdit.onReset();
-
- expect(vmEdit.name).toEqual(vmEdit.originalData.name);
- expect(vmEdit.divisible).toEqual(vmEdit.originalData.divisible);
- expect(vmEdit.wagon).toEqual(vmEdit.originalData.trays);
- });
-
- it('should reset if not have id', async () => {
- vmCreate.name = 'Changed name';
- vmCreate.divisible = false;
- vmCreate.wagon = [];
-
- vmCreate.onReset();
-
- expect(vmCreate.name).toEqual(null);
- expect(vmCreate.divisible).toEqual(false);
- expect(vmCreate.wagon.length).toEqual(1);
- });
- });
-
- describe('onPositionBlur()', () => {
- it('should set position null if position is negative', async () => {
- const negativeTray = {
- id: 1,
- position: -1,
- color: vmCreate.wagonTypeColors[0]
- };
-
- vmCreate.onPositionBlur(negativeTray);
-
- expect(negativeTray.position).toEqual(null);
- });
-
- it('should set position and reorder array', async () => {
- const trays = [{
- id: 0,
- position: 100,
- color: vmCreate.wagonTypeColors[0]
- },{
- id: 1,
- position: 0,
- color: vmCreate.wagonTypeColors[0]
- }];
- const newTray = {
- id: 2,
- position: 50,
- color: vmCreate.wagonTypeColors[0]
- };
- trays.push(newTray);
- vmCreate.wagon = trays;
-
- vmCreate.onPositionBlur(newTray);
-
- expect(vmCreate.wagon[0].position).toEqual(100);
- expect(vmCreate.wagon[1].position).toEqual(50);
- expect(vmCreate.wagon[2].position).toEqual(0);
- });
-
- it('should throw message if not have min height between trays and should set new adequate positions', async () => {
- vi.spyOn(vmCreate.quasar, 'notify');
- const trays = [{
- id: 0,
- position: 0,
- color: vmCreate.wagonTypeColors[0]
- }];
- const newTray = {
- id: 1,
- position: 20,
- color: vmCreate.wagonTypeColors[0]
- };
- trays.push(newTray);
- vmCreate.wagon = trays;
-
- vmCreate.onPositionBlur(newTray);
-
- expect(vmCreate.wagon[0].position).toEqual(50);
- expect(vmCreate.wagon[1].position).toEqual(0);
- expect(vmCreate.quasar.notify).toHaveBeenCalledWith(
- expect.objectContaining({
- type: 'warning',
- })
- );
- });
-
- it('should throw message if max height has been exceed', async () => {
- vi.spyOn(vmCreate.quasar, 'notify');
- const trays = [{
- id: 0,
- position: 0,
- color: vmCreate.wagonTypeColors[0]
- }];
- const newTray = {
- id: 1,
- position: 210,
- color: vmCreate.wagonTypeColors[0]
- };
- trays.push(newTray);
- vmCreate.wagon = trays;
-
- vmCreate.onPositionBlur(newTray);
-
- expect(vmCreate.wagon.length).toEqual(1);
- expect(vmCreate.quasar.notify).toHaveBeenCalledWith(
- expect.objectContaining({
- type: 'warning',
- })
- );
- });
- });
-});