Skip to content

Commit

Permalink
Merge branch 'develop' into grid
Browse files Browse the repository at this point in the history
  • Loading branch information
mozzy11 authored Jan 17, 2025
2 parents cac01b3 + 1ca3111 commit 9b5d2eb
Show file tree
Hide file tree
Showing 8 changed files with 227 additions and 86 deletions.
1 change: 1 addition & 0 deletions frontend/cypress.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ module.exports = defineConfig({
"cypress/e2e/report.cy.js",
"cypress/e2e/batchOrderEntry.cy.js",
"cypress/e2e/dashboard.cy.js",
"cypress/e2e/labNumberManagement.cy.js",
];
return config;
},
Expand Down
44 changes: 44 additions & 0 deletions frontend/cypress/e2e/labNumberManagement.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import LoginPage from "../pages/LoginPage";

let loginPage = null;
let homePage = null;
let adminPage = null;
let labNumMgtPage = null;

before(() => {
// Initialize LoginPage object and navigate to Admin Page
loginPage = new LoginPage();
loginPage.visit();

homePage = loginPage.goToHomePage();
adminPage = homePage.goToAdminPage();
});

beforeEach(() => {
// Load fixture data for each test
cy.fixture("LabNumberManagement").as("labNMData");
});

describe("Lab Number Management", function () {
it("User navigates to the Lab Number Management page", function () {
labNumMgtPage = adminPage.goToLabNumberManagementPage();
});

it("User selects legacy lab number type and submits", function () {
cy.get("@labNMData").then((labNumberManagementData) => {
labNumMgtPage.selectLabNumber(
labNumberManagementData.legacyLabNumberType,
);
labNumMgtPage.clickSubmitButton();
});
});

it("User selects alpha numeric lab number type and submits", function () {
cy.get("@labNMData").then((labNumberManagementData) => {
labNumMgtPage.selectLabNumber(labNumberManagementData.alphaLabNumberType);
labNumMgtPage.checkPrefixCheckBox();
labNumMgtPage.typePrefix(labNumberManagementData.userPrefix);
labNumMgtPage.clickSubmitButton();
});
});
});
5 changes: 5 additions & 0 deletions frontend/cypress/fixtures/LabNumberManagement.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"alphaLabNumberType": "Alpha Numeric",
"legacyLabNumberType": "Legacy",
"userPrefix": "REG-"
}
33 changes: 33 additions & 0 deletions frontend/cypress/pages/AdminPage.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
//This handles all pages of the admin
import LabNumberManagementPage from "./LabNumberManagementPage";

class AdminPage {
constructor() {}

visit() {
cy.visit("/administration"); //need to confirm this
}
//this page is also included in the homepage
goToAdminPage() {
this.openNavigationMenu();
cy.get("#menu_administration").click();
cy.get("#menu_administration_nav").click();
return new AdminPage();
}

//lab number management
goToLabNumberManagementPage() {
// Click on the element using the provided selector
cy.get("a.cds--side-nav__link[href='#labNumber']")
.should("be.visible") // Ensure the element is visible
.click(); // Click to navigate to the page

// Verify the URL or some unique identifier of the target page
cy.url().should("include", "#labNumber"); // Validate URL fragment
cy.contains("Lab Number Management").should("be.visible"); // Confirm presence of the page content

return new LabNumberManagementPage(); // Return the page object
}
}

export default AdminPage;
7 changes: 7 additions & 0 deletions frontend/cypress/pages/HomePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import RoutineReportPage from "./RoutineReportPage";
import StudyReportPage from "./StudyReportPage";

import DashBoardPage from "./DashBoard";
import AdminPage from "./AdminPage";

class HomePage {
constructor() {}
Expand Down Expand Up @@ -192,6 +193,12 @@ class HomePage {
cy.get("#menu_immunochemdashboard_nav").click();
return new DashBoardPage();
}

goToAdminPage() {
this.openNavigationMenu();
cy.get("#menu_administration").click();
return new AdminPage();
}
}

export default HomePage;
30 changes: 30 additions & 0 deletions frontend/cypress/pages/LabNumberManagementPage.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
class LabNumberManagementPage {
constructor() {}

verifyPageLoaded() {
// Confirm the page is loaded by checking a unique element
cy.contains("Lab Number Management").should("be.visible");
}

selectLabNumber(labNumberType) {
// Ensure the dropdown is visible and interactable
cy.get("#lab_number_type").should("be.visible").select(labNumberType); // Select the lab number type passed as an argument
}

checkPrefixCheckBox() {
cy.get("#usePrefix").check({ force: true }); // Check the checkbox
}
typePrefix(prefix) {
this.checkPrefixCheckBox();

// Wait for the input to become enabled
cy.get("#alphanumPrefix").should("not.be.disabled").type(prefix);
}
clickSubmitButton() {
cy.get("button.cds--btn.cds--btn--primary[type='submit']")
.should("be.visible")
.click();
}
}

