From ece76b6e041b77e66bff1aa81151f2f0b5194b32 Mon Sep 17 00:00:00 2001 From: Bart K Date: Thu, 21 Nov 2024 10:05:08 +0100 Subject: [PATCH] fix(portal): add modal tests --- .../PushHistoryModal/index.test.tsx | 28 +++++++++++++++++++ .../components/PushHistoryList/index.tsx | 6 ++-- .../components/PushHistoryModal/index.tsx | 2 +- 3 files changed, 33 insertions(+), 3 deletions(-) create mode 100644 kraken-app/kraken-app-portal/src/__test__/pages/EnvironmentActivityLog/PushHistoryModal/index.test.tsx diff --git a/kraken-app/kraken-app-portal/src/__test__/pages/EnvironmentActivityLog/PushHistoryModal/index.test.tsx b/kraken-app/kraken-app-portal/src/__test__/pages/EnvironmentActivityLog/PushHistoryModal/index.test.tsx new file mode 100644 index 00000000..5976300c --- /dev/null +++ b/kraken-app/kraken-app-portal/src/__test__/pages/EnvironmentActivityLog/PushHistoryModal/index.test.tsx @@ -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( + + + + + + ); + expect(container).toBeInTheDocument(); + const envSelect = findAllByText("Test Env"); + waitFor(() => { + expect(envSelect).toBeInTheDocument(); + }) +}); diff --git a/kraken-app/kraken-app-portal/src/pages/EnvironmentActivityLog/components/PushHistoryList/index.tsx b/kraken-app/kraken-app-portal/src/pages/EnvironmentActivityLog/components/PushHistoryList/index.tsx index 40931276..0be3ea79 100644 --- a/kraken-app/kraken-app-portal/src/pages/EnvironmentActivityLog/components/PushHistoryList/index.tsx +++ b/kraken-app/kraken-app-portal/src/pages/EnvironmentActivityLog/components/PushHistoryList/index.tsx @@ -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 = { @@ -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; @@ -91,7 +93,7 @@ const PushHistoryList = () => { { key: "pushedBy", title: "Pushed by", - render: (log: IPushHistory) => log.pushedBy, + render: (log: IPushHistory) => findUserName(log.pushedBy), }, { key: "status", diff --git a/kraken-app/kraken-app-portal/src/pages/EnvironmentActivityLog/components/PushHistoryModal/index.tsx b/kraken-app/kraken-app-portal/src/pages/EnvironmentActivityLog/components/PushHistoryModal/index.tsx index 62c98758..b89fd2a1 100644 --- a/kraken-app/kraken-app-portal/src/pages/EnvironmentActivityLog/components/PushHistoryModal/index.tsx +++ b/kraken-app/kraken-app-portal/src/pages/EnvironmentActivityLog/components/PushHistoryModal/index.tsx @@ -93,7 +93,7 @@ const PushHistoryModal = ({ > {envOptions.map((key) => ( - {capitalize(key.label)} + {capitalize(key.label)} ))}