Skip to content

Commit

Permalink
Merge pull request #155 from MeasureAuthoringTool/MAT-7502
Browse files Browse the repository at this point in the history
MAT-7502: Implement QI-Core6 render rules
  • Loading branch information
mcmcphillips authored Aug 14, 2024
2 parents c5fc8a7 + 8278e44 commit a4a9865
Show file tree
Hide file tree
Showing 5 changed files with 101 additions and 23 deletions.
40 changes: 20 additions & 20 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 @@ -27,7 +27,7 @@
"@babel/preset-react": "^7.14.5",
"@babel/preset-typescript": "^7.14.5",
"@babel/runtime": "^7.14.6",
"@madie/madie-models": "^1.3.34",
"@madie/madie-models": "^1.4.14",
"@testing-library/jest-dom": "^5.14.1",
"@testing-library/react": "^12.0.0",
"@testing-library/user-event": "^13.5.0",
Expand Down
68 changes: 68 additions & 0 deletions src/components/common/CreateNewLibraryDialog.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ jest.mock("@madie/madie-util", () => ({
useOrganizationApi: jest.fn(() => ({
getAllOrganizations: jest.fn().mockResolvedValue(organizations),
})),
useFeatureFlags: jest.fn(() => {
return {
qiCore6: false,
};
}),
}));
const organizations = [
{
Expand Down Expand Up @@ -294,4 +299,67 @@ describe("Library Dialog", () => {

await waitFor(() => expect(submitButton).toBeDisabled());
}, 20000);

test("QI-Core 6 is disabled", async () => {
const onFormSubmit = jest.fn();
const onFormCancel = jest.fn();
render(
<ApiContextProvider value={serviceConfig}>
<div>
<button data-testId="open-button" onClick={onFormSubmit}>
I open the dialog
</button>
<CreateNewLibraryDialog open={true} onClose={onFormCancel} />
</div>
</ApiContextProvider>
);

const modelSelect = await getByTestId("cql-library-model-select");
const modelSelectBtn = await within(modelSelect).getByRole("button");
userEvent.click(modelSelectBtn);
const options = await screen.findAllByRole("option");
expect(options.length).toEqual(2);
userEvent.click(options[1]);
expect(
(
(await within(modelSelect).getByRole("textbox", {
hidden: true,
})) as HTMLInputElement
).value
).toEqual("QDM v5.6");
}, 20000);

test("QI-Core 6 is enabled", async () => {
(useFeatureFlags as jest.Mock).mockClear().mockImplementation(() => {
return {
qiCore6: true,
};
});
const onFormSubmit = jest.fn();
const onFormCancel = jest.fn();
render(
<ApiContextProvider value={serviceConfig}>
<div>
<button data-testId="open-button" onClick={onFormSubmit}>
I open the dialog
</button>
<CreateNewLibraryDialog open={true} onClose={onFormCancel} />
</div>
</ApiContextProvider>
);

const modelSelect = await getByTestId("cql-library-model-select");
const modelSelectBtn = await within(modelSelect).getByRole("button");
userEvent.click(modelSelectBtn);
const options = await screen.findAllByRole("option");
expect(options.length).toEqual(3);
userEvent.click(options[1]);
expect(
(
(await within(modelSelect).getByRole("textbox", {
hidden: true,
})) as HTMLInputElement
).value
).toEqual("QI-Core v6.0.0");
}, 20000);
});
10 changes: 8 additions & 2 deletions src/components/common/CreateNewLibraryDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
import { Box } from "@mui/system";
import { FormHelperText, MenuItem } from "@mui/material";
import { useFormik } from "formik";
import { useOrganizationApi } from "@madie/madie-util";
import { useOrganizationApi, useFeatureFlags } from "@madie/madie-util";
import TextArea from "./TextArea";
import { v4 as uuidv4 } from "uuid";

Expand Down Expand Up @@ -43,7 +43,13 @@ const CreateNewLibraryDialog: React.FC<TestProps> = ({
const [organizations, setOrganizations] = useState<string[]>();
const organizationApi = useRef(useOrganizationApi()).current;

const modelOptions = Object.keys(Model);
let modelOptions = Object.keys(Model);
const featureFlags = useFeatureFlags();
const qiCore6 = featureFlags?.qiCore6;
// disableQiCore6
if (!qiCore6) {
modelOptions = modelOptions.filter((option) => option !== "QICORE_6_0_0");
}

// fetch organizations DB using measure service and sorts alphabetically
useEffect(() => {
Expand Down
4 changes: 4 additions & 0 deletions src/types/madie-madie-util.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ declare module "@madie/madie-util" {
redirectUri: string;
}

interface FeatureFlags {
qiCore6: boolean;
}

export interface ServiceConfig {
measureService: {
baseUrl: string;
Expand Down

0 comments on commit a4a9865

Please sign in to comment.