export default LabNumberManagementPage;
101 changes: 54 additions & 47 deletions frontend/src/components/cytology/CytologyDashBoard.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,10 @@ function CytologyDashboard() {
const [filters, setFilters] = useState({
searchTerm: "",
myCases: false,
statuses: [
{
id: "PREPARING_SLIDES",
value: "Preparing slides",
},
],
statuses: [{}],
});
const [inProgressStatuses, setInProgressStatuses] = useState([]);

const [counts, setCounts] = useState({
inProgress: 0,
awaitingReview: 0,
Expand All @@ -59,10 +56,31 @@ function CytologyDashboard() {
const [page, setPage] = useState(1);
const [pageSize, setPageSize] = useState(100);
const intl = useIntl();

const [inProgressStatusObjects, setInProgressStatusObjects] = useState(
inProgressStatuses.map((statusId) => ({ id: statusId })),
);
const setStatusList = (statusList) => {
if (componentMounted.current) {
// Set all statuses
setStatuses(statusList);

// Filter out COMPLETED statuses and update the in-progress statuses state
const filteredStatuses = statusList
.filter((status) => status.id !== "COMPLETED")
.map((status) => status.id);

setInProgressStatuses(filteredStatuses);

// Update the inProgressStatusObjects state
setInProgressStatusObjects(
filteredStatuses.map((statusId) => ({ id: statusId })),
);

// Set filters using the updated state
setFilters((prev) => ({
...prev,
statuses: filteredStatuses.map((statusId) => ({ id: statusId })),
}));
}
};

Expand Down Expand Up @@ -149,13 +167,29 @@ function CytologyDashboard() {
};

const setStatusFilter = (event) => {
if (event.target.value === "All") {
const { value } = event.target;

if (value === "All") {
setFilters({ ...filters, statuses: statuses });
} else if (value === "IN_PROGRESS") {
setFilters({ ...filters, statuses: inProgressStatusObjects });
} else {
setFilters({ ...filters, statuses: [{ id: event.target.value }] });
setFilters({ ...filters, statuses: [{ id: value }] });
}
};

const getSelectedValue = () => {
const selectedValue =
filters.statuses.length === inProgressStatuses.length &&
filters.statuses.every((status) => inProgressStatuses.includes(status.id))
? "IN_PROGRESS"
: filters.statuses.length > 1
? "All"
: filters.statuses[0].id;

return selectedValue;
};

const filtersToParameters = () => {
return (
"statuses=" +
Expand Down Expand Up @@ -242,23 +276,6 @@ function CytologyDashboard() {
},
];

useEffect(() => {
componentMounted.current = true;
setFilters({
...filters,
statuses: [
{
id: "PREPARING_SLIDES",
value: "Preparing slides",
},
],
});

return () => {
componentMounted.current = false;
};
}, [statuses]);

useEffect(() => {
componentMounted.current = true;
refreshItems();
Expand Down Expand Up @@ -329,30 +346,20 @@ function CytologyDashboard() {
id="statusFilter"
name="statusFilter"
labelText={intl.formatMessage({ id: "label.filters.status" })}
value={
filters.statuses.length > 1 ? "All" : filters.statuses[0].id
}
value={getSelectedValue()}
onChange={setStatusFilter}
noLabel
>
<SelectItem
disabled
value="placeholder"
text={intl.formatMessage({ id: "label.filters.status" })}
/>
<SelectItem
text={intl.formatMessage({ id: "all.label" })}
value="All"
/>
{statuses.map((status, index) => {
return (
<SelectItem
key={index}
text={status.value}
value={status.id}
/>
);
})}
<SelectItem disabled value="placeholder" text="Status" />
<SelectItem text="All" value="All" />
<SelectItem text="In Progress" value="IN_PROGRESS" />
{statuses.map((status, index) => (
<SelectItem
key={index}
text={status.value}
value={status.id}
/>
))}
</Select>
</div>
</Column>
Expand Down
Loading

0 comments on commit 9b5d2eb

Please sign in to comment.