From 9c868b29c9ee6ceaf1273af23e30a001fdee40dd Mon Sep 17 00:00:00 2001 From: Archie Agarwal Date: Mon, 7 Jul 2025 12:53:41 +0530 Subject: [PATCH] Updated the files --- .../Controls/Settings/SettingsComponent.test.tsx | 2 +- .../Controls/Settings/SettingsComponent.tsx | 4 ++-- src/Explorer/Tabs/QueryTab/IndexAdvisorUtils.ts | 4 ++-- src/Explorer/Tabs/QueryTab/Indexadvisor.test.tsx | 5 +---- src/Explorer/Tabs/QueryTab/QueryTabComponent.tsx | 16 ++++++++-------- src/Explorer/Tabs/QueryTab/ResultsView.tsx | 10 +++++----- 6 files changed, 19 insertions(+), 22 deletions(-) diff --git a/src/Explorer/Controls/Settings/SettingsComponent.test.tsx b/src/Explorer/Controls/Settings/SettingsComponent.test.tsx index 00e7dae72..456a96e7c 100644 --- a/src/Explorer/Controls/Settings/SettingsComponent.test.tsx +++ b/src/Explorer/Controls/Settings/SettingsComponent.test.tsx @@ -331,7 +331,7 @@ describe("SettingsComponent - indexing policy subscription", () => { expect(wrapper.state("indexingPolicyContent")).toEqual(mockIndexingPolicy); expect(wrapper.state("indexingPolicyContentBaseline")).toEqual(mockIndexingPolicy); // Optionally, check the collection's rawDataModel (ignore TS error in test) - // @ts-expect-error + // @ts-expect-error: rawDataModel is intentionally accessed for test validation expect(instance.collection.rawDataModel.indexingPolicy).toEqual(mockIndexingPolicy); }); }); \ No newline at end of file diff --git a/src/Explorer/Controls/Settings/SettingsComponent.tsx b/src/Explorer/Controls/Settings/SettingsComponent.tsx index 0bb81a376..5050417f6 100644 --- a/src/Explorer/Controls/Settings/SettingsComponent.tsx +++ b/src/Explorer/Controls/Settings/SettingsComponent.tsx @@ -303,7 +303,7 @@ export class SettingsComponent extends React.Component { + this.unsubscribe = useIndexingPolicyStore.subscribe(() => { this.refreshCollectionData(); }, (state) => state.indexingPolicies[this.collection.id()] @@ -311,7 +311,7 @@ export class SettingsComponent extends React.Component { }); test("calls replace when update button is clicked", async () => { - const cosmos = require("Common/CosmosClient"); - const mockReplace = cosmos.client().database().container().replace; render(); await waitFor(() => expect(screen.getByText("/bar/?")).toBeInTheDocument()); const checkboxes = screen.getAllByRole("checkbox"); @@ -140,7 +138,7 @@ test("selects all indexes when select-all is clicked", async () => { const checkboxes = screen.getAllByRole("checkbox"); fireEvent.click(checkboxes[0]); - checkboxes.forEach((cb, i) => { + checkboxes.forEach((cb) => { expect(cb).toBeChecked(); }); }); @@ -174,7 +172,6 @@ test("calls handleError if fetchIndexMetrics throws", async () => { }); test("calls handleError if fetchIndexMetrics throws2nd", async () => { - const cosmos = require("Common/CosmosClient"); mockFetchAll.mockRejectedValueOnce(new Error("fail")); render(); diff --git a/src/Explorer/Tabs/QueryTab/QueryTabComponent.tsx b/src/Explorer/Tabs/QueryTab/QueryTabComponent.tsx index 622421279..a454b6b31 100644 --- a/src/Explorer/Tabs/QueryTab/QueryTabComponent.tsx +++ b/src/Explorer/Tabs/QueryTab/QueryTabComponent.tsx @@ -28,6 +28,7 @@ import { TabsState, useTabs } from "hooks/useTabs"; import React, { Fragment, createRef } from "react"; import "react-splitter-layout/lib/index.css"; import { format } from "react-string-format"; +import create from "zustand"; import QueryCommandIcon from "../../../../images/CopilotCommand.svg"; import LaunchCopilot from "../../../../images/CopilotTabIcon.svg"; import DownloadQueryIcon from "../../../../images/DownloadQuery.svg"; @@ -55,7 +56,6 @@ import { BrowseQueriesPane } from "../../Panes/BrowseQueriesPane/BrowseQueriesPa import { SaveQueryPane } from "../../Panes/SaveQueryPane/SaveQueryPane"; import TabsBase from "../TabsBase"; import "./QueryTabComponent.less"; -import create from "zustand"; export interface QueryMetadataStore { userQuery: string; @@ -212,7 +212,7 @@ class QueryTabComponentImpl extends React.Component 0, visible: true, }; - + const isSaveQueryBtnEnabled = userContext.apiType === "SQL" || userContext.apiType === "Gremlin"; this.saveQueryButton = { enabled: isSaveQueryBtnEnabled, @@ -276,9 +276,9 @@ class QueryTabComponentImpl extends React.Component => { - const query1=this.state.sqlQueryEditorContent; - const db = this.props.collection.databaseId; - const container = this.props.collection.id(); + const query1 = this.state.sqlQueryEditorContent; + const db = this.props.collection.databaseId; + const container = this.props.collection.id(); useQueryMetadataStore.getState().setMetadata(query1, db, container); this._iterator = undefined; @@ -376,9 +376,9 @@ class QueryTabComponentImpl extends React.Component { const [isUpdating, setIsUpdating] = useState(false); const [justUpdatedPolicy, setJustUpdatedPolicy] = useState(false); useEffect(() => { - async function fetchIndexMetrics() { + const fetchIndexMetrics = async () => { const clearMessage = logConsoleProgress(`Querying items with IndexMetrics in container ${containerId}`); try { const querySpec = { @@ -585,7 +585,7 @@ export const IndexAdvisorTab: React.FC = () => { }, [userQuery, databaseId, containerId]); useEffect(() => { - if (!indexMetrics) { return }; + if (!indexMetrics) { return } const { included, notIncluded } = parseIndexMetrics(indexMetrics); setIncludedIndexes(included); @@ -686,9 +686,9 @@ export const IndexAdvisorTab: React.FC = () => { }; const renderImpactDots = (impact: string) => { let count = 0; - if (impact === "High") count = 3; - else if (impact === "Medium") count = 2; - else if (impact === "Low") count = 1; + if (impact === "High") { count = 3; } + else if (impact === "Medium") { count = 2; } + else if (impact === "Low") { count = 1; } return (
{Array.from({ length: count }).map((_, i) => (