@@ -278,8 +291,8 @@ en:
search: Contains
clientFk: Customer
orderFK: Order
- dateFrom: From
- dateTo: To
+ from: From
+ to: To
salesPersonFk: Salesperson
stateFk: State
refFk: Invoice Ref.
@@ -295,8 +308,8 @@ es:
search: Contiene
clientFk: Cliente
orderFK: Pedido
- dateFrom: Desde
- dateTo: Hasta
+ from: Desde
+ to: Hasta
salesPersonFk: Comercial
stateFk: Estado
refFk: Ref. Factura
diff --git a/src/pages/Ticket/TicketList.vue b/src/pages/Ticket/TicketList.vue
index 7b5598048..b8cf78181 100644
--- a/src/pages/Ticket/TicketList.vue
+++ b/src/pages/Ticket/TicketList.vue
@@ -5,7 +5,7 @@ import { useQuasar } from 'quasar';
import { useRouter } from 'vue-router';
import { useStateStore } from 'stores/useStateStore';
import Paginate from 'src/components/PaginateData.vue';
-import { toDate, toCurrency } from 'src/filters/index';
+import { toDate, toDateString, toCurrency } from 'src/filters/index';
import TicketSummaryDialog from './Card/TicketSummaryDialog.vue';
import VnSearchbar from 'src/components/ui/VnSearchbar.vue';
import TicketFilter from './TicketFilter.vue';
@@ -46,6 +46,15 @@ const filter = {
],
};
+const from = Date.vnNew();
+const to = Date.vnNew();
+to.setDate(to.getDate() + 1);
+
+const userParams = {
+ from: toDateString(from),
+ to: toDateString(to),
+};
+
function stateColor(row) {
if (row.alertLevelCode === 'OK') return 'green';
if (row.alertLevelCode === 'FREE') return 'blue-3';
@@ -104,6 +113,7 @@ function viewSummary(id) {
data-key="TicketList"
url="Tickets/filter"
:filter="filter"
+ :user-params="userParams"
order="id DESC"
auto-load
>
@@ -123,9 +133,9 @@ function viewSummary(id) {
{{ t('ticket.list.nickname') }}
- {{
- row.nickname
- }}
+
+ {{ row.nickname }}
+
diff --git a/src/pages/Worker/Card/WorkerCard.vue b/src/pages/Worker/Card/WorkerCard.vue
index 02c472d19..65d863143 100644
--- a/src/pages/Worker/Card/WorkerCard.vue
+++ b/src/pages/Worker/Card/WorkerCard.vue
@@ -12,6 +12,7 @@ const { t } = useI18n();
diff --git a/src/router/index.js b/src/router/index.js
index e69cc5e11..4eeee8fbb 100644
--- a/src/router/index.js
+++ b/src/router/index.js
@@ -1,5 +1,10 @@
import { route } from 'quasar/wrappers';
-import { createRouter, createMemoryHistory, createWebHistory, createWebHashHistory } from 'vue-router';
+import {
+ createRouter,
+ createMemoryHistory,
+ createWebHistory,
+ createWebHashHistory,
+} from 'vue-router';
import routes from './routes';
import { i18n } from 'src/boot/i18n';
import { useState } from 'src/composables/useState';
@@ -12,6 +17,22 @@ const session = useSession();
const role = useRole();
const { t } = i18n.global;
+const createHistory = process.env.SERVER
+ ? createMemoryHistory
+ : process.env.VUE_ROUTER_MODE === 'history'
+ ? createWebHistory
+ : createWebHashHistory;
+
+const Router = createRouter({
+ scrollBehavior: () => ({ left: 0, top: 0 }),
+ routes,
+
+ // Leave this as is and make changes in quasar.conf.js instead!
+ // quasar.conf.js -> build -> vueRouterMode
+ // quasar.conf.js -> build -> publicPath
+ history: createHistory(process.env.VUE_ROUTER_BASE),
+});
+
/*
* If not building with SSR mode, you can
* directly export the Router instantiation;
@@ -20,24 +41,8 @@ const { t } = i18n.global;
* async/await or return a Promise which resolves
* with the Router instance.
*/
-
+export { Router };
export default route(function (/* { store, ssrContext } */) {
- const createHistory = process.env.SERVER
- ? createMemoryHistory
- : process.env.VUE_ROUTER_MODE === 'history'
- ? createWebHistory
- : createWebHashHistory;
-
- const Router = createRouter({
- scrollBehavior: () => ({ left: 0, top: 0 }),
- routes,
-
- // Leave this as is and make changes in quasar.conf.js instead!
- // quasar.conf.js -> build -> vueRouterMode
- // quasar.conf.js -> build -> publicPath
- history: createHistory(process.env.VUE_ROUTER_BASE),
- });
-
Router.beforeEach(async (to, from, next) => {
const { isLoggedIn } = session;
diff --git a/test/vitest/__tests__/App.spec.js b/test/vitest/__tests__/App.spec.js
deleted file mode 100644
index 5013ca0b8..000000000
--- a/test/vitest/__tests__/App.spec.js
+++ /dev/null
@@ -1,70 +0,0 @@
-import { vi, describe, expect, it, beforeAll } from 'vitest';
-import { createWrapper } from 'app/test/vitest/helper';
-import App from 'src/App.vue';
-import { useSession } from 'src/composables/useSession';
-
-const mockLoggedIn = vi.fn();
-const mockDestroy = vi.fn();
-const session = useSession();
-
-vi.mock('src/composables/useSession', () => ({
- useSession: () => ({
- isLoggedIn: mockLoggedIn,
- destroy: mockDestroy,
- }),
-}));
-
-describe('App', () => {
- let vm;
-
- beforeAll(() => {
- const options = {
- global: {
- stubs: ['router-view'],
- },
- };
- vm = createWrapper(App, options).vm;
- });
-
- it('should return a login error message', async () => {
- vi.spyOn(vm.quasar, 'notify');
-
- session.isLoggedIn.mockReturnValue(false);
-
- const response = {
- response: {
- status: 401,
- },
- };
-
- expect(vm.responseError(response)).rejects.toEqual(expect.objectContaining(response));
- expect(vm.quasar.notify).toHaveBeenCalledWith(
- expect.objectContaining({
- message: 'Invalid username or password',
- type: 'negative',
- })
- );
- });
-
- it('should return an unauthorized error message', async () => {
- vi.spyOn(vm.quasar, 'notify');
-
- session.isLoggedIn.mockReturnValue(true);
-
- const response = {
- response: {
- status: 401,
- },
- };
-
- expect(vm.responseError(response)).rejects.toEqual(expect.objectContaining(response));
- expect(vm.quasar.notify).toHaveBeenCalledWith(
- expect.objectContaining({
- message: 'Access denied',
- type: 'negative',
- })
- );
-
- expect(session.destroy).toHaveBeenCalled();
- });
-});
diff --git a/test/vitest/__tests__/boot/axios.spec.js b/test/vitest/__tests__/boot/axios.spec.js
new file mode 100644
index 000000000..a95c57fba
--- /dev/null
+++ b/test/vitest/__tests__/boot/axios.spec.js
@@ -0,0 +1,81 @@
+import { vi, describe, expect, it } from 'vitest';
+import { onRequest, onResponseError } from 'src/boot/axios';
+import { Notify } from 'quasar'
+
+vi.mock('src/composables/useSession', () => ({
+ useSession: () => ({
+ getToken: () => 'DEFAULT_TOKEN'
+ }),
+}));
+
+vi.mock('src/router', () => ({}));
+
+describe('Axios boot', () => {
+
+ describe('onRequest()', async () => {
+ it('should set the "Authorization" property on the headers', async () => {
+ const config = { headers: {} };
+
+ const resultConfig = onRequest(config);
+
+ expect(resultConfig).toEqual(expect.objectContaining({
+ headers: {
+ Authorization: 'DEFAULT_TOKEN'
+ }
+ }));
+ });
+ })
+
+ describe('onResponseError()', async () => {
+ it('should call to the Notify plugin with a message error for an status code "500"', async () => {
+ Notify.create = vi.fn()
+
+ const error = {
+ response: {
+ status: 500
+ }
+ };
+
+ const result = onResponseError(error);
+
+
+ expect(result).rejects.toEqual(
+ expect.objectContaining(error)
+ );
+ expect(Notify.create).toHaveBeenCalledWith(
+ expect.objectContaining({
+ message: 'An internal server error has ocurred',
+ type: 'negative',
+ })
+ );
+ });
+
+ it('should call to the Notify plugin with a message from the response property', async () => {
+ Notify.create = vi.fn()
+
+ const error = {
+ response: {
+ status: 401,
+ data: {
+ error: {
+ message: 'Invalid user or password'
+ }
+ }
+ }
+ };
+
+ const result = onResponseError(error);
+
+
+ expect(result).rejects.toEqual(
+ expect.objectContaining(error)
+ );
+ expect(Notify.create).toHaveBeenCalledWith(
+ expect.objectContaining({
+ message: 'Invalid user or password',
+ type: 'negative',
+ })
+ );
+ });
+ })
+});
diff --git a/test/vitest/__tests__/pages/Claims/ClaimDescriptorMenu.spec.js b/test/vitest/__tests__/pages/Claims/ClaimDescriptorMenu.spec.js
index a1c3a38ed..b208f1704 100644
--- a/test/vitest/__tests__/pages/Claims/ClaimDescriptorMenu.spec.js
+++ b/test/vitest/__tests__/pages/Claims/ClaimDescriptorMenu.spec.js
@@ -18,12 +18,12 @@ describe('ClaimDescriptorMenu', () => {
vi.clearAllMocks();
});
- describe('deleteClaim()', () => {
+ describe('remove()', () => {
it('should delete the claim', async () => {
vi.spyOn(axios, 'delete').mockResolvedValue({ data: true });
vi.spyOn(vm.quasar, 'notify');
- await vm.deleteClaim();
+ await vm.remove();
expect(vm.quasar.notify).toHaveBeenCalledWith(
expect.objectContaining({ type: 'positive' })
diff --git a/test/vitest/__tests__/pages/Claims/ClaimPhoto.spec.js b/test/vitest/__tests__/pages/Claims/ClaimPhoto.spec.js
index 21c7865eb..c38852af1 100644
--- a/test/vitest/__tests__/pages/Claims/ClaimPhoto.spec.js
+++ b/test/vitest/__tests__/pages/Claims/ClaimPhoto.spec.js
@@ -21,7 +21,7 @@ describe('ClaimPhoto', () => {
beforeAll(() => {
vm = createWrapper(ClaimPhoto, {
global: {
- stubs: ['FetchData', 'TeleportSlot', 'vue-i18n'],
+ stubs: ['FetchData', 'vue-i18n'],
mocks: {
fetch: vi.fn(),
},
@@ -38,7 +38,7 @@ describe('ClaimPhoto', () => {
vi.spyOn(axios, 'post').mockResolvedValue({ data: true });
vi.spyOn(vm.quasar, 'notify');
- await vm.deleteDms(0);
+ await vm.deleteDms({ index: 0 });
expect(axios.post).toHaveBeenCalledWith(
`ClaimDms/${claimMock.claimDms[0].dmsFk}/removeFile`
@@ -46,7 +46,6 @@ describe('ClaimPhoto', () => {
expect(vm.quasar.notify).toHaveBeenCalledWith(
expect.objectContaining({ type: 'positive' })
);
- expect(vm.claimDms).toEqual([]);
});
});
@@ -59,8 +58,10 @@ describe('ClaimPhoto', () => {
expect(vm.quasar.dialog).toHaveBeenCalledWith(
expect.objectContaining({
componentProps: {
- message: 'This file will be deleted',
+ title: 'This file will be deleted',
icon: 'delete',
+ data: { index: 1 },
+ promise: vm.deleteDms
},
})
);
diff --git a/test/vitest/__tests__/pages/Login/Login.spec.js b/test/vitest/__tests__/pages/Login/Login.spec.js
index 0a4de730d..fadfc898f 100644
--- a/test/vitest/__tests__/pages/Login/Login.spec.js
+++ b/test/vitest/__tests__/pages/Login/Login.spec.js
@@ -23,7 +23,9 @@ describe('Login', () => {
},
};
vi.spyOn(axios, 'post').mockResolvedValue({ data: { token: 'token' } });
- vi.spyOn(axios, 'get').mockResolvedValue({ data: { roles: [], user: expectedUser } });
+ vi.spyOn(axios, 'get').mockResolvedValue({
+ data: { roles: [], user: expectedUser },
+ });
vi.spyOn(vm.quasar, 'notify');
expect(vm.session.getToken()).toEqual('');
@@ -31,7 +33,9 @@ describe('Login', () => {
await vm.onSubmit();
expect(vm.session.getToken()).toEqual('token');
- expect(vm.quasar.notify).toHaveBeenCalledWith(expect.objectContaining({ type: 'positive' }));
+ expect(vm.quasar.notify).toHaveBeenCalledWith(
+ expect.objectContaining({ type: 'positive' })
+ );
vm.session.destroy();
});