From 2e4ab6b3b78c8e7a80e250ca615aff9015b15e66 Mon Sep 17 00:00:00 2001 From: Sandeep Kumawat Date: Sat, 17 Aug 2024 03:40:45 +0530 Subject: [PATCH] Fix PR test failures Signed-off-by: Sandeep Kumawat --- .../CreateDataStream/CreateDataStream.test.tsx | 17 +++++++++++++++++ .../DataStreamDetail/DataStreamDetail.test.tsx | 17 +++++++++++++++++ .../CreateRollupForm/CreateRollupForm.test.tsx | 17 +++++++++++++++++ .../containers/DataStreams/DataStreams.test.tsx | 17 +++++++++++++++++ .../EditRollup/containers/EditRollup.test.tsx | 17 +++++++++++++++++ .../container/ForceMerge/ForceMerge.test.tsx | 17 +++++++++++++++++ .../containers/Rollover/Rollover.test.tsx | 17 +++++++++++++++++ .../RollupDetails/RollupDetails.test.tsx | 17 +++++++++++++++++ .../Rollups/containers/Rollups/Rollups.test.tsx | 17 +++++++++++++++++ 9 files changed, 153 insertions(+) diff --git a/public/pages/CreateDataStream/containers/CreateDataStream/CreateDataStream.test.tsx b/public/pages/CreateDataStream/containers/CreateDataStream/CreateDataStream.test.tsx index 5c7be025b..34695129c 100644 --- a/public/pages/CreateDataStream/containers/CreateDataStream/CreateDataStream.test.tsx +++ b/public/pages/CreateDataStream/containers/CreateDataStream/CreateDataStream.test.tsx @@ -12,6 +12,23 @@ import { ServicesContext } from "../../../../services"; import { browserServicesMock, coreServicesMock, apiCallerMock } from "../../../../../test/mocks"; import { ROUTES } from "../../../../utils/constants"; import { CoreServicesContext } from "../../../../components/core_services"; +import { getApplication, getNavigationUI, getUISettings } from "../../../../services/Services"; + +jest.mock("../../../../services/Services", () => ({ + ...jest.requireActual("../../../../services/Services"), + getUISettings: jest.fn(), + getApplication: jest.fn(), + getNavigationUI: jest.fn(), +})); + +beforeEach(() => { + (getUISettings as jest.Mock).mockReturnValue({ + get: jest.fn().mockReturnValue(false), // or false, depending on your test case + }); + (getApplication as jest.Mock).mockReturnValue({}); + + (getNavigationUI as jest.Mock).mockReturnValue({}); +}); function renderCreateDataStreamWithRouter(initialEntries = [ROUTES.DATA_STREAMS] as string[]) { return { diff --git a/public/pages/CreateDataStream/containers/DataStreamDetail/DataStreamDetail.test.tsx b/public/pages/CreateDataStream/containers/DataStreamDetail/DataStreamDetail.test.tsx index 594295ac1..7f6bb2fa5 100644 --- a/public/pages/CreateDataStream/containers/DataStreamDetail/DataStreamDetail.test.tsx +++ b/public/pages/CreateDataStream/containers/DataStreamDetail/DataStreamDetail.test.tsx @@ -12,6 +12,23 @@ import { CoreServicesContext } from "../../../../components/core_services"; import { HashRouter, Route } from "react-router-dom"; import { ROUTES } from "../../../../utils/constants"; import userEvent from "@testing-library/user-event"; +import { getApplication, getNavigationUI, getUISettings } from "../../../../services/Services"; + +jest.mock("../../../../services/Services", () => ({ + ...jest.requireActual("../../../../services/Services"), + getUISettings: jest.fn(), + getApplication: jest.fn(), + getNavigationUI: jest.fn(), +})); + +beforeEach(() => { + (getUISettings as jest.Mock).mockReturnValue({ + get: jest.fn().mockReturnValue(false), // or false, depending on your test case + }); + (getApplication as jest.Mock).mockReturnValue({}); + + (getNavigationUI as jest.Mock).mockReturnValue({}); +}); function renderCreateDataStream(props: Omit) { return { diff --git a/public/pages/CreateRollup/containers/CreateRollupForm/CreateRollupForm.test.tsx b/public/pages/CreateRollup/containers/CreateRollupForm/CreateRollupForm.test.tsx index e01642d13..3e498fbbc 100644 --- a/public/pages/CreateRollup/containers/CreateRollupForm/CreateRollupForm.test.tsx +++ b/public/pages/CreateRollup/containers/CreateRollupForm/CreateRollupForm.test.tsx @@ -16,6 +16,23 @@ import { BREADCRUMBS, ROUTES } from "../../../../utils/constants"; import CreateRollupForm from "./CreateRollupForm"; import { CoreServicesContext } from "../../../../components/core_services"; import { DataStream } from "../../../../../server/models/interfaces"; +import { getApplication, getNavigationUI, getUISettings } from "../../../../services/Services"; + +jest.mock("../../../../services/Services", () => ({ + ...jest.requireActual("../../../../services/Services"), + getUISettings: jest.fn(), + getApplication: jest.fn(), + getNavigationUI: jest.fn(), +})); + +beforeEach(() => { + (getUISettings as jest.Mock).mockReturnValue({ + get: jest.fn().mockReturnValue(false), // or false, depending on your test case + }); + (getApplication as jest.Mock).mockReturnValue({}); + + (getNavigationUI as jest.Mock).mockReturnValue({}); +}); const sampleMapping = { index_1: { diff --git a/public/pages/DataStreams/containers/DataStreams/DataStreams.test.tsx b/public/pages/DataStreams/containers/DataStreams/DataStreams.test.tsx index a3dff2001..978098a9e 100644 --- a/public/pages/DataStreams/containers/DataStreams/DataStreams.test.tsx +++ b/public/pages/DataStreams/containers/DataStreams/DataStreams.test.tsx @@ -16,6 +16,23 @@ import { CoreServicesContext } from "../../../../components/core_services"; import userEvent from "@testing-library/user-event"; import { DataStreamStats, DataStreamWithStats } from "../../interface"; import { DataStream } from "../../../../../server/models/interfaces"; +import { getApplication, getNavigationUI, getUISettings } from "../../../../services/Services"; + +jest.mock("../../../../services/Services", () => ({ + ...jest.requireActual("../../../../services/Services"), + getUISettings: jest.fn(), + getApplication: jest.fn(), + getNavigationUI: jest.fn(), +})); + +beforeEach(() => { + (getUISettings as jest.Mock).mockReturnValue({ + get: jest.fn().mockReturnValue(false), // or false, depending on your test case + }); + (getApplication as jest.Mock).mockReturnValue({}); + + (getNavigationUI as jest.Mock).mockReturnValue({}); +}); function renderWithRouter() { return { diff --git a/public/pages/EditRollup/containers/EditRollup.test.tsx b/public/pages/EditRollup/containers/EditRollup.test.tsx index ce82f4ac7..6e308c8ac 100644 --- a/public/pages/EditRollup/containers/EditRollup.test.tsx +++ b/public/pages/EditRollup/containers/EditRollup.test.tsx @@ -16,6 +16,23 @@ import { BrowserServices } from "../../../models/interfaces"; import { BREADCRUMBS, ROUTES } from "../../../utils/constants"; import { testRollup } from "../../../../test/constants"; import { CoreServicesContext } from "../../../components/core_services"; +import { getApplication, getNavigationUI, getUISettings } from "../../../services/Services"; + +jest.mock("../../../../services/Services", () => ({ + ...jest.requireActual("../../../../services/Services"), + getUISettings: jest.fn(), + getApplication: jest.fn(), + getNavigationUI: jest.fn(), +})); + +beforeEach(() => { + (getUISettings as jest.Mock).mockReturnValue({ + get: jest.fn().mockReturnValue(false), // or false, depending on your test case + }); + (getApplication as jest.Mock).mockReturnValue({}); + + (getNavigationUI as jest.Mock).mockReturnValue({}); +}); function renderEditRollupWithRouter(initialEntries = ["/"]) { return { diff --git a/public/pages/ForceMerge/container/ForceMerge/ForceMerge.test.tsx b/public/pages/ForceMerge/container/ForceMerge/ForceMerge.test.tsx index 247271ae0..c7ef09697 100644 --- a/public/pages/ForceMerge/container/ForceMerge/ForceMerge.test.tsx +++ b/public/pages/ForceMerge/container/ForceMerge/ForceMerge.test.tsx @@ -17,6 +17,23 @@ import { CoreServicesConsumer, CoreServicesContext } from "../../../../component import ForceMerge from "./ForceMerge"; import { ModalProvider, ModalRoot } from "../../../../components/Modal"; import { BrowserServices } from "../../../../models/interfaces"; +import { getApplication, getNavigationUI, getUISettings } from "../../../../services/Services"; + +jest.mock("../../../../services/Services", () => ({ + ...jest.requireActual("../../../../services/Services"), + getUISettings: jest.fn(), + getApplication: jest.fn(), + getNavigationUI: jest.fn(), +})); + +beforeEach(() => { + (getUISettings as jest.Mock).mockReturnValue({ + get: jest.fn().mockReturnValue(false), // or false, depending on your test case + }); + (getApplication as jest.Mock).mockReturnValue({}); + + (getNavigationUI as jest.Mock).mockReturnValue({}); +}); function renderWithRouter(initialEntries = [ROUTES.FORCE_MERGE] as string[]) { return { diff --git a/public/pages/Rollover/containers/Rollover/Rollover.test.tsx b/public/pages/Rollover/containers/Rollover/Rollover.test.tsx index 5339a1493..a850fb88d 100644 --- a/public/pages/Rollover/containers/Rollover/Rollover.test.tsx +++ b/public/pages/Rollover/containers/Rollover/Rollover.test.tsx @@ -13,6 +13,23 @@ import Rollover, { RolloverProps } from "./Rollover"; import { ModalProvider } from "../../../../components/Modal"; import { ServicesContext } from "../../../../services"; import { CoreServicesContext } from "../../../../components/core_services"; +import { getApplication, getNavigationUI, getUISettings } from "../../../../services/Services"; + +jest.mock("../../../../services/Services", () => ({ + ...jest.requireActual("../../../../services/Services"), + getUISettings: jest.fn(), + getApplication: jest.fn(), + getNavigationUI: jest.fn(), +})); + +beforeEach(() => { + (getUISettings as jest.Mock).mockReturnValue({ + get: jest.fn().mockReturnValue(false), // or false, depending on your test case + }); + (getApplication as jest.Mock).mockReturnValue({}); + + (getNavigationUI as jest.Mock).mockReturnValue({}); +}); function renderWithRouter(props: Omit, initialEntries: string[]) { return { diff --git a/public/pages/RollupDetails/containers/RollupDetails/RollupDetails.test.tsx b/public/pages/RollupDetails/containers/RollupDetails/RollupDetails.test.tsx index 30da5bc65..13334cc83 100644 --- a/public/pages/RollupDetails/containers/RollupDetails/RollupDetails.test.tsx +++ b/public/pages/RollupDetails/containers/RollupDetails/RollupDetails.test.tsx @@ -16,6 +16,23 @@ import RollupDetails from "./RollupDetails"; import { ServicesConsumer, ServicesContext } from "../../../../services"; import { testRollup, testRollup2 } from "../../../../../test/constants"; import { CoreServicesContext } from "../../../../components/core_services"; +import { getApplication, getNavigationUI, getUISettings } from "../../../../services/Services"; + +jest.mock("../../../../services/Services", () => ({ + ...jest.requireActual("../../../../services/Services"), + getUISettings: jest.fn(), + getApplication: jest.fn(), + getNavigationUI: jest.fn(), +})); + +beforeEach(() => { + (getUISettings as jest.Mock).mockReturnValue({ + get: jest.fn().mockReturnValue(false), // or false, depending on your test case + }); + (getApplication as jest.Mock).mockReturnValue({}); + + (getNavigationUI as jest.Mock).mockReturnValue({}); +}); function renderRollupDetailsWithRouter(initialEntries = ["/"]) { return { diff --git a/public/pages/Rollups/containers/Rollups/Rollups.test.tsx b/public/pages/Rollups/containers/Rollups/Rollups.test.tsx index 21a9c560d..24f3eced6 100644 --- a/public/pages/Rollups/containers/Rollups/Rollups.test.tsx +++ b/public/pages/Rollups/containers/Rollups/Rollups.test.tsx @@ -17,6 +17,23 @@ import Rollups from "./Rollups"; import { TEXT } from "../../components/RollupEmptyPrompt/RollupEmptyPrompt"; import { testRollup } from "../../../../../test/constants"; import { CoreServicesContext } from "../../../../components/core_services"; +import { getApplication, getNavigationUI, getUISettings } from "../../../../services/Services"; + +jest.mock("../../../../services/Services", () => ({ + ...jest.requireActual("../../../../services/Services"), + getUISettings: jest.fn(), + getApplication: jest.fn(), + getNavigationUI: jest.fn(), +})); + +beforeEach(() => { + (getUISettings as jest.Mock).mockReturnValue({ + get: jest.fn().mockReturnValue(false), // or false, depending on your test case + }); + (getApplication as jest.Mock).mockReturnValue({}); + + (getNavigationUI as jest.Mock).mockReturnValue({}); +}); function renderRollupsWithRouter() { return {