diff --git a/cypress.config.js b/cypress.config.js index d9cdbe728..7458c0b05 100644 --- a/cypress.config.js +++ b/cypress.config.js @@ -44,6 +44,7 @@ export default defineConfig({ supportFile: 'test/cypress/support/index.js', videosFolder: 'test/cypress/videos', downloadsFolder: 'test/cypress/downloads', + tmpUploadFolder: 'test/cypress/storage/tmp/dms', video: false, specPattern: 'test/cypress/integration/**/*.spec.js', experimentalRunAllSpecs: true, diff --git a/src/boot/__tests__/axios.spec.js b/src/boot/__tests__/axios.spec.js index 85d578517..45a3cc7f0 100644 --- a/src/boot/__tests__/axios.spec.js +++ b/src/boot/__tests__/axios.spec.js @@ -67,7 +67,7 @@ describe('Axios boot', () => { }; const result = onResponseError(error); - expect(result).rejects.toEqual(expect.objectContaining(error)); + await expect(result).rejects.toEqual(expect.objectContaining(error)); }); it('should call to the Notify plugin with a message from the response property', async () => { @@ -83,7 +83,7 @@ describe('Axios boot', () => { }; const result = onResponseError(error); - expect(result).rejects.toEqual(expect.objectContaining(error)); + await expect(result).rejects.toEqual(expect.objectContaining(error)); }); }); }); diff --git a/src/boot/vnDate.js b/src/boot/vnDate.js index 33d5ac27f..8f18e2400 100644 --- a/src/boot/vnDate.js +++ b/src/boot/vnDate.js @@ -1,4 +1,6 @@ import { boot } from 'quasar/wrappers'; +import { date as quasarDate } from 'quasar'; +const { formatDate } = quasarDate; export default boot(() => { Date.vnUTC = () => { @@ -25,4 +27,34 @@ export default boot(() => { const date = new Date(Date.vnUTC()); return new Date(date.getFullYear(), date.getMonth() + 1, 0); }; + + Date.getCurrentDateTimeFormatted = ( + options = { + startOfDay: false, + endOfDay: true, + iso: true, + mask: 'DD-MM-YYYY HH:mm', + }, + ) => { + const date = Date.vnUTC(); + if (options.startOfDay) { + date.setHours(0, 0, 0); + } + if (options.endOfDay) { + date.setHours(23, 59, 0); + } + if (options.iso) { + return date.toISOString(); + } + return formatDate(date, options.mask); + }; + + Date.convertToISODateTime = (dateTimeStr) => { + const [datePart, timePart] = dateTimeStr.split(' '); + const [day, month, year] = datePart.split('-'); + const [hours, minutes] = timePart.split(':'); + + const isoDate = new Date(year, month - 1, day, hours, minutes); + return isoDate.toISOString(); + }; }); diff --git a/src/components/CreateNewPostcodeForm.vue b/src/components/CreateNewPostcodeForm.vue index a57e2c01c..f6a606547 100644 --- a/src/components/CreateNewPostcodeForm.vue +++ b/src/components/CreateNewPostcodeForm.vue @@ -20,7 +20,6 @@ const postcodeFormData = reactive({ provinceFk: null, townFk: null, }); -const townFilter = ref({}); const countriesRef = ref(false); const provincesOptions = ref([]); @@ -33,11 +32,11 @@ function onDataSaved(formData) { newPostcode.town = town.value.name; newPostcode.townFk = town.value.id; const provinceObject = provincesOptions.value.find( - ({ id }) => id === formData.provinceFk + ({ id }) => id === formData.provinceFk, ); newPostcode.province = provinceObject?.name; const countryObject = countriesRef.value.opts.find( - ({ id }) => id === formData.countryFk + ({ id }) => id === formData.countryFk, ); newPostcode.country = countryObject?.name; emit('onDataSaved', newPostcode); @@ -67,21 +66,11 @@ function setTown(newTown, data) { } async function onCityCreated(newTown, formData) { newTown.province = provincesOptions.value.find( - (province) => province.id === newTown.provinceFk + (province) => province.id === newTown.provinceFk, ); formData.townFk = newTown; setTown(newTown, formData); } - -async function filterTowns(name) { - if (name !== '') { - townFilter.value.where = { - name: { - like: `%${name}%`, - }, - }; - } -}