Given the following code:
cy.intercept('POST', 'get_time_slots', { fixture: data }).as('getTimeslotList');
cy.get('input.datepicker').type("2024-01-10").trigger('change');
cy.get("checkbox#flexCheckDefault").click()
Explaination:
The
cy.get('input.datepicker').type("2024-01-10").trigger('change')command will trigger the call to theget_time_slotsAPI, which returns a list of timeslot - which is mocked by a fixture fileNote: Changing the date value is the only way to trigger the api call
The
cy.get("checkbox#flexCheckDefault").click()command will show the timeslot list to the UI, but the weird things are:- It also calls the
get_time_slotsAPI 1 more time - This behavior doesn't happen if the checkbox is clicked manually via the UI
- It also calls the
Components source code:
Date picker
<input
placeholder="Select date" type="date"
class="form-control date-input-custom datepicker"
t-att-max="state.maxDate"
t-att-disabled="this.checkDatePickerDisable()"
t-att-min="state.todayLabel"
t-on-change="(e) => this.onSelectDate(e.target.value)"
t-att-value="state.appointment.booking_date" />
The checkbox:
<input
type="checkbox" value=""
id="flexCheckDefault"
t-on-input="this.showSlot" />
(I got the same issue when using .check() instead of click())
Has anyone experienced this issue before, and how can it be fixed?

I would guess that the double-up of
changeevent occurs because the app is already set up to firechangewhen the element loses focus.This would occur when the second element is clicked, see the docs for
.click()at FocusIf this is true, you can omit the
.trigger('change')and add a.blur()instead.Docs .type() says
This is particularly true if the
changeevent is fired by the app - the DOM is likely to re-render. To be safe, issue anothercy.get('input.datepicker')for the next action.