From 13e41f232898eb7aa213a05bbf3cb958b954d7ef Mon Sep 17 00:00:00 2001 From: Kshitij Tandon Date: Thu, 22 Aug 2024 16:12:03 +0530 Subject: [PATCH] Resolved comments Signed-off-by: Kshitij Tandon --- .../IndexControls/IndexControls.tsx | 63 ++++--- .../IndexControls/IndexControls.tsx | 67 +++---- .../containers/IndicesActions/index.tsx | 1 - .../ManagedIndexControls.tsx | 50 ++--- .../container/Reindex/Reindex.test.tsx | 18 +- .../Reindex/container/Reindex/Reindex.tsx | 174 +++++++++--------- .../ShrinkIndex/ShrinkIndex.test.tsx | 18 +- .../container/ShrinkIndex/ShrinkIndex.tsx | 1 + .../container/SplitIndex/SplitIndex.test.tsx | 18 +- .../IndexControls/IndexControls.tsx | 29 +-- .../containers/Transforms/Transforms.tsx | 4 +- .../pages/Transforms/utils/metadataHelper.tsx | 2 +- test/helper.ts | 10 + 13 files changed, 222 insertions(+), 233 deletions(-) create mode 100644 test/helper.ts diff --git a/public/pages/Aliases/components/IndexControls/IndexControls.tsx b/public/pages/Aliases/components/IndexControls/IndexControls.tsx index 9bc518d30..47b0f0d1f 100644 --- a/public/pages/Aliases/components/IndexControls/IndexControls.tsx +++ b/public/pages/Aliases/components/IndexControls/IndexControls.tsx @@ -4,7 +4,7 @@ */ import React, { useEffect, useState } from "react"; -import { EuiCompressedComboBox, EuiCompressedFieldSearch, EuiFlexGroup, EuiFlexItem } from "@elastic/eui"; +import { EuiCompressedComboBox, EuiCompressedFieldSearch, EuiFlexGroup, EuiFlexItem, EuiSpacer } from "@elastic/eui"; import { ALIAS_STATUS_OPTIONS, IndicesUpdateMode } from "../../../../utils/constants"; import { getUISettings } from "../../../../services/Services"; import AliasesActions from "../../containers/AliasActions"; @@ -42,35 +42,38 @@ export default function SearchControls(props: SearchControlsProps) { const useUpdatedUX = uiSettings.get("home:useNewHomePage"); return useUpdatedUX ? ( - - - onChange("search", e.target.value)} - /> - - - onChange("status", (val || []).map((item) => item).join(","))} - value={state.status ? state.status.split(",").map((label) => label) : []} - options={ALIAS_STATUS_OPTIONS} - useNewUX={useUpdatedUX} - /> - - - - - + <> + + + onChange("search", e.target.value)} + /> + + + onChange("status", (val || []).map((item) => item).join(","))} + value={state.status ? state.status.split(",").map((label) => label) : []} + options={ALIAS_STATUS_OPTIONS} + useNewUX={useUpdatedUX} + /> + + + + + + + ) : ( diff --git a/public/pages/Indices/components/IndexControls/IndexControls.tsx b/public/pages/Indices/components/IndexControls/IndexControls.tsx index e1e557e8a..97e4a904a 100644 --- a/public/pages/Indices/components/IndexControls/IndexControls.tsx +++ b/public/pages/Indices/components/IndexControls/IndexControls.tsx @@ -84,38 +84,41 @@ export default class IndexControls extends Component - - - - - - - - - - - - - + <> + + + + + + + + + + + + + + + + ) : ( diff --git a/public/pages/Indices/containers/IndicesActions/index.tsx b/public/pages/Indices/containers/IndicesActions/index.tsx index e7f1e0372..35be9cd08 100644 --- a/public/pages/Indices/containers/IndicesActions/index.tsx +++ b/public/pages/Indices/containers/IndicesActions/index.tsx @@ -30,7 +30,6 @@ export interface IndicesActionsProps extends Pick void; onClose: () => void; onShrink: () => void; - history: RouteComponentProps["history"]; } export default function IndicesActions(props: IndicesActionsProps) { diff --git a/public/pages/ManagedIndices/components/ManagedIndexControls/ManagedIndexControls.tsx b/public/pages/ManagedIndices/components/ManagedIndexControls/ManagedIndexControls.tsx index 42771bb77..17aef000f 100644 --- a/public/pages/ManagedIndices/components/ManagedIndexControls/ManagedIndexControls.tsx +++ b/public/pages/ManagedIndices/components/ManagedIndexControls/ManagedIndexControls.tsx @@ -17,6 +17,7 @@ import { EuiContextMenuPanel, EuiButtonIcon, EuiButtonEmpty, + EuiSpacer, } from "@elastic/eui"; import { DataStream } from "../../../../../server/models/interfaces"; import { ManagedIndices } from "../../containers/ManagedIndices/ManagedIndices"; @@ -88,29 +89,32 @@ export default class ManagedIndexControls extends Component - - - - - - - {Actions} - - - - + <> + + + + + + + + {Actions} + + + + + + ) : ( diff --git a/public/pages/Reindex/container/Reindex/Reindex.test.tsx b/public/pages/Reindex/container/Reindex/Reindex.test.tsx index 79e8f8164..c3afc6646 100644 --- a/public/pages/Reindex/container/Reindex/Reindex.test.tsx +++ b/public/pages/Reindex/container/Reindex/Reindex.test.tsx @@ -17,22 +17,10 @@ import { CoreServicesConsumer, CoreServicesContext } from "../../../../component import Reindex from "./Reindex"; 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({}); +import { setupCoreStart } from "../../../../../test/helper"; - (getNavigationUI as jest.Mock).mockReturnValue({}); +beforeAll(() => { + setupCoreStart(); }); function renderWithRouter(initialEntries = [ROUTES.REINDEX] as string[]) { diff --git a/public/pages/Reindex/container/Reindex/Reindex.tsx b/public/pages/Reindex/container/Reindex/Reindex.tsx index 995db9a49..af4ed83c1 100644 --- a/public/pages/Reindex/container/Reindex/Reindex.tsx +++ b/public/pages/Reindex/container/Reindex/Reindex.tsx @@ -602,85 +602,85 @@ class Reindex extends Component { /> - - - { - this.setState({ subset: id === "subset" }); - }} - name="subsetOption" - data-test-subj="subsetOption" - legend={{ - children: Specify a reindex option, - }} - /> - - - {subset ? ( - - - Learn more about query DSL - - - } - > - + + { + this.setState({ subset: id === "subset" }); + }} + name="subsetOption" + data-test-subj="subsetOption" + legend={{ + children: Specify a reindex option, + }} /> - ) : null} - + + {subset ? ( + + + Learn more about query DSL + + + } + > + + + ) : null} + - - - - - - - - - - this.setState({ showCreateIndexFlyout: true })}> - Create index - - - - + + + + + + + + + + this.setState({ showCreateIndexFlyout: true })}> + Create index + + + + @@ -708,18 +708,18 @@ class Reindex extends Component { - - - - Cancel - - - - - Reindex - - - + + + + Cancel + + + + + Reindex + + + {showCreateIndexFlyout ? ( { const { setAppDescriptionControls } = getApplication(); return this.props.useUpdatedUX ? ( -
+
{Common()}
diff --git a/public/pages/ShrinkIndex/container/ShrinkIndex/ShrinkIndex.test.tsx b/public/pages/ShrinkIndex/container/ShrinkIndex/ShrinkIndex.test.tsx index 901259ed3..c6628209d 100644 --- a/public/pages/ShrinkIndex/container/ShrinkIndex/ShrinkIndex.test.tsx +++ b/public/pages/ShrinkIndex/container/ShrinkIndex/ShrinkIndex.test.tsx @@ -17,22 +17,10 @@ import { CoreServicesConsumer, CoreServicesContext } from "../../../../component import ShrinkIndex from "./ShrinkIndex"; 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({}); +import { setupCoreStart } from "../../../../../test/helper"; - (getNavigationUI as jest.Mock).mockReturnValue({}); +beforeAll(() => { + setupCoreStart(); }); function renderWithRouter(initialEntries = [ROUTES.SHRINK_INDEX] as string[]) { diff --git a/public/pages/ShrinkIndex/container/ShrinkIndex/ShrinkIndex.tsx b/public/pages/ShrinkIndex/container/ShrinkIndex/ShrinkIndex.tsx index 7ade6a886..6ecf631e4 100644 --- a/public/pages/ShrinkIndex/container/ShrinkIndex/ShrinkIndex.tsx +++ b/public/pages/ShrinkIndex/container/ShrinkIndex/ShrinkIndex.tsx @@ -52,6 +52,7 @@ import { openIndices } from "../../../Indices/utils/helpers"; import { EVENT_MAP, destroyListener, listenEvent } from "../../../../JobHandler"; import { useUpdateUrlWithDataSourceProperties } from "../../../../components/MDSEnabledComponent"; import { getApplication, getNavigationUI, getUISettings } from "../../../../services/Services"; +import { TopNavControlDescriptionData, TopNavControlLinkData } from "src/plugins/navigation/public"; const WrappedAliasSelect = EuiToolTipWrapper(AliasSelect as any, { disabledKey: "isDisabled", diff --git a/public/pages/SplitIndex/container/SplitIndex/SplitIndex.test.tsx b/public/pages/SplitIndex/container/SplitIndex/SplitIndex.test.tsx index 29fcd8ef0..e48e40cf7 100644 --- a/public/pages/SplitIndex/container/SplitIndex/SplitIndex.test.tsx +++ b/public/pages/SplitIndex/container/SplitIndex/SplitIndex.test.tsx @@ -17,22 +17,10 @@ import { IAlias } from "../../../Aliases/interface"; import { BrowserServices } from "../../../../models/interfaces"; import { ModalProvider, ModalRoot } from "../../../../components/Modal"; import { CoreStart } from "opensearch-dashboards/public"; -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({}); +import { setupCoreStart } from "../../../../../test/helper"; - (getNavigationUI as jest.Mock).mockReturnValue({}); +beforeAll(() => { + setupCoreStart(); }); function renderWithRouter(initialEntries = [ROUTES.SPLIT_INDEX] as string[]) { diff --git a/public/pages/Templates/components/IndexControls/IndexControls.tsx b/public/pages/Templates/components/IndexControls/IndexControls.tsx index 8a4d90c03..5ed10061c 100644 --- a/public/pages/Templates/components/IndexControls/IndexControls.tsx +++ b/public/pages/Templates/components/IndexControls/IndexControls.tsx @@ -38,19 +38,22 @@ export default function SearchControls(props: SearchControlsProps) { const useUpdatedUX = uiSettings.get("home:useNewHomePage"); return useUpdatedUX ? ( - - - onChange("search", e.target.value)} - /> - - - - - + <> + + + onChange("search", e.target.value)} + /> + + + + + + + ) : ( diff --git a/public/pages/Transforms/containers/Transforms/Transforms.tsx b/public/pages/Transforms/containers/Transforms/Transforms.tsx index bb05ab382..cd2a1e00b 100644 --- a/public/pages/Transforms/containers/Transforms/Transforms.tsx +++ b/public/pages/Transforms/containers/Transforms/Transforms.tsx @@ -26,6 +26,7 @@ import { Pagination, EuiTableSelectionType, EuiTableSortingType, + EuiSpacer, } from "@elastic/eui"; import queryString from "query-string"; import { RouteComponentProps } from "react-router-dom"; @@ -272,7 +273,7 @@ export class Transforms extends MDSEnabledComponent
- + @@ -300,6 +301,7 @@ export class Transforms extends MDSEnabledComponent + ( - + diff --git a/test/helper.ts b/test/helper.ts new file mode 100644 index 000000000..fc7a675f4 --- /dev/null +++ b/test/helper.ts @@ -0,0 +1,10 @@ +import { navigationPluginMock } from "../../../src/plugins/navigation/public/mocks"; +import { applicationServiceMock } from "../../../src/core/public/application/application_service.mock"; +import { uiSettingsServiceMock } from "../../../src/core/public/ui_settings/ui_settings_service.mock"; +import { setApplication, setNavigationUI, setUISettings } from "../public/services/Services"; + +export function setupCoreStart() { + setNavigationUI(navigationPluginMock.createStartContract().ui); + setApplication(applicationServiceMock.createStartContract()); + setUISettings(uiSettingsServiceMock.createStartContract()); +}