diff --git a/services/ui-src/src/components/reports/DrawerReportPage.test.tsx b/services/ui-src/src/components/reports/DrawerReportPage.test.tsx
index 7783747fb..bd75239d2 100644
--- a/services/ui-src/src/components/reports/DrawerReportPage.test.tsx
+++ b/services/ui-src/src/components/reports/DrawerReportPage.test.tsx
@@ -16,9 +16,13 @@ import {
mockEntityStore,
mockVerbiageIntro,
mockDrawerForm,
+ mockNaaarReportStore,
+ mockNaaarReportContext,
} from "utils/testing/setupJest";
// constants
-import { saveAndCloseText } from "../../constants";
+import { DEFAULT_ANALYSIS_METHODS, saveAndCloseText } from "../../constants";
+// types
+import { McrEntityState } from "types";
const mockUseNavigate = jest.fn();
jest.mock("react-router-dom", () => ({
@@ -306,6 +310,162 @@ describe("Test DrawerReportPage with completed entity", () => {
});
});
+describe("Test DrawerReportPage with custom entities", () => {
+ afterEach(() => {
+ jest.clearAllMocks();
+ });
+ const mockAnalysisMethodEntityStore: McrEntityState = {
+ entities: [],
+ entityType: "analysisMethods",
+ selectedEntity: {
+ id: "k9t7YoOeTOAXX3s7qF6XfN33",
+ name: "Geomapping",
+ isRequired: true,
+ },
+ // ACTIONS
+ setSelectedEntity: () => {},
+ setEntityType: () => {},
+ setEntities: () => {},
+ };
+ const mockAnalysisMethodsReportPageJson = {
+ name: "mock-route",
+ path: "/naaar/analysis-methods",
+ pageType: "drawer",
+ entityType: "analysisMethods",
+ verbiage: {
+ intro: mockVerbiageIntro,
+ dashboardTitle: "Mock dashboard title",
+ drawerTitle: "Mock drawer title",
+ addEntityButtonText: "Add other analysis method",
+ },
+ drawerForm: {
+ id: "am",
+ fields: [
+ {
+ id: "am_default_text",
+ type: "text",
+ validation: "text",
+ props: {
+ label: "Fill in info on analysis method",
+ },
+ },
+ ],
+ },
+ addEntityDrawerForm: {
+ id: "am_custom",
+ fields: [
+ {
+ id: "am_custom_text",
+ type: "text",
+ validation: "text",
+ props: {
+ label: "Fill in info on custom analysis method",
+ },
+ },
+ ],
+ },
+ };
+
+ const mockNaaarReportContextWithAnalysisMethods: any = mockNaaarReportContext;
+ mockNaaarReportContextWithAnalysisMethods.report.fieldData[
+ "analysisMethods"
+ ] = [DEFAULT_ANALYSIS_METHODS[0]];
+
+ const mockCustomNaaarReportStore = {
+ ...mockNaaarReportStore,
+ report: mockNaaarReportContextWithAnalysisMethods.report,
+ reportsByState: [mockNaaarReportContextWithAnalysisMethods.report],
+ };
+ const drawerReportPageWithCustomEntities = (
+
+
+
+
+
+ );
+ it("Can enter default analysis method drawer", async () => {
+ mockedUseStore.mockReturnValue({
+ ...mockStateUserStore,
+ ...mockCustomNaaarReportStore,
+ ...mockAnalysisMethodEntityStore,
+ });
+
+ render(drawerReportPageWithCustomEntities);
+ const enterDefaultMethod = screen.getAllByText("Enter")[0];
+ await userEvent.click(enterDefaultMethod);
+ expect(screen.getByRole("dialog")).toBeVisible();
+ const textField = await screen.getByLabelText(
+ "Fill in info on analysis method"
+ );
+ expect(textField).toBeVisible();
+ });
+
+ it("Can enter custom analysis method drawer and fill out form", async () => {
+ const mockAnalysisMethodNoSelectedEntityStore =
+ mockAnalysisMethodEntityStore;
+ mockAnalysisMethodNoSelectedEntityStore.selectedEntity = undefined;
+ mockedUseStore.mockReturnValue({
+ ...mockStateUserStore,
+ ...mockCustomNaaarReportStore,
+ ...mockAnalysisMethodNoSelectedEntityStore,
+ });
+
+ render(drawerReportPageWithCustomEntities);
+ const addCustomMethod = screen.getByText("Add other analysis method");
+ await userEvent.click(addCustomMethod);
+ expect(screen.getByRole("dialog")).toBeVisible();
+ const customTextField = await screen.getByLabelText(
+ "Fill in info on custom analysis method"
+ );
+ expect(customTextField).toBeVisible();
+ await userEvent.type(customTextField, "new analysis method");
+ const saveCustomMethod = screen.getByText("Save & close");
+ await userEvent.click(saveCustomMethod);
+ const enterDefaultMethod = screen.getAllByText("Enter")[0];
+ expect(enterDefaultMethod).toBeVisible();
+ });
+
+ it("Can shows statusing for custom analysis methods", async () => {
+ const mockNaaarReportContextWithCustomAnalysisMethods: any =
+ mockNaaarReportContext;
+ mockNaaarReportContextWithCustomAnalysisMethods.report.fieldData[
+ "analysisMethods"
+ ] = [
+ DEFAULT_ANALYSIS_METHODS[0],
+ {
+ id: "custom_entity",
+ name: "custom entity",
+ },
+ ];
+
+ const mockCustomNaaarReportStore = {
+ ...mockNaaarReportStore,
+ report: mockNaaarReportContextWithCustomAnalysisMethods.report,
+ reportsByState: [mockNaaarReportContextWithCustomAnalysisMethods.report],
+ };
+
+ mockedUseStore.mockReturnValue({
+ ...mockStateUserStore,
+ ...mockCustomNaaarReportStore,
+ ...mockAnalysisMethodEntityStore,
+ });
+
+ const drawerReportPageWithCustomEntities = (
+
+
+
+
+
+ );
+
+ render(drawerReportPageWithCustomEntities);
+ const iconAltText = screen.getAllByAltText("Entity is incomplete");
+ expect(iconAltText.length).toBeGreaterThan(0);
+ });
+});
+
describe("Test DrawerReportPage accessibility", () => {
it("Should not have basic accessibility issues", async () => {
mockedUseStore.mockReturnValue({
diff --git a/services/ui-src/src/types/formFields.ts b/services/ui-src/src/types/formFields.ts
index d84c40890..0391a6850 100644
--- a/services/ui-src/src/types/formFields.ts
+++ b/services/ui-src/src/types/formFields.ts
@@ -15,6 +15,7 @@ export const entityTypes = [
"sanctions",
"program",
"ilos",
+ "analysisMethods",
] as const;
/**