+ {{ console.log($q) }}
{
v-if="
($attrs.clearable == undefined || $attrs.clearable) &&
hover &&
- model &&
+ inputValue &&
!$attrs.disable
"
@click="
vnInputDateRef.focus();
+ inputValue = null;
model = null;
isPopupOpen = false;
"
diff --git a/src/components/common/__tests__/VnInputDate.spec.js b/src/components/common/__tests__/VnInputDate.spec.js
index 21ca91e96e..3cb037c63b 100644
--- a/src/components/common/__tests__/VnInputDate.spec.js
+++ b/src/components/common/__tests__/VnInputDate.spec.js
@@ -5,52 +5,71 @@ import VnInputDate from 'components/common/VnInputDate.vue';
let vm;
let wrapper;
-function generateWrapper(date, outlined, required) {
+function generateWrapper(outlined = false, required = false) {
wrapper = createWrapper(VnInputDate, {
props: {
- modelValue: date,
+ modelValue: '2000-12-31T23:00:00.000Z',
+ 'onUpdate:modelValue': (e) => wrapper.setProps({ modelValue: e }),
},
attrs: {
isOutlined: outlined,
- required: required
+ required: required,
},
});
wrapper = wrapper.wrapper;
vm = wrapper.vm;
-};
+}
describe('VnInputDate', () => {
-
- describe('formattedDate', () => {
- it('formats a valid date correctly', async () => {
- generateWrapper('2023-12-25', false, false);
+ describe('formattedDate', () => {
+ it('validateAndCleanInput should remove non-numeric characters', async () => {
+ generateWrapper();
+ vm.validateAndCleanInput('10a/1s2/2dd0a23');
await vm.$nextTick();
- expect(vm.formattedDate).toBe('25/12/2023');
+ expect(vm.inputValue).toBe('10/12/2023');
});
- it('updates the model value when a new date is set', async () => {
- const input = wrapper.find('input');
- await input.setValue('31/12/2023');
- expect(wrapper.emitted()['update:modelValue']).toBeTruthy();
- expect(wrapper.emitted()['update:modelValue'][0][0]).toBe('2023-12-31T00:00:00.000Z');
+ it('manageDate should reverse the date', async () => {
+ generateWrapper();
+ vm.manageDate('10/12/2023');
+ await vm.$nextTick();
+ expect(vm.inputValue).toBe('2023/12/10');
});
- it('should not update the model value when an invalid date is set', async () => {
+ it('formatDate should format the date correctly when a valid date is entered with full year', async () => {
const input = wrapper.find('input');
- await input.setValue('invalid-date');
- expect(wrapper.emitted()['update:modelValue'][0][0]).toBe('2023-12-31T00:00:00.000Z');
- });
+ await input.setValue('25.12/2002');
+ await vm.$nextTick();
+ await vm.formatDate();
+ expect(vm.model).toBe('2002-12-24T23:00:00.000Z');
+ });
+
+ it('should format the date correctly when a valid date is entered with short year', async () => {
+ const input = wrapper.find('input');
+ await input.setValue('31.12-23');
+ await vm.$nextTick();
+ await vm.formatDate();
+ expect(vm.model).toBe('2023-12-30T23:00:00.000Z');
+ });
+
+ it('should format the date correctly when a valid date is entered without year', async () => {
+ const input = wrapper.find('input');
+ await input.setValue('12.03');
+ await vm.$nextTick();
+ await vm.formatDate();
+ expect(vm.model).toBe('2001-03-11T23:00:00.000Z');
+ });
});
describe('styleAttrs', () => {
it('should return empty styleAttrs when isOutlined is false', async () => {
- generateWrapper('2023-12-25', false, false);
+ generateWrapper();
await vm.$nextTick();
- expect(vm.styleAttrs).toEqual({});
+ expect(vm.styleAttrs).toEqual({});
});
- it('should set styleAttrs when isOutlined is true', async () => {
- generateWrapper('2023-12-25', true, false);
+ it('should set styleAttrs when isOutlined is true', async () => {
+ generateWrapper(true, false);
await vm.$nextTick();
expect(vm.styleAttrs.outlined).toBe(true);
});
@@ -58,15 +77,15 @@ describe('VnInputDate', () => {
describe('required', () => {
it('should not applies required class when isRequired is false', async () => {
- generateWrapper('2023-12-25', false, false);
+ generateWrapper();
await vm.$nextTick();
expect(wrapper.find('.vn-input-date').classes()).not.toContain('required');
});
-
+
it('should applies required class when isRequired is true', async () => {
- generateWrapper('2023-12-25', false, true);
+ generateWrapper(false, true);
await vm.$nextTick();
expect(wrapper.find('.vn-input-date').classes()).toContain('required');
});
});
-});
\ No newline at end of file
+});
diff --git a/src/pages/InvoiceOut/InvoiceOutGlobalForm.vue b/src/pages/InvoiceOut/InvoiceOutGlobalForm.vue
index 53433c56bf..6d6dd2f517 100644
--- a/src/pages/InvoiceOut/InvoiceOutGlobalForm.vue
+++ b/src/pages/InvoiceOut/InvoiceOutGlobalForm.vue
@@ -164,6 +164,7 @@ onMounted(async () => {
unelevated
filled
dense
+ data-cy="formSubmitBtn"
/>
{
filled
dense
@click="getStatus = 'stopping'"
+ data-cy="formStopBtn"
/>
diff --git a/test/cypress/integration/entry/entryWasteRecalc.spec.js b/test/cypress/integration/entry/entryWasteRecalc.spec.js
index bd50e9c19f..902d5bbc5f 100644
--- a/test/cypress/integration/entry/entryWasteRecalc.spec.js
+++ b/test/cypress/integration/entry/entryWasteRecalc.spec.js
@@ -10,7 +10,7 @@ describe('EntryDms', () => {
cy.dataCy('recalc').should('be.disabled');
cy.dataCy('dateFrom').should('be.visible').click().type('01-01-2001');
- cy.dataCy('dateTo').should('be.visible').click().type('01-01-2001');
+ cy.dataCy('dateTo').should('be.visible').click().type('01-01-2001{enter}');
cy.dataCy('recalc').should('be.enabled').click();
cy.get('.q-notification__message').should(
diff --git a/test/cypress/integration/invoiceOut/invvoiceOutGlobal.spec.js b/test/cypress/integration/invoiceOut/invvoiceOutGlobal.spec.js
index 0170970a50..c6f75ef5f0 100644
--- a/test/cypress/integration/invoiceOut/invvoiceOutGlobal.spec.js
+++ b/test/cypress/integration/invoiceOut/invvoiceOutGlobal.spec.js
@@ -22,6 +22,7 @@ describe('InvoiceOut global invoicing', () => {
cy.get('.q-date__years-content > :nth-child(2) > .q-btn').click();
cy.get('.q-date__calendar-days > :nth-child(6) > .q-btn').click();
cy.get('[label="Max date ticket"]').type('01-01-2001{enter}');
+ cy.dataCy('formSubmitBtn').click();
cy.get('.q-card').should('be.visible');
});
});
diff --git a/test/cypress/support/commands.js b/test/cypress/support/commands.js
index c83674e3c5..f990c17748 100755
--- a/test/cypress/support/commands.js
+++ b/test/cypress/support/commands.js
@@ -195,8 +195,8 @@ Cypress.Commands.add('fillInForm', (obj, opts = {}) => {
break;
case 'date':
cy.get(el).type(
- `{selectall}{backspace}${val.split('-').join('')}`,
- );
+ `{selectall}{backspace}${val}`,
+ ).blur();
break;
case 'time':
cy.get(el).click();