Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
"@madie/madie-auth": "^0.0.1",
"@madie/madie-design-system": "^1.2.92",
"@madie/madie-editor": "^1.0.3",
"@madie/madie-models": "^1.4.72",
"@madie/madie-models": "^1.4.73",
"@madie/madie-root": "^0.0.3",
"@mui/icons-material": "^6.1.0",
"@mui/lab": "6.0.1-beta.34",
Expand Down
88 changes: 87 additions & 1 deletion src/__mocks__/@madie/madie-util.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useState, useEffect } from "react";
import React, { useState, useEffect } from "react";
// These functions are listed so that they can be referenced in jest files since jest cannot see browser.
// some functions are copy pasted from the source since their side effects are required for tests.
export function useKeyPress(targetKey) {
Expand Down Expand Up @@ -106,3 +106,89 @@ export const getOidFromString = (
}
return oidString?.split("ValueSet/")[1];
};

export const exportMeasure = jest.fn();
export const downloadZipFile = jest.fn();
export const parseErrorMessageFromBlob = jest.fn();
export const generateTimestampedFileName = jest.fn(
(baseName: string, extension: string) => `${baseName}_timestamp.${extension}`
);
export const EXPORT_FAILURE_MESSAGE =
"Unable to Export measure. Package could not be generated. Please try again and contact the Help Desk if the problem persists.";
export const getNewestMeasureInstance = jest.fn(
(measures: any[]) => measures?.[0]
);
export const ExportAction = ({ onClick }: any) => (
<div
role="button"
tabIndex={0}
data-testid="export-action"
onClick={() => onClick && onClick("Export")}
>
Export Action
</div>
);
export const ViewHRAction = ({ onClick }: any) => (
<button data-testid="view-hr-action-btn" onClick={onClick}>
View HR Action
</button>
);
export const HistoryAction = ({ onClick }: any) => (
<button data-testid="history-action-btn" onClick={onClick}>
History Action
</button>
);
export const CompareVersionsAction = ({ onClick }: any) => (
<button data-testid="compare-versions-action-btn" onClick={onClick}>
Compare Versions Action
</button>
);
export const ExportDialog = ({ open }: any) =>
open ? <div data-testid="export-dialog">Export Dialog</div> : null;
export const ExportIcon = () => <span data-testid="export-icon" />;
export const ViewHRModal = ({ open, onClose }: any) =>
open ? (
<div data-testid="view-human-readable-modal">
View HR Modal
<button data-testid="view-hr-close-btn" onClick={onClose}>
Close
</button>
</div>
) : null;
export const ViewMeasureHistoryDialog = ({ open, onClose }: any) =>
open ? (
<div data-testid="view-measure-history-dialog">
Measure History
<button data-testid="view-history-close-btn" onClick={onClose}>
Close
</button>
</div>
) : null;
export const CompareVersionsDialog = ({ open }: any) =>
open ? (
<div data-testid="compare-versions-dialog">Compare Versions</div>
) : null;
export const ShareAction = ({ measures, activeTab, onClick }: any) => {
const options = activeTab === 1 ? ["Unshare"] : ["Share With", "Unshare"];
return (
<div>
<button data-testid="share-action-btn" disabled={!measures?.length}>
Share
</button>
{options.map((option: string) => (
<div
key={option}
role="menuitem"
tabIndex={0}
onClick={() => onClick && onClick(option)}
>
{option}
</div>
))}
</div>
);
};
export const ShareDialog = ({ open }: any) =>
open ? <div data-testid="share-dialog">Share Dialog</div> : null;

export { formatCmsId, padCmsId } from "../cmsIdFormatterStubs";
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
export const CMS_ID_PAD_WIDTH = 4;
export const FHIR_SUFFIX = "FHIR";
// Shared jest stubs for @madie/madie-util's CMS-ID formatters. Bodies mirror
// madie-util/src/util/cmsIdFormatter.ts. Import as a `mock`-prefixed namespace
// and spread into an inline util mock factory:
// import * as mockCmsIdStubs from "<path>/__mocks__/cmsIdFormatterStubs";
// jest.mock("@madie/madie-util", () => ({ ...mockCmsIdStubs, ... }));
const CMS_ID_PAD_WIDTH = 4;
const FHIR_SUFFIX = "FHIR";

