diff --git a/package-lock.json b/package-lock.json index e7eb3f3..3adcace 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9376,10 +9376,11 @@ } }, "node_modules/express": { - "version": "4.21.1", - "resolved": "https://registry.npmjs.org/express/-/express-4.21.1.tgz", - "integrity": "sha512-YSFlK1Ee0/GC8QaO91tHcDxJiE/X4FbpAyQWkxAvG6AXCuR65YzK8ua6D9hvi/TzUfZMpc+BwuM1IPw8fmQBiQ==", + "version": "4.21.2", + "resolved": "https://registry.npmjs.org/express/-/express-4.21.2.tgz", + "integrity": "sha512-28HqgMZAmih1Czt9ny7qr6ek2qddF4FclbMzwhCREB6OFfH+rXAnuNCwo1/wFvrtbgsQDb4kSbX9de9lFbrXnA==", "dev": true, + "license": "MIT", "dependencies": { "accepts": "~1.3.8", "array-flatten": "1.1.1", @@ -9400,7 +9401,7 @@ "methods": "~1.1.2", "on-finished": "2.4.1", "parseurl": "~1.3.3", - "path-to-regexp": "0.1.10", + "path-to-regexp": "0.1.12", "proxy-addr": "~2.0.7", "qs": "6.13.0", "range-parser": "~1.2.1", @@ -9415,6 +9416,10 @@ }, "engines": { "node": ">= 0.10.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" } }, "node_modules/express/node_modules/cookie": { @@ -9442,10 +9447,11 @@ "dev": true }, "node_modules/express/node_modules/path-to-regexp": { - "version": "0.1.10", - "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.10.tgz", - "integrity": "sha512-7lf7qcQidTku0Gu3YDPc8DJ1q7OOucfa/BSsIwjuh56VU7katFvuM8hULfkwB3Fns/rsVF7PwPKVw1sl5KQS9w==", - "dev": true + "version": "0.1.12", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.12.tgz", + "integrity": "sha512-RA1GjUVMnvYFxuqovrEqZoxxW5NUZqbwKtYz/Tt7nXerk0LbLblQmrsgdeOxV5SFHf0UDggjS/bSeOZwt1pmEQ==", + "dev": true, + "license": "MIT" }, "node_modules/external-editor": { "version": "3.1.0", @@ -14241,15 +14247,16 @@ "integrity": "sha512-wynEP02LmIbLpcYw8uBKpcfF6dmg2vcpKqxeH5UcoKEYdExslsdUA4ugFauuaeYdTB76ez6gJW8XAZ6CgkXYxA==" }, "node_modules/nanoid": { - "version": "3.3.7", - "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.7.tgz", - "integrity": "sha512-eSRppjcPIatRIMC1U6UngP8XFcz8MQWGQdt1MTBQ7NaAmvXDfvNxbvWV3x2y6CdEUciCSsDHDQZbhYaB8QEo2g==", + "version": "3.3.8", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.8.tgz", + "integrity": "sha512-WNLf5Sd8oZxOm+TzppcYk8gVOgP+l58xNy58D0nbUnOxOWRWvlcCV4kUF7ltmI6PsrLl/BgKEyS4mqsGChFN0w==", "funding": [ { "type": "github", "url": "https://github.com/sponsors/ai" } ], + "license": "MIT", "bin": { "nanoid": "bin/nanoid.cjs" }, diff --git a/src/components/editCqlLibrary/EditCqlLibrary.test.tsx b/src/components/editCqlLibrary/EditCqlLibrary.test.tsx index 7aa9246..1515d7d 100644 --- a/src/components/editCqlLibrary/EditCqlLibrary.test.tsx +++ b/src/components/editCqlLibrary/EditCqlLibrary.test.tsx @@ -622,6 +622,72 @@ describe("Edit Cql Library Component", () => { }); }); + it("should update an existing cql library with the upated FhirHerlpers Alias and warn ", async () => { + (synchingEditorCqlContent as jest.Mock) + .mockClear() + .mockImplementation(() => { + return { + cql: "library UpdateName version '1.0.000' include FHIRHelers version '4.3.000' called Dummy", + isLibraryStatementChanged: false, + isUsingStatementChanged: false, + isFhirHelpersAliasChanged: true, + isValueSetChanged: false, + }; + }); + + isUsingEmpty.mockClear().mockImplementation(() => true); + + mockedAxios.put.mockResolvedValue({ + data: { + ...cqlLibrary, + cqlLibraryName: "UpdatedName", + cql: synchingEditorCqlContent, + }, + }); + renderWithRouter("/cql-libraries/:id/edit", [ + "/cql-libraries/cql-lib-1234/edit", + ]); + + expect(mockedAxios.get).toHaveBeenCalled(); + + expect( + await screen.findByRole("button", { + name: "Save", + }) + ).toBeInTheDocument(); + + const libraryNameInput = screen.getByTestId( + "cql-library-name-text-field-input" + ) as HTMLInputElement; + + expect(libraryNameInput.value).toBe("Library1"); + userEvent.clear(libraryNameInput); + userEvent.type(libraryNameInput, "UpdatedName1"); + fireEvent.blur(libraryNameInput); + expect(libraryNameInput.value).toBe("UpdatedName1"); + const input = screen.getByTestId("cql-library-editor") as HTMLInputElement; + expect(input).toHaveValue(""); + + fireEvent.change(screen.getByTestId("cql-library-editor"), { + target: { + value: + "library UpdateName version '1.0.000' include FHIRHelers version '4.3.000' called Dummmy", + }, + }); + + const updateButton = screen.getByRole("button", { + name: "Save", + }); + expect(updateButton).not.toBeDisabled(); + userEvent.click(updateButton); + await waitFor(() => { + const successMessage = screen.getByTestId("generic-success-text-header"); + expect(successMessage.textContent).toEqual( + "CQL updated successfully but the following issues were found" + ); + }); + }); + it("should update an existing cql library and displaying success message", async () => { const cqlLibrary: CqlLibrary = { id: "cql-lib-1234", diff --git a/src/components/editCqlLibrary/EditCqlLibrary.tsx b/src/components/editCqlLibrary/EditCqlLibrary.tsx index b37bd9a..eb087ee 100644 --- a/src/components/editCqlLibrary/EditCqlLibrary.tsx +++ b/src/components/editCqlLibrary/EditCqlLibrary.tsx @@ -261,6 +261,11 @@ const EditCqlLibrary = () => { "Library statement was incorrect. MADiE has overwritten it." ); } + if (updatedContent.isFhirHelpersAliasChanged) { + secondaryMessages.push( + "FHIRHelpers was incorrectly aliased. MADiE has overwritten the alias with 'FHIRHelpers'." + ); + } if (updatedContent.isUsingStatementChanged) { secondaryMessages.push( "Incorrect using statement(s) detected. MADiE has corrected it." diff --git a/src/types/madie-madie-editor.d.ts b/src/types/madie-madie-editor.d.ts index 654bae9..14be2f3 100644 --- a/src/types/madie-madie-editor.d.ts +++ b/src/types/madie-madie-editor.d.ts @@ -68,6 +68,7 @@ declare module "@madie/madie-editor" { isLibraryStatementChanged?: boolean; isUsingStatementChanged?: boolean; isValueSetChanged?: boolean; + isFhirHelpersAliasChanged?: boolean; } export const parseContent: (content: string) => CqlError[];