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

Fixed Multi-selection functionality. #9345

Closed
wants to merge 44 commits into from
Closed
Show file tree
Hide file tree
Changes from 32 commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
72c25c7
Fix multi-selection, closes #9144
Jeffrin2005 Dec 10, 2024
5e98869
Merge branch 'develop' into multiselection
Jeffrin2005 Dec 10, 2024
e8499fd
updated , closes 9144
Jeffrin2005 Dec 10, 2024
db2fb4c
updated index.tsx
Jeffrin2005 Dec 11, 2024
2098454
updated index.tsx
Jeffrin2005 Dec 13, 2024
7d99ffe
Merge branch 'develop' into multiselection
Jeffrin2005 Dec 17, 2024
b9c2913
final Board.tsx
Jeffrin2005 Dec 18, 2024
e721590
Switch out all the ButtonV2s and used button
Jeffrin2005 Dec 19, 2024
c2fe3a9
Merge branch 'multiselection' of https://github.com/Jeffrin2005/care_…
Jeffrin2005 Dec 19, 2024
7cd8d7f
button instead of buttonV2
Jeffrin2005 Dec 21, 2024
d869d1b
Merge branch 'develop' into multiselection
Jeffrin2005 Dec 21, 2024
aa51880
Final-updated shadcn button
Jeffrin2005 Dec 23, 2024
102bc74
Merge branch 'multiselection' of https://github.com/Jeffrin2005/care_…
Jeffrin2005 Dec 23, 2024
9a73618
orginal-used shadcn button
Jeffrin2005 Dec 23, 2024
1f667e2
Final-Latest-used shadcn Button
Jeffrin2005 Dec 23, 2024
fc1ff52
used_variant=primary,secondary
Jeffrin2005 Dec 23, 2024
de35c4d
Merge branch 'develop' into multiselection
nihal467 Dec 24, 2024
1ad5032
Merge branch 'develop' into multiselection
nihal467 Dec 24, 2024
b900f6f
latest-investigation
Jeffrin2005 Dec 26, 2024
db0e22e
Merge branch 'develop' into multiselection
Jeffrin2005 Dec 28, 2024
bad7863
Correct Failing Test Case
Jeffrin2005 Dec 28, 2024
0faeb64
Merge branch 'multiselection' of https://github.com/Jeffrin2005/care_…
Jeffrin2005 Dec 28, 2024
f52117b
Correct Failing Test case
Jeffrin2005 Dec 28, 2024
564a461
changed patientInvestigation.ts
Jeffrin2005 Dec 28, 2024
18fcf32
final test fail
Jeffrin2005 Dec 28, 2024
ce00cdf
latest check
Jeffrin2005 Dec 28, 2024
a2d1d38
final
Jeffrin2005 Dec 28, 2024
e6702d0
latest-final
Jeffrin2005 Dec 28, 2024
6c91c63
final1
Jeffrin2005 Dec 28, 2024
0c9da17
cypress test fail
Jeffrin2005 Dec 28, 2024
623dfa0
cypress3 test
Jeffrin2005 Dec 28, 2024
762c1ea
final2
Jeffrin2005 Dec 28, 2024
6a67690
orginal
Jeffrin2005 Dec 28, 2024
34d40da
latest1
Jeffrin2005 Dec 28, 2024
e9129e5
finall
Jeffrin2005 Dec 28, 2024
ec73916
rever
Jeffrin2005 Dec 28, 2024
33653fb
orginal
Jeffrin2005 Dec 28, 2024
a971c59
test final
Jeffrin2005 Dec 28, 2024
21601fe
temp1
Jeffrin2005 Dec 28, 2024
6d63a69
Test final
Jeffrin2005 Dec 28, 2024
a920771
Final commit of tests
Jeffrin2005 Dec 28, 2024
d6fe9b4
test1
Jeffrin2005 Dec 28, 2024
197c9a9
UP1
Jeffrin2005 Dec 28, 2024
4c56047
FINAL_COMMIT
Jeffrin2005 Dec 28, 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
35 changes: 33 additions & 2 deletions cypress/e2e/patient_spec/PatientInvestigation.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,48 @@ describe("Patient Investigation Creation from Patient consultation page", () =>
});

it("Create a investigation for a patient and verify its reflection", () => {
// Add retry-ability for network requests
cy.intercept("GET", "**/patients/**").as("patientLoad");
cy.intercept("GET", "**/investigations/**").as("investigationsLoad");

// Visit patient and wait for page load
patientPage.visitPatient(patientName);
cy.wait("@patientLoad");

// Add small delay to ensure page is stable
cy.wait(1000);

// Click investigation tab and verify content loads
patientInvestigation.clickInvestigationTab();
cy.wait("@investigationsLoad");

// Verify investigation tab is active
patientInvestigation.verifyPageLoaded();

// Continue with test
patientInvestigation.clickLogLabResults();

// Add verification before selecting options
cy.get("#investigations").should("exist").and("be.visible");

patientInvestigation.selectInvestigationOption([
"Haematology",
"Urine Test",
]);

// Verify save button exists before clicking
cy.get("button")
.contains("Save Investigation")
.should("exist")
.and("be.visible");

cy.clickSubmitButton("Save Investigation");
cy.verifyNotification("Please Enter at least one value");

// Verify notification with timeout
cy.verifyNotification("Please Enter at least one value", {
timeout: 10000,
});
cy.closeNotification();
// Temporary workflow for investigation since we dont have dummy data and moving away from existing module
});

