Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,6 @@ if (typeof window.DatePickerWidget === 'undefined') {
}
html += this.#clearButtonTemplate;

this.#dp = document.getElementsByClassName("datetimepicker")[0];
if (!this.#dp) {
this.#dp = document.createElement("div");
this.#dp.classList.add("datetimepicker", "datePickerTarget");
Expand Down
15 changes: 14 additions & 1 deletion ui.tests/test-module/specs/datepicker/datepicker.runtime.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ describe("Form Runtime with Date Picker", () => {

// check clear option
cy.get(`#${datePicker7}`).find(".cmp-adaptiveform-datepicker__calendar-icon").should("be.visible").click({force: true}).then(() => {
cy.get(".dp-clear").click();
cy.get(".dp-clear").eq(1).click();
});

cy.get(`#${datePicker7}`).find("input").should("have.value", "");
Expand Down Expand Up @@ -370,4 +370,17 @@ describe("Form Runtime with Date Picker", () => {
},
});
});

it("should create and attach an unique datepicker calendar if it doesn't exist", () => {
const [datePicker4, datePicker4FieldView] = Object.entries(formContainer._fields)[4];
const [datePicker6, datePicker6FieldView] = Object.entries(formContainer._fields)[6];
const input = "2023-01-01";

cy.get(`#${datePicker4}`).find("input").clear().type(input).should('have.value', '2023-01-01').blur();
cy.get(`#${datePicker6}`).find(".cmp-adaptiveform-datepicker__calendar-icon").click().then(x => {
cy.get(".datetimepicker").should("be.visible");
cy.get('.datetimepicker .dp-header .dp-caption').eq(1).click();
cy.get('.datetimepicker').should('be.visible');
});
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ describe("Form Runtime with Date Picker", () => {
cy.get(`#${datePicker8}`).find(".cmp-adaptiveform-datepicker__calendar-icon").should("be.visible").click().then(() => {
let todayDate = new Date();
cy.get(".dp-caption").invoke("text").should("eq", "مارس, 2024");
cy.get(".dp-caption").click();
cy.get(".dp-caption").eq(3).click();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changing existing test, means that this is backward incompatible change. What was the reason for adding this ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, @rismehta! Previously, whenever we used to add date-time picker widget to the form, the calendar element associated to widget is initialised and created only once even if there are multiple instances of the widget, i.e., same calendar element being initialised to every unique instance of date-time picker widget which was conflicting when interacting with each of it.

Now since there are multiple calendar elements, in the tests I had to specify which element the click() event had to occur on, hence the changes.

cy.get(".dp-caption").invoke("text").should("eq", '2024');
cy.get(".dp-rightnav").click();
cy.get(".dp-rightnav").eq(3).click();
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ describe("Form Runtime with Date Picker", () => {
const localizedYear = convertNumberToLocale(Number(yearObject.value));
const localizedMonth = monthObject.value;
cy.get(".dp-caption").invoke("text").should("eq", localizedMonth + ', ' + localizedYear);
cy.get(".dp-caption").click();
cy.get(".dp-caption").eq(1).click();
cy.get(".dp-caption").invoke("text").should("eq", localizedYear);
cy.get(".dp-rightnav").click();
cy.get(".dp-rightnav").eq(1).click();
});
});

Expand Down