diff --git a/src/components/FetchData.vue b/src/components/FetchData.vue index 4aaa0f64c..4324b6984 100644 --- a/src/components/FetchData.vue +++ b/src/components/FetchData.vue @@ -39,16 +39,20 @@ onMounted(async () => { }); async function fetch() { - const filter = Object.assign({}, $props.filter); - if ($props.where) filter.where = $props.where; - if ($props.sortBy) filter.order = $props.sortBy; - if ($props.limit) filter.limit = $props.limit; + try { + const filter = Object.assign({}, $props.filter); + if ($props.where) filter.where = $props.where; + if ($props.sortBy) filter.order = $props.sortBy; + if ($props.limit) filter.limit = $props.limit; - const { data } = await axios.get($props.url, { - params: { filter }, - }); + const { data } = await axios.get($props.url, { + params: { filter }, + }); - emit('onFetch', data); + emit('onFetch', data); + } catch (e) { + // + } } const render = () => { diff --git a/src/components/common/VnLog.vue b/src/components/common/VnLog.vue new file mode 100644 index 000000000..1213c8bbc --- /dev/null +++ b/src/components/common/VnLog.vue @@ -0,0 +1,208 @@ + + + + + +en: + actions: + insert: Creates + update: Updates + delete: Deletes + models: + Claim: Claim + ClaimDms: Document + ClaimBeginning: Claimed Sales + ClaimObservation: Observation + properties: + id: ID + claimFk: Claim ID + saleFk: Sale ID + quantity: Quantity + observation: Observation + ticketCreated: Created + created: Created + isChargedToMana: Charged to mana + hasToPickUp: Has to pick Up + dmsFk: Document ID + text: Description + claimStateFk: Claim State + workerFk: Worker + clientFk: Customer + rma: RMA + responsibility: Responsibility + packages: Packages +es: + Audit logs: Registros de auditoría + Property: Propiedad + Before: Antes + After: Después + Yes: Si + Nothing: Nada + actions: + insert: Crea + update: Actualiza + delete: Elimina + models: + Claim: Reclamación + ClaimDms: Documento + ClaimBeginning: Línea reclamada + ClaimObservation: Observación + properties: + id: ID + claimFk: ID reclamación + saleFk: ID linea de venta + quantity: Cantidad + observation: Observación + ticketCreated: Creado + created: Creado + isChargedToMana: Cargado a maná + hasToPickUp: Se debe recoger + dmsFk: ID documento + text: Descripción + claimStateFk: Estado de la reclamación + workerFk: Trabajador + clientFk: Cliente + rma: RMA + responsibility: Responsabilidad + packages: Bultos + diff --git a/src/pages/Claim/Card/ClaimLogFilter.vue b/src/components/common/VnLogFilter.vue similarity index 100% rename from src/pages/Claim/Card/ClaimLogFilter.vue rename to src/components/common/VnLogFilter.vue diff --git a/src/pages/Claim/Card/ClaimLog.vue b/src/pages/Claim/Card/ClaimLog.vue index a5af8c72a..6cf941688 100644 --- a/src/pages/Claim/Card/ClaimLog.vue +++ b/src/pages/Claim/Card/ClaimLog.vue @@ -1,201 +1,6 @@ - - - -en: - actions: - insert: Creates - update: Updates - delete: Deletes - models: - Claim: Claim - ClaimDms: Document - ClaimBeginning: Claimed Sales - ClaimObservation: Observation - properties: - id: ID - claimFk: Claim ID - saleFk: Sale ID - quantity: Quantity - observation: Observation - ticketCreated: Created - created: Created - isChargedToMana: Charged to mana - hasToPickUp: Has to pick Up - dmsFk: Document ID - text: Description - claimStateFk: Claim State - workerFk: Worker - clientFk: Customer - rma: RMA - responsibility: Responsibility - packages: Packages -es: - Audit logs: Registros de auditoría - Property: Propiedad - Before: Antes - After: Después - Yes: Si - Nothing: Nada - actions: - insert: Crea - update: Actualiza - delete: Elimina - models: - Claim: Reclamación - ClaimDms: Documento - ClaimBeginning: Línea reclamada - ClaimObservation: Observación - properties: - id: ID - claimFk: ID reclamación - saleFk: ID linea de venta - quantity: Cantidad - observation: Observación - ticketCreated: Creado - created: Creado - isChargedToMana: Cargado a maná - hasToPickUp: Se debe recoger - dmsFk: ID documento - text: Descripción - claimStateFk: Estado de la reclamación - workerFk: Trabajador - clientFk: Cliente - rma: RMA - responsibility: Responsabilidad - packages: Bultos - diff --git a/test/vitest/__tests__/components/common/VnLog.spec.js b/test/vitest/__tests__/components/common/VnLog.spec.js new file mode 100644 index 000000000..6787b6d51 --- /dev/null +++ b/test/vitest/__tests__/components/common/VnLog.spec.js @@ -0,0 +1,75 @@ +import { vi, describe, expect, it, beforeAll, afterEach } from 'vitest'; +import { createWrapper } from 'app/test/vitest/helper'; +import VnLog from 'src/components/common/VnLog.vue'; + +describe('VnLog', () => { + let vm; + beforeAll(() => { + vm = createWrapper(VnLog, { + global: { + stubs: ['FetchData', 'VnPaginate'], + mocks: { + fetch: vi.fn(), + }, + }, + propsData: { + model: "Claim", + }, + }).vm; + }); + + afterEach(() => { + vi.clearAllMocks(); + }); + + describe('formatValue()', () => { + it('should return Yes if has a true boolean', async () => { + const result = vm.formatValue(true); + + expect(result).toEqual('Yes'); + }); + it('should return No if has a true boolean', async () => { + const result = vm.formatValue(false); + + expect(result).toEqual('No'); + }); + it('should return Nothing if has no params', async () => { + const result = vm.formatValue(); + + expect(result).toEqual('Nothing'); + }); + it('should return a string from a string value', async () => { + const result = vm.formatValue('Something'); + + expect(result).toEqual(`"Something"`); + }); + it('should call to format a date', async () => { + vi.mock('src/filters', () => ({ + toDate: ()=>{ + return "Date formatted" + }, + })); + + const result = vm.formatValue('01-01-1970'); + expect(result).toEqual("Date formatted"); + }); + }); + + describe('actionColor()', () => { + it('should return positive if insert', async () => { + const result = vm.actionColor('insert'); + + expect(result).toEqual('positive'); + }); + it('should return positive if update', async () => { + const result = vm.actionColor('update'); + + expect(result).toEqual('positive'); + }); + it('should return negative if delete', async () => { + const result = vm.actionColor('delete'); + + expect(result).toEqual('negative'); + }); + }); +});