@terreno/ui 57.2.0 → 57.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.ai/guidelines/core.md +1 -1
- package/README.md +17 -8
- package/dist/ActionSheet.d.ts +3 -3
- package/dist/ActionSheet.js +2 -2
- package/dist/ActionSheet.js.map +1 -1
- package/dist/Box.d.ts +1 -1
- package/dist/Box.js +219 -177
- package/dist/Box.js.map +1 -1
- package/dist/Button.js +101 -34
- package/dist/Button.js.map +1 -1
- package/dist/Common.d.ts +119 -9
- package/dist/Common.js.map +1 -1
- package/dist/ConsentFormScreen.js +46 -12
- package/dist/ConsentFormScreen.js.map +1 -1
- package/dist/ConsentNavigator.d.ts +5 -1
- package/dist/ConsentNavigator.js.map +1 -1
- package/dist/DataTable.d.ts +2 -2
- package/dist/DataTable.js +203 -44
- package/dist/DataTable.js.map +1 -1
- package/dist/DataTableHeaderInfoMarkdown.d.ts +6 -0
- package/dist/DataTableHeaderInfoMarkdown.js +7 -0
- package/dist/DataTableHeaderInfoMarkdown.js.map +1 -0
- package/dist/EmojiSelector.d.ts +2 -46
- package/dist/EmojiSelector.js +46 -56
- package/dist/EmojiSelector.js.map +1 -1
- package/dist/GPTChat.js +1 -1
- package/dist/GPTChat.js.map +1 -1
- package/dist/Heading.d.ts +5 -2
- package/dist/Heading.js +6 -8
- package/dist/Heading.js.map +1 -1
- package/dist/Hyperlink.js.map +1 -1
- package/dist/Icon.d.ts +1 -2
- package/dist/Icon.js +4 -1
- package/dist/Icon.js.map +1 -1
- package/dist/MarkdownView.d.ts +6 -3
- package/dist/MarkdownView.js +45 -43
- package/dist/MarkdownView.js.map +1 -1
- package/dist/MediaQuery.d.ts +5 -3
- package/dist/MediaQuery.js +9 -40
- package/dist/MediaQuery.js.map +1 -1
- package/dist/OpenAPIContext.js +7 -6
- package/dist/OpenAPIContext.js.map +1 -1
- package/dist/Page.js +7 -1
- package/dist/Page.js.map +1 -1
- package/dist/PickerSelect.js +8 -1
- package/dist/PickerSelect.js.map +1 -1
- package/dist/Popover.d.ts +12 -0
- package/dist/Popover.js +37 -0
- package/dist/Popover.js.map +1 -0
- package/dist/PortalHost.js +10 -1
- package/dist/PortalHost.js.map +1 -1
- package/dist/ResponsiveBreakpoint.d.ts +65 -0
- package/dist/ResponsiveBreakpoint.js +111 -0
- package/dist/ResponsiveBreakpoint.js.map +1 -0
- package/dist/SplitPage.d.ts +2 -2
- package/dist/SplitPage.js +7 -12
- package/dist/SplitPage.js.map +1 -1
- package/dist/SplitPage.native.d.ts +2 -2
- package/dist/SplitPage.native.js +1 -6
- package/dist/SplitPage.native.js.map +1 -1
- package/dist/TapToEdit.js +12 -10
- package/dist/TapToEdit.js.map +1 -1
- package/dist/TerrenoFontProvider.d.ts +7 -0
- package/dist/TerrenoFontProvider.js +27 -0
- package/dist/TerrenoFontProvider.js.map +1 -0
- package/dist/TerrenoProvider.js +4 -2
- package/dist/TerrenoProvider.js.map +1 -1
- package/dist/Text.d.ts +5 -2
- package/dist/Text.js +6 -11
- package/dist/Text.js.map +1 -1
- package/dist/TextFieldNumberActionSheet.js +9 -2
- package/dist/TextFieldNumberActionSheet.js.map +1 -1
- package/dist/Theme.js +10 -8
- package/dist/Theme.js.map +1 -1
- package/dist/ToastNotifications.d.ts +4 -2
- package/dist/ToastNotifications.js.map +1 -1
- package/dist/Tooltip.d.ts +4 -3
- package/dist/Tooltip.js +14 -3
- package/dist/Tooltip.js.map +1 -1
- package/dist/Unifier.d.ts +26 -1
- package/dist/Unifier.js.map +1 -1
- package/dist/WebAddressAutocomplete.js +6 -1
- package/dist/WebAddressAutocomplete.js.map +1 -1
- package/dist/emojiCategories.d.ts +46 -0
- package/dist/emojiCategories.js +47 -0
- package/dist/emojiCategories.js.map +1 -0
- package/dist/index.d.ts +13 -13
- package/dist/index.js +2 -13
- package/dist/index.js.map +1 -1
- package/dist/lazyBoundaries/createLazyComponentExport.d.ts +6 -0
- package/dist/lazyBoundaries/createLazyComponentExport.js +35 -0
- package/dist/lazyBoundaries/createLazyComponentExport.js.map +1 -0
- package/dist/lazyBoundaries/heavyOptionalExports.d.ts +41 -0
- package/dist/lazyBoundaries/heavyOptionalExports.js +43 -0
- package/dist/lazyBoundaries/heavyOptionalExports.js.map +1 -0
- package/dist/login/LoginScreen.d.ts +1 -0
- package/dist/login/LoginScreen.js +4 -2
- package/dist/login/LoginScreen.js.map +1 -1
- package/dist/login/loginTypes.d.ts +2 -0
- package/package.json +40 -1
- package/src/AIRequestExplorer.test.tsx +141 -0
- package/src/ActionSheet.tsx +9 -7
- package/src/AttachmentPreview.test.tsx +80 -0
- package/src/Box.test.tsx +97 -10
- package/src/Box.tsx +263 -200
- package/src/Button.test.tsx +207 -0
- package/src/Button.tsx +146 -48
- package/src/Common.ts +124 -25
- package/src/ConsentFormScreen.markdownGate.test.tsx +129 -0
- package/src/ConsentFormScreen.test.tsx +145 -8
- package/src/ConsentFormScreen.tsx +74 -25
- package/src/ConsentNavigator.tsx +13 -5
- package/src/DataTable.tsx +418 -147
- package/src/DataTableHeaderInfoMarkdown.test.tsx +21 -0
- package/src/DataTableHeaderInfoMarkdown.tsx +17 -0
- package/src/DataTableVirtualizationRegression.test.tsx +266 -0
- package/src/DateTimeField.test.tsx +54 -0
- package/src/EmojiSelector.test.tsx +33 -42
- package/src/EmojiSelector.tsx +60 -57
- package/src/FilePickerButton.test.tsx +167 -0
- package/src/FilterAccordion.test.tsx +37 -0
- package/src/FilterBoolean.test.tsx +96 -0
- package/src/FilterSelectMenu.test.tsx +23 -0
- package/src/GPTChat.test.tsx +696 -0
- package/src/GPTChat.tsx +2 -2
- package/src/GPTMemoryModal.test.tsx +67 -0
- package/src/Heading.tsx +8 -14
- package/src/HeightActionSheet.test.tsx +6 -9
- package/src/Hyperlink.tsx +5 -18
- package/src/Icon.tsx +6 -2
- package/src/MarkdownEditor.test.tsx +134 -0
- package/src/MarkdownEditorField.test.tsx +124 -0
- package/src/MarkdownView.test.tsx +55 -11
- package/src/MarkdownView.tsx +149 -150
- package/src/MediaQuery.ts +30 -34
- package/src/OpenAPIContext.tsx +36 -29
- package/src/OpenAPIRenderRegression.test.tsx +200 -0
- package/src/P0RenderRegression.test.tsx +214 -0
- package/src/P1RenderRegression.test.tsx +141 -0
- package/src/P2ButtonRenderRegression.test.tsx +158 -0
- package/src/Page.test.tsx +13 -0
- package/src/Page.tsx +25 -5
- package/src/PickerSelect.test.tsx +38 -0
- package/src/PickerSelect.tsx +7 -0
- package/src/Popover.test.tsx +151 -0
- package/src/Popover.tsx +211 -0
- package/src/PortalHost.tsx +12 -6
- package/src/ResponsiveBreakpoint.test.tsx +184 -0
- package/src/ResponsiveBreakpoint.tsx +195 -0
- package/src/RootImportRegression.test.tsx +62 -0
- package/src/SplitPage.native.tsx +5 -9
- package/src/SplitPage.tsx +16 -19
- package/src/TapToEdit.test.tsx +45 -0
- package/src/TapToEdit.tsx +23 -18
- package/src/TerrenoFontProvider.test.tsx +38 -0
- package/src/TerrenoFontProvider.tsx +50 -0
- package/src/TerrenoProvider.tsx +6 -1
- package/src/Text.tsx +8 -21
- package/src/TextFieldNumberActionSheet.test.tsx +100 -0
- package/src/TextFieldNumberActionSheet.tsx +11 -2
- package/src/Theme.test.tsx +27 -0
- package/src/Theme.tsx +15 -10
- package/src/Toast.tsx +1 -1
- package/src/ToastNotifications.tsx +4 -4
- package/src/Tooltip.test.tsx +64 -0
- package/src/Tooltip.tsx +18 -4
- package/src/Unifier.ts +26 -3
- package/src/WebAddressAutocomplete.tsx +6 -2
- package/src/__snapshots__/ActionSheet.test.tsx.snap +0 -36
- package/src/__snapshots__/AddressField.test.tsx.snap +1 -0
- package/src/__snapshots__/AttachmentPreview.test.tsx.snap +225 -0
- package/src/__snapshots__/CustomSelectField.test.tsx.snap +7 -0
- package/src/__snapshots__/DataTable.test.tsx.snap +793 -250
- package/src/__snapshots__/DecimalRangeActionSheet.test.tsx.snap +0 -8
- package/src/__snapshots__/EmojiSelector.test.tsx.snap +35555 -30
- package/src/__snapshots__/Field.test.tsx.snap +7 -0
- package/src/__snapshots__/FilterSelectMenu.test.tsx.snap +1 -0
- package/src/__snapshots__/HeightActionSheet.test.tsx.snap +0 -8
- package/src/__snapshots__/HeightField.test.tsx.snap +0 -20
- package/src/__snapshots__/NumberPickerActionSheet.test.tsx.snap +0 -8
- package/src/__snapshots__/Page.test.tsx.snap +13 -1
- package/src/__snapshots__/PickerSelect.test.tsx.snap +7 -0
- package/src/__snapshots__/SelectField.test.tsx.snap +6 -0
- package/src/__snapshots__/TimezonePicker.test.tsx.snap +6 -0
- package/src/benchmarks/importGraph.test.ts +71 -0
- package/src/benchmarks/importGraph.ts +136 -0
- package/src/benchmarks/importTiming.test.ts +42 -0
- package/src/benchmarks/importTiming.ts +86 -0
- package/src/bunSetup.ts +174 -32
- package/src/emojiCategories.test.ts +23 -0
- package/src/emojiCategories.ts +46 -0
- package/src/index.tsx +27 -13
- package/src/lazyBoundaries/createLazyComponentExport.test.tsx +104 -0
- package/src/lazyBoundaries/createLazyComponentExport.tsx +63 -0
- package/src/lazyBoundaries/heavyOptionalExports.test.tsx +33 -0
- package/src/lazyBoundaries/heavyOptionalExports.tsx +106 -0
- package/src/login/LoginScreen.test.tsx +9 -2
- package/src/login/LoginScreen.tsx +6 -2
- package/src/login/loginTypes.ts +2 -0
- package/src/table/TableDate.test.tsx +35 -1
- package/src/table/__snapshots__/TableBadge.test.tsx.snap +1 -0
|
@@ -0,0 +1,696 @@
|
|
|
1
|
+
import {afterAll, afterEach, describe, it, mock} from "bun:test";
|
|
2
|
+
import {act, fireEvent, render, waitFor} from "@testing-library/react-native";
|
|
3
|
+
import {assert} from "chai";
|
|
4
|
+
import React from "react";
|
|
5
|
+
import {Platform, Pressable, ScrollView} from "react-native";
|
|
6
|
+
|
|
7
|
+
import type {SelectedFile} from "./FilePickerButton";
|
|
8
|
+
import type {GPTChatHistory, GPTChatMessage, GPTChatProps, MessageContentPart} from "./GPTChat";
|
|
9
|
+
import {GPTChat} from "./GPTChat";
|
|
10
|
+
import {ThemeProvider} from "./Theme";
|
|
11
|
+
import {renderWithTheme} from "./test-utils";
|
|
12
|
+
|
|
13
|
+
const setStringAsync = mock(async (_text: string) => {});
|
|
14
|
+
mock.module("expo-clipboard", () => ({setStringAsync}));
|
|
15
|
+
|
|
16
|
+
const pickedDocument = {mimeType: "text/plain", name: "notes.txt", uri: "file:///notes.txt"};
|
|
17
|
+
mock.module("expo-document-picker", () => ({
|
|
18
|
+
getDocumentAsync: mock(async () => ({assets: [pickedDocument], canceled: false})),
|
|
19
|
+
}));
|
|
20
|
+
|
|
21
|
+
// bunSetup.ts mocks IconButton to render null; GPTChat's controls are icon buttons, so replace it
|
|
22
|
+
// with a pressable stub that keeps the accessibility label and testID.
|
|
23
|
+
mock.module("./IconButton", () => ({
|
|
24
|
+
IconButton: ({
|
|
25
|
+
accessibilityLabel,
|
|
26
|
+
disabled,
|
|
27
|
+
onClick,
|
|
28
|
+
testID,
|
|
29
|
+
}: {
|
|
30
|
+
accessibilityLabel?: string;
|
|
31
|
+
disabled?: boolean;
|
|
32
|
+
onClick?: () => void;
|
|
33
|
+
testID?: string;
|
|
34
|
+
}) => React.createElement(Pressable, {accessibilityLabel, disabled, onPress: onClick, testID}),
|
|
35
|
+
}));
|
|
36
|
+
|
|
37
|
+
// Module mocks are global, so restore the bunSetup stub for test files that run after this one.
|
|
38
|
+
afterAll(() => {
|
|
39
|
+
mock.module("./IconButton", () => ({IconButton: mock(() => null)}));
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
// Box and IconButton presses run through an async haptic call, so state updates land in a
|
|
43
|
+
// microtask after the event.
|
|
44
|
+
const press = async (element: Parameters<typeof fireEvent.press>[0]): Promise<void> => {
|
|
45
|
+
await act(async () => {
|
|
46
|
+
fireEvent.press(element);
|
|
47
|
+
});
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
const histories: GPTChatHistory[] = [
|
|
51
|
+
{id: "h1", prompts: [], title: "First chat"},
|
|
52
|
+
{id: "h2", prompts: []},
|
|
53
|
+
];
|
|
54
|
+
|
|
55
|
+
const renderChat = (overrides: Partial<GPTChatProps> = {}): ReturnType<typeof renderWithTheme> => {
|
|
56
|
+
return renderWithTheme(
|
|
57
|
+
<GPTChat
|
|
58
|
+
currentMessages={[]}
|
|
59
|
+
histories={histories}
|
|
60
|
+
onCreateHistory={() => {}}
|
|
61
|
+
onDeleteHistory={() => {}}
|
|
62
|
+
onSelectHistory={() => {}}
|
|
63
|
+
onSubmit={() => {}}
|
|
64
|
+
testID="gpt-chat"
|
|
65
|
+
{...overrides}
|
|
66
|
+
/>
|
|
67
|
+
);
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
describe("GPTChat", () => {
|
|
71
|
+
it("renders the sidebar with chat histories", () => {
|
|
72
|
+
const {getByTestId, getByText} = renderChat();
|
|
73
|
+
|
|
74
|
+
assert.isOk(getByTestId("gpt-chat"));
|
|
75
|
+
assert.isOk(getByText("Chats"));
|
|
76
|
+
assert.isOk(getByText("First chat"));
|
|
77
|
+
assert.isOk(getByText("New Chat"));
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
it("selects, creates, and deletes histories", async () => {
|
|
81
|
+
const onSelectHistory = mock((_id: string) => {});
|
|
82
|
+
const onCreateHistory = mock(() => {});
|
|
83
|
+
const onDeleteHistory = mock((_id: string) => {});
|
|
84
|
+
const {getByLabelText, getByTestId} = renderChat({
|
|
85
|
+
currentHistoryId: "h1",
|
|
86
|
+
onCreateHistory,
|
|
87
|
+
onDeleteHistory,
|
|
88
|
+
onSelectHistory,
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
await press(getByLabelText("Select chat: First chat"));
|
|
92
|
+
await press(getByTestId("gpt-new-chat-button"));
|
|
93
|
+
await press(getByTestId("gpt-delete-history-h2"));
|
|
94
|
+
|
|
95
|
+
assert.deepEqual(onSelectHistory.mock.calls, [["h1"]]);
|
|
96
|
+
assert.equal(onCreateHistory.mock.calls.length, 1);
|
|
97
|
+
assert.deepEqual(onDeleteHistory.mock.calls, [["h2"]]);
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
it("renames a history and saves the new title once", async () => {
|
|
101
|
+
const onUpdateTitle = mock((_id: string, _title: string) => {});
|
|
102
|
+
const {getByTestId} = renderChat({onUpdateTitle});
|
|
103
|
+
|
|
104
|
+
await press(getByTestId("gpt-rename-history-h1"));
|
|
105
|
+
fireEvent.changeText(getByTestId("gpt-rename-input-h1"), "Renamed");
|
|
106
|
+
await press(getByTestId("gpt-rename-save-h1"));
|
|
107
|
+
|
|
108
|
+
assert.deepEqual(onUpdateTitle.mock.calls, [["h1", "Renamed"]]);
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
it("ignores a rename with a blank title and skips duplicate saves", async () => {
|
|
112
|
+
const onUpdateTitle = mock((_id: string, _title: string) => {});
|
|
113
|
+
const {getByTestId} = renderChat({onUpdateTitle});
|
|
114
|
+
|
|
115
|
+
await press(getByTestId("gpt-rename-history-h2"));
|
|
116
|
+
fireEvent.changeText(getByTestId("gpt-rename-input-h2"), " ");
|
|
117
|
+
fireEvent(getByTestId("gpt-rename-input-h2"), "blur");
|
|
118
|
+
|
|
119
|
+
assert.equal(onUpdateTitle.mock.calls.length, 0);
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
it("hides the rename button when renaming is not supported", () => {
|
|
123
|
+
const {queryByTestId} = renderChat();
|
|
124
|
+
|
|
125
|
+
assert.isNull(queryByTestId("gpt-rename-history-h1"));
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
it("renders a model selector only when models and a change handler are given", () => {
|
|
129
|
+
const onModelChange = mock((_id: string) => {});
|
|
130
|
+
const {getAllByText} = renderChat({
|
|
131
|
+
availableModels: [
|
|
132
|
+
{label: "Flash", value: "flash"},
|
|
133
|
+
{label: "Pro", value: "pro"},
|
|
134
|
+
],
|
|
135
|
+
onModelChange,
|
|
136
|
+
selectedModel: "pro",
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
assert.isNotEmpty(getAllByText("Pro"));
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
it("omits the model selector when there is no change handler", () => {
|
|
143
|
+
const {queryByText} = renderChat({
|
|
144
|
+
availableModels: [{label: "Flash", value: "flash"}],
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
assert.isNull(queryByText("Flash"));
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
it("hides the optional sidebar buttons when their handlers are missing", () => {
|
|
151
|
+
const {queryByTestId} = renderChat({mcpServers: []});
|
|
152
|
+
|
|
153
|
+
assert.isNull(queryByTestId("gpt-api-key-button"));
|
|
154
|
+
assert.isNull(queryByTestId("gpt-memory-button"));
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
it("edits the Gemini API key through the modal", async () => {
|
|
158
|
+
const onGeminiApiKeyChange = mock((_key: string) => {});
|
|
159
|
+
const {getByTestId, getByText} = renderChat({geminiApiKey: "old-key", onGeminiApiKeyChange});
|
|
160
|
+
|
|
161
|
+
await press(getByTestId("gpt-api-key-button"));
|
|
162
|
+
fireEvent.changeText(getByTestId("gpt-api-key-input"), "new-key");
|
|
163
|
+
await press(getByText("Save"));
|
|
164
|
+
|
|
165
|
+
assert.deepEqual(onGeminiApiKeyChange.mock.calls, [["new-key"]]);
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
it("dismisses the API key modal without saving", async () => {
|
|
169
|
+
const onGeminiApiKeyChange = mock((_key: string) => {});
|
|
170
|
+
const {getByTestId, getByText} = renderChat({onGeminiApiKeyChange});
|
|
171
|
+
|
|
172
|
+
await press(getByTestId("gpt-api-key-button"));
|
|
173
|
+
await press(getByText("Cancel"));
|
|
174
|
+
|
|
175
|
+
assert.equal(onGeminiApiKeyChange.mock.calls.length, 0);
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
it("opens the system memory editor with the current memory", async () => {
|
|
179
|
+
const onMemoryEdit = mock((_memory: string) => {});
|
|
180
|
+
const {getByTestId} = renderChat({onMemoryEdit, systemMemory: "remember this"});
|
|
181
|
+
|
|
182
|
+
await press(getByTestId("gpt-memory-button"));
|
|
183
|
+
|
|
184
|
+
assert.deepEqual(onMemoryEdit.mock.calls, [["remember this"]]);
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
it("opens the system memory editor with an empty memory by default", async () => {
|
|
188
|
+
const onMemoryEdit = mock((_memory: string) => {});
|
|
189
|
+
const {getByTestId} = renderChat({onMemoryEdit});
|
|
190
|
+
|
|
191
|
+
await press(getByTestId("gpt-memory-button"));
|
|
192
|
+
|
|
193
|
+
assert.deepEqual(onMemoryEdit.mock.calls, [[""]]);
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
it("toggles the MCP server list", async () => {
|
|
197
|
+
const {getByLabelText, getByText, queryByText} = renderChat({
|
|
198
|
+
mcpServers: [
|
|
199
|
+
{connected: true, name: "files"},
|
|
200
|
+
{connected: false, name: "search"},
|
|
201
|
+
],
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
assert.isOk(getByText("1/2 MCP"));
|
|
205
|
+
assert.isNull(queryByText("files"));
|
|
206
|
+
|
|
207
|
+
await press(getByLabelText("MCP server status"));
|
|
208
|
+
assert.isOk(getByText("files"));
|
|
209
|
+
assert.isOk(getByText("search"));
|
|
210
|
+
|
|
211
|
+
await press(getByLabelText("MCP server status"));
|
|
212
|
+
assert.isNull(queryByText("files"));
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
it("renders a disconnected MCP indicator when no server is connected", () => {
|
|
216
|
+
const {getByText} = renderChat({mcpServers: [{connected: false, name: "files"}]});
|
|
217
|
+
|
|
218
|
+
assert.isOk(getByText("0/1 MCP"));
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
it("lists the available MCP tools in a modal", async () => {
|
|
222
|
+
const {getByTestId, getByText} = renderChat({
|
|
223
|
+
mcpTools: [{description: "Reads files", name: "readFile"}, {name: "writeFile"}],
|
|
224
|
+
});
|
|
225
|
+
|
|
226
|
+
await press(getByTestId("gpt-tools-button"));
|
|
227
|
+
|
|
228
|
+
assert.isOk(getByText("readFile"));
|
|
229
|
+
assert.isOk(getByText("Reads files"));
|
|
230
|
+
assert.isOk(getByText("writeFile"));
|
|
231
|
+
});
|
|
232
|
+
|
|
233
|
+
it("hides the tools button when there are no tools", () => {
|
|
234
|
+
const {queryByTestId} = renderChat({mcpTools: []});
|
|
235
|
+
|
|
236
|
+
assert.isNull(queryByTestId("gpt-tools-button"));
|
|
237
|
+
});
|
|
238
|
+
|
|
239
|
+
it("renders suggested prompts and submits the tapped prompt", async () => {
|
|
240
|
+
const onSubmit = mock((_prompt: string) => {});
|
|
241
|
+
const {getByLabelText, getByText} = renderChat({
|
|
242
|
+
onSubmit,
|
|
243
|
+
suggestedPrompts: ["Summarize this"],
|
|
244
|
+
});
|
|
245
|
+
|
|
246
|
+
assert.isOk(getByText("Try asking..."));
|
|
247
|
+
await press(getByLabelText("Summarize this"));
|
|
248
|
+
|
|
249
|
+
assert.deepEqual(onSubmit.mock.calls, [["Summarize this"]]);
|
|
250
|
+
});
|
|
251
|
+
|
|
252
|
+
it("ignores suggested prompts while streaming", async () => {
|
|
253
|
+
const onSubmit = mock((_prompt: string) => {});
|
|
254
|
+
const {getByLabelText} = renderChat({
|
|
255
|
+
isStreaming: true,
|
|
256
|
+
onSubmit,
|
|
257
|
+
suggestedPrompts: ["Summarize this"],
|
|
258
|
+
});
|
|
259
|
+
|
|
260
|
+
await press(getByLabelText("Summarize this"));
|
|
261
|
+
|
|
262
|
+
assert.equal(onSubmit.mock.calls.length, 0);
|
|
263
|
+
});
|
|
264
|
+
|
|
265
|
+
it("submits typed input and clears the field", async () => {
|
|
266
|
+
const onSubmit = mock((_prompt: string) => {});
|
|
267
|
+
const {getByTestId} = renderChat({onSubmit});
|
|
268
|
+
|
|
269
|
+
fireEvent.changeText(getByTestId("gpt-input"), " Hello ");
|
|
270
|
+
await press(getByTestId("gpt-submit"));
|
|
271
|
+
|
|
272
|
+
assert.deepEqual(onSubmit.mock.calls, [["Hello"]]);
|
|
273
|
+
assert.equal(getByTestId("gpt-input").props.value, "");
|
|
274
|
+
});
|
|
275
|
+
|
|
276
|
+
it("does not submit blank input", async () => {
|
|
277
|
+
const onSubmit = mock((_prompt: string) => {});
|
|
278
|
+
const {getByTestId} = renderChat({onSubmit});
|
|
279
|
+
|
|
280
|
+
fireEvent.changeText(getByTestId("gpt-input"), " ");
|
|
281
|
+
await press(getByTestId("gpt-submit"));
|
|
282
|
+
|
|
283
|
+
assert.equal(onSubmit.mock.calls.length, 0);
|
|
284
|
+
});
|
|
285
|
+
|
|
286
|
+
it("does not submit while streaming", async () => {
|
|
287
|
+
const onSubmit = mock((_prompt: string) => {});
|
|
288
|
+
const {getByTestId} = renderChat({isStreaming: true, onSubmit});
|
|
289
|
+
|
|
290
|
+
fireEvent.changeText(getByTestId("gpt-input"), "Hello");
|
|
291
|
+
await press(getByTestId("gpt-submit"));
|
|
292
|
+
|
|
293
|
+
assert.equal(onSubmit.mock.calls.length, 0);
|
|
294
|
+
});
|
|
295
|
+
|
|
296
|
+
it("renders user and assistant messages", async () => {
|
|
297
|
+
const messages: GPTChatMessage[] = [
|
|
298
|
+
{content: "Hi there", role: "user"},
|
|
299
|
+
{content: "Hello!", role: "assistant"},
|
|
300
|
+
];
|
|
301
|
+
const {getByText, toJSON} = renderChat({currentMessages: messages});
|
|
302
|
+
|
|
303
|
+
assert.isOk(getByText("Hi there"));
|
|
304
|
+
// The assistant message renders through the lazily loaded markdown view.
|
|
305
|
+
await waitFor(() => {
|
|
306
|
+
assert.include(JSON.stringify(toJSON()), "Hello!");
|
|
307
|
+
});
|
|
308
|
+
});
|
|
309
|
+
|
|
310
|
+
it("expands tool call details", async () => {
|
|
311
|
+
const messages: GPTChatMessage[] = [
|
|
312
|
+
{
|
|
313
|
+
content: "",
|
|
314
|
+
role: "tool-call",
|
|
315
|
+
toolCall: {args: {path: "README.md"}, toolCallId: "1", toolName: "readFile"},
|
|
316
|
+
},
|
|
317
|
+
];
|
|
318
|
+
const {getByLabelText, getByText, queryByText} = renderChat({currentMessages: messages});
|
|
319
|
+
|
|
320
|
+
assert.isNull(queryByText(/README.md/));
|
|
321
|
+
await press(getByLabelText("Tool: readFile"));
|
|
322
|
+
assert.isOk(getByText(/README.md/));
|
|
323
|
+
});
|
|
324
|
+
|
|
325
|
+
it("expands string and object tool results", async () => {
|
|
326
|
+
const messages: GPTChatMessage[] = [
|
|
327
|
+
{
|
|
328
|
+
content: "",
|
|
329
|
+
role: "tool-result",
|
|
330
|
+
toolResult: {result: "done", toolCallId: "1", toolName: "readFile"},
|
|
331
|
+
},
|
|
332
|
+
{
|
|
333
|
+
content: "",
|
|
334
|
+
role: "tool-result",
|
|
335
|
+
toolResult: {result: {ok: true}, toolCallId: "2", toolName: "writeFile"},
|
|
336
|
+
},
|
|
337
|
+
];
|
|
338
|
+
const {getByLabelText, getByText} = renderChat({currentMessages: messages});
|
|
339
|
+
|
|
340
|
+
await press(getByLabelText("Result: readFile"));
|
|
341
|
+
await press(getByLabelText("Result: writeFile"));
|
|
342
|
+
|
|
343
|
+
assert.isOk(getByText("done"));
|
|
344
|
+
assert.isOk(getByText(/"ok": true/));
|
|
345
|
+
});
|
|
346
|
+
|
|
347
|
+
it("renders image and file content parts", () => {
|
|
348
|
+
const messages: GPTChatMessage[] = [
|
|
349
|
+
{
|
|
350
|
+
content: "See attached",
|
|
351
|
+
contentParts: [
|
|
352
|
+
{text: "See attached", type: "text"},
|
|
353
|
+
{type: "image", url: "https://example.com/pic.png"},
|
|
354
|
+
{mimeType: "application/pdf", type: "file", url: "https://example.com/doc.pdf"},
|
|
355
|
+
{filename: "notes.txt", mimeType: "text/plain", type: "file", url: "file:///notes.txt"},
|
|
356
|
+
],
|
|
357
|
+
role: "user",
|
|
358
|
+
},
|
|
359
|
+
];
|
|
360
|
+
const {getByText} = renderChat({currentMessages: messages});
|
|
361
|
+
|
|
362
|
+
assert.isOk(getByText("File"));
|
|
363
|
+
assert.isOk(getByText("notes.txt"));
|
|
364
|
+
});
|
|
365
|
+
|
|
366
|
+
it("downloads a file content part on press", async () => {
|
|
367
|
+
const messages: GPTChatMessage[] = [
|
|
368
|
+
{
|
|
369
|
+
content: "",
|
|
370
|
+
contentParts: [
|
|
371
|
+
{filename: "doc.pdf", mimeType: "application/pdf", type: "file", url: "data:abc"},
|
|
372
|
+
],
|
|
373
|
+
role: "assistant",
|
|
374
|
+
},
|
|
375
|
+
];
|
|
376
|
+
const clicked: string[] = [];
|
|
377
|
+
const link = {click: () => clicked.push("click"), download: "", href: ""};
|
|
378
|
+
const appended: unknown[] = [];
|
|
379
|
+
const removed: unknown[] = [];
|
|
380
|
+
const domGlobals = globalThis as typeof globalThis & {
|
|
381
|
+
document?: unknown;
|
|
382
|
+
window?: unknown;
|
|
383
|
+
};
|
|
384
|
+
const originalDocument = domGlobals.document;
|
|
385
|
+
const originalWindow = domGlobals.window;
|
|
386
|
+
domGlobals.window = {};
|
|
387
|
+
domGlobals.document = {
|
|
388
|
+
body: {
|
|
389
|
+
appendChild: (node: unknown) => appended.push(node),
|
|
390
|
+
removeChild: (node: unknown) => removed.push(node),
|
|
391
|
+
},
|
|
392
|
+
createElement: () => link,
|
|
393
|
+
};
|
|
394
|
+
|
|
395
|
+
try {
|
|
396
|
+
const {getByLabelText} = renderChat({currentMessages: messages});
|
|
397
|
+
await press(getByLabelText("File: doc.pdf"));
|
|
398
|
+
} finally {
|
|
399
|
+
domGlobals.document = originalDocument;
|
|
400
|
+
domGlobals.window = originalWindow;
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
assert.equal(link.href, "data:abc");
|
|
404
|
+
assert.equal(link.download, "doc.pdf");
|
|
405
|
+
assert.deepEqual(clicked, ["click"]);
|
|
406
|
+
assert.deepEqual(appended, [link]);
|
|
407
|
+
assert.deepEqual(removed, [link]);
|
|
408
|
+
});
|
|
409
|
+
|
|
410
|
+
it("skips the download outside a browser environment", async () => {
|
|
411
|
+
const messages: GPTChatMessage[] = [
|
|
412
|
+
{
|
|
413
|
+
content: "",
|
|
414
|
+
contentParts: [{mimeType: "text/plain", type: "file", url: "https://example.com/a.txt"}],
|
|
415
|
+
role: "assistant",
|
|
416
|
+
},
|
|
417
|
+
];
|
|
418
|
+
const domGlobals = globalThis as typeof globalThis & {window?: unknown};
|
|
419
|
+
const originalWindow = domGlobals.window;
|
|
420
|
+
domGlobals.window = undefined;
|
|
421
|
+
|
|
422
|
+
try {
|
|
423
|
+
const {getByLabelText} = renderChat({currentMessages: messages});
|
|
424
|
+
await press(getByLabelText("File: File"));
|
|
425
|
+
} finally {
|
|
426
|
+
domGlobals.window = originalWindow;
|
|
427
|
+
}
|
|
428
|
+
});
|
|
429
|
+
|
|
430
|
+
it("rates assistant messages and toggles the rating off", () => {
|
|
431
|
+
const onRateFeedback = mock((_index: number, _rating: "up" | "down" | null) => {});
|
|
432
|
+
const messages: GPTChatMessage[] = [
|
|
433
|
+
{content: "Hello!", rating: "up", role: "assistant"},
|
|
434
|
+
{content: "More", role: "assistant"},
|
|
435
|
+
];
|
|
436
|
+
const {getByTestId} = renderChat({currentMessages: messages, onRateFeedback});
|
|
437
|
+
|
|
438
|
+
fireEvent.press(getByTestId("gpt-rate-up-0"));
|
|
439
|
+
fireEvent.press(getByTestId("gpt-rate-down-0"));
|
|
440
|
+
fireEvent.press(getByTestId("gpt-rate-down-1"));
|
|
441
|
+
|
|
442
|
+
assert.deepEqual(onRateFeedback.mock.calls, [
|
|
443
|
+
[0, null],
|
|
444
|
+
[0, "down"],
|
|
445
|
+
[1, "down"],
|
|
446
|
+
]);
|
|
447
|
+
});
|
|
448
|
+
|
|
449
|
+
it("hides rating buttons without a feedback handler", () => {
|
|
450
|
+
const {queryByTestId} = renderChat({
|
|
451
|
+
currentMessages: [{content: "Hello!", role: "assistant"}],
|
|
452
|
+
});
|
|
453
|
+
|
|
454
|
+
assert.isNull(queryByTestId("gpt-rate-up-0"));
|
|
455
|
+
});
|
|
456
|
+
|
|
457
|
+
it("copies an assistant message to the clipboard", async () => {
|
|
458
|
+
setStringAsync.mockClear();
|
|
459
|
+
const {getByTestId} = renderChat({
|
|
460
|
+
currentMessages: [{content: "Copy me", role: "assistant"}],
|
|
461
|
+
});
|
|
462
|
+
|
|
463
|
+
await act(async () => {
|
|
464
|
+
fireEvent.press(getByTestId("gpt-copy-msg-0"));
|
|
465
|
+
});
|
|
466
|
+
|
|
467
|
+
assert.deepEqual(setStringAsync.mock.calls, [["Copy me"]]);
|
|
468
|
+
});
|
|
469
|
+
|
|
470
|
+
it("disables input and the attachment picker while streaming", () => {
|
|
471
|
+
const {getByTestId} = renderChat({isStreaming: true, onAttachFiles: () => {}});
|
|
472
|
+
|
|
473
|
+
assert.isTrue(getByTestId("gpt-input").props.readOnly);
|
|
474
|
+
assert.isTrue(getByTestId("gpt-attach-button").props.disabled);
|
|
475
|
+
});
|
|
476
|
+
|
|
477
|
+
it("keeps the attachment picker enabled when not streaming", () => {
|
|
478
|
+
const {getByTestId} = renderChat({onAttachFiles: () => {}});
|
|
479
|
+
|
|
480
|
+
assert.isNotTrue(getByTestId("gpt-attach-button").props.disabled);
|
|
481
|
+
});
|
|
482
|
+
|
|
483
|
+
it("hides the attachment picker without an attach handler", () => {
|
|
484
|
+
const {queryByTestId} = renderChat();
|
|
485
|
+
|
|
486
|
+
assert.isNull(queryByTestId("gpt-attach-button"));
|
|
487
|
+
});
|
|
488
|
+
|
|
489
|
+
it("shows the scroll to bottom button once scrolled away from the end", async () => {
|
|
490
|
+
const {getByTestId, getByText, queryByText, UNSAFE_getByType} = renderChat({
|
|
491
|
+
currentMessages: [{content: "Hello!", role: "assistant"}],
|
|
492
|
+
});
|
|
493
|
+
|
|
494
|
+
assert.isNull(queryByText("Scroll to bottom"));
|
|
495
|
+
|
|
496
|
+
fireEvent(getByTestId("gpt-viewport"), "layout", {
|
|
497
|
+
nativeEvent: {layout: {height: 200, width: 100, x: 0, y: 0}},
|
|
498
|
+
});
|
|
499
|
+
fireEvent(getByTestId("gpt-messages"), "layout", {
|
|
500
|
+
nativeEvent: {layout: {height: 600, width: 100, x: 0, y: 0}},
|
|
501
|
+
});
|
|
502
|
+
await act(async () => {
|
|
503
|
+
fireEvent.scroll(UNSAFE_getByType(ScrollView), {
|
|
504
|
+
nativeEvent: {contentOffset: {x: 0, y: 100}},
|
|
505
|
+
});
|
|
506
|
+
});
|
|
507
|
+
|
|
508
|
+
assert.isOk(getByText("Scroll to bottom"));
|
|
509
|
+
|
|
510
|
+
await press(getByText("Scroll to bottom"));
|
|
511
|
+
|
|
512
|
+
assert.isNull(queryByText("Scroll to bottom"));
|
|
513
|
+
});
|
|
514
|
+
|
|
515
|
+
it("renders attachments and the attach button", () => {
|
|
516
|
+
const onAttachFiles = mock(() => {});
|
|
517
|
+
const onRemoveAttachment = mock((_index: number) => {});
|
|
518
|
+
const {getByTestId} = renderChat({
|
|
519
|
+
attachments: [{mimeType: "image/png", name: "photo.png", uri: "file:///photo.png"}],
|
|
520
|
+
onAttachFiles,
|
|
521
|
+
onRemoveAttachment,
|
|
522
|
+
});
|
|
523
|
+
|
|
524
|
+
assert.isOk(getByTestId("gpt-attach-button"));
|
|
525
|
+
assert.isOk(getByTestId("attachment-preview"));
|
|
526
|
+
});
|
|
527
|
+
|
|
528
|
+
it("hides the attachment preview without a remove handler", () => {
|
|
529
|
+
const {queryByTestId} = renderChat({
|
|
530
|
+
attachments: [{mimeType: "image/png", name: "photo.png", uri: "file:///photo.png"}],
|
|
531
|
+
});
|
|
532
|
+
|
|
533
|
+
assert.isNull(queryByTestId("attachment-preview"));
|
|
534
|
+
});
|
|
535
|
+
|
|
536
|
+
it("renders nothing for unknown content part types", () => {
|
|
537
|
+
const parts = [
|
|
538
|
+
{type: "audio", url: "https://example.com/a.mp3"},
|
|
539
|
+
] as unknown as MessageContentPart[];
|
|
540
|
+
const {getByText, queryByText} = renderChat({
|
|
541
|
+
currentMessages: [{content: "Listen", contentParts: parts, role: "user"}],
|
|
542
|
+
});
|
|
543
|
+
|
|
544
|
+
assert.isOk(getByText("Listen"));
|
|
545
|
+
assert.isNull(queryByText("File"));
|
|
546
|
+
});
|
|
547
|
+
|
|
548
|
+
it("forwards picked files to onAttachFiles", async () => {
|
|
549
|
+
const onAttachFiles = mock((_files: SelectedFile[]) => {});
|
|
550
|
+
const {getByTestId, getByText} = renderChat({onAttachFiles});
|
|
551
|
+
|
|
552
|
+
await press(getByTestId("gpt-attach-button"));
|
|
553
|
+
await press(getByText("Document"));
|
|
554
|
+
|
|
555
|
+
await waitFor(() => {
|
|
556
|
+
assert.deepEqual(onAttachFiles.mock.calls, [[[pickedDocument]]]);
|
|
557
|
+
});
|
|
558
|
+
});
|
|
559
|
+
|
|
560
|
+
it("saves a rename only once when blur and enter both fire", async () => {
|
|
561
|
+
const onUpdateTitle = mock((_id: string, _title: string) => {});
|
|
562
|
+
const {getByTestId} = renderChat({onUpdateTitle});
|
|
563
|
+
|
|
564
|
+
await press(getByTestId("gpt-rename-history-h1"));
|
|
565
|
+
fireEvent.changeText(getByTestId("gpt-rename-input-h1"), "Renamed");
|
|
566
|
+
const input = getByTestId("gpt-rename-input-h1");
|
|
567
|
+
await act(async () => {
|
|
568
|
+
input.props.onSubmitEditing();
|
|
569
|
+
input.props.onBlur();
|
|
570
|
+
});
|
|
571
|
+
|
|
572
|
+
assert.deepEqual(onUpdateTitle.mock.calls, [["h1", "Renamed"]]);
|
|
573
|
+
});
|
|
574
|
+
|
|
575
|
+
it("scrolls to the bottom when new messages arrive", () => {
|
|
576
|
+
const {getByText, rerender} = renderChat({
|
|
577
|
+
currentMessages: [{content: "First", role: "assistant"}],
|
|
578
|
+
});
|
|
579
|
+
|
|
580
|
+
rerender(
|
|
581
|
+
<GPTChat
|
|
582
|
+
currentMessages={[
|
|
583
|
+
{content: "First", role: "assistant"},
|
|
584
|
+
{content: "Second", role: "assistant"},
|
|
585
|
+
]}
|
|
586
|
+
histories={histories}
|
|
587
|
+
onCreateHistory={() => {}}
|
|
588
|
+
onDeleteHistory={() => {}}
|
|
589
|
+
onSelectHistory={() => {}}
|
|
590
|
+
onSubmit={() => {}}
|
|
591
|
+
testID="gpt-chat"
|
|
592
|
+
/>
|
|
593
|
+
);
|
|
594
|
+
|
|
595
|
+
assert.isOk(getByText("Second"));
|
|
596
|
+
});
|
|
597
|
+
});
|
|
598
|
+
|
|
599
|
+
describe("GPTChat web keyboard submit", () => {
|
|
600
|
+
const originalOS = Platform.OS;
|
|
601
|
+
|
|
602
|
+
afterEach(() => {
|
|
603
|
+
Platform.OS = originalOS;
|
|
604
|
+
});
|
|
605
|
+
|
|
606
|
+
const renderOnWeb = (): {
|
|
607
|
+
handlers: Map<string, (event: Event) => void>;
|
|
608
|
+
onSubmit: ReturnType<typeof mock<(prompt: string) => void>>;
|
|
609
|
+
result: ReturnType<typeof render>;
|
|
610
|
+
removed: string[];
|
|
611
|
+
} => {
|
|
612
|
+
Platform.OS = "web";
|
|
613
|
+
const handlers = new Map<string, (event: Event) => void>();
|
|
614
|
+
const removed: string[] = [];
|
|
615
|
+
const onSubmit = mock((_prompt: string) => {});
|
|
616
|
+
const node = {
|
|
617
|
+
addEventListener: (type: string, handler: (event: Event) => void): void => {
|
|
618
|
+
handlers.set(type, handler);
|
|
619
|
+
},
|
|
620
|
+
removeEventListener: (type: string): void => {
|
|
621
|
+
removed.push(type);
|
|
622
|
+
},
|
|
623
|
+
scrollToEnd: () => {},
|
|
624
|
+
};
|
|
625
|
+
const result = render(
|
|
626
|
+
<GPTChat
|
|
627
|
+
currentMessages={[]}
|
|
628
|
+
histories={histories}
|
|
629
|
+
onCreateHistory={() => {}}
|
|
630
|
+
onDeleteHistory={() => {}}
|
|
631
|
+
onSelectHistory={() => {}}
|
|
632
|
+
onSubmit={onSubmit}
|
|
633
|
+
testID="gpt-chat"
|
|
634
|
+
/>,
|
|
635
|
+
{
|
|
636
|
+
createNodeMock: () => node,
|
|
637
|
+
wrapper: ThemeProvider,
|
|
638
|
+
}
|
|
639
|
+
);
|
|
640
|
+
return {handlers, onSubmit, removed, result};
|
|
641
|
+
};
|
|
642
|
+
|
|
643
|
+
const keyEvent = (init: {
|
|
644
|
+
key: string;
|
|
645
|
+
metaKey?: boolean;
|
|
646
|
+
shiftKey?: boolean;
|
|
647
|
+
}): {
|
|
648
|
+
event: Event;
|
|
649
|
+
prevented: () => boolean;
|
|
650
|
+
} => {
|
|
651
|
+
let prevented = false;
|
|
652
|
+
const event = {
|
|
653
|
+
key: init.key,
|
|
654
|
+
metaKey: init.metaKey ?? false,
|
|
655
|
+
preventDefault: (): void => {
|
|
656
|
+
prevented = true;
|
|
657
|
+
},
|
|
658
|
+
shiftKey: init.shiftKey ?? false,
|
|
659
|
+
} as unknown as Event;
|
|
660
|
+
return {event, prevented: (): boolean => prevented};
|
|
661
|
+
};
|
|
662
|
+
|
|
663
|
+
it("submits on Enter but not on other keys or modified Enter", async () => {
|
|
664
|
+
const {handlers, onSubmit, result} = renderOnWeb();
|
|
665
|
+
const keydown = handlers.get("keydown");
|
|
666
|
+
assert.isFunction(keydown);
|
|
667
|
+
|
|
668
|
+
fireEvent.changeText(result.getByTestId("gpt-input"), "Hello there");
|
|
669
|
+
|
|
670
|
+
const other = keyEvent({key: "a"});
|
|
671
|
+
const shifted = keyEvent({key: "Enter", shiftKey: true});
|
|
672
|
+
const meta = keyEvent({key: "Enter", metaKey: true});
|
|
673
|
+
await act(async () => {
|
|
674
|
+
keydown?.(other.event);
|
|
675
|
+
keydown?.(shifted.event);
|
|
676
|
+
keydown?.(meta.event);
|
|
677
|
+
});
|
|
678
|
+
assert.isFalse(other.prevented());
|
|
679
|
+
assert.isFalse(shifted.prevented());
|
|
680
|
+
assert.isFalse(meta.prevented());
|
|
681
|
+
assert.equal(onSubmit.mock.calls.length, 0);
|
|
682
|
+
|
|
683
|
+
const enter = keyEvent({key: "Enter"});
|
|
684
|
+
await act(async () => {
|
|
685
|
+
keydown?.(enter.event);
|
|
686
|
+
});
|
|
687
|
+
assert.isTrue(enter.prevented());
|
|
688
|
+
assert.deepEqual(onSubmit.mock.calls, [["Hello there"]]);
|
|
689
|
+
});
|
|
690
|
+
|
|
691
|
+
it("removes the keydown listener on unmount", () => {
|
|
692
|
+
const {removed, result} = renderOnWeb();
|
|
693
|
+
result.unmount();
|
|
694
|
+
assert.include(removed, "keydown");
|
|
695
|
+
});
|
|
696
|
+
});
|
package/src/GPTChat.tsx
CHANGED
|
@@ -990,9 +990,9 @@ export const GPTChat = ({
|
|
|
990
990
|
{/* Chat Panel */}
|
|
991
991
|
<Box direction="column" flex="grow" padding={4}>
|
|
992
992
|
{/* Messages */}
|
|
993
|
-
<Box flex="grow" marginBottom={3} onLayout={handleViewportLayout}>
|
|
993
|
+
<Box flex="grow" marginBottom={3} onLayout={handleViewportLayout} testID="gpt-viewport">
|
|
994
994
|
<Box flex="grow" gap={3} onScroll={handleScroll} scroll={true} scrollRef={scrollViewRef}>
|
|
995
|
-
<Box gap={3} onLayout={handleContentLayout}>
|
|
995
|
+
<Box gap={3} onLayout={handleContentLayout} testID="gpt-messages">
|
|
996
996
|
{currentMessages.length === 0 && suggestedPrompts && suggestedPrompts.length > 0 && (
|
|
997
997
|
<Box alignItems="center" gap={2} paddingY={4}>
|
|
998
998
|
<Text color="secondaryDark" size="sm">
|