Skip to content

Commit 9aa7d94

Browse files
committed
feat: remove warning
Signed-off-by: SuZhou-Joe <suzhou@amazon.com>
1 parent 0b86a09 commit 9aa7d94

File tree

1 file changed

+21
-9
lines changed

1 file changed

+21
-9
lines changed

public/chat_header_button.test.tsx

+21-9
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,9 @@ describe('<HeaderChatButton />', () => {
180180
expect(screen.queryByLabelText('chat flyout mock')).not.toBeVisible();
181181
// sidecar hide
182182
fireEvent.click(toggleButton);
183-
expect(screen.queryByLabelText('chat flyout mock')).toBeVisible();
183+
await waitFor(() => {
184+
expect(screen.queryByLabelText('chat flyout mock')).toBeVisible();
185+
});
184186
});
185187

186188
it('should call send message without active conversation id after input text submitted', async () => {
@@ -246,11 +248,12 @@ describe('<HeaderChatButton />', () => {
246248
code: 'Escape',
247249
charCode: 27,
248250
});
251+
249252
expect(screen.getByLabelText('chat input')).not.toHaveFocus();
250253
expect(screen.getByTitle('press Ctrl + / to start typing')).toBeInTheDocument();
251254
});
252255

253-
it('should focus on chat input when pressing global shortcut', () => {
256+
it('should focus on chat input when pressing global shortcut', async () => {
254257
render(
255258
<HeaderChatButton
256259
application={applicationServiceMock.createStartContract()}
@@ -267,10 +270,12 @@ describe('<HeaderChatButton />', () => {
267270
charCode: 111,
268271
ctrlKey: true,
269272
});
270-
expect(screen.getByLabelText('chat input')).toHaveFocus();
273+
await waitFor(() => {
274+
expect(screen.getByLabelText('chat input')).toHaveFocus();
275+
});
271276
});
272277

273-
it('should not focus on chat input when no access and pressing global shortcut', () => {
278+
it('should not focus on chat input when no access and pressing global shortcut', async () => {
274279
render(
275280
<HeaderChatButton
276281
application={applicationServiceMock.createStartContract()}
@@ -287,7 +292,9 @@ describe('<HeaderChatButton />', () => {
287292
charCode: 111,
288293
metaKey: true,
289294
});
290-
expect(screen.getByLabelText('chat input')).not.toHaveFocus();
295+
await waitFor(() => {
296+
expect(screen.getByLabelText('chat input')).not.toHaveFocus();
297+
});
291298
});
292299

293300
it('should call sidecar hide and close when button unmount and chat flyout is visible', async () => {
@@ -307,11 +314,16 @@ describe('<HeaderChatButton />', () => {
307314

308315
fireEvent.click(getByLabelText('toggle chat flyout icon'));
309316

310-
expect(sideCarHideMock).not.toHaveBeenCalled();
311-
expect(sideCarRefMock.close).not.toHaveBeenCalled();
317+
await waitFor(() => {
318+
expect(sideCarHideMock).not.toHaveBeenCalled();
319+
expect(sideCarRefMock.close).not.toHaveBeenCalled();
320+
});
321+
312322
unmount();
313-
expect(sideCarHideMock).toHaveBeenCalled();
314-
expect(sideCarRefMock.close).toHaveBeenCalled();
323+
await waitFor(() => {
324+
expect(sideCarHideMock).toHaveBeenCalled();
325+
expect(sideCarRefMock.close).toHaveBeenCalled();
326+
});
315327
});
316328

317329
it('should render toggle chat flyout button icon', () => {

0 commit comments

Comments
 (0)