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

Replace Material UI components in src/Components/Shifting/ListFilter.tsx. Fixes #4996 #5572

Merged
merged 25 commits into from
Jun 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
96fcc41
Merge pull request #1 from coronasafe/develop
JahnabDutta May 26, 2023
c348b50
Change MUI components to CARE components in ResultList.tsx
JahnabDutta May 26, 2023
b1fea78
Merge pull request #2 from coronasafe/develop
JahnabDutta May 26, 2023
393e374
Merge pull request #3 from coronasafe/develop
JahnabDutta May 26, 2023
0657d09
Merge branch 'develop' into develop
khavinshankar May 30, 2023
5296973
Merge branch 'coronasafe:develop' into develop
JahnabDutta May 31, 2023
a8eec96
replace MUI components in src/Components/Shifting/ListFilter.tsx
JahnabDutta May 31, 2023
a4c0702
change LegacySelectField to SelectFormField
JahnabDutta May 31, 2023
8ab013c
fix handChange issue
JahnabDutta May 31, 2023
b7c14e0
Merge branch 'develop' into develop
khavinshankar Jun 1, 2023
2cd2d15
Merge branch 'coronasafe:develop' into develop
JahnabDutta Jun 2, 2023
2be8dc5
fix shiftFilter issues
JahnabDutta Jun 2, 2023
ecf8294
add cypress tests
JahnabDutta Jun 2, 2023
f4016fd
Merge branch 'develop' into develop
nihal467 Jun 5, 2023
7b53f44
change DateRangePicker to DateRangeFormField and add cpyress tests
JahnabDutta Jun 5, 2023
ffff958
Merge original repository to develop repository
JahnabDutta Jun 5, 2023
2e4a9c0
CareUI: Adds `UserAutocompleteFormField` and used it in Assigned To f…
rithviknishad Jun 8, 2023
142f5ca
delete unused `UserSelect2`
rithviknishad Jun 8, 2023
eb3baaf
Merge branch 'develop' into tailwind/userautocompleteformfield
nihal467 Jun 9, 2023
b405d68
Merge branch 'develop' into tailwind/userautocompleteformfield
nihal467 Jun 10, 2023
aa9b9df
Merge branch 'coronasafe:develop' into develop
JahnabDutta Jun 11, 2023
2161dbf
change UserSelect to UserAutoCompleteFormField in ListFilter.tsx and …
JahnabDutta Jun 11, 2023
dc602d3
remove unnecessary grid around DateRangeFormField
JahnabDutta Jun 13, 2023
cc5342f
replace FieldLabel with SelectFormField label
JahnabDutta Jun 13, 2023
65761b2
resolve merge confilcts with ListFilter and cypress test
JahnabDutta Jun 13, 2023
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
118 changes: 103 additions & 15 deletions cypress/e2e/shifting_spec/filter.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,29 +15,36 @@ describe("Shifting section filter", () => {
it("filter by origin facility", () => {
cy.intercept(/\/api\/v1\/getallfacilities/).as("facilities_filter");
cy.get("[name='orgin_facility']")
.type("Dummy Facility 1")
.wait(100)
.type("Dummy")
.wait("@facilities_filter");
cy.get("[role='option']").first().click();
cy.get("[name='orgin_facility']").wait(100).type("{downarrow}{enter}");
cy.contains("Apply").click();
});

it("filter by assigned facility", () => {
cy.intercept(/\/api\/v1\/getallfacilities/).as("facilities_filter");
cy.get("[name='assigned_facility']")
.type("Dummy Shifting Center")
.wait(100)
.type("Dummy")
.wait("@facilities_filter");
cy.get("[role='option']").first().click();
cy.get("[name='assigned_facility']").wait(100).type("{downarrow}{enter}");
cy.contains("Apply").click();
});

it("filter by assigned to user", () => {
cy.intercept(/\/api\/v1\/users/).as("users_filter");
cy.get("[id='assigned_to']")
cy.get("[id='assigned-to']")
.wait(100)
.type("cypress")
.wait("@users_filter");
cy.get("[id='assigned_to']").wait(100).type("{downarrow}{enter}");
cy.get("[id='assigned-to']").wait(100).type("{downarrow}{enter}");
cy.contains("Apply").click();

// cy.intercept(/\/api\/v1\/users/).as("users_filter");
// cy.get("[name='assigned_to']").type("cypress").wait("@users_filter");
// cy.get("[name='assigned_to']").type("{downarrow}{enter}");
// cy.contains("Apply").click();
});

it("filter by ordering", () => {
Expand All @@ -47,46 +54,115 @@ describe("Shifting section filter", () => {
"DESC Modified Date",
"ASC Created Date",
].forEach((select) => {
cy.get("[name='ordering']").select(select).wait(100);
cy.get("[id='ordering'] > div > button")
.click()
.wait(100)
.get("li")
.contains(select)
.click()
.wait(100);
cy.intercept(/\/api\/v1\/shift/).as("shifting_filter");
cy.contains("Apply").click().wait("@shifting_filter");
cy.contains("Filters").click();
// cy.get("[name='ordering']").select(select).wait(100);
// cy.intercept(/\/api\/v1\/shift/).as("shifting_filter");
// cy.contains("Apply").click().wait("@shifting_filter");
// cy.contains("Filters").click();
});
});

it("filter by emergency case", () => {
["yes", "no"].forEach((select) => {
cy.get("[name='emergency']").select(select).wait(100);
cy.get("[id='emergency'] > div > button")
.click()
.wait(100)
.get("li")
.contains(select)
.click()
.wait(100);
cy.intercept(/\/api\/v1\/shift/).as("shifting_filter");
cy.contains("Apply").click().wait("@shifting_filter");
cy.contains("Filters").click();
// cy.get("[name='emergency']").select(select).wait(100);
// cy.intercept(/\/api\/v1\/shift/).as("shifting_filter");
// cy.contains("Apply").click().wait("@shifting_filter");
// cy.contains("Filters").click();
});
});

it("filter by antenatal", () => {
["yes", "no"].forEach((select) => {
cy.get("[name='is_antenatal']").select(select);
cy.get("[id='is-antenatal'] > div > button")
.click()
.wait(100)
.get("li")
.contains(select)
.click()
.wait(100);
cy.intercept(/\/api\/v1\/shift/).as("shifting_filter");
cy.contains("Apply").click().wait("@shifting_filter");
cy.contains("Filters").click();
// cy.get("[name='is-antenatal']").select(select);
// cy.intercept(/\/api\/v1\/shift/).as("shifting_filter");
// cy.contains("Apply").click().wait("@shifting_filter");
// cy.contains("Filters").click();
});
});

it("filter by upshift case", () => {
["yes", "no"].forEach((select) => {
cy.get("[name='is_up_shift']").select(select);
cy.get("[id='is-up-shift'] > div > button")
.click()
.wait(100)
.get("li")
.contains(select)
.click()
.wait(100);
cy.intercept(/\/api\/v1\/shift/).as("shifting_filter");
cy.contains("Apply").click().wait("@shifting_filter");
cy.contains("Filters").click();
// cy.get("[name='is-up-shift']").select(select);
// cy.intercept(/\/api\/v1\/shift/).as("shifting_filter");
// cy.contains("Apply").click().wait("@shifting_filter");
// cy.contains("Filters").click();
});
});

it("filter by disease status", () => {
["POSITIVE", "SUSPECTED", "NEGATIVE", "RECOVERED"].forEach((select) => {
cy.get("[name='disease_status']").select(select);
cy.get("[id='disease-status'] > div > button")
.click()
.wait(100)
.get("li")
.contains(select)
.click()
.wait(100);
cy.intercept(/\/api\/v1\/shift/).as("shifting_filter");
cy.contains("Apply").click().wait("@shifting_filter");
cy.contains("Filters").click();
// cy.get("[name='disease_status']").select(select);
// cy.intercept(/\/api\/v1\/shift/).as("shifting_filter");
// cy.contains("Apply").click().wait("@shifting_filter");
// cy.contains("Filters").click();
});
});

it("filter by breathlessness level", () => {
["NOT BREATHLESS", "MILD", "MODERATE", "SEVERE"].forEach((select) => {
cy.get("[id='breathlessness-level'] > div > button")
.click()
.wait(100)
.get("li")
.contains(select)
.click()
.wait(100);
cy.intercept(/\/api\/v1\/shift/).as("shifting_filter");
cy.contains("Apply").click().wait("@shifting_filter");
cy.contains("Filters").click();
// cy.get("[name='breathlessness_level']").select(select);
// cy.intercept(/\/api\/v1\/shift/).as("shifting_filter");
// cy.contains("Apply").click().wait("@shifting_filter");
// cy.contains("Filters").click();
});
});

Expand All @@ -103,15 +179,27 @@ describe("Shifting section filter", () => {
});

it("filter by created date", () => {
cy.get("[name='created_date_after']").type("22/05/2020");
cy.get("[name='created_date_before']").type("09/09/2021");
cy.contains("Created Date")
.parent()
.within(() => {
cy.get("input[placeholder='Start date']").click();
cy.contains("1").click();
cy.get("input[placeholder='End date']").click();
cy.contains("21").click();
});
cy.intercept(/\/api\/v1\/shift/).as("shifting_filter");
cy.contains("Apply").click().wait("@shifting_filter");
});

it("filter by modified date", () => {
cy.get("[name='modified_date_after']").type("22/05/2020");
cy.get("[name='modified_date_before']").type("09/09/2021");
cy.contains("Modified Date")
.parent()
.within(() => {
cy.get("input[placeholder='Start date']").click();
cy.contains("1").click();
cy.get("input[placeholder='End date']").click();
cy.contains("21").click();
});
cy.intercept(/\/api\/v1\/shift/).as("shifting_filter");
cy.contains("Apply").click().wait("@shifting_filter");
});
Expand Down
20 changes: 10 additions & 10 deletions src/Components/Shifting/Commons.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
export const limit = 14;

export const initialFilterData = {
status: "--",
status: "",
facility: "",
orgin_facility: "",
shifting_approving_facility: "",
assigned_facility: "",
emergency: "--",
is_up_shift: "--",
emergency: "",
is_up_shift: "",
limit: limit,
patient_name: "",
created_date_before: null,
Expand All @@ -17,30 +17,30 @@ export const initialFilterData = {
patient_phone_number: "",
offset: 0,
ordering: null,
is_kasp: "--",
is_kasp: "",
assigned_to: "",
disease_status: "",
is_antenatal: "--",
is_antenatal: "",
breathlessness_level: "",
};

export const formatFilter = (params: any) => {
const filter = { ...initialFilterData, ...params };
return {
status: filter.status === "--" ? null : filter.status,
status: filter.status === "" ? null : filter.status,
facility: "",
orgin_facility: filter.orgin_facility || undefined,
shifting_approving_facility:
filter.shifting_approving_facility || undefined,
assigned_facility: filter.assigned_facility || undefined,
emergency:
(filter.emergency && filter.emergency) === "--"
(filter.emergency && filter.emergency) === ""
? ""
: filter.emergency === "yes"
? "true"
: "false",
is_up_shift:
(filter.is_up_shift && filter.is_up_shift) === "--"
(filter.is_up_shift && filter.is_up_shift) === ""
? ""
: filter.is_up_shift === "yes"
? "true"
Expand All @@ -58,13 +58,13 @@ export const formatFilter = (params: any) => {
disease_status: filter.disease_status || undefined,
breathlessness_level: filter.breathlessness_level || undefined,
is_kasp:
(filter.is_kasp && filter.is_kasp) === "--"
(filter.is_kasp && filter.is_kasp) === ""
? ""
: filter.is_kasp === "yes"
? "true"
: "false",
is_antenatal:
(filter.is_antenatal && filter.is_antenatal) === "--"
(filter.is_antenatal && filter.is_antenatal) === ""
? ""
: filter.is_antenatal === "yes"
? "true"
Expand Down
Loading