mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2026-01-06 11:11:23 +00:00
Compare commits
18 Commits
dependabot
...
2262594
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
311e517836 | ||
|
|
04092c9da5 | ||
|
|
7b82a8ff81 | ||
|
|
832964f1b9 | ||
|
|
1e5042c2ec | ||
|
|
bc9f617537 | ||
|
|
288dc675d4 | ||
|
|
c727d82cdd | ||
|
|
ec9d56e55f | ||
|
|
4766b69799 | ||
|
|
19cf52353c | ||
|
|
fd50580ff7 | ||
|
|
140313e5e3 | ||
|
|
8f228260a3 | ||
|
|
045d038a93 | ||
|
|
42e11d5160 | ||
|
|
10037d844e | ||
|
|
13434715b3 |
@@ -435,24 +435,89 @@ export const QueryCopilotSampleContainerId = "SampleContainer";
|
||||
export const QueryCopilotSampleContainerSchema = {
|
||||
product: {
|
||||
sampleData: {
|
||||
id: "de6fadec-0384-43c8-93ea-16c0170b5460",
|
||||
name: "Premium Phone Mini (Red)",
|
||||
price: 652.04,
|
||||
id: "c415e70f-9bf5-4cda-aebe-a290cb8b94c2",
|
||||
name: "Amazing Phone 3000 (Black)",
|
||||
price: 223.33,
|
||||
category: "Electronics",
|
||||
description:
|
||||
"This Premium Phone Mini (Red) is designed by the company under agreement with the FCC, so we'd give it a pass in either direction, but no one should be using this handset without a compatible handset. All in all, this phone is one of the most affordable Android handsets out there at $100. Check them out.\n\n9. HTC One M9 4",
|
||||
stock: 74,
|
||||
countryOfOrigin: "Mexico",
|
||||
firstAvailable: "2018-07-07 17:42:28",
|
||||
priceHistory: [592.81],
|
||||
"This Amazing Phone 3000 (Black) is made of black metal! It has a very well made aluminum body and it feels very comfortable. We loved the sound that comes out of it! Also, the design of the phone was a little loose at first because I was using the camera and felt uncomfortable wearing it. The phone is actually made slightly smaller than these photos! This is due to the addition of a 3.3mm filter",
|
||||
stock: 84,
|
||||
countryOfOrigin: "USA",
|
||||
firstAvailable: "2018-09-07 19:41:44",
|
||||
priceHistory: [238.68, 234.7, 221.49, 205.88, 220.15],
|
||||
customerRatings: [
|
||||
{ username: "dannyhowell", stars: 1, date: "2022-03-12 17:01:23", verifiedUser: true },
|
||||
{ username: "lindsay26", stars: 1, date: "2022-12-29 07:18:20", verifiedUser: false },
|
||||
{ username: "smithmiguel", stars: 3, date: "2022-09-08 11:43:27", verifiedUser: false },
|
||||
{ username: "julie07", stars: 3, date: "2021-03-14 23:54:10", verifiedUser: true },
|
||||
{ username: "kelly93", stars: 3, date: "2022-11-05 12:45:43", verifiedUser: false },
|
||||
{ username: "katherinereynolds", stars: 2, date: "2022-09-14 11:49:36", verifiedUser: false },
|
||||
{ username: "chandlerkenneth", stars: 1, date: "2022-01-14 12:14:43", verifiedUser: true },
|
||||
{
|
||||
username: "steven66",
|
||||
firstName: "Carol",
|
||||
gender: "female",
|
||||
lastName: "Shelton",
|
||||
age: "25-35",
|
||||
area: "suburban",
|
||||
address: "261 Collins Burgs Apt. 332\nNorth Taylor, NM 32268",
|
||||
stars: 5,
|
||||
date: "2021-04-22 13:42:14",
|
||||
verifiedUser: true,
|
||||
},
|
||||
{
|
||||
username: "khudson",
|
||||
firstName: "Ronald",
|
||||
gender: "male",
|
||||
lastName: "Webb",
|
||||
age: "18-24",
|
||||
area: "suburban",
|
||||
address: "9912 Parker Court Apt. 068\nNorth Austin, HI 76225",
|
||||
stars: 5,
|
||||
date: "2021-02-07 07:00:22",
|
||||
verifiedUser: false,
|
||||
},
|
||||
{
|
||||
username: "lfrancis",
|
||||
firstName: "Brady",
|
||||
gender: "male",
|
||||
lastName: "Wright",
|
||||
age: "35-45",
|
||||
area: "urban",
|
||||
address: "PSC 5437, Box 3159\nAPO AA 26385",
|
||||
stars: 2,
|
||||
date: "2022-02-23 21:40:10",
|
||||
verifiedUser: false,
|
||||
},
|
||||
{
|
||||
username: "nicolemartinez",
|
||||
firstName: "Megan",
|
||||
gender: "female",
|
||||
lastName: "Tran",
|
||||
age: "18-24",
|
||||
area: "rural",
|
||||
address: "7445 Salazar Brooks\nNew Sarah, PW 18097",
|
||||
stars: 4,
|
||||
date: "2021-09-01 22:21:40",
|
||||
verifiedUser: false,
|
||||
},
|
||||
{
|
||||
username: "uguzman",
|
||||
firstName: "Deanna",
|
||||
gender: "female",
|
||||
lastName: "Campbell",
|
||||
age: "18-24",
|
||||
area: "urban",
|
||||
address: "41104 Moreno Fort Suite 872\nPort Michaelbury, AK 48712",
|
||||
stars: 1,
|
||||
date: "2022-03-07 02:23:14",
|
||||
verifiedUser: false,
|
||||
},
|
||||
{
|
||||
username: "rebeccahunt",
|
||||
firstName: "Jared",
|
||||
gender: "male",
|
||||
lastName: "Lopez",
|
||||
age: "18-24",
|
||||
area: "rural",
|
||||
address: "392 Morgan Village Apt. 785\nGreenshire, CT 05921",
|
||||
stars: 5,
|
||||
date: "2021-04-17 04:17:49",
|
||||
verifiedUser: false,
|
||||
},
|
||||
],
|
||||
rareProperty: true,
|
||||
},
|
||||
@@ -494,6 +559,24 @@ export const QueryCopilotSampleContainerSchema = {
|
||||
username: {
|
||||
type: "string",
|
||||
},
|
||||
firstName: {
|
||||
type: "string",
|
||||
},
|
||||
gender: {
|
||||
type: "string",
|
||||
},
|
||||
lastName: {
|
||||
type: "string",
|
||||
},
|
||||
age: {
|
||||
type: "string",
|
||||
},
|
||||
area: {
|
||||
type: "string",
|
||||
},
|
||||
address: {
|
||||
type: "string",
|
||||
},
|
||||
stars: {
|
||||
type: "number",
|
||||
},
|
||||
|
||||
@@ -1291,7 +1291,7 @@ export default class Explorer {
|
||||
return;
|
||||
}
|
||||
|
||||
const sampleDataResourceTokenCollection = new ResourceTokenCollection(this, databaseId, collection);
|
||||
const sampleDataResourceTokenCollection = new ResourceTokenCollection(this, databaseId, collection, true);
|
||||
useDatabases.setState({ sampleDataResourceTokenCollection });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -1,11 +1,48 @@
|
||||
import { IconButton } from "@fluentui/react";
|
||||
import { shallow } from "enzyme";
|
||||
import React from "react";
|
||||
import { any } from "underscore";
|
||||
import { CopyPopup } from "./CopyPopup";
|
||||
|
||||
describe("Copy Popup snapshot test", () => {
|
||||
const setShowCopyPopupMock = jest.fn();
|
||||
it("should render when showCopyPopup is true", () => {
|
||||
const wrapper = shallow(<CopyPopup showCopyPopup={true} setShowCopyPopup={() => any} />);
|
||||
const wrapper = shallow(<CopyPopup showCopyPopup={true} setShowCopyPopup={setShowCopyPopupMock} />);
|
||||
expect(wrapper.exists()).toBe(true);
|
||||
expect(wrapper.prop("setShowCopyPopup")).toBeUndefined();
|
||||
expect(wrapper).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it("should render when showCopyPopup is false", () => {
|
||||
const wrapper = shallow(<CopyPopup showCopyPopup={false} setShowCopyPopup={setShowCopyPopupMock} />);
|
||||
expect(wrapper.prop("showCopyPopup")).toBeFalsy();
|
||||
expect(wrapper.prop("setShowCopyPopup")).toBeUndefined();
|
||||
expect(wrapper).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it("should call setShowCopyPopup(false) when close button is clicked", () => {
|
||||
const wrapper = shallow(<CopyPopup showCopyPopup={true} setShowCopyPopup={setShowCopyPopupMock} />);
|
||||
|
||||
const closeButton = wrapper.find(IconButton);
|
||||
closeButton.props().onClick?.({} as React.MouseEvent<HTMLButtonElement, MouseEvent>);
|
||||
|
||||
expect(setShowCopyPopupMock).toHaveBeenCalledWith(false);
|
||||
});
|
||||
|
||||
it("should have the correct inline styles", () => {
|
||||
const wrapper = shallow(<CopyPopup showCopyPopup={true} setShowCopyPopup={setShowCopyPopupMock} />);
|
||||
|
||||
const stackStyle = wrapper.find("Stack").first().props().style;
|
||||
|
||||
expect(stackStyle).toEqual({
|
||||
position: "fixed",
|
||||
width: 345,
|
||||
height: 66,
|
||||
padding: 10,
|
||||
gap: 5,
|
||||
top: 75,
|
||||
right: 20,
|
||||
background: "#FFFFFF",
|
||||
boxShadow: "0 2px 6px rgba(0, 0, 0, 0.16)",
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,19 +1,113 @@
|
||||
import { shallow } from "enzyme";
|
||||
import { mount, shallow } from "enzyme";
|
||||
import React from "react";
|
||||
import { any } from "underscore";
|
||||
import { DeletePopup } from "./DeletePopup";
|
||||
|
||||
describe("Delete Popup snapshot test", () => {
|
||||
const setShowDeletePopupMock = jest.fn();
|
||||
const setQueryMock = jest.fn();
|
||||
const clearFeedbackMock = jest.fn();
|
||||
const showFeedbackBarMock = jest.fn();
|
||||
|
||||
it("should render when showDeletePopup is true", () => {
|
||||
const wrapper = shallow(
|
||||
<DeletePopup
|
||||
showDeletePopup={true}
|
||||
setShowDeletePopup={() => any}
|
||||
setQuery={() => any}
|
||||
clearFeedback={() => any}
|
||||
showFeedbackBar={() => any}
|
||||
setShowDeletePopup={setShowDeletePopupMock}
|
||||
setQuery={setQueryMock}
|
||||
clearFeedback={clearFeedbackMock}
|
||||
showFeedbackBar={showFeedbackBarMock}
|
||||
/>
|
||||
);
|
||||
expect(wrapper.find("Modal").prop("isOpen")).toBeTruthy();
|
||||
expect(wrapper).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it("should not render when showDeletePopup is false", () => {
|
||||
const wrapper = shallow(
|
||||
<DeletePopup
|
||||
showDeletePopup={false}
|
||||
setShowDeletePopup={setShowDeletePopupMock}
|
||||
setQuery={setQueryMock}
|
||||
clearFeedback={clearFeedbackMock}
|
||||
showFeedbackBar={showFeedbackBarMock}
|
||||
/>
|
||||
);
|
||||
expect(wrapper.props().children.props.showDeletePopup).toBeFalsy();
|
||||
expect(wrapper).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it("should call setQuery with an empty string and setShowDeletePopup(false) when delete button is clicked", () => {
|
||||
const wrapper = mount(
|
||||
<DeletePopup
|
||||
showDeletePopup={true}
|
||||
setShowDeletePopup={setShowDeletePopupMock}
|
||||
setQuery={setQueryMock}
|
||||
clearFeedback={clearFeedbackMock}
|
||||
showFeedbackBar={showFeedbackBarMock}
|
||||
/>
|
||||
);
|
||||
|
||||
wrapper.find("PrimaryButton").simulate("click");
|
||||
|
||||
expect(setQueryMock).toHaveBeenCalledWith("");
|
||||
expect(setShowDeletePopupMock).toHaveBeenCalledWith(false);
|
||||
});
|
||||
|
||||
it("should call setShowDeletePopup(false) when close button is clicked", () => {
|
||||
const setShowDeletePopupMock = jest.fn();
|
||||
const wrapper = mount(
|
||||
<DeletePopup
|
||||
showDeletePopup={true}
|
||||
setShowDeletePopup={setShowDeletePopupMock}
|
||||
setQuery={setQueryMock}
|
||||
clearFeedback={clearFeedbackMock}
|
||||
showFeedbackBar={showFeedbackBarMock}
|
||||
/>
|
||||
);
|
||||
|
||||
wrapper.find("DefaultButton").at(1).simulate("click");
|
||||
|
||||
expect(setShowDeletePopupMock).toHaveBeenCalledWith(false);
|
||||
});
|
||||
|
||||
it("should render the appropriate text content", () => {
|
||||
const wrapper = shallow(
|
||||
<DeletePopup
|
||||
showDeletePopup={true}
|
||||
setShowDeletePopup={setShowDeletePopupMock}
|
||||
setQuery={setQueryMock}
|
||||
clearFeedback={clearFeedbackMock}
|
||||
showFeedbackBar={showFeedbackBarMock}
|
||||
/>
|
||||
);
|
||||
|
||||
const textContent = wrapper
|
||||
.find("Text")
|
||||
.map((text, index) => <React.Fragment key={index}>{text.props().children}</React.Fragment>);
|
||||
|
||||
expect(textContent).toEqual([
|
||||
<React.Fragment key={0}>
|
||||
<b>Delete code?</b>
|
||||
</React.Fragment>,
|
||||
<React.Fragment key={1}>
|
||||
This will clear the query from the query builder pane along with all comments and also reset the prompt pane
|
||||
</React.Fragment>,
|
||||
]);
|
||||
});
|
||||
|
||||
it("should have the correct inline style", () => {
|
||||
const wrapper = shallow(
|
||||
<DeletePopup
|
||||
showDeletePopup={true}
|
||||
setShowDeletePopup={setShowDeletePopupMock}
|
||||
setQuery={setQueryMock}
|
||||
clearFeedback={clearFeedbackMock}
|
||||
showFeedbackBar={showFeedbackBarMock}
|
||||
/>
|
||||
);
|
||||
|
||||
const stackStyle = wrapper.find("Stack[style]").props().style;
|
||||
|
||||
expect(stackStyle).toEqual({ padding: "16px 24px", height: "auto" });
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`Copy Popup snapshot test should render when showCopyPopup is false 1`] = `<Fragment />`;
|
||||
|
||||
exports[`Copy Popup snapshot test should render when showCopyPopup is true 1`] = `
|
||||
<Stack
|
||||
style={
|
||||
|
||||
@@ -1,5 +1,83 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`Delete Popup snapshot test should not render when showDeletePopup is false 1`] = `
|
||||
<Modal
|
||||
isOpen={false}
|
||||
styles={
|
||||
Object {
|
||||
"main": Object {
|
||||
"minHeight": "122px",
|
||||
"minWidth": "880px",
|
||||
},
|
||||
}
|
||||
}
|
||||
>
|
||||
<Stack
|
||||
style={
|
||||
Object {
|
||||
"height": "auto",
|
||||
"padding": "16px 24px",
|
||||
}
|
||||
}
|
||||
>
|
||||
<Text
|
||||
style={
|
||||
Object {
|
||||
"fontSize": "18px",
|
||||
"height": 24,
|
||||
}
|
||||
}
|
||||
>
|
||||
<b>
|
||||
Delete code?
|
||||
</b>
|
||||
</Text>
|
||||
<Text
|
||||
style={
|
||||
Object {
|
||||
"marginBottom": 20,
|
||||
"marginTop": 10,
|
||||
}
|
||||
}
|
||||
>
|
||||
This will clear the query from the query builder pane along with all comments and also reset the prompt pane
|
||||
</Text>
|
||||
<Stack
|
||||
horizontal={true}
|
||||
horizontalAlign="start"
|
||||
tokens={
|
||||
Object {
|
||||
"childrenGap": 10,
|
||||
}
|
||||
}
|
||||
>
|
||||
<CustomizedPrimaryButton
|
||||
onClick={[Function]}
|
||||
style={
|
||||
Object {
|
||||
"height": 24,
|
||||
"padding": "0px 20px",
|
||||
}
|
||||
}
|
||||
>
|
||||
Delete
|
||||
</CustomizedPrimaryButton>
|
||||
<CustomizedDefaultButton
|
||||
onClick={[Function]}
|
||||
style={
|
||||
Object {
|
||||
"height": 24,
|
||||
"padding": "0px 20px",
|
||||
}
|
||||
}
|
||||
>
|
||||
Close
|
||||
</CustomizedDefaultButton>
|
||||
</Stack>
|
||||
</Stack>
|
||||
</Modal>
|
||||
`;
|
||||
|
||||
exports[`Delete Popup snapshot test should render when showDeletePopup is true 1`] = `
|
||||
<Modal
|
||||
isOpen={true}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -1,26 +1,91 @@
|
||||
import { DefaultButton, IconButton } from "@fluentui/react";
|
||||
import { shallow } from "enzyme";
|
||||
import React from "react";
|
||||
import { SamplePrompts, SamplePromptsProps } from "./SamplePrompts";
|
||||
|
||||
describe("Sample Prompts snapshot test", () => {
|
||||
it("should render properly if isSamplePromptsOpen is true", () => {
|
||||
const sampleProps: SamplePromptsProps = {
|
||||
isSamplePromptsOpen: true,
|
||||
setIsSamplePromptsOpen: () => undefined,
|
||||
setTextBox: () => undefined,
|
||||
};
|
||||
const setTextBoxMock = jest.fn();
|
||||
const setIsSamplePromptsOpenMock = jest.fn();
|
||||
const sampleProps: SamplePromptsProps = {
|
||||
isSamplePromptsOpen: true,
|
||||
setIsSamplePromptsOpen: setIsSamplePromptsOpenMock,
|
||||
setTextBox: setTextBoxMock,
|
||||
};
|
||||
beforeEach(() => jest.clearAllMocks());
|
||||
|
||||
it("should render properly if isSamplePromptsOpen is true", () => {
|
||||
const wrapper = shallow(<SamplePrompts sampleProps={sampleProps} />);
|
||||
|
||||
expect(wrapper).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it("should render properly if isSamplePromptsOpen is false", () => {
|
||||
const sampleProps: SamplePromptsProps = {
|
||||
isSamplePromptsOpen: false,
|
||||
setIsSamplePromptsOpen: () => undefined,
|
||||
setTextBox: () => undefined,
|
||||
};
|
||||
sampleProps.isSamplePromptsOpen = false;
|
||||
|
||||
const wrapper = shallow(<SamplePrompts sampleProps={sampleProps} />);
|
||||
|
||||
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);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -28,8 +28,9 @@ export default class ResourceTokenCollection implements ViewModels.CollectionBas
|
||||
public children: ko.ObservableArray<ViewModels.TreeNode>;
|
||||
public selectedSubnodeKind: ko.Observable<ViewModels.CollectionTabKind>;
|
||||
public isCollectionExpanded: ko.Observable<boolean>;
|
||||
public isSampleCollection?: boolean;
|
||||
|
||||
constructor(container: Explorer, databaseId: string, data: DataModels.Collection) {
|
||||
constructor(container: Explorer, databaseId: string, data: DataModels.Collection, isSampleCollection?: boolean) {
|
||||
this.nodeKind = "Collection";
|
||||
this.container = container;
|
||||
this.databaseId = databaseId;
|
||||
@@ -42,6 +43,7 @@ export default class ResourceTokenCollection implements ViewModels.CollectionBas
|
||||
this.children = ko.observableArray<ViewModels.TreeNode>([]);
|
||||
this.selectedSubnodeKind = ko.observable<ViewModels.CollectionTabKind>();
|
||||
this.isCollectionExpanded = ko.observable<boolean>(true);
|
||||
this.isSampleCollection = isSampleCollection;
|
||||
}
|
||||
|
||||
public expandCollection(): void {
|
||||
|
||||
@@ -66,11 +66,12 @@ export const useSelectedNode: UseStore<SelectedNodeState> = create((set, get) =>
|
||||
return useNotebook.getState().connectionInfo?.status === ConnectionStatusType.Connected;
|
||||
},
|
||||
isQueryCopilotCollectionSelected: (): boolean => {
|
||||
const selectedNode = get().selectedNode;
|
||||
const selectedNode = get().selectedNode as ViewModels.CollectionBase;
|
||||
if (
|
||||
selectedNode &&
|
||||
selectedNode.isSampleCollection &&
|
||||
selectedNode.id() === QueryCopilotSampleContainerId &&
|
||||
(selectedNode as ViewModels.Collection)?.databaseId === QueryCopilotSampleDatabaseId
|
||||
selectedNode.databaseId === QueryCopilotSampleDatabaseId
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -163,4 +163,4 @@
|
||||
"src/Terminal/**/*",
|
||||
"src/Utils/arm/**/*"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user