Skip to content

Commit

Permalink
fix(portal): add modal tests
Browse files Browse the repository at this point in the history
  • Loading branch information
KsiBart committed Nov 21, 2024
1 parent b81d88c commit ece76b6
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { render, waitFor } from "@testing-library/react";
import { QueryClientProvider } from "@tanstack/react-query";
import { queryClient } from "@/utils/helpers/reactQuery";
import { BrowserRouter } from "react-router-dom";
import PushHistoryModal from '@/pages/EnvironmentActivityLog/components/PushHistoryModal';

test("PushHistoryModal", () => {
const { container, findAllByText } = render(
<QueryClientProvider client={queryClient}>
<BrowserRouter>
<PushHistoryModal
isOpen={true}
onClose={vi.fn()}
onOK={vi.fn()}
envOptions={[{
value: "testEnv",
label: "Test Env"
}]}
/>
</BrowserRouter>
</QueryClientProvider>
);
expect(container).toBeInTheDocument();
const envSelect = findAllByText("Test Env");
waitFor(() => {
expect(envSelect).toBeInTheDocument();
})
});
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import mockData from "./historyMockData.json"
import { DAY_FORMAT, DAY_TIME_FORMAT_NORMAL } from '@/utils/constants/format';
import { capitalize } from 'lodash';
import { PresetStatusColorType } from 'antd/es/_util/colors';
import { useUser } from '@/hooks/user/useUser';


const initPagination = {
Expand Down Expand Up @@ -51,8 +52,9 @@ const PushHistoryList = () => {
handlePaginationChange,
handlePaginationShowSizeChange,
} = useCommonListProps({}, initPagination);

const { findUserName } = useUser();
const { data, isLoading } = useGetPushActivityLogHistory();

useEffect(() => {
if (!isLoading) {
const updatedTableData = data?.data ?? mockData.data.data;
Expand Down Expand Up @@ -91,7 +93,7 @@ const PushHistoryList = () => {
{
key: "pushedBy",
title: "Pushed by",
render: (log: IPushHistory) => log.pushedBy,
render: (log: IPushHistory) => findUserName(log.pushedBy),
},
{
key: "status",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ const PushHistoryModal = ({
>
<Radio.Group size="middle" name="Environment" >
{envOptions.map((key) => (
<Radio value={key.value}>{capitalize(key.label)}</Radio>
<Radio key={key.value} value={key.value}>{capitalize(key.label)}</Radio>
))}
</Radio.Group>
</Form.Item>
Expand Down

0 comments on commit ece76b6

Please sign in to comment.