From a6ba5e91209e1ec97828f56a1c3db8246788c8eb Mon Sep 17 00:00:00 2001 From: Cecilia Liu Date: Wed, 14 Aug 2024 07:41:30 -0500 Subject: [PATCH] MAT-7501 support QICore v6.0.0 --- .github/workflows/unit_test_coverage.yml | 2 +- package-lock.json | 9 ++--- package.json | 2 +- .../CreateNewMeasureDialog.test.tsx | 34 +++++++++++++++++++ .../NewMeasure/CreateNewMeasureDialog.tsx | 8 +++-- src/types/madie-madie-util.d.ts | 2 ++ 6 files changed, 49 insertions(+), 8 deletions(-) diff --git a/.github/workflows/unit_test_coverage.yml b/.github/workflows/unit_test_coverage.yml index c452acd..dbd4d86 100644 --- a/.github/workflows/unit_test_coverage.yml +++ b/.github/workflows/unit_test_coverage.yml @@ -45,7 +45,7 @@ jobs: run: npm ci - name: Audit dependencies for security vulnerabilities - run: npm audit --production + run: npm audit --omit=dev --audit-level=${{ vars.NPM_AUDIT_LEVEL }} - name: Lint the source code run: npm run-script lint diff --git a/package-lock.json b/package-lock.json index d329748..4a9b094 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,7 +13,7 @@ "@madie/madie-auth": "^0.0.2", "@madie/madie-design-system": "^1.2.23", "@madie/madie-editor": "^0.0.2", - "@madie/madie-models": "^1.3.18", + "@madie/madie-models": "^1.4.14", "@madie/madie-root": "^0.0.2", "@mui/icons-material": "^5.8.2", "@mui/lab": "^5.0.0-alpha.82", @@ -3134,9 +3134,10 @@ } }, "node_modules/@madie/madie-models": { - "version": "1.3.18", - "resolved": "https://registry.npmjs.org/@madie/madie-models/-/madie-models-1.3.18.tgz", - "integrity": "sha512-J2s0ijlmN/wvXbBJw6LmxqvUsp02mLqBRLzsSt09RzLZdXIf9rGxsizUd4TZrrQzuFkifM0D2NRQwIno6vQkbQ==" + "version": "1.4.14", + "resolved": "https://registry.npmjs.org/@madie/madie-models/-/madie-models-1.4.14.tgz", + "integrity": "sha512-1hUqfCOyHnySn5cYopbzf0s+oQGiyx8/QxwbApGQpk5Ve+5PngQEwGDzTh0v39DPbWhqYoZ4Tc03s4u6XHZmdg==", + "license": "ISC" }, "node_modules/@madie/madie-root": { "version": "0.0.2", diff --git a/package.json b/package.json index bd7d8f4..f2915ff 100644 --- a/package.json +++ b/package.json @@ -77,7 +77,7 @@ "@madie/madie-auth": "^0.0.2", "@madie/madie-design-system": "^1.2.23", "@madie/madie-editor": "^0.0.2", - "@madie/madie-models": "^1.3.18", + "@madie/madie-models": "^1.4.14", "@madie/madie-root": "^0.0.2", "@mui/icons-material": "^5.8.2", "@mui/lab": "^5.0.0-alpha.82", diff --git a/src/components/NewMeasure/CreateNewMeasureDialog.test.tsx b/src/components/NewMeasure/CreateNewMeasureDialog.test.tsx index 5194c57..423f846 100644 --- a/src/components/NewMeasure/CreateNewMeasureDialog.test.tsx +++ b/src/components/NewMeasure/CreateNewMeasureDialog.test.tsx @@ -422,4 +422,38 @@ describe("Measures Create Dialog", () => { const submitButton = await getByTestId("continue-button"); await waitFor(() => expect(submitButton).toBeDisabled()); }, 10000); + + test("Model dropdown does not show QI-Core v6.0.0", async () => { + (useFeatureFlags as jest.Mock).mockReturnValue({ qiCore6: false }); + const { queryByTestId, getByTestId } = await render( + + ); + const modelSelectDropDown = getByTestId("measure-model-select"); + const modelSelectBtn = within(modelSelectDropDown).getByRole("button"); + userEvent.click(modelSelectBtn); + expect( + getByTestId("measure-model-option-QI-Core v4.1.1") + ).toBeInTheDocument(); + expect( + queryByTestId("measure-model-option-QI-Core v6.0.0") + ).not.toBeInTheDocument(); + expect(getByTestId("measure-model-option-QDM v5.6")).toBeInTheDocument(); + }); + + test("Model dropdown shows QI-Core v6.0.0 when feature flag is on", async () => { + (useFeatureFlags as jest.Mock).mockReturnValue({ qiCore6: true }); + const { getByTestId } = await render( + + ); + const modelSelectDropDown = getByTestId("measure-model-select"); + const modelSelectBtn = within(modelSelectDropDown).getByRole("button"); + userEvent.click(modelSelectBtn); + expect( + getByTestId("measure-model-option-QI-Core v4.1.1") + ).toBeInTheDocument(); + expect( + getByTestId("measure-model-option-QI-Core v6.0.0") + ).toBeInTheDocument(); + expect(getByTestId("measure-model-option-QDM v5.6")).toBeInTheDocument(); + }); }); diff --git a/src/components/NewMeasure/CreateNewMeasureDialog.tsx b/src/components/NewMeasure/CreateNewMeasureDialog.tsx index 8039f44..7cebbe8 100644 --- a/src/components/NewMeasure/CreateNewMeasureDialog.tsx +++ b/src/components/NewMeasure/CreateNewMeasureDialog.tsx @@ -13,12 +13,12 @@ import { MadieAlert, } from "@madie/madie-design-system/dist/react"; import { Box } from "@mui/system"; - import { wafIntercept, getServiceConfig, ServiceConfig, useOktaTokens, + useFeatureFlags, } from "@madie/madie-util"; import axios from "../../../api/axios-instance"; import { @@ -67,7 +67,11 @@ const CreateNewMeasureDialog = ({ open, onClose }) => { }, }); - const modelOptions = Object.keys(Model); + let modelOptions = Object.keys(Model); + const featureFlags = useFeatureFlags(); + if (!featureFlags?.qiCore6) { + modelOptions = modelOptions.filter((option) => option !== "QICORE_6_0_0"); + } async function createMeasure(measure: Measure) { const config: ServiceConfig = await getServiceConfig(); diff --git a/src/types/madie-madie-util.d.ts b/src/types/madie-madie-util.d.ts index 457025c..7e32a42 100644 --- a/src/types/madie-madie-util.d.ts +++ b/src/types/madie-madie-util.d.ts @@ -24,6 +24,7 @@ declare module "@madie/madie-util" { populationCriteriaTabs: boolean; importTestCases: boolean; qdm: boolean; + qiCore6: boolean; }; } @@ -34,6 +35,7 @@ declare module "@madie/madie-util" { interface FeatureFlags { importTestCases: boolean; + qiCore6: boolean; } export const cqlLibraryStore: {