From bd84faa32c9427a1cda0c839ae4067c780b7ee44 Mon Sep 17 00:00:00 2001 From: mcmcphillips Date: Tue, 1 Oct 2024 17:00:32 -0700 Subject: [PATCH 1/2] MAT-7576b: Add missing AC, on create page 1 --- .../createTestCase/CreateNewTestCaseDialog.tsx | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/components/createTestCase/CreateNewTestCaseDialog.tsx b/src/components/createTestCase/CreateNewTestCaseDialog.tsx index 2212a1fe0..73c0c2290 100644 --- a/src/components/createTestCase/CreateNewTestCaseDialog.tsx +++ b/src/components/createTestCase/CreateNewTestCaseDialog.tsx @@ -1,5 +1,6 @@ import React, { useState, useRef, useEffect } from "react"; -import { useParams } from "react-router-dom"; +import { useParams, useNavigate, useLocation } from "react-router-dom"; +import queryString from "query-string"; import { TestCase, Measure, Model } from "@madie/madie-models"; import { TestCaseValidator } from "../../validators/TestCaseValidator"; import { @@ -73,6 +74,10 @@ const CreateNewTestCaseDialog = ({ onClose, measure, }: createNewTestCaseDialogProps) => { + let navigate = useNavigate(); + const { search } = useLocation(); + const values = queryString.parse(search); + const [toast, setToast] = useState({ toastOpen: false, toastType: "danger", @@ -162,6 +167,13 @@ const CreateNewTestCaseDialog = ({ measureId ); handleTestCaseResponse(savedTestCase); + // go to page 1 + const newPath = `/measures/${measureId}/edit/test-cases/list-page/${ + measure.groups[0].id + }?filter=${values.filter ? values.filter : ""}&search=${ + values.search ? values.search : "" + }&page=1&limit=${values.limit ? values.limit : 10}`; + navigate(newPath); } catch (error) { setToast({ toastOpen: true, From d159e16981f6412b8f23a77e55d64d43dcd6e98d Mon Sep 17 00:00:00 2001 From: mcmcphillips Date: Tue, 1 Oct 2024 19:56:20 -0700 Subject: [PATCH 2/2] MAT-7576: update tests --- .../CreateNewTestCaseDialog.test.tsx | 59 +++++++++++++++---- 1 file changed, 46 insertions(+), 13 deletions(-) diff --git a/src/components/createTestCase/CreateNewTestCaseDialog.test.tsx b/src/components/createTestCase/CreateNewTestCaseDialog.test.tsx index 8478fc7d8..4a494dd35 100644 --- a/src/components/createTestCase/CreateNewTestCaseDialog.test.tsx +++ b/src/components/createTestCase/CreateNewTestCaseDialog.test.tsx @@ -7,6 +7,7 @@ import CreateNewTestCaseDialog from "./CreateNewTestCaseDialog"; import { Measure } from "@madie/madie-models"; import axios from "../../api/axios-instance"; import { specialChars } from "../../util/checkSpecialCharacters"; +import { MemoryRouter } from "react-router-dom"; jest.mock("../../api/axios-instance"); const mockedAxios = axios as jest.Mocked; @@ -39,10 +40,18 @@ describe("Create New Test Case Dialog", () => { jest.clearAllMocks(); }); + const mockMeasure = { ...formikInfo, id: "test-id" }; + test("should render all the fields in the test case creation form", async () => { await act(async () => { const { findByTestId } = await render( - + + + ); expect(await findByTestId("create-test-case-title")).toBeInTheDocument(); @@ -64,7 +73,13 @@ describe("Create New Test Case Dialog", () => { test("Save button should not be enabled when required field is empty", async () => { await act(async () => { const { getByTestId } = await render( - + + + ); const titleInput = await getByTestId("create-test-case-title-input"); @@ -96,11 +111,17 @@ describe("Create New Test Case Dialog", () => { } as unknown as Measure; await act(async () => { const { getByRole, getByTestId, getByText, queryByTestId } = await render( - + + + ); const titleInput = await getByTestId("create-test-case-title-input"); @@ -143,7 +164,13 @@ describe("Create New Test Case Dialog", () => { await act(async () => { const { getByRole, getByTestId, getByText, queryByTestId } = await render( - + + + ); const titleInput = await getByTestId("create-test-case-title-input"); @@ -196,11 +223,17 @@ describe("Create New Test Case Dialog", () => { } as unknown as Measure; await act(async () => { const { getByRole, getByTestId, getByText, queryByTestId } = await render( - + + + ); const titleInput = await getByTestId("create-test-case-title-input");