Compare commits

...

16 Commits

Author SHA1 Message Date
MokireddySampath
311e517836 Update PanelContainerComponent.tsx 2023-10-11 14:20:02 +05:30
MokireddySampath
04092c9da5 Update tsconfig.strict.json 2023-10-11 13:42:27 +05:30
MokireddySampath
7b82a8ff81 Update tsconfig.strict.json 2023-10-11 13:39:51 +05:30
MokireddySampath
832964f1b9 Update PanelContainerComponent.tsx 2023-10-11 13:39:11 +05:30
MokireddySampath
1e5042c2ec Update PanelContainerComponent.tsx 2023-08-17 22:34:02 +05:30
Sampath
bc9f617537 Merge branch '2262594' of https://github.com/Azure/cosmos-explorer into 2262594 2023-07-27 21:27:05 +05:30
Sampath
288dc675d4 removing panelcontainercomponent and its corresponding test file since the changes made are failing the typescript compilation 2023-07-27 21:25:49 +05:30
MokireddySampath
c727d82cdd Update PanelContainerComponent.tsx 2023-07-26 22:56:08 +05:30
MokireddySampath
ec9d56e55f Update PanelContainerComponent.tsx 2023-07-26 21:56:31 +05:30
MokireddySampath
4766b69799 Update PanelContainerComponent.tsx 2023-07-26 20:36:12 +05:30
MokireddySampath
19cf52353c Update PanelContainerComponent.tsx 2023-07-26 20:32:04 +05:30
MokireddySampath
fd50580ff7 Update PanelContainerComponent.tsx 2023-07-26 20:31:35 +05:30
MokireddySampath
140313e5e3 Update PanelContainerComponent.tsx 2023-07-26 20:22:10 +05:30
MokireddySampath
8f228260a3 Update PanelContainerComponent.tsx 2023-07-26 20:09:41 +05:30
Sampath
045d038a93 focus getting restored to more button on closing the delete collection dialog using close button 2023-07-26 19:59:33 +05:30
Predrag Klepic
42e11d5160 [Query Copilot] Hide error message bar when request is successful (#1542)
Co-authored-by: Predrag Klepic <v-prklepic@microsoft.com>
2023-07-19 16:05:09 -07:00
4 changed files with 82 additions and 1 deletions

View File

@@ -1,4 +1,5 @@
import { IPanelProps, IRenderFunction, Panel, PanelType } from "@fluentui/react";
import { useSelectedNode } from "Explorer/useSelectedNode";
import * as React from "react";
import { useNotificationConsole } from "../../hooks/useNotificationConsole";
import { useSidePanel } from "../../hooks/useSidePanel";
@@ -77,6 +78,20 @@ export class PanelContainerComponent extends React.Component<PanelContainerProps
}
private onDissmiss = (ev?: KeyboardEvent | React.SyntheticEvent<HTMLElement>): void => {
const collection = useSelectedNode.getState().findSelectedCollection();
if (collection) {
const targetElementDataTest: string | undefined = collection.id();
const targetElement: HTMLElement | null = document.querySelector(`[data-test="${targetElementDataTest}"]`);
if (targetElement) {
setTimeout(() => {
const moreButton: HTMLElement | null = targetElement.querySelector('[name="More"]');
if (moreButton) {
moreButton.focus();
}
}, 100);
clearTimeout;
}
}
if (ev && (ev.target as HTMLElement).id === "notificationConsoleHeader") {
ev.preventDefault();
} else {

View File

@@ -188,6 +188,7 @@ export const QueryCopilotTab: React.FC<QueryCopilotTabProps> = ({
query += generateSQLQueryResponse.sql;
setQuery(query);
setGeneratedQuery(generateSQLQueryResponse.sql);
setShowErrorMessageBar(false);
}
} else {
handleError(JSON.stringify(generateSQLQueryResponse), "copilotInternalServerError");
@@ -231,6 +232,7 @@ export const QueryCopilotTab: React.FC<QueryCopilotTabProps> = ({
setQueryResults(queryResults);
setErrorMessage("");
setShowErrorMessageBar(false);
} catch (error) {
const errorMessage = getErrorMessage(error);
setErrorMessage(errorMessage);

View File

@@ -1,3 +1,4 @@
import { DefaultButton, IconButton } from "@fluentui/react";
import { shallow } from "enzyme";
import React from "react";
import { SamplePrompts, SamplePromptsProps } from "./SamplePrompts";
@@ -10,6 +11,7 @@ describe("Sample Prompts snapshot test", () => {
setIsSamplePromptsOpen: setIsSamplePromptsOpenMock,
setTextBox: setTextBoxMock,
};
beforeEach(() => jest.clearAllMocks());
it("should render properly if isSamplePromptsOpen is true", () => {
const wrapper = shallow(<SamplePrompts sampleProps={sampleProps} />);
@@ -24,4 +26,66 @@ describe("Sample Prompts snapshot test", () => {
expect(wrapper).toMatchSnapshot();
});
it("should call setTextBox and setIsSamplePromptsOpen(false) when a button is clicked", () => {
const wrapper = shallow(<SamplePrompts sampleProps={sampleProps} />);
wrapper.find(DefaultButton).at(0).simulate("click");
expect(setTextBoxMock).toHaveBeenCalledWith("Show me products less than 100 dolars");
expect(setIsSamplePromptsOpenMock).toHaveBeenCalledWith(false);
wrapper.find(DefaultButton).at(3).simulate("click");
expect(setTextBoxMock).toHaveBeenCalledWith(
"Write a query to return all records in this table created in the last thirty days"
);
expect(setIsSamplePromptsOpenMock).toHaveBeenCalledWith(false);
});
it("should call setIsSamplePromptsOpen(false) when the close button is clicked", () => {
const wrapper = shallow(<SamplePrompts sampleProps={sampleProps} />);
wrapper.find(IconButton).first().simulate("click");
expect(setIsSamplePromptsOpenMock).toHaveBeenCalledWith(false);
});
it("should call setTextBox and setIsSamplePromptsOpen(false) when a simple prompt button is clicked", () => {
const wrapper = shallow(<SamplePrompts sampleProps={sampleProps} />);
wrapper.find(DefaultButton).at(0).simulate("click");
expect(setTextBoxMock).toHaveBeenCalledWith("Show me products less than 100 dolars");
expect(setIsSamplePromptsOpenMock).toHaveBeenCalledWith(false);
wrapper.find(DefaultButton).at(1).simulate("click");
expect(setTextBoxMock).toHaveBeenCalledWith("Show schema");
expect(setIsSamplePromptsOpenMock).toHaveBeenCalledWith(false);
});
it("should call setTextBox and setIsSamplePromptsOpen(false) when an intermediate prompt button is clicked", () => {
const wrapper = shallow(<SamplePrompts sampleProps={sampleProps} />);
wrapper.find(DefaultButton).at(2).simulate("click");
expect(setTextBoxMock).toHaveBeenCalledWith(
"Show items with a description that contains a number between 0 and 99 inclusive."
);
expect(setIsSamplePromptsOpenMock).toHaveBeenCalledWith(false);
wrapper.find(DefaultButton).at(3).simulate("click");
expect(setTextBoxMock).toHaveBeenCalledWith(
"Write a query to return all records in this table created in the last thirty days"
);
expect(setIsSamplePromptsOpenMock).toHaveBeenCalledWith(false);
});
it("should call setTextBox and setIsSamplePromptsOpen(false) when a complex prompt button is clicked", () => {
const wrapper = shallow(<SamplePrompts sampleProps={sampleProps} />);
wrapper.find(DefaultButton).at(4).simulate("click");
expect(setTextBoxMock).toHaveBeenCalledWith("Show all the products that customer Bob has reviewed.");
expect(setIsSamplePromptsOpenMock).toHaveBeenCalledWith(false);
wrapper.find(DefaultButton).at(5).simulate("click");
expect(setTextBoxMock).toHaveBeenCalledWith("Which computers are more than 300 dollars and less than 400 dollars?");
expect(setIsSamplePromptsOpenMock).toHaveBeenCalledWith(false);
});
});

View File

@@ -163,4 +163,4 @@
"src/Terminal/**/*",
"src/Utils/arm/**/*"
]
}
}