Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MAT-8012: Updating error handling on CQLLibrary Save to show error fo… #171

Merged
merged 3 commits into from
Dec 12, 2024
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
29 changes: 18 additions & 11 deletions package-lock.json

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

66 changes: 66 additions & 0 deletions src/components/editCqlLibrary/EditCqlLibrary.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
5 changes: 5 additions & 0 deletions src/components/editCqlLibrary/EditCqlLibrary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@
setErrorMessage("An error occurred while fetching the CQL Library!");
});
}
}, [id, resetForm, loadedCqlLibrary, cqlLibraryServiceApi]);

Check warning on line 176 in src/components/editCqlLibrary/EditCqlLibrary.tsx

View workflow job for this annotation

GitHub Actions / Checkout, install, lint, build and test with coverage

React Hook useEffect has a missing dependency: 'handleAnnotations'. Either include it or remove the dependency array

// fetch organizations DB using measure service and sorts alphabetically
useEffect(() => {
Expand All @@ -189,7 +189,7 @@
const message = `Error fetching organizations`;
handleToast("danger", message, true);
});
}, []);

Check warning on line 192 in src/components/editCqlLibrary/EditCqlLibrary.tsx

View workflow job for this annotation

GitHub Actions / Checkout, install, lint, build and test with coverage

React Hook useEffect has a missing dependency: 'organizationApi'. Either include it or remove the dependency array

async function updateCqlLibrary(cqlLibrary: CqlLibrary) {
setActiveSpinner(true);
Expand Down Expand Up @@ -261,6 +261,11 @@
"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."
Expand Down
1 change: 1 addition & 0 deletions src/types/madie-madie-editor.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ declare module "@madie/madie-editor" {
isLibraryStatementChanged?: boolean;
isUsingStatementChanged?: boolean;
isValueSetChanged?: boolean;
isFhirHelpersAliasChanged?: boolean;
}

export const parseContent: (content: string) => CqlError[];
Expand Down
Loading