Skip to content

Commit

Permalink
Added support for time in dateinput component (#8504)
Browse files Browse the repository at this point in the history
  • Loading branch information
shivankacker authored Oct 28, 2024
1 parent eeed897 commit 8eb4dc4
Show file tree
Hide file tree
Showing 39 changed files with 885 additions and 469 deletions.
8 changes: 4 additions & 4 deletions cypress/e2e/patient_spec/PatientConsultationCreation.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ describe("Patient Consultation in multiple combination", () => {
patientConsultationPage.selectPatientPrincipalDiagnosis(diagnosis4);
patientTreatmentPlan.clickAddProcedure();
patientTreatmentPlan.typeProcedureName(procedureName);
patientTreatmentPlan.typeProcedureTime("2024-02-22T12:30");
patientTreatmentPlan.typeProcedureTime("220220241230");
patientTreatmentPlan.typeTreatmentPlan(patientTreatment);
patientTreatmentPlan.typePatientGeneralInstruction(generalInstruction);
patientTreatmentPlan.typeSpecialInstruction(specialInstruction);
Expand Down Expand Up @@ -182,12 +182,12 @@ describe("Patient Consultation in multiple combination", () => {
patientConsultationPage.typeCauseOfDeath("Cause of Death");
patientConsultationPage.typePatientConsultationDate(
"#death_datetime",
"2024-02-22T12:45",
"220220241230",
);
patientConsultationPage.typeDeathConfirmedBy(doctorName);
patientConsultationPage.typePatientConsultationDate(
"#encounter_date",
"2024-02-22T12:30",
"220220241230",
);
cy.submitButton("Create Consultation");
cy.verifyNotification(
Expand Down Expand Up @@ -245,7 +245,7 @@ describe("Patient Consultation in multiple combination", () => {
);
patientConsultationPage.typePatientConsultationDate(
"#icu_admission_date",
"2024-02-23T12:30",
"230220241230",
);
// add investigation
patientInvestigation.clickAddInvestigation();
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/patient_spec/PatientRegistration.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const getRelativeDateString = (deltaDays = 0) => {
month: "2-digit",
year: "numeric",
})
.replace("/", "");
.replace(/\//g, "");
};

describe("Patient Creation with consultation", () => {
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/users_spec/UsersCreation.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ describe("User Creation", () => {
userCreationPage.typeIntoElementById("password", "Test@123");
userCreationPage.selectHomeFacility("Dummy Shifting Center");
userCreationPage.typeIntoElementById("phone_number", phone_number);
userCreationPage.setInputDate("date_of_birth", "date-input", "25081999");
userCreationPage.setInputDate("date_of_birth", "25081999");
userCreationPage.selectDropdownOption("user_type", "Doctor");
userCreationPage.typeIntoElementById("c_password", "Test@123");
userCreationPage.typeIntoElementById("qualification", "MBBS");
Expand Down
19 changes: 9 additions & 10 deletions cypress/pageobject/Asset/AssetCreation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ export class AssetPage {
cy.get("[data-testid=asset-support-email-input] input").type(supportEmail);
cy.get("[data-testid=asset-vendor-name-input] input").type(vendorName);
cy.get("[data-testid=asset-serial-number-input] input").type(serialNumber);
cy.get(
"[data-testid=asset-last-serviced-on-input] input[type='text']",
).click();
cy.get("#date-input").click().type(lastServicedOn);
cy.clickAndTypeDate(
"[data-testid=asset-last-serviced-on-input]",
lastServicedOn,
);
cy.get("[data-testid=asset-notes-input] textarea").type(notes);
}

Expand Down Expand Up @@ -117,10 +117,10 @@ export class AssetPage {
cy.get("[data-testid=asset-vendor-name-input] input")
.clear()
.type(vendorName);
cy.get(
"[data-testid=asset-last-serviced-on-input] input[type='text']",
).click();
cy.get("#date-input").click().clear().type(lastServicedOn);
cy.clickAndTypeDate(
"[data-testid=asset-last-serviced-on-input]",
lastServicedOn,
);
cy.get("[data-testid=asset-notes-input] textarea").clear().type(notes);
}

Expand Down Expand Up @@ -267,8 +267,7 @@ export class AssetPage {
}

enterAssetservicedate(text: string) {
cy.get("input[name='last_serviced_on']").click();
cy.get("#date-input").click().type(text);
cy.clickAndTypeDate("input[name='last_serviced_on']", text);
}

scrollintoWarrantyDetails() {
Expand Down
3 changes: 1 addition & 2 deletions cypress/pageobject/Facility/FacilityCreation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,7 @@ class FacilityPage {
}

fillEntryDate(date: string) {
cy.get("#entry_date").click();
cy.get("#date-input").click().type(date);
cy.clickAndTypeDate("#entry_date", date);
}

clickEditButton() {
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).clear().click().type(date);
cy.clickAndTypeDate(selector, date);
}

clickPatientDetails() {
Expand Down
10 changes: 3 additions & 7 deletions cypress/pageobject/Patient/PatientCreation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,7 @@ export class PatientPage {

typePatientDateOfBirth(dateOfBirth: string) {
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.clickAndTypeDate("#date_of_birth", dateOfBirth);
}

typePatientAge(age: string) {
Expand All @@ -80,13 +78,11 @@ export class PatientPage {
}

typeLastMenstruationStartDate(date: string) {
cy.get("#last_menstruation_start_date").click();
cy.get("#date-input").click().type(date);
cy.clickAndTypeDate("#last_menstruation_start_date", date);
}

typeDateOfDelivery(date: string) {
cy.get("#date_of_delivery").click();
cy.get("#date-input").click().type(date);
cy.clickAndTypeDate("#date_of_delivery", date);
}

clickPermanentAddress() {
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 @@ -33,7 +33,7 @@ class PatientTreatmentPlan {
}

typeProcedureTime(time: string) {
cy.get("#procedure-time").type(time);
cy.clickAndTypeDate("#procedure-time", time);
}

typeTreatmentPlan(treatment: string) {
Expand Down
10 changes: 2 additions & 8 deletions cypress/pageobject/Shift/ShiftFilters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,18 +139,12 @@ class ShiftingPage {
modified_date_end: string,
) {
this.createdDateStartInput().click();
cy.get("[id^='headlessui-popover-panel-'] .care-l-angle-left-b")
.eq(0)
.closest("button")
.click();
cy.get("[data-test-id='increment-date-range']").click();
cy.get(created_date_start).click();
cy.get(created_date_end).click();

this.modifiedDateStartInput().click();
cy.get("[id^='headlessui-popover-panel-'] .care-l-angle-left-b")
.eq(0)
.closest("button")
.click();
cy.get("[data-test-id='increment-date-range']").click();
cy.get(modified_date_start).click();
cy.get(modified_date_end).click();

Expand Down
12 changes: 3 additions & 9 deletions cypress/pageobject/Users/UserCreation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ export class UserCreationPage {
.type(value);
}
typeIntoElementByIdPostClearDob(elementId: string, value: string) {
cy.get("#" + elementId).click();
cy.get("#date-input").clear().type(value);
cy.clickAndTypeDate("#" + elementId, value);
}
clearIntoElementById(elementId: string) {
cy.get("#" + elementId)
Expand Down Expand Up @@ -54,13 +53,8 @@ export class UserCreationPage {
this.selectOptionContainingText(name);
}

setInputDate(
dateElementId: string,
inputElementId: string,
dateValue: string,
) {
this.clickElementById(dateElementId);
this.typeIntoElementById(inputElementId, dateValue);
setInputDate(dateElementId: string, dateValue: string) {
cy.clickAndTypeDate("#" + dateElementId, dateValue);
}

selectDropdownOption(dropdownId: string, optionText: string) {
Expand Down
4 changes: 1 addition & 3 deletions cypress/pageobject/Users/UserProfilePage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,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.clickAndTypeDate("#date_of_birth", date_of_birth);
}

selectGender(gender: string) {
Expand Down
10 changes: 8 additions & 2 deletions cypress/support/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,10 +183,16 @@ 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) => {
cy.get(selector).scrollIntoView();
cy.get(selector).click();
cy.get("#date-input").click().type(date);
cy.get('[data-test-id="date-input"]:visible [data-time-input]').each((el) =>
cy.wrap(el).clear(),
);
cy.get(`[data-test-id="date-input"]:visible [data-time-input="0"]`)
.click()
.type(date);
cy.get("body").click(0, 0);
});

Cypress.Commands.add(
Expand Down
7 changes: 6 additions & 1 deletion src/CAREUI/interactive/SlideOver.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,12 @@ export default function SlideOver({
<h1 className="w-full text-xl font-black">{title}</h1>
</div>
</div>
<div className="flex-1 overflow-auto p-4">{children}</div>
<div
className="flex-1 overflow-auto p-4"
data-test-id="slide-over-container"
>
{children}
</div>
</div>
)}
</DialogPanel>
Expand Down
1 change: 0 additions & 1 deletion src/components/ABDM/FetchRecordsModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,6 @@ export default function FetchRecordsModal({ abha, show, onClose }: IProps) {
label={t("consent_request__expiry")}
required
disablePast
position="TOP-RIGHT"
/>

<div className="mt-6 flex items-center justify-end">
Expand Down
1 change: 0 additions & 1 deletion src/components/Assets/AssetServiceEditModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,6 @@ export const AssetServiceEditModal = (props: {
label={t("serviced_on")}
name="serviced_on"
className="mt-2"
position="LEFT"
value={new Date(form.serviced_on)}
max={new Date(props.service_record.created_date)}
onChange={(date) => {
Expand Down
Loading

0 comments on commit 8eb4dc4

Please sign in to comment.