Skip to content

Commit 15b4a5d

Browse files
committed
add test
1 parent 1f2a226 commit 15b4a5d

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

tests/common/widgets/chat/options.tsx

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,46 @@ export function createOptionsTests(
139139
);
140140
});
141141

142+
test('disables clear button when chat is in progress', async () => {
143+
const searchClient = createSearchClient();
144+
const chat = new Chat({});
145+
146+
await setup({
147+
instantSearchOptions: {
148+
indexName: 'indexName',
149+
searchClient,
150+
},
151+
widgetParams: {
152+
javascript: createDefaultWidgetParams(chat),
153+
react: createDefaultWidgetParams(chat),
154+
vue: {},
155+
},
156+
});
157+
158+
await openChat(act);
159+
160+
await act(async () => {
161+
chat._state.messages = [
162+
{
163+
id: '1',
164+
role: 'user' as const,
165+
parts: [{ type: 'text' as const, text: 'hello' }],
166+
},
167+
];
168+
await wait(0);
169+
});
170+
171+
const clearButton = document.querySelector('.ais-ChatHeader-clear');
172+
expect(clearButton).not.toBeDisabled();
173+
174+
await act(async () => {
175+
chat._state.status = 'streaming';
176+
await wait(0);
177+
});
178+
179+
expect(clearButton).toBeDisabled();
180+
});
181+
142182
describe('cssClasses', () => {
143183
test('adds custom CSS classes', async () => {
144184
const searchClient = createSearchClient();

0 commit comments

Comments
 (0)