Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cypress tests replace cy.wait with cy.intercept or dynamic waits #8963

Merged
Changes from 1 commit
Commits
Show all changes
107 commits
Select commit Hold shift + click to select a range
bb972f2
Cypress Tests cy.wait() replace with cy.intercept() or dynamic wait
Rishith25 Oct 28, 2024
f5d5cc8
Refactor Cypress tests: replaced static cy.wait() with dynamic waits …
Rishith25 Oct 29, 2024
a6f10ee
Merge branch 'develop' into cypress-tests-replace-cy.wait-with-cy.int…
Rishith25 Nov 8, 2024
f8cd9c8
Merge branch 'develop' into cypress-tests-replace-cy.wait-with-cy.int…
nihal467 Nov 8, 2024
814aebc
Resolved merge conflicts
Rishith25 Nov 23, 2024
568c7e2
Cypress test cases
Rishith25 Nov 24, 2024
f5734f6
Added intercept in Facility Inventory
Rishith25 Nov 26, 2024
ac1072c
Merge branch 'cypress-tests-replace-cy.wait-with-cy.intercept' of htt…
Rishith25 Nov 26, 2024
277fb42
reverting .env file
Rishith25 Nov 26, 2024
ef2c4a8
Merge branch 'develop' into cypress-tests-replace-cy.wait-with-cy.int…
Rishith25 Nov 30, 2024
88d7c77
cy.wait is replaced with cy.intercept in ManageUser
Rishith25 Nov 30, 2024
800d764
Testing for Wait in FacilityHomepage
Rishith25 Nov 30, 2024
58cd29e
Merge branch 'develop' into cypress-tests-replace-cy.wait-with-cy.int…
Rishith25 Dec 2, 2024
c6e95c2
AssetHomepage tests
Rishith25 Dec 2, 2024
8d4e83d
Add Precription intercept added
Rishith25 Dec 2, 2024
5ff8428
Wait added before medicine prescribed
Rishith25 Dec 2, 2024
f81f85f
Get request in consultationcreation
Rishith25 Dec 2, 2024
e47d2b0
Logupdate
Rishith25 Dec 2, 2024
c2fdb54
Merge branch 'develop' into cypress-tests-replace-cy.wait-with-cy.int…
Rishith25 Dec 4, 2024
443d438
AssetHomePage Wait removal
Rishith25 Dec 4, 2024
54eee2a
FacilityHomepage.cy.ts test case wait
Rishith25 Dec 4, 2024
1e55ab4
Patient Registration Waits
Rishith25 Dec 4, 2024
1d80441
revert PatientInsurance.ts
Rishith25 Dec 4, 2024
e461b91
Patient Consultation wait corrected
Rishith25 Dec 4, 2024
b4dfc9f
Paatient Discharge
Rishith25 Dec 4, 2024
c2bb8ba
Patient Consultation creation updated cypress
Rishith25 Dec 4, 2024
acdd07c
Patient discharge updated cypress
Rishith25 Dec 4, 2024
47d521b
Edit Consultation cypress test intercept added
Rishith25 Dec 4, 2024
a2a8cdf
FacilityHomepage wait
Rishith25 Dec 4, 2024
4a22cd4
Merge branch 'develop' into cypress-tests-replace-cy.wait-with-cy.int…
Rishith25 Dec 5, 2024
c2b454c
Merge branch 'develop' into cypress-tests-replace-cy.wait-with-cy.int…
Rishith25 Dec 5, 2024
2b282e4
PatientLogUpdate waits
Rishith25 Dec 5, 2024
f7a0281
PatientLogUpdate waits
Rishith25 Dec 5, 2024
3fa7459
PatientLogUpdate waits
Rishith25 Dec 5, 2024
60512d6
PatientLogUpdate waits
Rishith25 Dec 5, 2024
09d5f55
Merge branch 'develop' into cypress-tests-replace-cy.wait-with-cy.int…
Rishith25 Dec 6, 2024
c31f369
PatientLogUpdate new Progress log update
Rishith25 Dec 6, 2024
cf04eb7
PatientLogUpdate new Progress log update
Rishith25 Dec 6, 2024
5a4d28b
PatientLogUpdate new Progress log update
Rishith25 Dec 6, 2024
0c51eca
PatientLogUpdate new Normal log update
Rishith25 Dec 6, 2024
d4dd88b
PatientLogUpdate new Normal log update
Rishith25 Dec 6, 2024
36c6606
PatientLogUpdate new Normal log update
Rishith25 Dec 6, 2024
545ddd0
Merge branch 'develop' into cypress-tests-replace-cy.wait-with-cy.int…
Rishith25 Dec 6, 2024
228bbef
PatientLogUpdate new Normal log update
Rishith25 Dec 6, 2024
227ee29
PatientLogUpdate new Progress
Rishith25 Dec 6, 2024
c6d36b3
Patient Registration cy.wait with intercepts
Rishith25 Dec 6, 2024
e417e0d
Patient Registration cy.wait with intercepts
Rishith25 Dec 7, 2024
e8140a3
Patient Discharge cy.wait
Rishith25 Dec 7, 2024
307a1b1
Patient LogUpdate reflection cards
Rishith25 Dec 7, 2024
02fc708
Facility Homepage cy.wait
Rishith25 Dec 7, 2024
d9b8539
Facility Homepage cy.wait
Rishith25 Dec 7, 2024
5e844f9
Patient Doctor Notes, File Upload cy.wait
Rishith25 Dec 7, 2024
943bb79
Patient Registration cy.waits
Rishith25 Dec 7, 2024
582e982
Patient File Upload cy.wait
Rishith25 Dec 7, 2024
a6f2bf1
Patient File Upload cy.wait
Rishith25 Dec 7, 2024
c88bce8
Patient File Upload cy.wait
Rishith25 Dec 8, 2024
18f1ccd
Patient Registration wait
Rishith25 Dec 8, 2024
48eb1a1
Patient Registration Edit Button
Rishith25 Dec 8, 2024
2c00829
Patient Edit details
Rishith25 Dec 8, 2024
29906d2
Patient File Upload with waits
Rishith25 Dec 8, 2024
1099d9a
Patient File Upload with waits
Rishith25 Dec 8, 2024
da4f978
Merge branch 'develop' into cypress-tests-replace-cy.wait-with-cy.int…
Rishith25 Dec 11, 2024
1ccab9c
Reusable functions for intercepts in cypress testcases
Rishith25 Dec 11, 2024
eee4f1a
Reusable functions for intercepts in cypress testcases
Rishith25 Dec 11, 2024
c16381c
User Manage Test Cases updated
Rishith25 Dec 11, 2024
4dda5aa
User Manage Test Cases updated
Rishith25 Dec 11, 2024
d016b30
Merge branch 'develop' into cypress-tests-replace-cy.wait-with-cy.int…
Rishith25 Dec 11, 2024
c7c035b
UserManage test cases
Rishith25 Dec 11, 2024
d835081
UserManage
Rishith25 Dec 11, 2024
612aaae
Merge branch 'develop' into cypress-tests-replace-cy.wait-with-cy.int…
Rishith25 Dec 12, 2024
145edec
AddSkillButton with username
Rishith25 Dec 12, 2024
f6fa2d9
Merge branch 'develop' into cypress-tests-replace-cy.wait-with-cy.int…
Rishith25 Dec 12, 2024
fede9a6
AssetsManage and AssetHomepage cypress tests
Rishith25 Dec 13, 2024
94ab84e
Merge branch 'develop' into cypress-tests-replace-cy.wait-with-cy.int…
Rishith25 Dec 13, 2024
962d6ca
FacilityCreation cypress tests
Rishith25 Dec 13, 2024
559f5a7
Merge branch 'develop' into cypress-tests-replace-cy.wait-with-cy.int…
Rishith25 Dec 14, 2024
8f0b0f2
Facility deletion test case resolve
Rishith25 Dec 14, 2024
c951801
Facility creation error resolved
Rishith25 Dec 14, 2024
edafae3
fixed the cypress test
Rishith25 Dec 15, 2024
32ea381
Merge branch 'develop' into cypress-tests-replace-cy.wait-with-cy.int…
Rishith25 Dec 15, 2024
dd9bc77
fixed the cypress test
Rishith25 Dec 15, 2024
46607cd
fcility creation test
Rishith25 Dec 15, 2024
31258b8
fcility creation test
Rishith25 Dec 15, 2024
1692999
Merge branch 'develop' into cypress-tests-replace-cy.wait-with-cy.int…
Rishith25 Dec 16, 2024
9e2a124
Facility creation display error
Rishith25 Dec 16, 2024
fadca5e
Facility creation display error
Rishith25 Dec 16, 2024
13ebbee
Facility creation display error
Rishith25 Dec 16, 2024
1a63161
Patient Discharge recovered test case
Rishith25 Dec 16, 2024
68830a8
Facility Homepage bed capacity test case
Rishith25 Dec 16, 2024
035370b
Facility Creation test cases
Rishith25 Dec 16, 2024
ff719a6
Facility Creation test cases
Rishith25 Dec 16, 2024
75936d7
Facility Creation test cases
Rishith25 Dec 16, 2024
87b78fc
Merge branch 'develop' into cypress-tests-replace-cy.wait-with-cy.int…
Rishith25 Dec 16, 2024
86492c3
commented notification for check
Rishith25 Dec 16, 2024
0c2705e
Facility creation test cases
Rishith25 Dec 16, 2024
48456f2
Merge branch 'develop' into cypress-tests-replace-cy.wait-with-cy.int…
nihal467 Dec 17, 2024
d09b794
Search UI for discharge patients (#9320)
Mahendar0701 Dec 17, 2024
754c9a4
Fixes UI Bug Issue in Symptom Editor (#9270)
JavidSumra Dec 17, 2024
fa51d9f
Occupancy bed tooltip fully visible in mobile view (#9235)
Rishith25 Dec 17, 2024
fad3f8c
Disallowing out of date range (#9201)
Rishith25 Dec 17, 2024
5be34d7
Bump @sentry/browser from 8.42.0 to 8.45.1 (#9473)
dependabot[bot] Dec 17, 2024
20efe33
Patient registration form url intercept
Rishith25 Dec 17, 2024
6fe4087
Patient registration form url intercept
Rishith25 Dec 17, 2024
c4ace63
Merge branch 'develop' into cypress-tests-replace-cy.wait-with-cy.int…
nihal467 Dec 18, 2024
266e1c5
debug the facility creation
nihal467 Dec 18, 2024
a984390
removed hardcorded pagination verification
nihal467 Dec 18, 2024
31282ab
Merge branch 'develop' into cypress-tests-replace-cy.wait-with-cy.int…
nihal467 Dec 18, 2024
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
Prev Previous commit
Next Next commit
Disallowing out of date range (#9201)
Rishith25 committed Dec 17, 2024
commit fad3f8c8cd8f7b774aafcf42c02b733c735adaf4
274 changes: 208 additions & 66 deletions src/components/Common/DateInputV2.tsx
Original file line number Diff line number Diff line change
@@ -89,15 +89,18 @@ const DateInputV2: React.FC<Props> = ({
);
break;
case "month":
setDatePickerHeaderDate((prev) =>
dayjs(prev).subtract(1, "year").toDate(),
);
setDatePickerHeaderDate((prev) => {
const newDate = dayjs(prev).subtract(1, "year").toDate();
if (min && newDate < min) {
return new Date(min.getFullYear(), min.getMonth(), 1);
}
return newDate;
});
Rishith25 marked this conversation as resolved.
Show resolved Hide resolved
break;
case "year":
setDatePickerHeaderDate((prev) =>
dayjs(prev).subtract(1, "year").toDate(),
);
setYear((prev) => dayjs(prev).subtract(10, "year").toDate());
if (!min || year.getFullYear() - 10 >= min.getFullYear()) {
setYear((prev) => dayjs(prev).subtract(10, "year").toDate());
}
break;
}
};
@@ -108,11 +111,18 @@ const DateInputV2: React.FC<Props> = ({
setDatePickerHeaderDate((prev) => dayjs(prev).add(1, "month").toDate());
break;
case "month":
setDatePickerHeaderDate((prev) => dayjs(prev).add(1, "year").toDate());
setDatePickerHeaderDate((prev) => {
const newDate = dayjs(prev).add(1, "year").toDate();
if (max && newDate > max) {
return new Date(max.getFullYear(), max.getMonth(), 1);
}
return newDate;
});
break;
case "year":
setDatePickerHeaderDate((prev) => dayjs(prev).add(1, "year").toDate());
setYear((prev) => dayjs(prev).add(10, "year").toDate());
if (!max || year.getFullYear() + 10 <= max.getFullYear()) {
setYear((prev) => dayjs(prev).add(10, "year").toDate());
}
break;
}
};
@@ -209,32 +219,82 @@ const DateInputV2: React.FC<Props> = ({
return true;
};

const isMonthWithinConstraints = (month: number) => {
const year = datePickerHeaderDate.getFullYear();

if (min && year < min.getFullYear()) return false;
if (max && year > max.getFullYear()) return false;

const firstDay = new Date(year, month, 1);
const lastDay = new Date(year, month + 1, 0);
if (min && lastDay < min) return false;
if (max && firstDay > max) return false;

return true;
};

const isYearWithinConstraints = (year: number) => {
if (min && year < min.getFullYear()) return false;
if (max && year > max.getFullYear()) return false;

const yearStart = new Date(year, 0, 1);
const yearEnd = new Date(year, 11, 31);

if (min && yearEnd < min) return false;
if (max && yearStart > max) return false;

return true;
};

const isSelectedMonth = (month: number) =>
month === datePickerHeaderDate.getMonth();

const isSelectedYear = (year: number) =>
year === datePickerHeaderDate.getFullYear();

const setMonthValue = (month: number) => () => {
setDatePickerHeaderDate(
new Date(
if (isMonthWithinConstraints(month)) {
const lastDayOfMonth = new Date(
datePickerHeaderDate.getFullYear(),
month,
datePickerHeaderDate.getDate(),
),
);
setType("date");
month + 1,
0,
).getDate();
const newDate = Math.min(datePickerHeaderDate.getDate(), lastDayOfMonth);
setDatePickerHeaderDate(
new Date(datePickerHeaderDate.getFullYear(), month, newDate),
);
setType("date");
} else {
Notification.Error({
msg: outOfLimitsErrorMessage ?? "Cannot select month out of range",
});
}
};

//min and max setting for year
const setYearValue = (year: number) => () => {
setDatePickerHeaderDate(
new Date(
if (isYearWithinConstraints(year)) {
const newDate = new Date(
year,
datePickerHeaderDate.getMonth(),
datePickerHeaderDate.getDate(),
),
);
setType("date");
);
if (min && year === min.getFullYear() && newDate < min) {
setDatePickerHeaderDate(
new Date(min.getFullYear(), min.getMonth(), min.getDate()),
);
} else if (max && year === max.getFullYear() && newDate > max) {
setDatePickerHeaderDate(
new Date(max.getFullYear(), max.getMonth(), max.getDate()),
);
} else {
setDatePickerHeaderDate(newDate);
}
setType("date");
} else {
Notification.Error({
msg: outOfLimitsErrorMessage ?? "Cannot select year out of range",
});
}
};

useEffect(() => {
@@ -372,23 +432,62 @@ const DateInputV2: React.FC<Props> = ({
<div className="flex flex-col items-center gap-4 px-4 md:flex-row md:px-0">
<div className="flex flex-1 flex-col items-center justify-between">
<div className="flex">
<button
type="button"
disabled={
!isDateWithinConstraints(
getLastDay(),
datePickerHeaderDate.getMonth() - 1,
)
}
className="inline-flex aspect-square cursor-pointer items-center justify-center rounded p-2 transition duration-100 ease-in-out hover:bg-secondary-300"
onClick={decrement}
data-test-id="decrement-date-range"
>
<CareIcon
icon="l-angle-left-b"
className="text-lg"
/>
</button>
{type === "date" && (
<button
type="button"
disabled={
!isDateWithinConstraints(
getLastDay(),
datePickerHeaderDate.getMonth() - 1,
datePickerHeaderDate.getFullYear(),
)
}
className="inline-flex aspect-square cursor-pointer items-center justify-center rounded p-2 transition duration-100 ease-in-out hover:bg-secondary-300"
onClick={decrement}
data-test-id="decrement-date-range"
>
<CareIcon
icon="l-angle-left-b"
className="text-lg"
/>
</button>
)}
{type === "month" && (
<button
type="button"
disabled={
min &&
datePickerHeaderDate.getFullYear() <=
min.getFullYear()
}
className="inline-flex aspect-square cursor-pointer items-center justify-center rounded p-2 transition duration-100 ease-in-out hover:bg-secondary-300"
onClick={decrement}
data-test-id="decrement-month-range"
>
<CareIcon
icon="l-angle-left-b"
className="text-lg"
/>
</button>
)}

{type === "year" && (
<button
type="button"
disabled={
min &&
year.getFullYear() - 10 < min.getFullYear()
}
className="inline-flex aspect-square cursor-pointer items-center justify-center rounded p-2 transition duration-100 ease-in-out hover:bg-secondary-300"
onClick={decrement}
data-test-id="decrement-year-range"
>
<CareIcon
icon="l-angle-left-b"
className="text-lg"
/>
</button>
)}

<div className="flex items-center justify-center text-sm">
{type === "date" && (
@@ -412,23 +511,62 @@ const DateInputV2: React.FC<Props> = ({
</p>
</div>
</div>
<button
type="button"
disabled={
(type === "year" &&
new Date().getFullYear() ===
year.getFullYear()) ||
!isDateWithinConstraints(getLastDay())
}
className="inline-flex aspect-square cursor-pointer items-center justify-center rounded p-2 transition duration-100 ease-in-out hover:bg-secondary-300"
onClick={increment}
data-test-id="increment-date-range"
>
<CareIcon
icon="l-angle-right-b"
className="text-lg"
/>
</button>
{type === "date" && (
<button
type="button"
disabled={
!isDateWithinConstraints(
getLastDay(),
datePickerHeaderDate.getMonth(),
datePickerHeaderDate.getFullYear(),
)
}
className="inline-flex aspect-square cursor-pointer items-center justify-center rounded p-2 transition duration-100 ease-in-out hover:bg-secondary-300"
onClick={increment}
data-test-id="increment-date-range"
>
<CareIcon
icon="l-angle-right-b"
className="text-lg"
/>
</button>
)}
{type === "month" && (
<button
type="button"
disabled={
max &&
datePickerHeaderDate.getFullYear() >=
max.getFullYear()
}
className="inline-flex aspect-square cursor-pointer items-center justify-center rounded p-2 transition duration-100 ease-in-out hover:bg-secondary-300"
onClick={increment}
data-test-id="increment-month-range"
>
<CareIcon
icon="l-angle-right-b"
className="text-lg"
/>
</button>
)}

{type === "year" && (
<button
type="button"
disabled={
max &&
year.getFullYear() + 10 > max.getFullYear()
}
className="inline-flex aspect-square cursor-pointer items-center justify-center rounded p-2 transition duration-100 ease-in-out hover:bg-secondary-300"
onClick={increment}
data-test-id="increment-year-range"
>
<CareIcon
icon="l-angle-right-b"
className="text-lg"
/>
</button>
)}
</div>

{type === "date" && (
@@ -511,10 +649,12 @@ const DateInputV2: React.FC<Props> = ({
key={i}
id={`month-${i}`}
className={classNames(
"w-1/4 cursor-pointer rounded-lg px-2 py-4 text-center text-sm font-semibold",
value && isSelectedMonth(i)
? "bg-primary-500 text-white"
: "text-secondary-700 hover:bg-secondary-300",
"w-1/4 rounded-lg px-2 py-4 text-center text-sm font-semibold",
isSelectedMonth(i)
? "bg-primary-500 text-white cursor-pointer"
: isMonthWithinConstraints(i)
? "text-secondary-700 hover:bg-secondary-300 cursor-pointer"
: "!text-secondary-400 !cursor-not-allowed",
)}
onClick={setMonthValue(i)}
>
@@ -534,16 +674,18 @@ const DateInputV2: React.FC<Props> = ({
{Array(12)
.fill(null)
.map((_, i) => {
const y = year.getFullYear() - 11 + i;
const y = year.getFullYear() - 10 + i;
return (
<div
key={i}
id={`year-${i}`}
className={classNames(
"w-1/4 cursor-pointer rounded-lg px-2 py-4 text-center text-sm font-semibold",
value && isSelectedYear(y)
? "bg-primary-500 text-white"
: "text-secondary-700 hover:bg-secondary-300",
"w-1/4 rounded-lg px-2 py-4 text-center text-sm font-semibold",
isSelectedYear(y)
? "bg-primary-500 text-white cursor-pointer"
: isYearWithinConstraints(y)
? "text-secondary-700 hover:bg-secondary-300 cursor-pointer"
: "!text-secondary-400 !cursor-not-allowed",
)}
onClick={setYearValue(y)}
>