Skip to content

Commit

Permalink
Merge pull request #721 from MeasureAuthoringTool/MAT-7107_hookUpClon…
Browse files Browse the repository at this point in the history
…eTestCase

Mat 7107 hook up clone test case
  • Loading branch information
sb-cecilialiu authored Jan 3, 2025
2 parents 3edadd3 + c0c1a3e commit 19505f0
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -155,5 +155,25 @@ describe("ActionCenter Component", () => {
const exportTooltip = await screen.findByTestId("export-tooltip");
expect(exportTooltip).toHaveAttribute("aria-label", "Export test cases");
});

it("should clone test case when clone button is clicked", () => {
const selectedTestCase = [{ id: "1", validResource: true }];
const onCloneTestCase = jest.fn();
render(
<MemoryRouter>
<ActionCenter
selectedTestCases={selectedTestCase}
canEdit={true}
isQDM={true}
onCloneTestCase={onCloneTestCase}
/>
</MemoryRouter>
);

const cloneBtn = screen.getByTestId("clone-action-btn");
expect(cloneBtn).toBeEnabled();
userEvent.click(cloneBtn);
expect(onCloneTestCase).toBeCalled();
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,20 @@ import queryString from "query-string";
import { useNavigate, useLocation } from "react-router-dom";
import { useFeatureFlags } from "@madie/madie-util";
import { blue, grey, red } from "@mui/material/colors";
import { TestCase } from "@madie/madie-models";

interface ActionCenterProps {
onSubmit?: any;
selectedTestCases: any;
canEdit: boolean;
isQDM: boolean;
onCloneTestCase?: (testCase: TestCase) => void;
}

const filterByOptions = ["Case #", "Status", "Group", "Title", "Description"];

export default function ActionCenter(props: ActionCenterProps) {
const { selectedTestCases, canEdit, isQDM } = props;
const { selectedTestCases, canEdit, isQDM, onCloneTestCase } = props;
const [disableDeleteBtn, setDisableDeleteBtn] = useState<boolean>(true);
const [disableCloneBtn, setDisableCloneBtn] = useState<boolean>(true);
const [disableExportBtn, setDisableExportBtn] = useState<boolean>(true);
Expand Down Expand Up @@ -252,7 +254,9 @@ export default function ActionCenter(props: ActionCenterProps) {
>
<span>
<IconButton
onClick={() => {}}
onClick={(e) => {
onCloneTestCase(selectedTestCases?.[0]);
}}
disabled={disableCloneBtn}
data-testid="clone-action-btn"
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -790,6 +790,7 @@ const TestCaseList = (props: TestCaseListProps) => {
selectedTestCases={selectedTestCases}
canEdit={canEdit}
isQDM={true}
onCloneTestCase={handleCloneTestCase}
/>
<TestCaseTable
sorting={sorting}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -630,6 +630,7 @@ const TestCaseList = (props: TestCaseListProps) => {
selectedTestCases={selectedTestCases}
canEdit={canEdit}
isQDM={false}
onCloneTestCase={handleQiCloneTestCase}
/>
<TestCaseTable
sorting={sorting}
Expand Down

0 comments on commit 19505f0

Please sign in to comment.