afterEach(() => {
Expand Down
66 changes: 56 additions & 10 deletions cypress/pageobject/Patient/PatientInvestigation.ts
Original file line number Diff line number Diff line change
@@ -1,33 +1,79 @@
class PatientInvestigation {
clickAddInvestigation() {
cy.verifyAndClickElement("#investigation", "Add Investigation");
cy.get("#investigation")
.should("exist")
.and("be.visible")
.contains("Add Investigation")
.click();
}

clickInvestigationTab() {
cy.verifyAndClickElement("#consultation_tab_nav", "Investigations");
cy.intercept("GET", "**/investigations/**").as("investigationsLoad");

cy.get("#consultation_tab_nav")
.should("exist")
.and("be.visible")
.contains("Investigations")
.click();

cy.wait("@investigationsLoad", { timeout: 10000 });

cy.get("#investigations").should("exist").and("be.visible");
}

selectInvestigation(investigation: string) {
cy.get("#search-patient-investigation").type(investigation);
cy.verifyAndClickElement("#investigation-group", investigation);
cy.verifyAndClickElement("#investigation", "Investigation No. 1");
cy.get("#search-patient-investigation")
.should("exist")
.and("be.visible")
.clear()
.type(investigation, { delay: 100 });

cy.get("#investigation-group")
.should("exist")
.and("be.visible")
.contains(investigation)
.click();

cy.get("#investigation")
.should("exist")
.and("be.visible")
.contains("Investigation No. 1")
.click();
}

clickInvestigationCheckbox() {
cy.get("#investigation-checkbox").click();
cy.get("#investigation-checkbox").should("exist").and("be.visible").click();
}

selectInvestigationOption(options: string[]) {
cy.clickAndMultiSelectOption("#investigations", options);
cy.get("#investigations")
.should("exist")
.and("be.visible")
.then(() => {
cy.clickAndMultiSelectOption("#investigations", options);
});
}

clickLogLabResults() {
cy.verifyAndClickElement("#log-lab-results", "Log Lab Results");
cy.get("#log-lab-results")
.should("exist")
.and("be.visible")
.contains("Log Lab Results")
.click();
}

selectInvestigationFrequency(frequency: string) {
cy.get("#investigation-frequency").click();
cy.contains("button", frequency).should("be.visible").click();
cy.get("#investigation-frequency")
.should("exist")
.and("be.visible")
.click();

cy.contains("button", frequency).should("exist").and("be.visible").click();
}

verifyPageLoaded() {
return cy.get("#investigations").should("exist").and("be.visible");
}
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codebase verification

Test coverage needs to be expanded for multi-selection scenarios

Based on the code analysis, the current test coverage is incomplete for the multi-selection functionality mentioned in issue #9144:

  1. The investigation test file only covers a basic multi-selection scenario with two options ("Haematology", "Urine Test") in one test case.
  2. The clear button functionality is not tested.
  3. Multi-selection in create investigation page is not covered.

Key areas that need test coverage:

  • Test selecting multiple investigations with more than two options
  • Test clearing selected investigations
  • Test multi-selection in both log lab results and create investigation pages
  • Test edge cases (selecting all options, deselecting options)
🔗 Analysis chain

Ensure comprehensive test coverage for multi-selection scenarios.

While the page object methods have been improved, we need to ensure all scenarios from issue #9144 are covered:

  1. Multi-selection in Patient log lab results section
  2. Multi-selection in create investigation page
  3. Clear button functionality
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check test coverage for multi-selection scenarios
echo "Checking test coverage..."

# Look for test cases covering multi-selection
echo "Multi-selection test cases:"
rg -B 2 -A 2 "selectInvestigationOption.*\[.*\]" cypress/e2e/

# Look for clear button test cases
echo -e "\nClear button test cases:"
rg -B 2 -A 2 "clear.*button|clearSelected" cypress/e2e/

# Look for create investigation page test cases
echo -e "\nCreate investigation page test cases:"
rg -B 2 -A 2 "create.*investigation" cypress/e2e/

Length of output: 928


Script:

#!/bin/bash
# Let's try a different approach to find test coverage

# Look for test files that might contain investigation-related tests
echo "Investigation test files:"
fd ".*investigation.*\.cy\.ts$" cypress/e2e/

# Search for investigation-related test descriptions
echo -e "\nInvestigation test cases:"
rg -B 2 -A 2 "it\(.*investigation.*" cypress/e2e/

# Look for usage of PatientInvestigation page object
echo -e "\nPatientInvestigation usage:"
rg -B 2 -A 2 "new PatientInvestigation\(\)" cypress/e2e/

# Search for multi-select related code
echo -e "\nMulti-select related code:"
rg -B 2 -A 2 "multiSelect|multiple.*select" cypress/e2e/

Length of output: 2941


Script:

#!/bin/bash
# Let's examine the actual test file content to understand coverage

echo "Content of PatientInvestigation.cy.ts:"
cat cypress/e2e/patient_spec/PatientInvestigation.cy.ts

echo -e "\nChecking for clickAndMultiSelectOption implementation:"
rg -B 2 -A 2 "clickAndMultiSelectOption" cypress/support/

echo -e "\nChecking PatientLogUpdate.cy.ts for lab results tests:"
cat cypress/e2e/patient_spec/PatientLogUpdate.cy.ts

Length of output: 19730

export default PatientInvestigation;
77 changes: 41 additions & 36 deletions src/components/Facility/Investigations/Reports/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { useCallback, useReducer, useState } from "react";
import { useTranslation } from "react-i18next";

import ButtonV2 from "@/components/Common/ButtonV2";
import { Button } from "@/components/ui/button";

import CircularProgress from "@/components/Common/CircularProgress";
import Loading from "@/components/Common/Loading";
import Page from "@/components/Common/Page";
Expand Down Expand Up @@ -53,42 +54,36 @@ const initialState: InitialState = {

const investigationReportsReducer = (state = initialState, action: any) => {
switch (action.type) {
case "set_investigation_groups": {
case "set_investigation_groups":
return {
...state,
investigationGroups: action.payload,
};
}
case "set_selected_group": {
case "set_selected_group":
return {
...state,
selectedGroup: action.payload,
};
}
case "set_investigations": {
case "set_investigations":
return {
...state,
investigations: action.payload,
};
}
case "set_selected_investigations": {
case "set_selected_investigations":
return {
...state,
selectedInvestigations: action.payload,
};
}
case "set_investigation_table_data": {
case "set_investigation_table_data":
return {
...state,
investigationTableData: action.payload,
};
}
case "set_loading": {
case "set_loading":
return {
...state,
isLoading: action.payload,
};
}
default:
return state;
}
Expand All @@ -113,6 +108,10 @@ const InvestigationReports = ({ id }: any) => {
selectedInvestigations,
} = state as InitialState;

const clearSelectedInvestigations = () => {
dispatch({ type: "set_selected_investigations", payload: [] });
};

const fetchInvestigationsData = useCallback(
async (
onSuccess: (
Expand Down Expand Up @@ -314,14 +313,13 @@ const InvestigationReports = ({ id }: any) => {
/>
</div>
{!isLoading.investigationLoading && (
<ButtonV2
<Button
onClick={() => fetchInvestigation()}
disabled={getTestDisabled}
variant="primary"
className="my-2.5"
>
{t("get_tests")}
</ButtonV2>
</Button>
)}
{!!isLoading.investigationLoading && (
<CircularProgress className="text-primary-500" />
Expand All @@ -342,23 +340,31 @@ const InvestigationReports = ({ id }: any) => {
})
}
optionLabel={(option) => option.name}
optionValue={(option) => option}
optionValue={(option) => option.external_id}
isLoading={isLoading.investigationLoading}
placeholder={t("select_investigations")}
selectAll={true}
/>
</div>

<ButtonV2
onClick={() => {
setSessionPage(1);
handleGenerateReports(1);
}}
disabled={generateReportDisabled}
variant="primary"
className="my-2.5"
>
{t("generate_report")}
</ButtonV2>
<div className="flex space-x-2">
<Button
onClick={() => {
setSessionPage(1);
handleGenerateReports(1);
}}
disabled={generateReportDisabled}
variant="primary"
>
{t("generate_report")}
</Button>
<Button
onClick={clearSelectedInvestigations}
disabled={!selectedInvestigations.length}
variant="secondary"
>
{t("clear")}
</Button>
</div>
</>
)}
{isLoading.tableData && (
Expand All @@ -370,19 +376,19 @@ const InvestigationReports = ({ id }: any) => {
{!!investigationTableData.length && (
<>
<div className="my-2.5">
<ButtonV2
<Button
onClick={() => handleSessionPage("NEXT")}
disabled={prevSessionDisabled}
>
{isLoading.tableData ? "Loading..." : t("next_sessions")}
</ButtonV2>
<ButtonV2
</Button>
<Button
onClick={() => handleSessionPage("PREV")}
disabled={nextSessionDisabled}
className="ml-3"
>
{isLoading.tableData ? "Loading..." : t("prev_sessions")}
</ButtonV2>
</Button>
</div>

<ReportTable
Expand All @@ -396,14 +402,13 @@ const InvestigationReports = ({ id }: any) => {
/>

{!loadMoreDisabled && (
<ButtonV2
<Button
disabled={loadMoreDisabled}
onClick={handleLoadMore}
className="my-2.5 w-full"
variant="primary"
>
{t("load_more")}
</ButtonV2>
</Button>
)}
</>
)}
Expand Down
Loading
Loading