diff --git a/CHANGELOG.md b/CHANGELOG.md index e110e4cd6..6908d764a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,167 @@ +# Version 24.52 - 2024-01-07 + +### Added 🆕 + +- chore: refs #8197 remove console log by:alexm +- chore: refs #8197 replace name by:alexm +- chore: refs #8197 unnecessary file by:alexm +- feat: #8110 apply mixin in quasar components by:Javier Segarra +- feat(Account & AccountRole): refs #8197 add VnCardMain by:alexm +- feat: addDptoLink by:Jtubau +- feat: added restore ticket function in ticket descriptor menu by:Jon +- feat: add support service wip by:jorgep +- feat: focus menu searchbar by:jorgep +- feat: make additional data object by:jorgep +- feat: message to grant access by:jorgep +- feat: refs #6583 add default param by:jorgep +- feat: refs #6583 add destination opt filter by:jorgep +- feat: refs #6583 add icon by:jorgep +- feat: refs #6583 add locale by:jorgep +- feat: refs #7072 added test to computed fn total by:Jtubau +- feat: refs #7235 update invoice out global form to fetch config based on serial type by:jgallego +- feat: refs #7301 add exclude inventory supplier from list by:pablone +- feat: refs #7301 enhance VnDateBadge styling and improve ItemLastEntries component by:pablone +- feat: refs #7882 Added distribution point by:guillermo +- feat: refs #7882 Added longitude & latitude by:guillermo +- feat: refs #7936 add autocomplete on tab fn by:jorgep +- feat: refs #7936 add company filter by:jorgep +- feat: refs #7936 add currency check before fetching by:jorgep +- feat: refs #7936 add dueDated field by:jorgep +- feat: refs #7936 add number validation to VnInputNumber & new daysAgo filter in InvoiceInFilter by:jorgep +- feat: refs #7936 add optionCaption by:jorgep +- feat: refs #7936 add row click navigation to InvoiceInSerial by:jorgep +- feat: refs #7936 add unit tests by:jorgep +- feat: refs #7936 add useAccountShortToStandard composable by:jorgep +- feat: refs #7936 calculate exchange & update taxable base by:jorgep +- feat: refs #7936 enhance downloadFile function to support opening in a new tab by:jorgep +- feat: refs #7936 enhance getTotal fn & add unit tests by:jorgep +- feat: refs #7936 enhance vn-select by:jorgep +- feat: refs #7936 improve optionLabel logic in InvoiceInVat component for better handling of numeric values by:jorgep +- feat: refs #7936 limit decimal places by:jorgep +- feat: refs #7936 make fields required by:jorgep +- feat: refs #7936 show country code & isVies fields by:jorgep +- feat: refs #7936 show id & value by:jorgep +- feat: refs #7936 simplify optionLabel wip by:jorgep +- feat: refs #7936 update 'isVies' label to use global translation key by:jorgep +- feat: refs #7936 update option labels in InvoiceIn components for better clarity by:jorgep +- feat: refs #7936 use default invoice data by:jorgep +- feat: refs #8001 change request by:robert +- feat: refs #8001 ticketExpeditionGrafana by:robert +- feat: refs #8194 created VnSelectWorker component and use it in Lilium by:Jon +- feat: refs #8197 better leftMenu and VnCardMain improvements by:alexm +- feat: refs #8197 default leftMenu by:alexm +- feat: refs #8197 default sectionName by:alexm +- feat: refs #8197 keepData in VnSection by:alexm +- feat: refs #8197 vnTableFilter by:alexm +- feat: refs #8197 working rightMenu by:alexm +- feat: remove re-fetch when add element by:Javier Segarra +- feat: remove search after category by:Javier Segarra +- feat: requested changes in item module by:Jon +- feat: update quantity by:Javier Segarra +- feat(VnPaginate): refs #8197 hold data when change to Card by:alexm + +### Changed 📦 + +- perf: #6896 REMOVE COMMENTS by:Javier Segarra +- perf: qFormMixin by:Javier Segarra +- perf: qFormMixin improvement by:Javier Segarra +- perf: refs #8194 select worker component by:Jon +- perf: refs #8197 perf by:alexm +- perf: remove comments by:Javier Segarra +- perf: remove unused variables (origin/warmfix_noUsedVars) by:Javier Segarra +- refactor: added again search emit by:Jon +- refactor: add useCau composable by:jorgep +- refactor: deleted log by:Jon +- refactor: deleted onUnmounted code by:Jon +- refactor: deleted useless hidden tag by:Jon +- refactor: deleted warnings and corrected itemTag by:Jon +- refactor: drop logic by:jorgep +- refactor: ignore params when searching by id on searchbar (origin/VnSearchbar-SearchRemoveParams) by:Jon +- refactor: log error by:Jon +- refactor: refs #7936 locale by:jorgep +- refactor: refs #7936 simplify getTotal fn by:jorgep +- refactor: refs #7936 update label capitalization and replace invoice type options by:jorgep +- refactor: refs #8194 deleted unnecessary label by:Jon +- refactor: refs #8194 modified select worker template by:Jon +- refactor: refs #8194 modified select worker to allow no one filter from monitor ticket by:Jon +- refactor: refs #8194 moved translation to the correct place by:Jon +- refactor: refs #8194 requested changes by:Jon +- refactor: refs #8194 structure changes in component and related files by:Jon +- refactor: refs #8197 adapt AccountAcls to VnCardMain by:alexm +- refactor: refs #8197 adapt AccountAlias by:alexm +- refactor: refs #8197 adapt Ticket to VnCardMain by:alexm +- refactor: refs #8197 backward compatible (8197-VnCardMain_backwardCompatibility) by:alexm +- refactor: refs #8197 rename VnSectionMain to VnModule and VnCardMain to VnSection by:alexm +- refactor: refs #8288 changed invoice out spanish translation by:provira +- refactor: use locale keys by:jorgep +- refactor: use teleport to avoid qdrawer overlapping by:Jon +- refactor: use VnSelectWorker by:Jon + +### Fixed 🛠️ + +- fix: account by:carlossa +- fix: account create by:carlossa +- fix: accountList create by:carlossa +- fix(AccountList): use $refs by:alexm +- fix: add data-key by:alexm +- fix: addLocales by:Jtubau +- fix: dated field by:Jon +- fix: e2e by:jorgep +- fix: fix department filter by:carlossa +- fix: fixed translations by:Javier Segarra +- fix: fixed translations by:provira +- fix: get total from api by:Javier Segarra +- fix: handle non-object options by:jorgep +- fix: monitorPayMethodFilter by:carlossa +- fix: orderBy priority by:Javier Segarra +- fix: prevent null by:jorgep +- fix: redirection vnTable VnTableFilter by:alexm +- fix: refs #6389 fix filter trad by:carlossa +- fix: refs #6389 fix front, filters, itp by:carlossa +- fix: refs #6389 front add packing filter by:carlossa +- fix: refs #6389 front by:carlossa +- fix: refs #6389 front filters by:carlossa +- fix: refs #6389 ipt by:carlossa +- fix: refs #6389 packing by:carlossa +- fix: refs #6583 update checkbox for filtering by destination in TicketAdvanceFilter by:jorgep +- fix: refs #7031 add test e2e by:carlossa +- fix: refs #7031 fix zoneTest by:carlossa +- fix: refs #7301 unnecessary console logs from ItemLastEntries.vue by:pablone +- fix: refs #7936 changes by:jorgep +- fix: refs #7936 decimal places & locale by:jorgep +- fix: refs #7936 descriptor & dueday by:jorgep +- fix: refs #7936 exclude disabled els on tab by:jorgep +- fix: refs #7936 format tax calculation to two decimal places by:jorgep +- fix: refs #7936 improve error handling by:jorgep +- fix: refs #7936 redirection by:jorgep +- fix: refs #7936 rollback by:jorgep +- fix: refs #7936 serial by:jorgep +- fix: refs #7936 tabulation wip by:jorgep +- fix: refs #7936 test by:jorgep +- fix: refs #8114 clean by:carlossa +- fix: refs #8114 fix agencyList by:carlossa +- fix: refs #8114 fix lifeCycle hooks by:carlossa +- fix: refs #8114 fix pr by:carlossa +- fix: refs #8114 fix removeAddress by:carlossa +- fix: refs #8114 orderList by:carlossa +- fix: refs #8114 remove logs by:carlossa +- fix: refs #8197 mapKey (origin/8197-perf_vnTableInside, 8197-perf_vnTableInside) by:alexm +- fix: refs #8197 redirection (8197-perf_redirection) by:alexm +- fix: refs #8197 staticParams and redirect by:alexm +- fix: refs #8197 vnPaginate onFetch emit by:alexm +- fix: refs #8197 vnPaginate when change :id by:alexm +- fix: refs #8197 vnTableFilter in vnTable by:alexm +- fix: refs #8315 ticketBoxing test by:alexm +- fix: remove url by:carlossa +- fix: rollback by:jorgep +- fix: test by:jorgep +- fix(VnDmsList): refs #8197 add mapKey by:alexm +- revert: refs #8197 arrayData changes by:alexm +- test: refs #8197 fix e2e by:alexm +- test: refs #8315 fix claimDevelopment fixtures by:alexm +- test: refs #8315 fix clientList by:alexm +- test: refs #8315 fix VnSelect in e2e by:alexm + # Version 24.50 - 2024-12-10 ### Added 🆕 diff --git a/package.json b/package.json index b5e62af11..c638b6c32 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "salix-front", - "version": "25.02.0", + "version": "25.04.0", "description": "Salix frontend", "productName": "Salix", "author": "Verdnatura", diff --git a/test/vitest/__tests__/boot/axios.spec.js b/src/boot/__tests__/axios.spec.js similarity index 100% rename from test/vitest/__tests__/boot/axios.spec.js rename to src/boot/__tests__/axios.spec.js diff --git a/src/components/CreateNewPostcodeForm.vue b/src/components/CreateNewPostcodeForm.vue index c656fcb2f..39ebfe540 100644 --- a/src/components/CreateNewPostcodeForm.vue +++ b/src/components/CreateNewPostcodeForm.vue @@ -55,13 +55,6 @@ async function setCountry(countryFk, data) { } // Province - -async function handleProvinces(data) { - provincesOptions.value = data; - if (postcodeFormData.countryFk) { - await fetchTowns(); - } -} async function setProvince(id, data) { if (data.provinceFk === id) return; const newProvince = provincesOptions.value.find((province) => province.id == id); @@ -69,6 +62,7 @@ async function setProvince(id, data) { postcodeFormData.provinceFk = id; await fetchTowns(); } + async function onProvinceCreated(data) { postcodeFormData.provinceFk = data.id; } diff --git a/src/components/CrudModel.vue b/src/components/CrudModel.vue index 7fdb54bc4..940b72ff0 100644 --- a/src/components/CrudModel.vue +++ b/src/components/CrudModel.vue @@ -127,7 +127,7 @@ function resetData(data) { originalData.value = JSON.parse(JSON.stringify(data)); formData.value = JSON.parse(JSON.stringify(data)); - if (watchChanges.value) watchChanges.value(); //destoy watcher + if (watchChanges.value) watchChanges.value(); //destroy watcher watchChanges.value = watch(formData, () => (hasChanges.value = true), { deep: true }); } @@ -270,10 +270,8 @@ function getChanges() { function isEmpty(obj) { if (obj == null) return true; - if (obj === undefined) return true; - if (Object.keys(obj).length === 0) return true; - - if (obj.length > 0) return false; + if (Array.isArray(obj)) return !obj.length; + return !Object.keys(obj).length; } async function reload(params) { diff --git a/src/components/FormModel.vue b/src/components/FormModel.vue index c569f2553..ea1ea53f2 100644 --- a/src/components/FormModel.vue +++ b/src/components/FormModel.vue @@ -1,7 +1,7 @@ + diff --git a/test/vitest/__tests__/components/VnTable.spec.js b/src/components/VnTable/__tests__/VnTable.spec.js similarity index 82% rename from test/vitest/__tests__/components/VnTable.spec.js rename to src/components/VnTable/__tests__/VnTable.spec.js index 162df727d..74ba06987 100644 --- a/test/vitest/__tests__/components/VnTable.spec.js +++ b/src/components/VnTable/__tests__/VnTable.spec.js @@ -1,4 +1,4 @@ -import { describe, expect, it, beforeAll, beforeEach } from 'vitest'; +import { describe, expect, it, beforeAll, beforeEach, vi } from 'vitest'; import { createWrapper } from 'app/test/vitest/helper'; import VnTable from 'src/components/VnTable/VnTable.vue'; @@ -13,6 +13,15 @@ describe('VnTable', () => { }, }); vm = wrapper.vm; + + vi.mock('src/composables/useFilterParams', () => { + return { + useFilterParams: vi.fn(() => ({ + params: {}, + orders: {}, + })), + }; + }); }); beforeEach(() => (vm.selected = [])); diff --git a/src/components/__tests__/CrudModel.spec.js b/src/components/__tests__/CrudModel.spec.js new file mode 100644 index 000000000..e0afd30ad --- /dev/null +++ b/src/components/__tests__/CrudModel.spec.js @@ -0,0 +1,248 @@ +import { createWrapper, axios } from 'app/test/vitest/helper'; +import CrudModel from 'components/CrudModel.vue'; +import { vi, afterEach, beforeEach, beforeAll, describe, expect, it } from 'vitest'; + +describe('CrudModel', () => { + let wrapper; + let vm; + let data; + beforeAll(() => { + wrapper = createWrapper(CrudModel, { + global: { + stubs: [ + 'vnPaginate', + 'useState', + 'arrayData', + 'useStateStore', + 'vue-i18n', + ], + mocks: { + validate: vi.fn(), + }, + }, + propsData: { + dataRequired: { + fk: 1, + }, + dataKey: 'crudModelKey', + model: 'crudModel', + url: 'crudModelUrl', + saveFn: '', + }, + }); + wrapper=wrapper.wrapper; + vm=wrapper.vm; + }); + + beforeEach(() => { + vm.fetch([]); + vm.watchChanges = null; + }); + + 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, + }); + }); + }); + + describe('isEmpty()', () => { + let dummyObj; + let dummyArray; + let result; + it('should return true if object si null', async () => { + dummyObj = null; + result = vm.isEmpty(dummyObj); + + expect(result).toBe(true); + }); + + it('should return true if object si undefined', async () => { + dummyObj = undefined; + result = vm.isEmpty(dummyObj); + + expect(result).toBe(true); + }); + + it('should return true if object is empty', async () => { + dummyObj ={}; + result = vm.isEmpty(dummyObj); + + expect(result).toBe(true); + }); + + it('should return false if object is not empty', async () => { + dummyObj = {a:1, b:2, c:3}; + result = vm.isEmpty(dummyObj); + + expect(result).toBe(false); + }); + + it('should return true if array is empty', async () => { + dummyArray = []; + result = vm.isEmpty(dummyArray); + + expect(result).toBe(true); + }); + + it('should return false if array is not empty', async () => { + dummyArray = [1,2,3]; + result = vm.isEmpty(dummyArray); + + expect(result).toBe(false); + }) + }); + + describe('resetData()', () => { + it('should add $index to elements in data[] and sets originalData and formData with data', async () => { + data = [{ + name: 'Tony', + lastName: 'Stark', + age: 42, + }]; + + vm.resetData(data); + + expect(vm.originalData).toEqual(data); + expect(vm.originalData[0].$index).toEqual(0); + expect(vm.formData).toEqual(data); + expect(vm.formData[0].$index).toEqual(0); + expect(vm.watchChanges).not.toBeNull(); + }); + + it('should dont do nothing if data is null', async () => { + vm.resetData(null); + + expect(vm.watchChanges).toBeNull(); + }); + + it('should set originalData and formatData with data and generate watchChanges', async () => { + data = { + name: 'Tony', + lastName: 'Stark', + age: 42, + }; + + vm.resetData(data); + + expect(vm.originalData).toEqual(data); + expect(vm.formData).toEqual(data); + expect(vm.watchChanges).not.toBeNull(); + }); + }); + + describe('saveChanges()', () => { + data = [{ + name: 'Tony', + lastName: 'Stark', + age: 42, + }]; + + it('should call saveFn if exists', async () => { + await wrapper.setProps({ saveFn: vi.fn() }); + + vm.saveChanges(data); + + expect(vm.saveFn).toHaveBeenCalledOnce(); + expect(vm.isLoading).toBe(false); + expect(vm.hasChanges).toBe(false); + + await wrapper.setProps({ saveFn: '' }); + }); + + it("should use default url if there's not saveFn", async () => { + const postMock =vi.spyOn(axios, 'post'); + + vm.formData = [{ + name: 'Bruce', + lastName: 'Wayne', + age: 45, + }] + + await vm.saveChanges(data); + + expect(postMock).toHaveBeenCalledWith(vm.url + '/crud', data); + expect(vm.isLoading).toBe(false); + expect(vm.hasChanges).toBe(false); + expect(vm.originalData).toEqual(JSON.parse(JSON.stringify(vm.formData))); + }); + }); +}); diff --git a/src/components/__tests__/EditTableCellValueForm.spec.js b/src/components/__tests__/EditTableCellValueForm.spec.js new file mode 100644 index 000000000..fa47d8f73 --- /dev/null +++ b/src/components/__tests__/EditTableCellValueForm.spec.js @@ -0,0 +1,56 @@ +import { createWrapper, axios } from 'app/test/vitest/helper'; +import EditForm from 'components/EditTableCellValueForm.vue'; +import { vi, afterEach, beforeAll, describe, expect, it } from 'vitest'; + +const fieldA = 'fieldA'; +const fieldB = 'fieldB'; + +describe('EditForm', () => { + let vm; + const mockRows = [ + { id: 1, itemFk: 101 }, + { id: 2, itemFk: 102 }, + ]; + const mockFieldsOptions = [ + { label: 'Field A', field: fieldA, component: 'input', attrs: {} }, + { label: 'Field B', field: fieldB, component: 'date', attrs: {} }, + ]; + const editUrl = '/api/edit'; + + beforeAll(() => { + vi.spyOn(axios, 'post').mockResolvedValue({ status: 200 }); + vm = createWrapper(EditForm, { + props: { + rows: mockRows, + fieldsOptions: mockFieldsOptions, + editUrl, + }, + }).vm; + }); + + afterEach(() => { + vi.clearAllMocks(); + }); + + describe('onSubmit()', () => { + it('should call axios.post with the correct parameters in the payload', async () => { + const selectedField = { field: fieldA, component: 'input', attrs: {} }; + const newValue = 'Test Value'; + + vm.selectedField = selectedField; + vm.newValue = newValue; + + await vm.onSubmit(); + + const payload = axios.post.mock.calls[0][1]; + + expect(axios.post).toHaveBeenCalledWith(editUrl, expect.any(Object)); + expect(payload.field).toEqual(fieldA); + expect(payload.newValue).toEqual(newValue); + + expect(payload.lines).toEqual(expect.arrayContaining(mockRows)); + + expect(vm.isLoading).toEqual(false); + }); + }); +}); diff --git a/src/components/__tests__/FormModel.spec.js b/src/components/__tests__/FormModel.spec.js new file mode 100644 index 000000000..e35684bc3 --- /dev/null +++ b/src/components/__tests__/FormModel.spec.js @@ -0,0 +1,149 @@ +import { describe, expect, it, beforeAll, vi, afterAll } from 'vitest'; +import { createWrapper, axios } from 'app/test/vitest/helper'; +import FormModel from 'src/components/FormModel.vue'; + +describe('FormModel', () => { + const model = 'mockModel'; + const url = 'mockUrl'; + const formInitialData = { mockKey: 'mockVal' }; + + describe('modelValue', () => { + it('should use the provided model', () => { + const { vm } = mount({ propsData: { model } }); + expect(vm.modelValue).toBe(model); + }); + + it('should use the route meta title when model is not provided', () => { + const { vm } = mount({}); + expect(vm.modelValue).toBe('formModel_mockTitle'); + }); + }); + + describe('onMounted()', () => { + let mockGet; + + beforeAll(() => { + mockGet = vi.spyOn(axios, 'get').mockResolvedValue({ data: {} }); + }); + + afterAll(() => { + mockGet.mockRestore(); + }); + + it('should not fetch when has formInitialData', () => { + mount({ propsData: { url, model, autoLoad: true, formInitialData } }); + expect(mockGet).not.toHaveBeenCalled(); + }); + + it('should fetch when there is url and auto-load', () => { + mount({ propsData: { url, model, autoLoad: true } }); + expect(mockGet).toHaveBeenCalled(); + }); + + it('should not observe changes', () => { + const { vm } = mount({ + propsData: { url, model, observeFormChanges: false, formInitialData }, + }); + + expect(vm.hasChanges).toBe(true); + vm.reset(); + expect(vm.hasChanges).toBe(true); + }); + + it('should observe changes', async () => { + const { vm } = mount({ + propsData: { url, model, formInitialData }, + }); + vm.state.set(model, formInitialData); + expect(vm.hasChanges).toBe(false); + + vm.formData.mockKey = 'newVal'; + await vm.$nextTick(); + expect(vm.hasChanges).toBe(true); + vm.formData.mockKey = 'mockVal'; + }); + }); + + describe('trimData()', () => { + let vm; + beforeAll(() => { + vm = mount({}).vm; + }); + + it('should trim whitespace from string values', () => { + const data = { key1: ' value1 ', key2: ' value2 ' }; + const trimmedData = vm.trimData(data); + expect(trimmedData).toEqual({ key1: 'value1', key2: 'value2' }); + }); + + it('should not modify non-string values', () => { + const data = { key1: 123, key2: true, key3: null, key4: undefined }; + const trimmedData = vm.trimData(data); + expect(trimmedData).toEqual(data); + }); + }); + + describe('save()', async () => { + it('should not call if there are not changes', async () => { + const { vm } = mount({ propsData: { url, model } }); + + await vm.save(); + expect(vm.hasChanges).toBe(false); + }); + + it('should call axios.patch with the right data', async () => { + const spy = vi.spyOn(axios, 'patch').mockResolvedValue({ data: {} }); + const { vm } = mount({ propsData: { url, model, formInitialData } }); + vm.formData.mockKey = 'newVal'; + await vm.$nextTick(); + await vm.save(); + expect(spy).toHaveBeenCalled(); + vm.formData.mockKey = 'mockVal'; + }); + + it('should call axios.post with the right data', async () => { + const spy = vi.spyOn(axios, 'post').mockResolvedValue({ data: {} }); + const { vm } = mount({ + propsData: { url, model, formInitialData, urlCreate: 'mockUrlCreate' }, + }); + vm.formData.mockKey = 'newVal'; + await vm.$nextTick(); + await vm.save(); + expect(spy).toHaveBeenCalled(); + vm.formData.mockKey = 'mockVal'; + }); + + it('should use the saveFn', async () => { + const { vm } = mount({ + propsData: { url, model, formInitialData, saveFn: () => {} }, + }); + const spyPatch = vi.spyOn(axios, 'patch').mockResolvedValue({ data: {} }); + const spySaveFn = vi.spyOn(vm.$props, 'saveFn'); + + vm.formData.mockKey = 'newVal'; + await vm.$nextTick(); + await vm.save(); + expect(spyPatch).not.toHaveBeenCalled(); + expect(spySaveFn).toHaveBeenCalled(); + vm.formData.mockKey = 'mockVal'; + }); + + it('should reload the data after save', async () => { + const { vm } = mount({ + propsData: { url, model, formInitialData, reload: true }, + }); + vi.spyOn(axios, 'patch').mockResolvedValue({ data: {} }); + + vm.formData.mockKey = 'newVal'; + await vm.$nextTick(); + await vm.save(); + vm.formData.mockKey = 'mockVal'; + }); + }); +}); + +function mount({ propsData = {} }) { + return createWrapper(FormModel, { + propsData, + }); +} diff --git a/test/vitest/__tests__/components/Leftmenu.spec.js b/src/components/__tests__/Leftmenu.spec.js similarity index 100% rename from test/vitest/__tests__/components/Leftmenu.spec.js rename to src/components/__tests__/Leftmenu.spec.js diff --git a/src/components/common/VnBreadcrumbs.vue b/src/components/common/VnBreadcrumbs.vue index 02226e497..334ab4d21 100644 --- a/src/components/common/VnBreadcrumbs.vue +++ b/src/components/common/VnBreadcrumbs.vue @@ -15,7 +15,7 @@ let root = ref(null); watchEffect(() => { matched.value = currentRoute.value.matched.filter( - (matched) => Object.keys(matched.meta).length + (matched) => !!matched?.meta?.title || !!matched?.meta?.icon ); breadcrumbs.value.length = 0; if (!matched.value[0]) return; diff --git a/src/components/common/VnBtnSelect.vue b/src/components/common/VnBtnSelect.vue index b0616a6b2..3d96a55a6 100644 --- a/src/components/common/VnBtnSelect.vue +++ b/src/components/common/VnBtnSelect.vue @@ -14,6 +14,7 @@ defineProps({ hide-dropdown-icon focus-on-mount @update:model-value="promise" + data-cy="vnBtnSelect_select" /> diff --git a/src/components/common/VnCardBeta.vue b/src/components/common/VnCardBeta.vue new file mode 100644 index 000000000..349956be9 --- /dev/null +++ b/src/components/common/VnCardBeta.vue @@ -0,0 +1,67 @@ + + diff --git a/src/components/common/VnDateBadge.vue b/src/components/common/VnDateBadge.vue index fd6c9e8a4..83d39937a 100644 --- a/src/components/common/VnDateBadge.vue +++ b/src/components/common/VnDateBadge.vue @@ -11,9 +11,9 @@ function getBadgeAttrs(date) { let timeDiff = today - timeTicket; - if (timeDiff == 0) return { color: 'warning', 'text-color': 'black' }; - if (timeDiff < 0) return { color: 'success', 'text-color': 'black' }; - return { color: 'transparent', 'text-color': 'white' }; + if (timeDiff == 0) return { color: 'warning', class: 'black-text-color' }; + if (timeDiff < 0) return { color: 'success', class: 'black-text-color' }; + return { color: 'transparent', class: 'normal-text-color' }; } function formatShippedDate(date) { @@ -29,3 +29,11 @@ function formatShippedDate(date) { {{ formatShippedDate(date) }} + diff --git a/src/components/common/VnDmsList.vue b/src/components/common/VnDmsList.vue index 52dd6ef79..ed3cadc6b 100644 --- a/src/components/common/VnDmsList.vue +++ b/src/components/common/VnDmsList.vue @@ -297,7 +297,7 @@ defineExpose({ ref="dmsRef" :data-key="$props.model" :url="$props.model" - :filter="dmsFilter" + :user-filter="dmsFilter" :order="['dmsFk DESC']" :auto-load="true" @on-fetch="setData" diff --git a/src/components/common/VnInputDate.vue b/src/components/common/VnInputDate.vue index fdef6a9a8..952a843e3 100644 --- a/src/components/common/VnInputDate.vue +++ b/src/components/common/VnInputDate.vue @@ -1,14 +1,12 @@