Skip to content

Commit

Permalink
tests
Browse files Browse the repository at this point in the history
  • Loading branch information
shivankacker committed Oct 10, 2024
1 parent fa0bfc9 commit 4ef4f0c
Show file tree
Hide file tree
Showing 11 changed files with 22 additions and 16 deletions.
6 changes: 3 additions & 3 deletions cypress/pageobject/Asset/AssetCreation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
}

Expand Down
2 changes: 1 addition & 1 deletion cypress/pageobject/Facility/FacilityCreation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
2 changes: 1 addition & 1 deletion cypress/pageobject/Patient/PatientConsultation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
6 changes: 3 additions & 3 deletions cypress/pageobject/Patient/PatientCreation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -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);
}

Expand Down
2 changes: 1 addition & 1 deletion cypress/pageobject/Patient/PatientLogupdate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion cypress/pageobject/Patient/PatientTreatmentPlan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
2 changes: 1 addition & 1 deletion cypress/pageobject/Users/UserCreation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion cypress/pageobject/Users/UserProfilePage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
6 changes: 4 additions & 2 deletions cypress/support/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});

Expand Down
6 changes: 5 additions & 1 deletion cypress/support/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@ declare global {
input: string,
symptoms: string | string[],
): Chainable<Element>;
clickAndTypeDate(date: string, selector: string): Chainable<Element>;
clickAndTypeDate(
date: string,
selector: string,
selectorIndex?: number,
): Chainable<Element>;
clickAndSelectOption(
element: string,
reference: string,
Expand Down
2 changes: 1 addition & 1 deletion src/Components/Common/DateInputV2.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ const DateInputV2: React.FC<Props> = ({
disabled={disabled}
className="w-full"
ref={popoverButtonRef}
id="date-input"
data-test-id="date-input"
>
<input type="hidden" name="date" />
<input
Expand Down

0 comments on commit 4ef4f0c

Please sign in to comment.