diff --git a/packages/form/tests/integration/components/cf-content-test.js b/packages/form/tests/integration/components/cf-content-test.js index f04ab369e..4bc7c5280 100644 --- a/packages/form/tests/integration/components/cf-content-test.js +++ b/packages/form/tests/integration/components/cf-content-test.js @@ -46,6 +46,8 @@ module("Integration | Component | cf-content", function (hooks) { this.server.create("question", { formIds: [form.id], type: "DATE", + minDate: "2023-01-01", + maxDate: "2030-12-31", }), this.server.create("question", { formIds: [form.id], @@ -181,6 +183,8 @@ module("Integration | Component | cf-content", function (hooks) { formIds: [form.id], slug: "date-question", type: "DATE", + minDate: "2023-01-01", + maxDate: null, }); this.server.create("question", { formIds: [form.id], @@ -229,7 +233,7 @@ module("Integration | Component | cf-content", function (hooks) { ); await setFlatpickrDate( `[name="Document:${document.id}:Question:date-question"]`, - new Date(2019, 2, 25), // month is zero based + new Date(2023, 2, 25), // month is zero based ); await triggerEvent( @@ -272,7 +276,7 @@ module("Integration | Component | cf-content", function (hooks) { }, { slug: "date-question", - value: "2019-03-25", + value: "2023-03-25", }, { slug: "files-question", diff --git a/packages/form/tests/integration/components/cf-field/input/date-test.js b/packages/form/tests/integration/components/cf-field/input/date-test.js index 407782068..9e79f21ef 100644 --- a/packages/form/tests/integration/components/cf-field/input/date-test.js +++ b/packages/form/tests/integration/components/cf-field/input/date-test.js @@ -101,4 +101,40 @@ module("Integration | Component | cf-field/input/date", function (hooks) { .hasValue("25.03.2021"); assert.dom(".ember-flatpickr-input[type='hidden']").hasValue("2021-03-25"); }); + + test("the date accept min date and max date", async function (assert) { + this.value = null; + this.field = { + question: { + raw: { + minDate: "2023-01-01", + maxDate: "2024-01-01", + }, + }, + }; + + await render( + hbs``, + ); + + await setLocale("en-us"); + await setFlatpickrDate("input", new Date(2023, 6, 10)); // month is zero based + assert.strictEqual(this.value, "2023-07-10"); + assert + .dom(".ember-flatpickr-input:not([type='hidden'])") + .hasValue("07/10/2023"); + assert.dom(".ember-flatpickr-input[type='hidden']").hasValue("2023-07-10"); + + // the date here is less then the min dafined date + await setFlatpickrDate("input", new Date(2022, 6, 10)); // month is zero based + assert.strictEqual(this.value, null); + assert.dom(".ember-flatpickr-input:not([type='hidden'])").hasValue(""); + assert.dom(".ember-flatpickr-input[type='hidden']").hasValue(""); + + // the date here is more then the max defined date + await setFlatpickrDate("input", new Date(2024, 6, 10)); // month is zero based + assert.strictEqual(this.value, null); + assert.dom(".ember-flatpickr-input:not([type='hidden'])").hasValue(""); + assert.dom(".ember-flatpickr-input[type='hidden']").hasValue(""); + }); }); diff --git a/packages/testing/addon/scenarios/distribution.js b/packages/testing/addon/scenarios/distribution.js index 8efb633b7..a7db92e58 100644 --- a/packages/testing/addon/scenarios/distribution.js +++ b/packages/testing/addon/scenarios/distribution.js @@ -27,6 +27,8 @@ export function createBlueprint(server) { label: "Deadline", isRequired: "true", formIds: [inquiryForm.id], + minDate: null, + maxDate: null, type: "DATE", });