diff --git a/kraken-app/kraken-app-portal/src/__test__/pages/Homepage/components/ActivityDiagrams.test.tsx b/kraken-app/kraken-app-portal/src/__test__/pages/Homepage/components/ActivityDiagrams.test.tsx
index 997ab9a3..673b8d14 100644
--- a/kraken-app/kraken-app-portal/src/__test__/pages/Homepage/components/ActivityDiagrams.test.tsx
+++ b/kraken-app/kraken-app-portal/src/__test__/pages/Homepage/components/ActivityDiagrams.test.tsx
@@ -1,10 +1,9 @@
import ActivityDiagrams from '@/pages/HomePage/components/ActivityDiagrams';
-import { queryClient } from "@/utils/helpers/reactQuery";
-import { QueryClientProvider } from "@tanstack/react-query";
-import { fireEvent, render } from "@testing-library/react";
-import { BrowserRouter } from "react-router-dom";
+import { fireEvent } from "@testing-library/react";
+import * as homepageHooks from '@/hooks/homepage'
+import { render } from "@/__test__/utils";
-test("ActivityDiagrams test", () => {
+test("ActivityDiagrams test with data", () => {
const envs = {
data: [
{
@@ -16,14 +15,89 @@ test("ActivityDiagrams test", () => {
],
};
+ vi.spyOn(homepageHooks, "useGetErrorBrakedown").mockReturnValue({
+ data: {
+ errorBreakdowns: [
+ {
+ date: "2024-05-30T13:02:03.224486Z",
+ errors: {
+ 400: 1,
+ 401: 1,
+ 404: 1,
+ 500: 1,
+ }
+ },
+ ],
+ },
+ isLoading: false,
+ refetch: vi.fn()
+ } as any);
+
+
+ vi.spyOn(homepageHooks, "useGetActivityRequests").mockReturnValue({
+ data: {
+ requestStatistics: [
+ {
+ date: "2024-05-30T13:02:03.224486Z",
+ success: 1,
+ error: 2,
+ },
+ ],
+ },
+ isLoading: false,
+ refetch: vi.fn(),
+ isRefetching: false
+ } as any);
+
const { container, getByTestId } = render(
-
-
-
-
-
+
);
expect(container).toBeInTheDocument();
- const recentButton = getByTestId('recent-7-days');
+ const recentButton = getByTestId('recent-90-days');
fireEvent.click(recentButton);
});
+
+test("ActivityDiagrams test with no data", () => {
+ const envs = {
+ data: [
+ {
+ id: "32b4832f-fb2f-4c99-b89a-c5c995b18dfc",
+ productId: "mef.sonata",
+ createdAt: "2024-05-30T13:02:03.224486Z",
+ name: "stage",
+ },
+ ],
+ };
+
+ vi.spyOn(homepageHooks, "useGetErrorBrakedown").mockReturnValue({
+ data: {
+ errorBreakdowns: [],
+ },
+ isLoading: false,
+ refetch: vi.fn()
+ } as any);
+
+
+ vi.spyOn(homepageHooks, "useGetActivityRequests").mockReturnValue({
+ data: {},
+ isLoading: false,
+ refetch: vi.fn(),
+ isRefetching: false
+ } as any);
+
+ const { container } = render(
+
+ );
+ expect(container).toBeInTheDocument();
+});
+
+test("ActivityDiagrams test with no data", () => {
+ const envs = {
+ data: [],
+ };
+
+ const { container } = render(
+
+ );
+ expect(container).toBeInTheDocument();
+});
\ No newline at end of file
diff --git a/kraken-app/kraken-app-portal/src/pages/HomePage/components/ActivityDiagrams/ApiActivityDiagram/index.tsx b/kraken-app/kraken-app-portal/src/pages/HomePage/components/ActivityDiagrams/ApiActivityDiagram/index.tsx
index cff22200..c9924011 100644
--- a/kraken-app/kraken-app-portal/src/pages/HomePage/components/ActivityDiagrams/ApiActivityDiagram/index.tsx
+++ b/kraken-app/kraken-app-portal/src/pages/HomePage/components/ActivityDiagrams/ApiActivityDiagram/index.tsx
@@ -38,7 +38,11 @@ const ApiActivityDiagram = ({ props }: Props) => {
}, [props]);
const activityData = useMemo(
- () => data?.requestStatistics,
+ () => (data?.requestStatistics || []).map(entry => ({
+ ...entry,
+ error: entry.error || 0,
+ success: entry.success || 0,
+ })),
[isLoading, data]
);
@@ -49,7 +53,7 @@ const ApiActivityDiagram = ({ props }: Props) => {
{!isLoading && !activityData
- ?
+ ?
:
{
/>