/**
* Zero-pads a CMS ID to {@link CMS_ID_PAD_WIDTH} digits. Values already wider
* than the pad width are returned unchanged. Null / undefined / 0 / negative
* inputs return an empty string.
*/
export function padCmsId(cmsId: number | string | null | undefined): string {
if (cmsId === null || cmsId === undefined || cmsId === "") {
return "";
Expand All @@ -17,10 +17,6 @@ export function padCmsId(cmsId: number | string | null | undefined): string {
return String(Math.trunc(n)).padStart(CMS_ID_PAD_WIDTH, "0");
}

/**
* Display form of a CMS ID: zero-padded, with the "FHIR" suffix appended for
* QI-Core measures. Returns an empty string when the CMS ID is missing.
*/
export function formatCmsId(
cmsId: number | string | null | undefined,
model: string | null | undefined
Expand Down
97 changes: 97 additions & 0 deletions src/__mocks__/measureActionStubs.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
import * as React from "react";

// Stubs for the shared action-center components that live in @madie/madie-util.
// Spread into a test's inline `jest.mock("@madie/madie-util", ...)` factory —
// import as `mockMeasureActionStubs` (the mock* prefix satisfies jest hoisting).
export const exportMeasure = jest.fn();
export const downloadZipFile = jest.fn();
export const parseErrorMessageFromBlob = jest.fn();
export const generateTimestampedFileName = jest.fn(
(baseName: string, extension: string) => `${baseName}_timestamp.${extension}`
);
export const EXPORT_FAILURE_MESSAGE =
"Unable to Export measure. Package could not be generated. Please try again and contact the Help Desk if the problem persists.";
export const getNewestMeasureInstance = jest.fn(
(measures: any[]) => measures?.[0]
);
export const ExportAction = ({ onClick }: any) => (
<div>
<button data-testid="export-action-btn">Export</button>
<div
role="menuitem"
tabIndex={0}
onClick={() => onClick && onClick("Export")}
>
Export
</div>
<div
role="menuitem"
tabIndex={0}
onClick={() => onClick && onClick("Export for Publishing")}
>
Export for Publishing
</div>
</div>
);
export const ViewHRAction = ({ onClick }: any) => (
<button data-testid="view-hr-action-btn" onClick={onClick}>
View HR Action
</button>
);
export const HistoryAction = ({ onClick }: any) => (
<button data-testid="history-action-btn" onClick={onClick}>
History Action
</button>
);
export const CompareVersionsAction = ({ onClick }: any) => (
<button data-testid="compare-versions-action-btn" onClick={onClick}>
Compare Versions Action
</button>
);
export const ExportDialog = ({ open }: any) =>
open ? <div data-testid="export-dialog">Export Dialog</div> : null;
export const ExportIcon = () => <span data-testid="export-icon" />;
export const ViewHRModal = ({ open, onClose }: any) =>
open ? (
<div data-testid="view-human-readable-modal">
View HR Modal
<button data-testid="view-hr-close-btn" onClick={onClose}>
Close
</button>
</div>
) : null;
export const ViewMeasureHistoryDialog = ({ open, onClose }: any) =>
open ? (
<div data-testid="view-measure-history-dialog">
Measure History
<button data-testid="view-history-close-btn" onClick={onClose}>
Close
</button>
</div>
) : null;
export const CompareVersionsDialog = ({ open }: any) =>
open ? (
<div data-testid="compare-versions-dialog">Compare Versions</div>
) : null;
export const ShareAction = ({ measures, activeTab, onClick }: any) => {
const options = activeTab === 1 ? ["Unshare"] : ["Share With", "Unshare"];
return (
<div>
<button data-testid="share-action-btn" disabled={!measures?.length}>
Share
</button>
{options.map((option: string) => (
<div
key={option}
role="menuitem"
tabIndex={0}
onClick={() => onClick && onClick(option)}
>
{option}
</div>
))}
</div>
);
};
export const ShareDialog = ({ open }: any) =>
open ? <div data-testid="share-dialog">Share Dialog</div> : null;
10 changes: 0 additions & 10 deletions src/components/common/HrIcon.tsx

This file was deleted.

15 changes: 0 additions & 15 deletions src/components/common/ShareIcon.tsx

This file was deleted.

Loading
Loading