Skip to content

Commit 1692b1d

Browse files
Merge pull request #542 from rebeccaalpert/type-fix
fix(MessageBar): Adjust button types
2 parents b780f4a + 125bcf3 commit 1692b1d

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed

packages/module/src/MessageBar/MessageBar.test.tsx

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,17 @@ describe('Message bar', () => {
148148
await userEvent.click(screen.getByRole('button', { name: 'Send' }));
149149
expect(screen.getByRole('tooltip', { name: 'Test' })).toBeTruthy();
150150
});
151+
it('can handle buttonProps tooltipProps appropriately for send', () => {
152+
render(
153+
<MessageBar
154+
onSendMessage={jest.fn}
155+
alwayShowSendButton
156+
buttonProps={{ send: { tooltipProps: { isVisible: true } } }}
157+
/>
158+
);
159+
// isVisible, so no need for click
160+
expect(screen.getByRole('tooltip', { name: 'Send' })).toBeTruthy();
161+
});
151162
it('can handle buttonProps props appropriately for send', async () => {
152163
render(
153164
<MessageBar
@@ -236,6 +247,17 @@ describe('Message bar', () => {
236247
await userEvent.click(screen.getByRole('button', { name: 'Attach' }));
237248
expect(screen.getByRole('tooltip', { name: 'Test' })).toBeTruthy();
238249
});
250+
it('can handle buttonProps tooltipProps appropriately for attach', () => {
251+
render(
252+
<MessageBar
253+
onSendMessage={jest.fn}
254+
alwayShowSendButton
255+
buttonProps={{ attach: { tooltipProps: { isVisible: true } } }}
256+
/>
257+
);
258+
// isVisible, so no need for click
259+
expect(screen.getByRole('tooltip', { name: 'Attach' })).toBeTruthy();
260+
});
239261
it('can handle buttonProps props appropriately for attach', async () => {
240262
render(
241263
<MessageBar
@@ -271,6 +293,18 @@ describe('Message bar', () => {
271293
await userEvent.click(screen.getByRole('button', { name: 'Stop' }));
272294
expect(screen.getByRole('tooltip', { name: 'Test' })).toBeTruthy();
273295
});
296+
it('can handle buttonProps tooltipProps appropriately for stop', () => {
297+
render(
298+
<MessageBar
299+
onSendMessage={jest.fn}
300+
hasStopButton
301+
handleStopButton={jest.fn}
302+
buttonProps={{ stop: { tooltipProps: { isVisible: true } } }}
303+
/>
304+
);
305+
// isVisible, so no need for click
306+
expect(screen.getByRole('tooltip', { name: 'Stop' })).toBeTruthy();
307+
});
274308
it('can handle buttonProps props appropriately for stop', async () => {
275309
render(
276310
<MessageBar
@@ -317,6 +351,17 @@ describe('Message bar', () => {
317351
const input = screen.getByRole('textbox', { name: /I am listening/i });
318352
expect(input).toBeTruthy();
319353
});
354+
it('can handle buttonProps tooltipProps appropriately for microphone', () => {
355+
render(
356+
<MessageBar
357+
onSendMessage={jest.fn}
358+
hasMicrophoneButton
359+
buttonProps={{ microphone: { tooltipProps: { isVisible: true } } }}
360+
/>
361+
);
362+
// isVisible, so no need for click
363+
expect(screen.getByRole('tooltip', { name: 'Use microphone' })).toBeTruthy();
364+
});
320365
it('can handle buttonProps props appropriately for microphone', async () => {
321366
mockSpeechRecognition();
322367
render(

packages/module/src/MessageBar/MessageBar.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,7 @@ export const MessageBar: React.FunctionComponent<MessageBarProps> = ({
279279
onClick={handleStopButton}
280280
tooltipContent={buttonProps?.stop?.tooltipContent}
281281
isCompact={isCompact}
282+
tooltipProps={buttonProps?.stop?.tooltipProps}
282283
{...buttonProps?.stop?.props}
283284
/>
284285
);
@@ -292,6 +293,7 @@ export const MessageBar: React.FunctionComponent<MessageBarProps> = ({
292293
isDisabled={isListeningMessage}
293294
tooltipContent={buttonProps?.attach?.tooltipContent}
294295
isCompact={isCompact}
296+
tooltipProps={buttonProps?.attach?.tooltipProps}
295297
{...buttonProps?.attach?.props}
296298
/>
297299
)}
@@ -302,6 +304,7 @@ export const MessageBar: React.FunctionComponent<MessageBarProps> = ({
302304
tooltipContent={buttonProps?.attach?.tooltipContent}
303305
inputTestId={buttonProps?.attach?.inputTestId}
304306
isCompact={isCompact}
307+
tooltipProps={buttonProps?.attach?.tooltipProps}
305308
{...buttonProps?.attach?.props}
306309
/>
307310
)}
@@ -313,6 +316,7 @@ export const MessageBar: React.FunctionComponent<MessageBarProps> = ({
313316
tooltipContent={buttonProps?.microphone?.tooltipContent}
314317
language={buttonProps?.microphone?.language}
315318
isCompact={isCompact}
319+
tooltipProps={buttonProps?.microphone?.tooltipProps}
316320
{...buttonProps?.microphone?.props}
317321
/>
318322
)}
@@ -323,6 +327,7 @@ export const MessageBar: React.FunctionComponent<MessageBarProps> = ({
323327
isDisabled={isSendButtonDisabled}
324328
tooltipContent={buttonProps?.send?.tooltipContent}
325329
isCompact={isCompact}
330+
tooltipProps={buttonProps?.send?.tooltipProps}
326331
{...buttonProps?.send?.props}
327332
/>
328333
)}

0 commit comments

Comments
 (0)