@@ -78,55 +92,15 @@ function getWorkerAvatar() {
-
-
- {{ entity.user.nickname }}
- {{ entity.user.nickname }}
-
-
-
-
-
- {{ t('worker.card.name') }}
- {{ entity.user.nickname }}
-
-
-
-
-
- {{ t('worker.card.email') }}
-
- {{ entity.user.email }}
-
-
-
-
-
- {{ t('worker.list.department') }}
-
-
- {{ entity.department.department.name }}
-
-
-
-
-
-
- {{ t('worker.card.phone') }}
-
- {{ entity.phone }}
-
-
-
-
- {{ t('worker.summary.sipExtension') }}
-
- {{ sip }}
-
-
-
+
+
+
+
+
diff --git a/src/pages/Worker/Card/WorkerNotificationsManager.vue b/src/pages/Worker/Card/WorkerNotificationsManager.vue
index 13c9b3de2..44573adca 100644
--- a/src/pages/Worker/Card/WorkerNotificationsManager.vue
+++ b/src/pages/Worker/Card/WorkerNotificationsManager.vue
@@ -1,10 +1,12 @@
+
-
-
-
-
-
- {{ t('worker.notificationsManager.activeNotifications') }}
-
-
-
-
-
-
-
-
-
- {{ t('worker.notificationsManager.availableNotifications') }}
-
-
-
+
+
+
+
+
-
- {{ notification.name }}
- {{
- notification.description
- }}
-
-
+
+
+
+
+
+ {{ notification.name }}
+
+ {{ notification.description }}
+
+
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
diff --git a/src/pages/Worker/Card/WorkerSummary.vue b/src/pages/Worker/Card/WorkerSummary.vue
index 7fc4802c6..7c8accc5d 100644
--- a/src/pages/Worker/Card/WorkerSummary.vue
+++ b/src/pages/Worker/Card/WorkerSummary.vue
@@ -1,13 +1,12 @@
-
-
-
-
-
-
-
-
-
- {{ t('worker.summary.basicData') }}
-
-
-
- ID
- {{ worker.id }}
-
-
-
-
- {{ t('worker.card.name') }}
-
-
- {{ worker.user.nickname }}
-
-
-
-
-
- {{ t('worker.list.department') }}
-
- {{
- worker.department.department.name
- }}
-
-
-
-
- {{ t('worker.list.email') }}
-
- {{ worker.user.email }}
-
-
-
+
+ {{ entity.id }} - {{ entity.firstName }} {{ entity.lastName }}
+
+
+
+
+
+
+
+
+
+
+ {{ dashIfEmpty(worker.boss?.name) }}
+
-
-
- {{ t('worker.summary.boss') }}
-
-
-
- {{ worker.boss.name }}
-
-
-
-
-
-
-
- {{ t('worker.summary.phoneExtension') }}
-
-
- {{
- worker.mobileExtension == ''
- ? worker.mobileExtension
- : '-'
- }}
-
-
-
-
-
- {{ t('worker.summary.entPhone') }}
-
- {{
- worker.phone == '' ? worker.phone : '-'
- }}
-
-
-
-
- {{ t('worker.summary.personalPhone') }}
-
- {{
- worker.client.phone == ''
- ? worker.client.phone
- : '-'
- }}
-
-
-
-
-
-
-
- {{ t('worker.summary.userData') }}
-
-
-
-
- {{ t('worker.summary.userId') }}
-
- {{ worker.user.id }}
-
-
-
-
- {{ t('worker.card.name') }}
-
- {{ worker.user.nickname }}
-
-
-
-
- {{ t('worker.summary.role') }}
-
- {{ worker.user.role.name }}
-
-
-
-
- {{ t('worker.summary.sipExtension') }}
-
- {{ sipExtension() }}
-
-
-
-
+ />
+
+
+
+
+
+
+
+
+
+
-
-
-
+
+
+
+
+
+
+
-
diff --git a/src/pages/Worker/WorkerList.vue b/src/pages/Worker/WorkerList.vue
index 15df7373a..cb75cdee3 100644
--- a/src/pages/Worker/WorkerList.vue
+++ b/src/pages/Worker/WorkerList.vue
@@ -7,6 +7,8 @@ import VnPaginate from 'src/components/ui/VnPaginate.vue';
import WorkerSummaryDialog from './Card/WorkerSummaryDialog.vue';
import VnSearchbar from 'src/components/ui/VnSearchbar.vue';
import WorkerFilter from './WorkerFilter.vue';
+import VnLv from 'src/components/ui/VnLv.vue';
+import CardList from 'src/components/ui/CardList.vue';
const stateStore = useStateStore();
const router = useRouter();
@@ -66,73 +68,38 @@ function viewSummary(id) {
auto-load
>
-
-
-
-
- {{ row.nickname }}
-
- #{{ row.id }}
-
-
-
-
- {{ t('worker.list.name') }}
-
- {{ row.userName }}
-
-
-
-
-
- {{ t('worker.list.email') }}
-
- {{ row.email }}
-
-
-
-
- {{
- t('worker.list.department')
- }}
-
- {{ row.department }}
-
-
-
-
-
-
-
-
-
- {{ t('components.smartCard.openCard') }}
-
-
-
-
- {{ t('components.smartCard.openSummary') }}
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+ {{ t('components.smartCard.openCard') }}
+
+
+
+
+ {{ t('components.smartCard.openSummary') }}
+
+
+
+
diff --git a/src/router/index.js b/src/router/index.js
index 9bc199047..ca560e9c9 100644
--- a/src/router/index.js
+++ b/src/router/index.js
@@ -45,8 +45,8 @@ export { Router };
export default route(function (/* { store, ssrContext } */) {
Router.beforeEach(async (to, from, next) => {
const { isLoggedIn } = session;
-
- if (!isLoggedIn() && to.name !== 'Login') {
+ const outLayout = ['Login', 'TwoFactor', 'VerifyEmail'];
+ if (!isLoggedIn() && !outLayout.includes(to.name)) {
return next({ name: 'Login', query: { redirect: to.fullPath } });
}
diff --git a/src/router/modules/claim.js b/src/router/modules/claim.js
index c43ed5012..1dfd75cff 100644
--- a/src/router/modules/claim.js
+++ b/src/router/modules/claim.js
@@ -11,7 +11,16 @@ export default {
redirect: { name: 'ClaimMain' },
menus: {
main: ['ClaimList', 'ClaimRmaList'],
- card: ['ClaimBasicData', 'ClaimLines', 'ClaimRma', 'ClaimPhotos', 'ClaimLog'],
+ card: [
+ 'ClaimBasicData',
+ 'ClaimLines',
+ 'ClaimRma',
+ 'ClaimPhotos',
+ 'ClaimLog',
+ 'ClaimNotes',
+ 'ClaimDevelopment',
+ 'ClaimAction',
+ ],
},
children: [
{
@@ -94,6 +103,16 @@ export default {
},
component: () => import('src/pages/Claim/Card/ClaimPhoto.vue'),
},
+ {
+ name: 'ClaimDevelopment',
+ path: 'development',
+ meta: {
+ title: 'development',
+ icon: 'vn:traceability',
+ roles: ['claimManager'],
+ },
+ component: () => import('src/pages/Claim/Card/ClaimDevelopment.vue'),
+ },
{
name: 'ClaimLog',
path: 'log',
@@ -103,6 +122,24 @@ export default {
},
component: () => import('src/pages/Claim/Card/ClaimLog.vue'),
},
+ {
+ name: 'ClaimNotes',
+ path: 'notes',
+ meta: {
+ title: 'notes',
+ icon: 'draft',
+ },
+ component: () => import('src/pages/Claim/Card/ClaimNotes.vue'),
+ },
+ {
+ name: 'ClaimAction',
+ path: 'action',
+ meta: {
+ title: 'action',
+ icon: 'vn:actions',
+ },
+ component: () => import('src/pages/Claim/Card/ClaimAction.vue'),
+ },
],
},
],
diff --git a/src/router/modules/customer.js b/src/router/modules/customer.js
index c7e978eec..832a1e0fd 100644
--- a/src/router/modules/customer.js
+++ b/src/router/modules/customer.js
@@ -10,7 +10,7 @@ export default {
component: RouterView,
redirect: { name: 'CustomerMain' },
menus: {
- main: ['CustomerList', 'CustomerPayments', 'CustomerCreate'],
+ main: ['CustomerList', 'CustomerPayments'],
card: ['CustomerBasicData'],
},
children: [
@@ -27,7 +27,7 @@ export default {
title: 'list',
icon: 'view_list',
},
- component: () => import('src/pages/Customer/CustomerList.vue')
+ component: () => import('src/pages/Customer/CustomerList.vue'),
},
{
path: 'payments',
@@ -36,17 +36,7 @@ export default {
title: 'webPayments',
icon: 'vn:onlinepayment',
},
- component: () => import('src/pages/Customer/CustomerPayments.vue')
- },
- {
- path: 'create',
- name: 'CustomerCreate',
- meta: {
- title: 'createCustomer',
- icon: 'vn:addperson',
- roles: ['developer'],
- },
- component: () => import('src/pages/Customer/CustomerCreate.vue'),
+ component: () => import('src/pages/Customer/CustomerPayments.vue'),
},
],
},
@@ -63,7 +53,8 @@ export default {
title: 'summary',
icon: 'launch',
},
- component: () => import('src/pages/Customer/Card/CustomerSummary.vue'),
+ component: () =>
+ import('src/pages/Customer/Card/CustomerSummary.vue'),
},
{
path: 'basic-data',
@@ -72,7 +63,8 @@ export default {
title: 'basicData',
icon: 'vn:settings',
},
- component: () => import('src/pages/Customer/Card/CustomerBasicData.vue'),
+ component: () =>
+ import('src/pages/Customer/Card/CustomerBasicData.vue'),
},
],
},
diff --git a/src/router/modules/index.js b/src/router/modules/index.js
index 30c51939d..2916b98ef 100644
--- a/src/router/modules/index.js
+++ b/src/router/modules/index.js
@@ -4,6 +4,7 @@ import Claim from './claim';
import InvoiceOut from './invoiceOut';
import Worker from './worker';
import Wagon from './wagon';
+import Route from './route';
export default [
Customer,
@@ -11,5 +12,6 @@ export default [
Claim,
InvoiceOut,
Worker,
- Wagon
+ Wagon,
+ Route
]
diff --git a/src/router/modules/route.js b/src/router/modules/route.js
new file mode 100644
index 000000000..acda898de
--- /dev/null
+++ b/src/router/modules/route.js
@@ -0,0 +1,35 @@
+import { RouterView } from 'vue-router';
+
+export default {
+ path: '/route',
+ name: 'Route',
+ meta: {
+ title: 'routes',
+ icon: 'vn:delivery',
+ },
+ component: RouterView,
+ redirect: { name: 'RouteMain' },
+ menus: {
+ main: ['CmrList'],
+ card: [],
+ },
+ children: [
+ {
+ path: '/route',
+ name: 'RouteMain',
+ component: () => import('src/pages/Route/RouteMain.vue'),
+ redirect: { name: 'CmrList' },
+ children: [
+ {
+ path: 'cmr',
+ name: 'CmrList',
+ meta: {
+ title: 'cmrsList',
+ icon: 'fact_check',
+ },
+ component: () => import('src/pages/Route/Cmr/CmrList.vue'),
+ },
+ ],
+ },
+ ],
+};
diff --git a/src/router/modules/ticket.js b/src/router/modules/ticket.js
index 4f06a1808..73c441b4d 100644
--- a/src/router/modules/ticket.js
+++ b/src/router/modules/ticket.js
@@ -11,7 +11,7 @@ export default {
redirect: { name: 'TicketMain' },
menus: {
main: ['TicketList'],
- card: ['TicketBoxing'],
+ card: ['TicketBoxing', 'TicketSms'],
},
children: [
{
@@ -74,6 +74,15 @@ export default {
},
component: () => import('src/pages/Ticket/Card/TicketBoxing.vue'),
},
+ {
+ path: 'sms',
+ name: 'TicketSms',
+ meta: {
+ title: 'sms',
+ icon: 'sms',
+ },
+ component: () => import('src/pages/Ticket/Card/TicketSms.vue'),
+ },
],
},
],
diff --git a/src/router/modules/wagon.js b/src/router/modules/wagon.js
index 02513d5a8..238e482dd 100644
--- a/src/router/modules/wagon.js
+++ b/src/router/modules/wagon.js
@@ -10,7 +10,7 @@ export default {
component: RouterView,
redirect: { name: 'WagonMain' },
menus: {
- main: ['WagonList', 'WagonTypeList'],
+ main: ['WagonList', 'WagonTypeList', 'WagonCounter'],
card: [],
},
children: [
@@ -27,7 +27,7 @@ export default {
title: 'wagonsList',
icon: 'vn:trolley',
},
- component: () => import('src/pages/Wagon/WagonList.vue')
+ component: () => import('src/pages/Wagon/WagonList.vue'),
},
{
path: 'create',
@@ -36,7 +36,7 @@ export default {
title: 'wagonCreate',
icon: 'create',
},
- component: () => import('src/pages/Wagon/WagonCreate.vue')
+ component: () => import('src/pages/Wagon/WagonCreate.vue'),
},
{
path: ':id/edit',
@@ -45,7 +45,16 @@ export default {
title: 'wagonEdit',
icon: 'edit',
},
- component: () => import('src/pages/Wagon/WagonCreate.vue')
+ component: () => import('src/pages/Wagon/WagonCreate.vue'),
+ },
+ {
+ path: 'counter',
+ name: 'WagonCounter',
+ meta: {
+ title: 'wagonCounter',
+ icon: 'add_circle',
+ },
+ component: () => import('src/pages/Wagon/WagonCounter.vue'),
},
],
},
@@ -62,7 +71,7 @@ export default {
title: 'typesList',
icon: 'view_list',
},
- component: () => import('src/pages/Wagon/Type/WagonTypeList.vue')
+ component: () => import('src/pages/Wagon/Type/WagonTypeList.vue'),
},
{
path: 'create',
@@ -71,7 +80,7 @@ export default {
title: 'typeCreate',
icon: 'create',
},
- component: () => import('src/pages/Wagon/Type/WagonTypeCreate.vue')
+ component: () => import('src/pages/Wagon/Type/WagonTypeCreate.vue'),
},
{
path: ':id/edit',
@@ -80,9 +89,9 @@ export default {
title: 'typeEdit',
icon: 'edit',
},
- component: () => import('src/pages/Wagon/Type/WagonTypeCreate.vue')
+ component: () => import('src/pages/Wagon/Type/WagonTypeCreate.vue'),
},
],
- }
+ },
],
};
diff --git a/src/router/modules/worker.js b/src/router/modules/worker.js
index f79d7f06d..e5ee7c1a2 100644
--- a/src/router/modules/worker.js
+++ b/src/router/modules/worker.js
@@ -11,7 +11,7 @@ export default {
redirect: { name: 'WorkerMain' },
menus: {
main: ['WorkerList'],
- // card: ['WorkerNotificationsManager'],
+ card: ['WorkerNotificationsManager'],
},
children: [
{
@@ -46,15 +46,16 @@ export default {
},
component: () => import('src/pages/Worker/Card/WorkerSummary.vue'),
},
- // {
- // name: 'WorkerNotificationsManager',
- // path: 'notifications',
- // meta: {
- // title: 'notifications',
- // icon: 'notifications',
- // },
- // component: () => import('src/pages/Worker/Card/WorkerNotificationsManager.vue'),
- // },
+ {
+ name: 'WorkerNotificationsManager',
+ path: 'notifications',
+ meta: {
+ title: 'notifications',
+ icon: 'notifications',
+ },
+ component: () =>
+ import('src/pages/Worker/Card/WorkerNotificationsManager.vue'),
+ },
],
},
],
diff --git a/src/router/routes.js b/src/router/routes.js
index 17a56505d..e3aa22a06 100644
--- a/src/router/routes.js
+++ b/src/router/routes.js
@@ -4,13 +4,32 @@ import claim from './modules/claim';
import worker from './modules/worker';
import invoiceOut from './modules/invoiceOut';
import wagon from './modules/wagon';
+import route from './modules/route';
const routes = [
{
path: '/login',
- name: 'Login',
- meta: { title: 'logIn' },
- component: () => import('../pages/Login/LoginMain.vue'),
+ component: () => import('../layouts/OutLayout.vue'),
+ children: [
+ {
+ path: '',
+ name: 'Login',
+ meta: { title: 'logIn' },
+ component: () => import('../pages/Login/LoginMain.vue'),
+ },
+ {
+ path: '/twoFactor',
+ name: 'TwoFactor',
+ meta: { title: 'twoFactor' },
+ component: () => import('../pages/Login/TwoFactor.vue'),
+ },
+ {
+ path: '/verifyEmail',
+ name: 'VerifyEmail',
+ meta: { title: 'verifyEmail' },
+ component: () => import('../pages/Login/VerifyEmail.vue'),
+ },
+ ],
},
{
path: '/',
@@ -35,7 +54,8 @@ const routes = [
name: 'NotFound',
component: () => import('../pages/NotFound.vue'),
},
- wagon
+ wagon,
+ route,
],
},
];
diff --git a/src/stores/useArrayDataStore.js b/src/stores/useArrayDataStore.js
index f9a32a6fa..223406a33 100644
--- a/src/stores/useArrayDataStore.js
+++ b/src/stores/useArrayDataStore.js
@@ -18,7 +18,8 @@ export const useArrayDataStore = defineStore('arrayDataStore', () => {
skip: 0,
order: '',
data: ref(),
- isLoading: false
+ isLoading: false,
+ exprBuilder: null,
};
}
diff --git a/src/stores/useNavigationStore.js b/src/stores/useNavigationStore.js
index bcaeeb953..168c1f9dc 100644
--- a/src/stores/useNavigationStore.js
+++ b/src/stores/useNavigationStore.js
@@ -6,7 +6,7 @@ import { useRole } from 'src/composables/useRole';
import routes from 'src/router/modules';
export const useNavigationStore = defineStore('navigationStore', () => {
- const modules = ['customer', 'claim', 'ticket', 'invoiceOut', 'worker', 'wagon'];
+ const modules = ['customer', 'claim', 'ticket', 'invoiceOut', 'worker', 'wagon', 'route'];
const pinnedModules = ref([]);
const role = useRole();
diff --git a/src/stores/useStateStore.js b/src/stores/useStateStore.js
index 8704c46e4..74b65e71f 100644
--- a/src/stores/useStateStore.js
+++ b/src/stores/useStateStore.js
@@ -30,6 +30,13 @@ export const useStateStore = defineStore('stateStore', () => {
return rightDrawer.value;
}
+ function isSubToolbarShown() {
+ return (
+ !!document.querySelector('#st-data') &&
+ !!document.querySelector('#st-actions')
+ );
+ }
+
return {
leftDrawer,
rightDrawer,
@@ -39,5 +46,6 @@ export const useStateStore = defineStore('stateStore', () => {
toggleRightDrawer,
isLeftDrawerShown,
isRightDrawerShown,
+ isSubToolbarShown,
};
});
diff --git a/test/cypress/integration/claimAction.spec.js b/test/cypress/integration/claimAction.spec.js
new file mode 100644
index 000000000..f181722fa
--- /dev/null
+++ b/test/cypress/integration/claimAction.spec.js
@@ -0,0 +1,45 @@
+///
+describe('ClaimAction', () => {
+ const claimId = 2;
+
+ const firstRow = 'tbody > :nth-child(1)';
+ const destinationRow = '.q-item__section > .q-field';
+
+ beforeEach(() => {
+ cy.viewport(1920, 1080);
+ cy.login('developer');
+ cy.visit(`/#/claim/${claimId}/action`);
+ });
+
+ it('should import claim', () => {
+ cy.get('[title="Import claim"]').click();
+ });
+
+ it('should change destination', () => {
+ const rowData = [true, null, null, 'Bueno'];
+ cy.fillRow(firstRow, rowData);
+ });
+
+ it('should change destination from other button', () => {
+ const rowData = [true];
+
+ cy.fillRow(firstRow, rowData);
+ cy.get('[title="Change destination"]').click();
+ cy.selectOption(destinationRow, 'Confeccion');
+ cy.get('.q-card > .q-card__actions > .q-btn--standard').click();
+ });
+
+ it('should regularize', () => {
+ cy.get('[title="Regularize"]').click();
+ cy.clickConfirm();
+ });
+
+ it('should remove the line', () => {
+ cy.fillRow(firstRow, [true]);
+ cy.removeCard();
+ cy.clickConfirm();
+
+ cy.reload();
+ cy.get(firstRow).should('not.exist');
+ });
+});
diff --git a/test/cypress/integration/claimDevelopment.spec.js b/test/cypress/integration/claimDevelopment.spec.js
new file mode 100755
index 000000000..88ccbfab8
--- /dev/null
+++ b/test/cypress/integration/claimDevelopment.spec.js
@@ -0,0 +1,58 @@
+///
+describe('ClaimDevelopment', () => {
+ const claimId = 1;
+ const firstLineReason = 'tbody > :nth-child(1) > :nth-child(2)';
+ const thirdRow = 'tbody > :nth-child(3)';
+
+ beforeEach(() => {
+ cy.viewport(1920, 1080);
+ cy.login('developer');
+ cy.visit(`/#/claim/${claimId}/development`);
+ });
+
+ it('should reset line', () => {
+ cy.selectOption(firstLineReason, 'Novato');
+ cy.resetCard();
+ cy.getValue(firstLineReason).should('have.value', 'Prisas');
+ });
+
+ it('should edit line', () => {
+ cy.selectOption(firstLineReason, 'Novato');
+
+ cy.saveCard();
+ cy.login('developer');
+ cy.visit(`/#/claim/${claimId}/development`);
+
+ cy.getValue(firstLineReason).should('have.value', 'Novato');
+
+ //Restart data
+ cy.selectOption(firstLineReason, 'Prisas');
+ cy.saveCard();
+ });
+
+ it('should add and remove new line', () => {
+ cy.addCard();
+ cy.get(thirdRow).should('exist');
+
+ const rowData = [false, 'Novato', 'Roces', 'Compradores', 'employeeNick', 'Tour'];
+ cy.fillRow(thirdRow, rowData);
+
+ cy.saveCard();
+ cy.login('developer');
+ cy.visit(`/#/claim/${claimId}/development`);
+
+ cy.validateRow(thirdRow, rowData);
+
+ cy.reload();
+ cy.validateRow(thirdRow, rowData);
+
+ //remove row
+ cy.fillRow(thirdRow, [true]);
+ cy.removeCard();
+ cy.clickConfirm();
+ cy.get(thirdRow).should('not.exist');
+
+ cy.reload();
+ cy.get(thirdRow).should('not.exist');
+ });
+});
diff --git a/test/cypress/integration/claimNotes.spec.js b/test/cypress/integration/claimNotes.spec.js
new file mode 100644
index 000000000..5b52dd339
--- /dev/null
+++ b/test/cypress/integration/claimNotes.spec.js
@@ -0,0 +1,17 @@
+///
+describe('ClaimNotes', () => {
+ beforeEach(() => {
+ cy.login('developer');
+ cy.visit(`/#/claim/${2}/notes`);
+ });
+
+ it('should add a new note', () => {
+ const message = 'This is a new message.';
+ cy.get('.q-page-sticky button').click();
+ cy.get('.q-dialog .q-card__section:nth-child(2)').type(message);
+ cy.get('.q-card__actions button:nth-child(2)').click();
+ cy.get('.q-card .q-card__section:nth-child(2)')
+ .eq(0)
+ .should('have.text', message);
+ });
+});
diff --git a/test/cypress/integration/login.spec.js b/test/cypress/integration/login.spec.js
index 4cf10f226..f8a9f5c64 100755
--- a/test/cypress/integration/login.spec.js
+++ b/test/cypress/integration/login.spec.js
@@ -3,28 +3,37 @@ describe('Login', () => {
beforeEach(() => {
cy.visit('/#/login');
cy.get('#switchLanguage').click();
- cy.get('div.q-menu div.q-item:nth-child(1)').click();
+ cy.get('.q-menu > :nth-child(1) > .q-item').click();
});
it('should fail to log in using wrong user', () => {
cy.get('input[aria-label="Username"]').type('incorrectUser');
cy.get('input[aria-label="Password"]').type('nightmare');
cy.get('button[type="submit"]').click();
- cy.get('.q-notification__message').should('have.text', 'Invalid username or password');
+ cy.get('.q-notification__message').should(
+ 'have.text',
+ 'Invalid username or password'
+ );
});
it('should fail to log in using wrong password', () => {
cy.get('input[aria-label="Username"]').type('employee');
cy.get('input[aria-label="Password"]').type('wrongPassword');
cy.get('button[type="submit"]').click();
- cy.get('.q-notification__message').should('have.text', 'Invalid username or password');
+ cy.get('.q-notification__message').should(
+ 'have.text',
+ 'Invalid username or password'
+ );
});
it('should log in', () => {
cy.get('input[aria-label="Username"]').type('employee');
cy.get('input[aria-label="Password"]').type('nightmare');
cy.get('button[type="submit"]').click();
- cy.get('.q-notification__message').should('have.text', 'You have successfully logged in');
+ cy.get('.q-notification__message').should(
+ 'have.text',
+ 'You have successfully logged in'
+ );
cy.url().should('contain', '/dashboard');
});
@@ -32,7 +41,10 @@ describe('Login', () => {
cy.get('input[aria-label="Username"]').type('employee');
cy.get('input[aria-label="Password"]').type('nightmare');
cy.get('button[type="submit"]').click();
- cy.get('.q-notification__message').should('have.text', 'You have successfully logged in');
+ cy.get('.q-notification__message').should(
+ 'have.text',
+ 'You have successfully logged in'
+ );
cy.url().should('contain', '/dashboard');
cy.get('#user').click();
cy.get('#logout').click();
diff --git a/test/cypress/integration/vnBreadcrumbs.spec.js b/test/cypress/integration/vnBreadcrumbs.spec.js
new file mode 100644
index 000000000..3c839c1c7
--- /dev/null
+++ b/test/cypress/integration/vnBreadcrumbs.spec.js
@@ -0,0 +1,21 @@
+///
+describe('VnBreadcrumbs', () => {
+ const firstCard = '.q-infinite-scroll > :nth-child(1)';
+ const lastBreadcrumb = '.q-breadcrumbs--last > .q-breadcrumbs__el';
+ beforeEach(() => {
+ cy.login('developer');
+ cy.visit('/');
+ });
+
+ it('should not be breadcrumbs', () => {
+ cy.get('.q-breadcrumbs').should('not.exist');
+ });
+
+ it('should get the correct breadcrumbs', () => {
+ cy.visit('#/customer/list');
+ cy.get('.q-breadcrumbs__el').should('have.length', 2);
+
+ cy.get(firstCard).click();
+ cy.get(`${lastBreadcrumb} > .q-icon`).should('have.text', 'launch');
+ });
+});
diff --git a/test/cypress/integration/workerList.spec.js b/test/cypress/integration/workerList.spec.js
index 79f2400bf..219633263 100644
--- a/test/cypress/integration/workerList.spec.js
+++ b/test/cypress/integration/workerList.spec.js
@@ -6,18 +6,21 @@ describe('WorkerList', () => {
});
it('should load workers', () => {
- cy.get('div[class="q-item__label text-h6"]').eq(0).should('have.text', 'Jessica Jones');
- cy.get('div[class="q-item__label text-h6"]').eq(1).should('have.text', 'Bruce Banner');
- cy.get('div[class="q-item__label text-h6"]').eq(2).should('have.text', 'Charles Xavier');
+ cy.get('.card-list-body > .list-items > :nth-child(2) > .value > span')
+ .eq(0)
+ .should('have.text', 'JessicaJones');
+ cy.get('.card-list-body > .list-items > :nth-child(2) > .value > span')
+ .eq(1)
+ .should('have.text', 'BruceBanner');
+ cy.get('.card-list-body > .list-items > :nth-child(2) > .value > span')
+ .eq(2)
+ .should('have.text', 'CharlesXavier');
});
it('should open the worker summary', () => {
- cy.get('div.text-h6')
- .parentsUntil('div.q-card')
- .find('div.q-card__actions')
- .find('button').first().click();
- cy.get('div[class="header bg-primary q-pa-sm q-mb-md"').should('have.text', '1110 - Jessica Jones');
- cy.get('div[class="q-item__label q-item__label--header text-h6"]').eq(0).should('have.text', 'Basic data');
- cy.get('div[class="q-item__label q-item__label--header text-h6"]').eq(1).should('have.text', 'User data');
+ cy.get('.card-list-body .actions .q-btn:nth-child(2)').eq(1).click();
+ cy.get('.summaryHeader div').should('have.text', '1109 - Bruce Banner');
+ cy.get('.summary .header').eq(0).invoke('text').should('include', 'Basic data');
+ cy.get('.summary .header').eq(1).should('have.text', 'User data');
});
});
diff --git a/test/cypress/integration/workerNotificationsManager.spec.js b/test/cypress/integration/workerNotificationsManager.spec.js
index 6c5aa21fb..175933277 100644
--- a/test/cypress/integration/workerNotificationsManager.spec.js
+++ b/test/cypress/integration/workerNotificationsManager.spec.js
@@ -1,27 +1,79 @@
describe('WorkerNotificationsManager', () => {
+ const salesPersonId = 18;
+ const developerId = 9;
+
+ const activeList = ':nth-child(1) > .q-list';
+ const availableList = ':nth-child(2) > .q-list';
+ const firstActiveNotification =
+ ':nth-child(1) > .q-list > :nth-child(1) > .q-item > .q-toggle > .q-toggle__inner';
+ const firstAvailableNotification =
+ ':nth-child(2) > .q-list > :nth-child(1) > .q-item > .q-toggle > .q-toggle__inner';
+
beforeEach(() => {
- const workerId = 1110;
cy.viewport(1280, 720);
- cy.login('salesBoss');
- cy.visit(`/#/worker/${workerId}/notifications`);
});
- it('should unsubscribe 2 notifications, check the unsubscription has been saved, subscribe to other one and should check the data has been saved', () => {
- cy.get('.q-chip').should('have.length', 3);
- cy.get('.q-toggle__thumb').eq(0).click();
- cy.get('.q-notification__message').should('have.text', 'Unsubscribed from the notification');
- cy.get('.q-chip > .q-icon').eq(0).click();
+ it('should throw an error if you try to change a notification that is not yours', () => {
+ cy.login('developer');
+ cy.visit(`/#/worker/${salesPersonId}/notifications`);
+ cy.get(firstAvailableNotification).click();
+ cy.notificationHas(
+ '.q-notification__message',
+ 'The notification subscription of this worker cant be modified'
+ );
+ });
- cy.reload();
+ it('should active a notification that is yours', () => {
+ cy.login('developer');
+ cy.visit(`/#/worker/${developerId}/notifications`);
+ cy.waitForElement(activeList);
+ cy.waitForElement(availableList);
- cy.get('.q-chip').should('have.length', 1);
- cy.get('.q-toggle__thumb').should('have.length', 3).eq(0).click();
- cy.get('.q-notification__message').should('have.text', 'Subscribed to the notification');
- cy.get('.q-toggle__thumb').should('have.length', 3).eq(1).click();
- cy.get('.q-notification__message').should('have.text', 'Subscribed to the notification');
+ cy.get(activeList)
+ .children()
+ .its('length')
+ .then((beforeSize) => {
+ cy.get(firstAvailableNotification).click();
+ cy.get(activeList)
+ .children()
+ .should('have.length', beforeSize + 1);
+ });
+ });
- cy.reload();
+ it('should deactivate a notification that is yours', () => {
+ cy.login('developer');
+ cy.visit(`/#/worker/${developerId}/notifications`);
+ cy.waitForElement(activeList);
+ cy.waitForElement(availableList);
- cy.get('.q-chip').should('have.length', 3);
+ cy.get(availableList)
+ .children()
+ .its('length')
+ .then((beforeSize) => {
+ cy.get(firstActiveNotification).click();
+ cy.get(availableList)
+ .children()
+ .should('have.length', beforeSize + 1);
+ });
+ });
+
+ it('should active a notification if you are their boss', () => {
+ cy.login('salesBoss');
+ cy.visit(`/#/worker/${salesPersonId}/notifications`);
+ cy.waitForElement(activeList);
+ cy.waitForElement(availableList);
+
+ cy.get(activeList)
+ .children()
+ .its('length')
+ .then((beforeSize) => {
+ cy.get(firstAvailableNotification).click();
+ cy.get(activeList)
+ .children()
+ .should('have.length', beforeSize + 1);
+
+ //Rollback
+ cy.get(firstActiveNotification).click();
+ });
});
});
diff --git a/test/cypress/integration/workerSummary.spec.js b/test/cypress/integration/workerSummary.spec.js
index cef26d061..7228b4b31 100644
--- a/test/cypress/integration/workerSummary.spec.js
+++ b/test/cypress/integration/workerSummary.spec.js
@@ -1,15 +1,15 @@
describe('WorkerSummary', () => {
beforeEach(() => {
- cy.viewport(1280, 720)
- cy.login('developer')
+ cy.viewport(1280, 720);
+ cy.login('developer');
cy.visit('/#/worker/19/summary');
});
it('should load worker summary', () => {
- cy.get('div[class="header bg-primary q-pa-sm q-mb-md"').should('have.text', '19 - salesBoss salesBoss');
- cy.get('div[class="q-item__label q-item__label--header text-h6"]').eq(0).should('have.text', 'Basic data');
- cy.get('div[class="q-item__label q-item__label--header text-h6"]').eq(1).should('have.text', 'User data');
- cy.get('div[class="q-item__section column q-item__section--main justify-center"]').eq(0).should('have.text', 'NamesalesBossNick');
+ cy.get('.summaryHeader > div').should('have.text', '19 - salesBoss salesBoss');
+ cy.get(':nth-child(1) > :nth-child(2) > .value > span').should(
+ 'have.text',
+ 'salesBossNick'
+ );
});
-
});
diff --git a/test/cypress/support/commands.js b/test/cypress/support/commands.js
index a3a61c423..d361eee1a 100755
--- a/test/cypress/support/commands.js
+++ b/test/cypress/support/commands.js
@@ -40,4 +40,95 @@ Cypress.Commands.add('login', (user) => {
window.localStorage.setItem('token', response.body.token);
});
});
+
+Cypress.Commands.add('waitForElement', (element) => {
+ cy.get(element, { timeout: 2000 }).should('be.visible');
+});
+
+Cypress.Commands.add('getValue', (selector) => {
+ cy.get(selector).then(($el) => {
+ if ($el.find('.q-checkbox__inner').length > 0) {
+ return cy.get(selector + '.q-checkbox__inner');
+ }
+ // Si es un QSelect
+ else 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'
+ );
+ } else {
+ // Puedes añadir un log o lanzar un error si el elemento no es reconocido
+ cy.log('Elemento no soportado');
+ }
+ });
+});
+
+// Fill Inputs
+Cypress.Commands.add('selectOption', (selector, option) => {
+ cy.get(selector).find('.q-select__dropdown-icon').click();
+ cy.get('.q-menu .q-item').contains(option).click();
+});
+
+Cypress.Commands.add('checkOption', (selector) => {
+ cy.wrap(selector).find('.q-checkbox__inner').click();
+});
+
+// Global buttons
+Cypress.Commands.add('saveCard', () => {
+ cy.get('[title="Save"]').click();
+});
+Cypress.Commands.add('resetCard', () => {
+ cy.get('[title="Reset"]').click();
+});
+Cypress.Commands.add('removeCard', () => {
+ cy.get('[title="Remove"]').click();
+});
+Cypress.Commands.add('addCard', () => {
+ cy.waitForElement('tbody');
+ cy.get('.q-page-sticky > div > .q-btn').click();
+});
+Cypress.Commands.add('clickConfirm', () => {
+ cy.waitForElement('.q-dialog__inner > .q-card');
+ cy.get('.q-card__actions > .q-btn--unelevated > .q-btn__content > .block').click();
+});
+
+Cypress.Commands.add('notificationHas', (selector, text) => {
+ cy.get(selector).should('have.text', text);
+});
+
+Cypress.Commands.add('fillRow', (rowSelector, data) => {
+ // Usar el selector proporcionado para obtener la fila deseada
+ cy.waitForElement('tbody');
+ cy.get(rowSelector).as('currentRow');
+
+ data.forEach((value, index) => {
+ if (value === null) return;
+ cy.get('@currentRow')
+ .find('td')
+ .eq(index)
+ .then((td) => {
+ if (td.find('.q-select__dropdown-icon').length) {
+ cy.selectOption(td, value);
+ }
+ if (td.find('.q-checkbox__inner').length && value) {
+ cy.checkOption(td);
+ }
+ });
+ });
+});
+
+Cypress.Commands.add('validateRow', (rowSelector, expectedValues) => {
+ cy.waitForElement('tbody');
+ cy.get(rowSelector).within(() => {
+ for (const [index, value] of expectedValues.entries()) {
+ cy.log('CHECKING ', index, value);
+ 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('have.value', value);
+ }
+ });
+});
// registerCommands();
diff --git a/test/vitest/__tests__/components/common/CrudModel.spec.js b/test/vitest/__tests__/components/common/CrudModel.spec.js
new file mode 100644
index 000000000..6ce93e59c
--- /dev/null
+++ b/test/vitest/__tests__/components/common/CrudModel.spec.js
@@ -0,0 +1,120 @@
+import { createWrapper } from 'app/test/vitest/helper';
+import CrudModel from 'components/CrudModel.vue';
+import { vi, afterEach, beforeEach, beforeAll, describe, expect, it } from 'vitest';
+
+describe('CrudModel', () => {
+ let vm;
+ beforeAll(() => {
+ vm = createWrapper(CrudModel, {
+ global: {
+ stubs: [
+ 'vnPaginate',
+ 'useState',
+ 'arrayData',
+ 'useStateStore',
+ 'vue-i18n',
+ ],
+ mocks: {
+ validate: vi.fn(),
+ },
+ },
+ propsData: {
+ dataRequired: {
+ fk: 1,
+ },
+ dataKey: 'crudModelKey',
+ model: 'crudModel',
+ url: 'crudModelUrl',
+ },
+ }).vm;
+ });
+
+ beforeEach(() => {
+ vm.fetch([]);
+ });
+
+ afterEach(() => {
+ vi.clearAllMocks();
+ });
+
+ describe('insert()', () => {
+ it('should new element in list with index 0 if formData not has data', () => {
+ vm.insert();
+
+ expect(vm.formData.length).toEqual(1);
+ expect(vm.formData[0].fk).toEqual(1);
+ expect(vm.formData[0].$index).toEqual(0);
+ });
+ });
+
+ describe('getChanges()', () => {
+ it('should return correct updates and creates', async () => {
+ vm.fetch([
+ { id: 1, name: 'New name one' },
+ { id: 2, name: 'New name two' },
+ { id: 3, name: 'Bruce Wayne' },
+ ]);
+
+ vm.originalData = [
+ { id: 1, name: 'Tony Starks' },
+ { id: 2, name: 'Jessica Jones' },
+ { id: 3, name: 'Bruce Wayne' },
+ ];
+
+ vm.insert();
+ const result = vm.getChanges();
+
+ const expected = {
+ creates: [
+ {
+ $index: 3,
+ fk: 1,
+ },
+ ],
+ updates: [
+ {
+ data: {
+ name: 'New name one',
+ },
+ where: {
+ id: 1,
+ },
+ },
+ {
+ data: {
+ name: 'New name two',
+ },
+ where: {
+ id: 2,
+ },
+ },
+ ],
+ };
+
+ expect(result).toEqual(expected);
+ });
+ });
+
+ describe('getDifferences()', () => {
+ it('should return the differences between two objects', async () => {
+ const obj1 = {
+ a: 1,
+ b: 2,
+ c: 3,
+ };
+ const obj2 = {
+ a: null,
+ b: 4,
+ d: 5,
+ };
+
+ const result = vm.getDifferences(obj1, obj2);
+
+ expect(result).toEqual({
+ a: null,
+ b: 4,
+ d: 5,
+ });
+ });
+ });
+});
diff --git a/test/vitest/__tests__/pages/Claims/ClaimLines.spec.js b/test/vitest/__tests__/pages/Claims/ClaimLines.spec.js
index dda59a98d..6dd6b89e6 100644
--- a/test/vitest/__tests__/pages/Claims/ClaimLines.spec.js
+++ b/test/vitest/__tests__/pages/Claims/ClaimLines.spec.js
@@ -5,7 +5,6 @@ import ClaimLines from 'pages/Claim/Card/ClaimLines.vue';
describe('ClaimLines', () => {
let vm;
-
beforeAll(() => {
vm = createWrapper(ClaimLines, {
global: {
@@ -13,25 +12,26 @@ describe('ClaimLines', () => {
mocks: {
fetch: vi.fn(),
},
- }
+ },
}).vm;
});
beforeEach(() => {
vm.claim = {
id: 1,
- ticketFk: 1
- }
+ ticketFk: 1,
+ };
vm.store.data = [
{
id: 1,
quantity: 10,
sale: {
- id: 1, discount: 0
- }
- }
- ]
- })
+ id: 1,
+ discount: 0,
+ },
+ },
+ ];
+ });
afterEach(() => {
vi.clearAllMocks();
@@ -42,13 +42,17 @@ describe('ClaimLines', () => {
vi.spyOn(axios, 'post').mockResolvedValue({ data: true });
vi.spyOn(vm.quasar, 'notify');
- const canceller = new AbortController()
+ const canceller = new AbortController();
await vm.updateDiscount({ saleFk: 1, discount: 5, canceller });
- const expectedData = { salesIds: [1], newDiscount: 5 }
- expect(axios.post).toHaveBeenCalledWith('Tickets/1/updateDiscount', expectedData, {
- signal: canceller.signal
- })
+ const expectedData = { salesIds: [1], newDiscount: 5 };
+ expect(axios.post).toHaveBeenCalledWith(
+ 'Tickets/1/updateDiscount',
+ expectedData,
+ {
+ signal: canceller.signal,
+ }
+ );
});
});
@@ -56,37 +60,14 @@ describe('ClaimLines', () => {
it('should make a POST request and then set the discount on the original row', async () => {
vi.spyOn(vm.quasar, 'notify');
-
vm.onUpdateDiscount({ discount: 5, rowIndex: 0 });
- const firstRow = vm.store.data[0]
+ const firstRow = vm.store.data[0];
- expect(firstRow.sale.discount).toEqual(5)
+ expect(firstRow.sale.discount).toEqual(5);
expect(vm.quasar.notify).toHaveBeenCalledWith(
expect.objectContaining({
message: 'Discount updated',
- type: 'positive'
- })
- );
- });
- });
-
- describe('remove()', () => {
- it('should make a POST request and then call to the quasar notify() method', async () => {
- vi.spyOn(axios, 'post').mockResolvedValue({ data: true });
- vi.spyOn(vm.quasar, 'notify');
-
- await vm.remove({
- rows: [
- { id: 1 }
- ]
- });
- const expectedData = { deletes: [1] }
-
- expect(axios.post).toHaveBeenCalledWith('ClaimBeginnings/crud', expectedData)
- expect(vm.quasar.notify).toHaveBeenCalledWith(
- expect.objectContaining({
- message: 'Row removed',
- type: 'positive'
+ type: 'positive',
})
);
});
diff --git a/test/vitest/__tests__/pages/Wagons/WagonCreate.spec.js b/test/vitest/__tests__/pages/Wagons/WagonCreate.spec.js
index bc6b92639..f195c183f 100644
--- a/test/vitest/__tests__/pages/Wagons/WagonCreate.spec.js
+++ b/test/vitest/__tests__/pages/Wagons/WagonCreate.spec.js
@@ -7,9 +7,11 @@ describe('WagonCreate', () => {
const entityId = 1;
beforeAll(() => {
- vmEdit = createWrapper(WagonCreate, {propsData: {
+ vmEdit = createWrapper(WagonCreate, {
+ propsData: {
id: entityId,
- }}).vm;
+ },
+ }).vm;
vmCreate = createWrapper(WagonCreate).vm;
});
@@ -29,9 +31,7 @@ describe('WagonCreate', () => {
await vmCreate.onSubmit();
- expect(axios.patch).toHaveBeenCalledWith(
- `Wagons`, vmCreate.wagon
- );
+ expect(axios.patch).toHaveBeenCalledWith(`Wagons`, vmCreate.wagon);
});
it('should update a wagon', async () => {
@@ -46,9 +46,7 @@ describe('WagonCreate', () => {
await vmEdit.onSubmit();
- expect(axios.patch).toHaveBeenCalledWith(
- `Wagons`, vmEdit.wagon
- );
+ expect(axios.patch).toHaveBeenCalledWith(`Wagons`, vmEdit.wagon);
});
});
@@ -88,16 +86,12 @@ describe('WagonCreate', () => {
describe('fetch()', () => {
it('should fetch data', async () => {
- vi.spyOn(axios, 'get').mockResolvedValue({ data: true });
+ vi.spyOn(axios, 'get').mockResolvedValue({ data: [] });
await vmEdit.fetch();
- expect(axios.get).toHaveBeenCalledWith(
- `WagonTypes`
- );
- expect(axios.get).toHaveBeenCalledWith(
- `Wagons/${entityId}`
- );
+ expect(axios.get).toHaveBeenCalledWith(`WagonTypes`);
+ expect(axios.get).toHaveBeenCalledWith(`Wagons/${entityId}`);
});
});
});
diff --git a/test/vitest/__tests__/pages/Worker/WorkerNotificationsManager.spec.js b/test/vitest/__tests__/pages/Worker/WorkerNotificationsManager.spec.js
index 744346078..35ce91e61 100644
--- a/test/vitest/__tests__/pages/Worker/WorkerNotificationsManager.spec.js
+++ b/test/vitest/__tests__/pages/Worker/WorkerNotificationsManager.spec.js
@@ -1,15 +1,15 @@
import { vi, describe, expect, it, beforeAll, afterEach } from 'vitest';
-import { createWrapper, axios } from 'app/test/vitest/helper';
+import { createWrapper } from 'app/test/vitest/helper';
import WorkerNotificationsManager from 'src/pages/Worker/Card/WorkerNotificationsManager.vue';
+import { ref } from 'vue';
describe('WorkerNotificationsManager', () => {
let vm;
- const entityId = 1110;
beforeAll(() => {
vm = createWrapper(WorkerNotificationsManager, {
- propsData: {
- id: entityId,
+ global: {
+ stubs: ['CrudModel'],
},
}).vm;
});
@@ -18,83 +18,16 @@ describe('WorkerNotificationsManager', () => {
vi.clearAllMocks();
});
- describe('fetch()', () => {
- it('should fetch notification subscriptions and role mappings', async () => {
- vi.spyOn(axios, 'get')
- .mockResolvedValueOnce({
- data: [
- {
- id: 1,
- name: 'Name 1',
- description: 'Description 1',
- notificationFk: 1,
- active: true
- },
- ],
- });
- await vm.fetch();
+ describe('swapEntry()', () => {
+ it('should swap notification', async () => {
+ const from = ref(new Map());
+ const to = ref(new Map());
+ from.value.set(1, { notificationFk: 1 });
+ to.value.set(2, { notificationFk: 2 });
- expect(axios.get).toHaveBeenCalledWith(`NotificationSubscriptions/${entityId}/getList`);
- expect(vm.notifications).toEqual([
- {
- id: 1,
- notificationFk: 1,
- name: 'Name 1',
- description: 'Description 1',
- active: true,
- },
- ]);
- });
- });
-
- describe('disableNotification()', () => {
- it('should disable the notification', async () => {
- vi.spyOn(axios, 'delete').mockResolvedValue({ data: { count: 1 } });
- vi.spyOn(vm.quasar, 'notify');
- const subscriptionId = 1;
- vm.notifications = [{ id: 1, active: true }];
-
- await vm.disableNotification(vm.notifications[0]);
-
- expect(axios.delete).toHaveBeenCalledWith(
- `NotificationSubscriptions/${subscriptionId}`
- );
- expect(vm.notifications[0].id).toBeNull();
- expect(vm.notifications[0].id).toBeFalsy();
- expect(vm.quasar.notify).toHaveBeenCalledWith(
- expect.objectContaining({ type: 'positive' })
- );
- });
- });
-
- describe('toggleNotification()', () => {
- it('should activate the notification', async () => {
- vi.spyOn(axios, 'post').mockResolvedValue({
- data: { id: 1, notificationFk: 1 },
- });
- vm.notifications = [{ id: null, active: true, notificationFk: 1 }];
-
- await vm.toggleNotification(vm.notifications[0]);
-
- expect(axios.post).toHaveBeenCalledWith('NotificationSubscriptions', {
- notificationFk: 1,
- userFk: entityId,
- });
- expect(vm.notifications[0].id).toBe(1);
- expect(vm.notifications[0].active).toBeTruthy();
- expect(vm.quasar.notify).toHaveBeenCalledWith(
- expect.objectContaining({ type: 'positive' })
- );
- });
-
- it('should disable the notification', async () => {
- vi.spyOn(vm, 'disableNotification');
- vm.notifications = [{ id: 1, active: false, notificationFk: 1 }];
-
- await vm.toggleNotification(vm.notifications[0]);
-
- expect(vm.notifications[0].id).toBe(null);
- expect(vm.notifications[0].active).toBeFalsy();
+ await vm.swapEntry(from.value, to.value, 1);
+ expect(to.value.size).toBe(2);
+ expect(from.value.size).toBe(0);
});
});
});
diff --git a/test/vitest/helper.js b/test/vitest/helper.js
index 8a6fb1415..7cc2bdfa5 100644
--- a/test/vitest/helper.js
+++ b/test/vitest/helper.js
@@ -5,6 +5,7 @@ import { vi } from 'vitest';
import { i18n } from 'src/boot/i18n';
import { Notify, Dialog } from 'quasar';
import axios from 'axios';
+import * as useValidator from 'src/composables/useValidator';
installQuasarPlugin({
plugins: {
@@ -34,6 +35,10 @@ vi.mock('vue-router', () => ({
}),
}));
+vi.spyOn(useValidator, 'useValidator').mockImplementation(() => {
+ return { validate: vi.fn(), fetch: vi.fn() };
+});
+
class FormDataMock {
append() {
vi.fn();
@@ -58,12 +63,17 @@ class FormDataMock {
}
}
global.FormData = FormDataMock;
+global.URL = class URL {};
export function createWrapper(component, options) {
const defaultOptions = {
global: {
plugins: [i18n, pinia],
},
+ mocks: {
+ t: (tKey) => tKey,
+ $t: (tKey) => tKey,
+ },
};
const mountOptions = Object.assign({}, defaultOptions);