diff --git a/cypress/pageobject/Asset/AssetCreation.ts b/cypress/pageobject/Asset/AssetCreation.ts index 2484bb5affe..7e28a67332f 100644 --- a/cypress/pageobject/Asset/AssetCreation.ts +++ b/cypress/pageobject/Asset/AssetCreation.ts @@ -62,7 +62,7 @@ export class AssetPage { cy.get( "[data-testid=asset-last-serviced-on-input] input[type='text']", ).click(); - cy.get("#date-input").click().type(lastServicedOn); + cy.get('[data-test-id="date-input"]').click().type(lastServicedOn); cy.get("body").click(0, 0); cy.get("[data-testid=asset-notes-input] textarea").type(notes); } @@ -121,7 +121,7 @@ export class AssetPage { cy.get( "[data-testid=asset-last-serviced-on-input] input[type='text']", ).click(); - cy.get("#date-input").click().clear().type(lastServicedOn); + cy.get('[data-test-id="date-input"]').click().clear().type(lastServicedOn); cy.get("body").click(0, 0); cy.get("[data-testid=asset-notes-input] textarea").clear().type(notes); } @@ -278,7 +278,7 @@ export class AssetPage { enterAssetservicedate(text: string) { cy.get("input[name='last_serviced_on']").click(); - cy.get("#date-input").click().type(text); + cy.get('[data-test-id="date-input"]').click().type(text); cy.get("body").click(0, 0); } diff --git a/cypress/pageobject/Facility/FacilityCreation.ts b/cypress/pageobject/Facility/FacilityCreation.ts index 0552a130adc..72215055829 100644 --- a/cypress/pageobject/Facility/FacilityCreation.ts +++ b/cypress/pageobject/Facility/FacilityCreation.ts @@ -246,7 +246,7 @@ class FacilityPage { fillEntryDate(date) { cy.get("#entry_date").click(); - cy.get("#date-input").click().type(date); + cy.get('[data-test-id="date-input"]').click().type(date); cy.get("body").click(0, 0); } diff --git a/cypress/pageobject/Patient/PatientConsultation.ts b/cypress/pageobject/Patient/PatientConsultation.ts index 470febaa852..f28c3e20ed5 100644 --- a/cypress/pageobject/Patient/PatientConsultation.ts +++ b/cypress/pageobject/Patient/PatientConsultation.ts @@ -61,7 +61,7 @@ export class PatientConsultationPage { typePatientConsultationDate(selector: string, date: string) { cy.get(selector).click(); - cy.get("#date-input").clear().type(date); + cy.get('[data-test-id="date-input"]').clear().type(date); cy.get("body").click(0, 0); } diff --git a/cypress/pageobject/Patient/PatientCreation.ts b/cypress/pageobject/Patient/PatientCreation.ts index f0cb415df95..3ec9ffe709b 100644 --- a/cypress/pageobject/Patient/PatientCreation.ts +++ b/cypress/pageobject/Patient/PatientCreation.ts @@ -54,7 +54,7 @@ export class PatientPage { cy.clickAndSelectOption("#patientAge", "DOB"); cy.get("#date_of_birth").scrollIntoView(); cy.get("#date_of_birth").should("be.visible").click(); - cy.get("#date-input").click().type(dateOfBirth); + cy.get('[data-test-id="date-input"]').click().type(dateOfBirth); cy.get("body").click(0, 0); } @@ -82,13 +82,13 @@ export class PatientPage { typeLastMenstruationStartDate(date: string) { cy.get("#last_menstruation_start_date").click(); - cy.get("#date-input").click().type(date); + cy.get('[data-test-id="date-input"]').click().type(date); cy.get("body").click(0, 0); } typeDateOfDelivery(date: string) { cy.get("#date_of_delivery").click(); - cy.get("#date-input").click().type(date); + cy.get('[data-test-id="date-input"]').click().type(date); cy.get("body").click(0, 0); } diff --git a/cypress/pageobject/Patient/PatientLogupdate.ts b/cypress/pageobject/Patient/PatientLogupdate.ts index add3fbb0590..9e3f34b8602 100644 --- a/cypress/pageobject/Patient/PatientLogupdate.ts +++ b/cypress/pageobject/Patient/PatientLogupdate.ts @@ -36,7 +36,7 @@ class PatientLogupdate { cy.typeAndMultiSelectOption("#additional_symptoms", input, symptoms); } selectSymptomsDate(date: string) { - cy.clickAndTypeDate("#symptoms_onset_date", date); + cy.clickAndTypeDate("#symptoms_onset_date", date, 2); } clickAddSymptom() { cy.get("#add-symptom").click(); diff --git a/cypress/pageobject/Patient/PatientTreatmentPlan.ts b/cypress/pageobject/Patient/PatientTreatmentPlan.ts index a78cc3d4a0c..66c883b817c 100644 --- a/cypress/pageobject/Patient/PatientTreatmentPlan.ts +++ b/cypress/pageobject/Patient/PatientTreatmentPlan.ts @@ -34,7 +34,7 @@ class PatientTreatmentPlan { typeProcedureTime(time: string) { cy.get("#procedure-time").click(); - cy.get("#date-input").clear().type(time); + cy.get('[data-test-id="date-input"]').clear().type(time); cy.get("body").click(0, 0); } diff --git a/cypress/pageobject/Users/UserCreation.ts b/cypress/pageobject/Users/UserCreation.ts index 7503ea3fb07..ce68d47ce65 100644 --- a/cypress/pageobject/Users/UserCreation.ts +++ b/cypress/pageobject/Users/UserCreation.ts @@ -19,7 +19,7 @@ export class UserCreationPage { } typeIntoElementByIdPostClearDob(elementId: string, value: string) { cy.get("#" + elementId).click(); - cy.get("#date-input").clear().type(value); + cy.get('[data-test-id="date-input"]').clear().type(value); } clearIntoElementById(elementId: string) { cy.get("#" + elementId) diff --git a/cypress/pageobject/Users/UserProfilePage.ts b/cypress/pageobject/Users/UserProfilePage.ts index 20fd1911c49..5832b844d9b 100644 --- a/cypress/pageobject/Users/UserProfilePage.ts +++ b/cypress/pageobject/Users/UserProfilePage.ts @@ -18,7 +18,7 @@ export default class UserProfilePage { typedate_of_birth(date_of_birth: string) { //check cy.get("#date_of_birth").click(); - cy.get("#date-input").clear().type(date_of_birth); + cy.get('[data-test-id="date-input"]').clear().type(date_of_birth); } selectGender(gender: string) { diff --git a/cypress/support/commands.ts b/cypress/support/commands.ts index d6ec9e067f9..0ce91ed85ec 100644 --- a/cypress/support/commands.ts +++ b/cypress/support/commands.ts @@ -173,10 +173,12 @@ Cypress.Commands.add("selectRadioOption", (name: string, value: string) => { cy.get(`input[type='radio'][name='${name}'][value=${value}]`).click(); }); -Cypress.Commands.add("clickAndTypeDate", (selector: string, date: string) => { +Cypress.Commands.add("clickAndTypeDate", (selector, date, inputIndex = 1) => { cy.get(selector).scrollIntoView(); cy.get(selector).click(); - cy.get("#date-input").click().type(date); + cy.get(`[data-test-id="date-input"]:nth-child(${inputIndex})`) + .click() + .type(date); cy.get("body").click(0, 0); }); diff --git a/cypress/support/index.ts b/cypress/support/index.ts index d660246324f..4ccbe0ad969 100644 --- a/cypress/support/index.ts +++ b/cypress/support/index.ts @@ -29,7 +29,11 @@ declare global { input: string, symptoms: string | string[], ): Chainable; - clickAndTypeDate(date: string, selector: string): Chainable; + clickAndTypeDate( + date: string, + selector: string, + selectorIndex?: number, + ): Chainable; clickAndSelectOption( element: string, reference: string, diff --git a/src/Components/Common/DateInputV2.tsx b/src/Components/Common/DateInputV2.tsx index bf0ee5cfc12..687ab489e9c 100644 --- a/src/Components/Common/DateInputV2.tsx +++ b/src/Components/Common/DateInputV2.tsx @@ -296,7 +296,7 @@ const DateInputV2: React.FC = ({ disabled={disabled} className="w-full" ref={popoverButtonRef} - id="date-input" + data-test-id="date-input" >