@patternfly/chatbot 6.3.0-prerelease.10 → 6.3.0-prerelease.12

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.
Files changed (51) hide show
  1. package/dist/cjs/Message/CodeBlockMessage/CodeBlockMessage.js +1 -1
  2. package/dist/cjs/Message/Message.test.js +3 -3
  3. package/dist/cjs/MessageBar/AttachButton.js +1 -1
  4. package/dist/cjs/MessageBar/AttachButton.test.js +7 -7
  5. package/dist/cjs/MessageBar/MessageBar.test.js +29 -29
  6. package/dist/cjs/MessageBar/MicrophoneButton.js +1 -1
  7. package/dist/cjs/MessageBar/SendButton.js +1 -1
  8. package/dist/cjs/MessageBar/SendButton.test.js +5 -5
  9. package/dist/cjs/MessageBar/StopButton.js +1 -1
  10. package/dist/cjs/MessageBar/StopButton.test.js +5 -5
  11. package/dist/cjs/MessageBox/JumpButton.js +1 -1
  12. package/dist/cjs/MessageBox/JumpButton.test.js +4 -4
  13. package/dist/cjs/MessageBox/MessageBox.test.js +2 -2
  14. package/dist/cjs/ResponseActions/ResponseActionButton.d.ts +2 -2
  15. package/dist/cjs/ResponseActions/ResponseActions.d.ts +4 -1
  16. package/dist/cjs/ResponseActions/ResponseActions.js +6 -6
  17. package/dist/cjs/ResponseActions/ResponseActions.test.js +16 -1
  18. package/dist/esm/Message/CodeBlockMessage/CodeBlockMessage.js +1 -1
  19. package/dist/esm/Message/Message.test.js +3 -3
  20. package/dist/esm/MessageBar/AttachButton.js +1 -1
  21. package/dist/esm/MessageBar/AttachButton.test.js +7 -7
  22. package/dist/esm/MessageBar/MessageBar.test.js +29 -29
  23. package/dist/esm/MessageBar/MicrophoneButton.js +1 -1
  24. package/dist/esm/MessageBar/SendButton.js +1 -1
  25. package/dist/esm/MessageBar/SendButton.test.js +5 -5
  26. package/dist/esm/MessageBar/StopButton.js +1 -1
  27. package/dist/esm/MessageBar/StopButton.test.js +5 -5
  28. package/dist/esm/MessageBox/JumpButton.js +1 -1
  29. package/dist/esm/MessageBox/JumpButton.test.js +4 -4
  30. package/dist/esm/MessageBox/MessageBox.test.js +2 -2
  31. package/dist/esm/ResponseActions/ResponseActionButton.d.ts +2 -2
  32. package/dist/esm/ResponseActions/ResponseActions.d.ts +4 -1
  33. package/dist/esm/ResponseActions/ResponseActions.js +6 -6
  34. package/dist/esm/ResponseActions/ResponseActions.test.js +16 -1
  35. package/package.json +1 -1
  36. package/src/Message/CodeBlockMessage/CodeBlockMessage.tsx +1 -1
  37. package/src/Message/Message.test.tsx +3 -3
  38. package/src/MessageBar/AttachButton.test.tsx +7 -7
  39. package/src/MessageBar/AttachButton.tsx +1 -1
  40. package/src/MessageBar/MessageBar.test.tsx +29 -29
  41. package/src/MessageBar/MicrophoneButton.tsx +2 -1
  42. package/src/MessageBar/SendButton.test.tsx +5 -5
  43. package/src/MessageBar/SendButton.tsx +1 -1
  44. package/src/MessageBar/StopButton.test.tsx +5 -5
  45. package/src/MessageBar/StopButton.tsx +1 -1
  46. package/src/MessageBox/JumpButton.test.tsx +4 -4
  47. package/src/MessageBox/JumpButton.tsx +1 -1
  48. package/src/MessageBox/MessageBox.test.tsx +2 -2
  49. package/src/ResponseActions/ResponseActionButton.tsx +2 -2
  50. package/src/ResponseActions/ResponseActions.test.tsx +18 -1
  51. package/src/ResponseActions/ResponseActions.tsx +10 -1
@@ -52,7 +52,7 @@ const CodeBlockMessage = (_a) => {
52
52
  const actions = (react_1.default.createElement(react_1.default.Fragment, null,
53
53
  react_1.default.createElement(react_core_1.CodeBlockAction, null,
54
54
  language && react_1.default.createElement("div", { className: "pf-chatbot__message-code-block-language" }, language),
55
- react_1.default.createElement(react_core_1.Button, { ref: buttonRef, "aria-label": ariaLabel !== null && ariaLabel !== void 0 ? ariaLabel : 'Copy code button', variant: "plain", className: "pf-chatbot__button--copy", onClick: (event) => handleCopy(event, children) }, copied ? react_1.default.createElement(check_icon_1.CheckIcon, null) : react_1.default.createElement(copy_icon_1.CopyIcon, null)),
55
+ react_1.default.createElement(react_core_1.Button, { ref: buttonRef, "aria-label": ariaLabel !== null && ariaLabel !== void 0 ? ariaLabel : 'Copy code', variant: "plain", className: "pf-chatbot__button--copy", onClick: (event) => handleCopy(event, children) }, copied ? react_1.default.createElement(check_icon_1.CheckIcon, null) : react_1.default.createElement(copy_icon_1.CopyIcon, null)),
56
56
  react_1.default.createElement(react_core_1.Tooltip, { id: tooltipID, content: "Copy", position: "top", triggerRef: buttonRef }))));
57
57
  return (react_1.default.createElement("div", { className: "pf-chatbot__message-code-block" },
58
58
  react_1.default.createElement(react_core_1.CodeBlock, { actions: actions },
@@ -396,7 +396,7 @@ describe('Message', () => {
396
396
  it('should render code correctly', () => {
397
397
  (0, react_2.render)(react_1.default.createElement(Message_1.default, { avatar: "./img", role: "user", name: "User", content: CODE_MESSAGE }));
398
398
  expect(react_2.screen.getByText('Here is some YAML code:')).toBeTruthy();
399
- expect(react_2.screen.getByRole('button', { name: 'Copy code button' })).toBeTruthy();
399
+ expect(react_2.screen.getByRole('button', { name: 'Copy code' })).toBeTruthy();
400
400
  expect(react_2.screen.getByText(/yaml/)).toBeTruthy();
401
401
  expect(react_2.screen.getByText(/apiVersion:/i)).toBeTruthy();
402
402
  expect(react_2.screen.getByText(/helm.openshift.io\/v1beta1/i)).toBeTruthy();
@@ -412,8 +412,8 @@ describe('Message', () => {
412
412
  // need explicit setup since RTL stubs clipboard if you do this
413
413
  const user = user_event_1.default.setup();
414
414
  (0, react_2.render)(react_1.default.createElement(Message_1.default, { avatar: "./img", role: "user", name: "User", content: CODE_MESSAGE }));
415
- expect(react_2.screen.getByRole('button', { name: 'Copy code button' })).toBeTruthy();
416
- yield user.click(react_2.screen.getByRole('button', { name: 'Copy code button' }));
415
+ expect(react_2.screen.getByRole('button', { name: 'Copy code' })).toBeTruthy();
416
+ yield user.click(react_2.screen.getByRole('button', { name: 'Copy code' }));
417
417
  const clipboardText = yield navigator.clipboard.readText();
418
418
  expect(clipboardText.trim()).toEqual(CODE.trim());
419
419
  }));
@@ -34,7 +34,7 @@ const AttachButtonBase = (_a) => {
34
34
  react_1.default.createElement(react_core_1.Tooltip, Object.assign({ id: "pf-chatbot__tooltip--attach", content: tooltipContent, position: "top", entryDelay: (tooltipProps === null || tooltipProps === void 0 ? void 0 : tooltipProps.entryDelay) || 0, exitDelay: (tooltipProps === null || tooltipProps === void 0 ? void 0 : tooltipProps.exitDelay) || 0, distance: (tooltipProps === null || tooltipProps === void 0 ? void 0 : tooltipProps.distance) || 8, animationDuration: (tooltipProps === null || tooltipProps === void 0 ? void 0 : tooltipProps.animationDuration) || 0,
35
35
  // prevents VO announcements of both aria label and tooltip
36
36
  aria: "none" }, tooltipProps),
37
- react_1.default.createElement(react_core_1.Button, Object.assign({ variant: "plain", ref: innerRef, className: `pf-chatbot__button--attach ${isCompact ? 'pf-m-compact' : ''} ${className !== null && className !== void 0 ? className : ''}`, "aria-label": props['aria-label'] || 'Attach button', isDisabled: isDisabled, onClick: onClick !== null && onClick !== void 0 ? onClick : open, icon: react_1.default.createElement(react_core_1.Icon, { iconSize: isCompact ? 'lg' : 'xl', isInline: true },
37
+ react_1.default.createElement(react_core_1.Button, Object.assign({ variant: "plain", ref: innerRef, className: `pf-chatbot__button--attach ${isCompact ? 'pf-m-compact' : ''} ${className !== null && className !== void 0 ? className : ''}`, "aria-label": props['aria-label'] || 'Attach', isDisabled: isDisabled, onClick: onClick !== null && onClick !== void 0 ? onClick : open, icon: react_1.default.createElement(react_core_1.Icon, { iconSize: isCompact ? 'lg' : 'xl', isInline: true },
38
38
  react_1.default.createElement(paperclip_icon_1.PaperclipIcon, null)), size: isCompact ? 'sm' : undefined }, props)))));
39
39
  };
40
40
  exports.AttachButton = react_1.default.forwardRef((props, ref) => (react_1.default.createElement(AttachButtonBase, Object.assign({ innerRef: ref }, props))));
@@ -20,11 +20,11 @@ const AttachButton_1 = require("./AttachButton");
20
20
  describe('Attach button', () => {
21
21
  it('should render button correctly', () => {
22
22
  (0, react_2.render)(react_1.default.createElement(AttachButton_1.AttachButton, null));
23
- expect(react_2.screen.getByRole('button', { name: 'Attach button' })).toBeTruthy();
23
+ expect(react_2.screen.getByRole('button', { name: 'Attach' })).toBeTruthy();
24
24
  });
25
25
  it('should handle isDisabled prop', () => {
26
26
  (0, react_2.render)(react_1.default.createElement(AttachButton_1.AttachButton, { isDisabled: true }));
27
- expect(react_2.screen.getByRole('button', { name: 'Attach button' })).toBeDisabled();
27
+ expect(react_2.screen.getByRole('button', { name: 'Attach' })).toBeDisabled();
28
28
  });
29
29
  it('should handle spread props, including aria-label', () => {
30
30
  (0, react_2.render)(react_1.default.createElement(AttachButton_1.AttachButton, { "aria-label": "test" }));
@@ -33,22 +33,22 @@ describe('Attach button', () => {
33
33
  it('should handle onClick', () => __awaiter(void 0, void 0, void 0, function* () {
34
34
  const spy = jest.fn();
35
35
  (0, react_2.render)(react_1.default.createElement(AttachButton_1.AttachButton, { onClick: spy }));
36
- yield user_event_1.default.click(react_2.screen.getByRole('button', { name: 'Attach button' }));
36
+ yield user_event_1.default.click(react_2.screen.getByRole('button', { name: 'Attach' }));
37
37
  expect(react_2.screen.getByRole('tooltip', { name: 'Attach' })).toBeTruthy();
38
38
  expect(spy).toHaveBeenCalledTimes(1);
39
39
  }));
40
40
  it('should handle className prop', () => {
41
41
  (0, react_2.render)(react_1.default.createElement(AttachButton_1.AttachButton, { className: "test" }));
42
- expect(react_2.screen.getByRole('button', { name: 'Attach button' })).toHaveClass('test');
42
+ expect(react_2.screen.getByRole('button', { name: 'Attach' })).toHaveClass('test');
43
43
  });
44
44
  it('should handle custom tooltip correctly', () => __awaiter(void 0, void 0, void 0, function* () {
45
45
  (0, react_2.render)(react_1.default.createElement(AttachButton_1.AttachButton, { onClick: jest.fn, tooltipContent: "Test" }));
46
- yield user_event_1.default.click(react_2.screen.getByRole('button', { name: 'Attach button' }));
46
+ yield user_event_1.default.click(react_2.screen.getByRole('button', { name: 'Attach' }));
47
47
  expect(react_2.screen.getByRole('tooltip', { name: 'Test' })).toBeTruthy();
48
48
  }));
49
49
  it('should handle tooltipProps prop', () => __awaiter(void 0, void 0, void 0, function* () {
50
50
  (0, react_2.render)(react_1.default.createElement(AttachButton_1.AttachButton, { tooltipProps: { id: 'test' } }));
51
- yield user_event_1.default.click(react_2.screen.getByRole('button', { name: 'Attach button' }));
51
+ yield user_event_1.default.click(react_2.screen.getByRole('button', { name: 'Attach' }));
52
52
  expect(react_2.screen.getByRole('tooltip', { name: 'Attach' })).toHaveAttribute('id', 'test');
53
53
  }));
54
54
  // Based on this because I had no idea how to do this and was looking around: https://stackoverflow.com/a/75562651
@@ -56,7 +56,7 @@ describe('Attach button', () => {
56
56
  it('should handle onAttachAccepted prop', () => __awaiter(void 0, void 0, void 0, function* () {
57
57
  const spy = jest.fn();
58
58
  (0, react_2.render)(react_1.default.createElement(AttachButton_1.AttachButton, { onAttachAccepted: spy, inputTestId: "input" }));
59
- yield user_event_1.default.click(react_2.screen.getByRole('button', { name: 'Attach button' }));
59
+ yield user_event_1.default.click(react_2.screen.getByRole('button', { name: 'Attach' }));
60
60
  const file = new File(['test'], 'test.json');
61
61
  const input = react_2.screen.getByTestId('input');
62
62
  yield user_event_1.default.upload(input, file);
@@ -53,9 +53,9 @@ describe('Message bar', () => {
53
53
  });
54
54
  it('should render correctly', () => {
55
55
  (0, react_2.render)(react_1.default.createElement(MessageBar_1.MessageBar, { onSendMessage: jest.fn }));
56
- expect(react_2.screen.getByRole('button', { name: 'Attach button' })).toBeTruthy();
57
- expect(react_2.screen.queryByRole('button', { name: 'Send button' })).toBeFalsy();
58
- expect(react_2.screen.queryByRole('button', { name: 'Microphone button' })).toBeFalsy();
56
+ expect(react_2.screen.getByRole('button', { name: 'Attach' })).toBeTruthy();
57
+ expect(react_2.screen.queryByRole('button', { name: 'Send' })).toBeFalsy();
58
+ expect(react_2.screen.queryByRole('button', { name: 'Use microphone' })).toBeFalsy();
59
59
  expect(react_2.screen.getByRole('textbox', { name: /Send a message.../i })).toBeTruthy();
60
60
  });
61
61
  it('can send via enter key', () => __awaiter(void 0, void 0, void 0, function* () {
@@ -89,15 +89,15 @@ describe('Message bar', () => {
89
89
  const input = react_2.screen.getByRole('textbox', { name: /Send a message.../i });
90
90
  yield user_event_1.default.type(input, 'Hello world');
91
91
  expect(input).toHaveTextContent('Hello world');
92
- expect(react_2.screen.getByRole('button', { name: 'Send button' })).toBeTruthy();
92
+ expect(react_2.screen.getByRole('button', { name: 'Send' })).toBeTruthy();
93
93
  }));
94
94
  it('can disable send button shown when text is input', () => __awaiter(void 0, void 0, void 0, function* () {
95
95
  (0, react_2.render)(react_1.default.createElement(MessageBar_1.MessageBar, { onSendMessage: jest.fn, isSendButtonDisabled: true }));
96
96
  const input = react_2.screen.getByRole('textbox', { name: /Send a message.../i });
97
97
  yield user_event_1.default.type(input, 'Hello world');
98
98
  expect(input).toHaveTextContent('Hello world');
99
- expect(react_2.screen.getByRole('button', { name: 'Send button' })).toBeTruthy();
100
- expect(react_2.screen.getByRole('button', { name: 'Send button' })).toBeDisabled();
99
+ expect(react_2.screen.getByRole('button', { name: 'Send' })).toBeTruthy();
100
+ expect(react_2.screen.getByRole('button', { name: 'Send' })).toBeDisabled();
101
101
  }));
102
102
  it('can click send button', () => __awaiter(void 0, void 0, void 0, function* () {
103
103
  const spy = jest.fn();
@@ -105,24 +105,24 @@ describe('Message bar', () => {
105
105
  const input = react_2.screen.getByRole('textbox', { name: /Send a message.../i });
106
106
  yield user_event_1.default.type(input, 'Hello world');
107
107
  expect(input).toHaveTextContent('Hello world');
108
- const sendButton = react_2.screen.getByRole('button', { name: 'Send button' });
108
+ const sendButton = react_2.screen.getByRole('button', { name: 'Send' });
109
109
  expect(sendButton).toBeTruthy();
110
110
  yield user_event_1.default.click(sendButton);
111
111
  expect(spy).toHaveBeenCalledTimes(1);
112
112
  }));
113
113
  it('can always show send button', () => {
114
114
  (0, react_2.render)(react_1.default.createElement(MessageBar_1.MessageBar, { onSendMessage: jest.fn, alwayShowSendButton: true }));
115
- expect(react_2.screen.getByRole('button', { name: 'Send button' })).toBeTruthy();
116
- expect(react_2.screen.getByRole('button', { name: 'Send button' })).toBeEnabled();
115
+ expect(react_2.screen.getByRole('button', { name: 'Send' })).toBeTruthy();
116
+ expect(react_2.screen.getByRole('button', { name: 'Send' })).toBeEnabled();
117
117
  });
118
118
  it('can disable send button if always showing', () => {
119
119
  (0, react_2.render)(react_1.default.createElement(MessageBar_1.MessageBar, { onSendMessage: jest.fn, alwayShowSendButton: true, isSendButtonDisabled: true }));
120
- expect(react_2.screen.getByRole('button', { name: 'Send button' })).toBeTruthy();
121
- expect(react_2.screen.getByRole('button', { name: 'Send button' })).toBeDisabled();
120
+ expect(react_2.screen.getByRole('button', { name: 'Send' })).toBeTruthy();
121
+ expect(react_2.screen.getByRole('button', { name: 'Send' })).toBeDisabled();
122
122
  });
123
123
  it('can handle buttonProps tooltipContent appropriately for send', () => __awaiter(void 0, void 0, void 0, function* () {
124
124
  (0, react_2.render)(react_1.default.createElement(MessageBar_1.MessageBar, { onSendMessage: jest.fn, alwayShowSendButton: true, buttonProps: { send: { tooltipContent: 'Test' } } }));
125
- yield user_event_1.default.click(react_2.screen.getByRole('button', { name: 'Send button' }));
125
+ yield user_event_1.default.click(react_2.screen.getByRole('button', { name: 'Send' }));
126
126
  expect(react_2.screen.getByRole('tooltip', { name: 'Test' })).toBeTruthy();
127
127
  }));
128
128
  it('can handle buttonProps props appropriately for send', () => __awaiter(void 0, void 0, void 0, function* () {
@@ -163,30 +163,30 @@ describe('Message bar', () => {
163
163
  expect(react_2.screen.queryByRole('menuitem', { name: /Logs/i })).toBeFalsy();
164
164
  expect(react_2.screen.queryByRole('menuitem', { name: /YAML - Status/i })).toBeFalsy();
165
165
  expect(react_2.screen.queryByRole('menuitem', { name: /YAML - All contents/i })).toBeFalsy();
166
- const attachButton = react_2.screen.getByRole('button', { name: 'Attach button' });
166
+ const attachButton = react_2.screen.getByRole('button', { name: 'Attach' });
167
167
  yield user_event_1.default.click(attachButton);
168
168
  expect(attachToggleClickSpy).toHaveBeenCalledTimes(1);
169
169
  }));
170
170
  it('can hide attach button', () => {
171
171
  (0, react_2.render)(react_1.default.createElement(MessageBar_1.MessageBar, { onSendMessage: jest.fn, hasAttachButton: false }));
172
- expect(react_2.screen.queryByRole('button', { name: 'Attach button' })).toBeFalsy();
172
+ expect(react_2.screen.queryByRole('button', { name: 'Attach' })).toBeFalsy();
173
173
  });
174
174
  // Based on this because I had no idea how to do this and was looking around: https://stackoverflow.com/a/75562651
175
175
  // See also https://developer.mozilla.org/en-US/docs/Web/API/File/File for what that file variable is doing
176
176
  it('can handle handleAttach', () => __awaiter(void 0, void 0, void 0, function* () {
177
177
  const spy = jest.fn();
178
178
  (0, react_2.render)(react_1.default.createElement(MessageBar_1.MessageBar, { onSendMessage: jest.fn, hasAttachButton: true, handleAttach: spy, buttonProps: { attach: { inputTestId: 'input' } } }));
179
- expect(react_2.screen.getByRole('button', { name: 'Attach button' })).toBeTruthy();
180
- yield user_event_1.default.click(react_2.screen.getByRole('button', { name: 'Attach button' }));
179
+ expect(react_2.screen.getByRole('button', { name: 'Attach' })).toBeTruthy();
180
+ yield user_event_1.default.click(react_2.screen.getByRole('button', { name: 'Attach' }));
181
181
  const file = new File(['test'], 'test.json');
182
182
  const input = react_2.screen.getByTestId('input');
183
183
  yield user_event_1.default.upload(input, file);
184
184
  expect(input.files).toHaveLength(1);
185
185
  expect(spy).toHaveBeenCalledTimes(1);
186
186
  }));
187
- it('can handle buttonProps tooltipContent appropriately for attach', () => __awaiter(void 0, void 0, void 0, function* () {
187
+ it('can handle buttonProps tooltipContent appropriately for attach', () => __awaiter(void 0, void 0, void 0, function* () {
188
188
  (0, react_2.render)(react_1.default.createElement(MessageBar_1.MessageBar, { onSendMessage: jest.fn, hasAttachButton: true, buttonProps: { attach: { tooltipContent: 'Test' } } }));
189
- yield user_event_1.default.click(react_2.screen.getByRole('button', { name: 'Attach button' }));
189
+ yield user_event_1.default.click(react_2.screen.getByRole('button', { name: 'Attach' }));
190
190
  expect(react_2.screen.getByRole('tooltip', { name: 'Test' })).toBeTruthy();
191
191
  }));
192
192
  it('can handle buttonProps props appropriately for attach', () => __awaiter(void 0, void 0, void 0, function* () {
@@ -197,17 +197,17 @@ describe('Message bar', () => {
197
197
  // --------------------------------------------------------------------------
198
198
  it('can show stop button', () => {
199
199
  (0, react_2.render)(react_1.default.createElement(MessageBar_1.MessageBar, { onSendMessage: jest.fn, hasStopButton: true, handleStopButton: jest.fn }));
200
- expect(react_2.screen.getByRole('button', { name: 'Stop button' })).toBeTruthy();
200
+ expect(react_2.screen.getByRole('button', { name: 'Stop' })).toBeTruthy();
201
201
  });
202
202
  it('can call handleStopButton', () => __awaiter(void 0, void 0, void 0, function* () {
203
203
  const spy = jest.fn();
204
204
  (0, react_2.render)(react_1.default.createElement(MessageBar_1.MessageBar, { onSendMessage: jest.fn, hasStopButton: true, handleStopButton: spy }));
205
- yield user_event_1.default.click(react_2.screen.getByRole('button', { name: 'Stop button' }));
205
+ yield user_event_1.default.click(react_2.screen.getByRole('button', { name: 'Stop' }));
206
206
  expect(spy).toHaveBeenCalledTimes(1);
207
207
  }));
208
208
  it('can handle buttonProps tooltipContent appropriately for stop', () => __awaiter(void 0, void 0, void 0, function* () {
209
209
  (0, react_2.render)(react_1.default.createElement(MessageBar_1.MessageBar, { onSendMessage: jest.fn, hasStopButton: true, handleStopButton: jest.fn, buttonProps: { stop: { tooltipContent: 'Test' } } }));
210
- yield user_event_1.default.click(react_2.screen.getByRole('button', { name: 'Stop button' }));
210
+ yield user_event_1.default.click(react_2.screen.getByRole('button', { name: 'Stop' }));
211
211
  expect(react_2.screen.getByRole('tooltip', { name: 'Test' })).toBeTruthy();
212
212
  }));
213
213
  it('can handle buttonProps props appropriately for stop', () => __awaiter(void 0, void 0, void 0, function* () {
@@ -218,27 +218,27 @@ describe('Message bar', () => {
218
218
  // --------------------------------------------------------------------------
219
219
  it('can hide microphone button when window.SpeechRecognition is not there', () => {
220
220
  (0, react_2.render)(react_1.default.createElement(MessageBar_1.MessageBar, { onSendMessage: jest.fn, hasMicrophoneButton: true }));
221
- expect(react_2.screen.queryByRole('button', { name: 'Microphone button' })).toBeFalsy();
221
+ expect(react_2.screen.queryByRole('button', { name: 'Use microphone' })).toBeFalsy();
222
222
  });
223
223
  it('can show microphone button', () => {
224
224
  mockSpeechRecognition();
225
225
  (0, react_2.render)(react_1.default.createElement(MessageBar_1.MessageBar, { onSendMessage: jest.fn, hasMicrophoneButton: true }));
226
- expect(react_2.screen.getByRole('button', { name: 'Microphone button' })).toBeTruthy();
226
+ expect(react_2.screen.getByRole('button', { name: 'Use microphone' })).toBeTruthy();
227
227
  });
228
228
  it('can handle buttonProps appropriately for microphone', () => __awaiter(void 0, void 0, void 0, function* () {
229
229
  mockSpeechRecognition();
230
230
  (0, react_2.render)(react_1.default.createElement(MessageBar_1.MessageBar, { onSendMessage: jest.fn, hasMicrophoneButton: true, buttonProps: {
231
231
  microphone: { tooltipContent: { active: 'Currently listening', inactive: 'Not currently listening' } }
232
232
  } }));
233
- yield user_event_1.default.click(react_2.screen.getByRole('button', { name: 'Microphone button' }));
233
+ yield user_event_1.default.click(react_2.screen.getByRole('button', { name: 'Use microphone' }));
234
234
  expect(react_2.screen.getByRole('tooltip', { name: 'Currently listening' })).toBeTruthy();
235
- yield user_event_1.default.click(react_2.screen.getByRole('button', { name: 'Microphone button' }));
235
+ yield user_event_1.default.click(react_2.screen.getByRole('button', { name: 'Stop listening' }));
236
236
  expect(react_2.screen.getByRole('tooltip', { name: 'Not currently listening' })).toBeTruthy();
237
237
  }));
238
238
  it('can customize the listening placeholder', () => __awaiter(void 0, void 0, void 0, function* () {
239
239
  mockSpeechRecognition();
240
240
  (0, react_2.render)(react_1.default.createElement(MessageBar_1.MessageBar, { onSendMessage: jest.fn, hasMicrophoneButton: true, listeningText: "I am listening" }));
241
- yield user_event_1.default.click(react_2.screen.getByRole('button', { name: 'Microphone button' }));
241
+ yield user_event_1.default.click(react_2.screen.getByRole('button', { name: 'Use microphone' }));
242
242
  const input = react_2.screen.getByRole('textbox', { name: /I am listening/i });
243
243
  expect(input).toBeTruthy();
244
244
  }));
@@ -249,9 +249,9 @@ describe('Message bar', () => {
249
249
  }));
250
250
  it('can be controlled', () => {
251
251
  (0, react_2.render)(react_1.default.createElement(MessageBar_1.MessageBar, { onSendMessage: jest.fn, value: "test" }));
252
- expect(react_2.screen.getByRole('button', { name: 'Attach button' })).toBeTruthy();
253
- expect(react_2.screen.getByRole('button', { name: 'Send button' })).toBeTruthy();
254
- expect(react_2.screen.queryByRole('button', { name: 'Microphone button' })).toBeFalsy();
252
+ expect(react_2.screen.getByRole('button', { name: 'Attach' })).toBeTruthy();
253
+ expect(react_2.screen.getByRole('button', { name: 'Send' })).toBeTruthy();
254
+ expect(react_2.screen.queryByRole('button', { name: 'Use microphone' })).toBeFalsy();
255
255
  expect(react_2.screen.getByRole('textbox', { name: /Send a message.../i })).toBeTruthy();
256
256
  expect(react_2.screen.getByRole('textbox', { name: /Send a message.../i })).toHaveValue('test');
257
257
  });
@@ -69,7 +69,7 @@ const MicrophoneButton = (_a) => {
69
69
  return null;
70
70
  }
71
71
  return (react_1.default.createElement(react_core_1.Tooltip, Object.assign({ aria: "none", "aria-live": "polite", id: "pf-chatbot__tooltip--use-microphone", content: isListening ? tooltipContent.active : tooltipContent.inactive, position: (tooltipProps === null || tooltipProps === void 0 ? void 0 : tooltipProps.position) || 'top', entryDelay: (tooltipProps === null || tooltipProps === void 0 ? void 0 : tooltipProps.entryDelay) || 0, exitDelay: (tooltipProps === null || tooltipProps === void 0 ? void 0 : tooltipProps.exitDelay) || 0, distance: (tooltipProps === null || tooltipProps === void 0 ? void 0 : tooltipProps.distance) || 8, animationDuration: (tooltipProps === null || tooltipProps === void 0 ? void 0 : tooltipProps.animationDuration) || 0 }, tooltipProps),
72
- react_1.default.createElement(react_core_1.Button, Object.assign({ variant: "plain", className: `pf-chatbot__button--microphone ${isListening ? 'pf-chatbot__button--microphone--active' : ''} ${isCompact ? 'pf-m-compact' : ''} ${className !== null && className !== void 0 ? className : ''}`, "aria-label": props['aria-label'] || 'Microphone button', onClick: isListening ? stopListening : startListening, icon: react_1.default.createElement(react_core_1.Icon, { iconSize: isCompact ? 'lg' : 'xl', isInline: true },
72
+ react_1.default.createElement(react_core_1.Button, Object.assign({ variant: "plain", className: `pf-chatbot__button--microphone ${isListening ? 'pf-chatbot__button--microphone--active' : ''} ${isCompact ? 'pf-m-compact' : ''} ${className !== null && className !== void 0 ? className : ''}`, "aria-label": props['aria-label'] || (isListening ? 'Stop listening' : 'Use microphone'), "aria-pressed": isListening, onClick: isListening ? stopListening : startListening, icon: react_1.default.createElement(react_core_1.Icon, { iconSize: isCompact ? 'lg' : 'xl', isInline: true },
73
73
  react_1.default.createElement(microphone_icon_1.MicrophoneIcon, null)), size: isCompact ? 'sm' : undefined }, props))));
74
74
  };
75
75
  exports.MicrophoneButton = MicrophoneButton;
@@ -27,7 +27,7 @@ const SendButton = (_a) => {
27
27
  return (react_1.default.createElement(react_core_1.Tooltip, Object.assign({ id: "pf-chatbot__tooltip--send", content: tooltipContent, position: (tooltipProps === null || tooltipProps === void 0 ? void 0 : tooltipProps.position) || 'top', entryDelay: (tooltipProps === null || tooltipProps === void 0 ? void 0 : tooltipProps.entryDelay) || 0, exitDelay: (tooltipProps === null || tooltipProps === void 0 ? void 0 : tooltipProps.exitDelay) || 0, distance: (tooltipProps === null || tooltipProps === void 0 ? void 0 : tooltipProps.distance) || 8, animationDuration: (tooltipProps === null || tooltipProps === void 0 ? void 0 : tooltipProps.animationDuration) || 0,
28
28
  // prevents VO announcements of both aria label and tooltip
29
29
  aria: "none" }, tooltipProps),
30
- react_1.default.createElement(react_core_1.Button, Object.assign({ variant: "plain", className: `pf-chatbot__button--send ${isCompact ? 'pf-m-compact' : ''} ${className !== null && className !== void 0 ? className : ''}`, "aria-label": props['aria-label'] || 'Send button', onClick: onClick, icon: react_1.default.createElement(react_core_1.Icon, { iconSize: isCompact ? 'lg' : 'xl', isInline: true },
30
+ react_1.default.createElement(react_core_1.Button, Object.assign({ variant: "plain", className: `pf-chatbot__button--send ${isCompact ? 'pf-m-compact' : ''} ${className !== null && className !== void 0 ? className : ''}`, "aria-label": props['aria-label'] || 'Send', onClick: onClick, icon: react_1.default.createElement(react_core_1.Icon, { iconSize: isCompact ? 'lg' : 'xl', isInline: true },
31
31
  react_1.default.createElement(paper_plane_icon_1.PaperPlaneIcon, null)), size: isCompact ? 'sm' : undefined }, props))));
32
32
  };
33
33
  exports.SendButton = SendButton;
@@ -24,23 +24,23 @@ const renderSend = (props) => {
24
24
  describe('Send button', () => {
25
25
  it('should render button correctly', () => {
26
26
  renderSend();
27
- expect(react_2.screen.getByRole('button', { name: 'Send button' })).toBeTruthy();
27
+ expect(react_2.screen.getByRole('button', { name: 'Send' })).toBeTruthy();
28
28
  });
29
29
  it('should handle onClick correctly', () => __awaiter(void 0, void 0, void 0, function* () {
30
30
  const spy = jest.fn();
31
31
  (0, react_2.render)(react_1.default.createElement(SendButton_1.SendButton, { onClick: spy }));
32
- yield user_event_1.default.click(react_2.screen.getByRole('button', { name: 'Send button' }));
32
+ yield user_event_1.default.click(react_2.screen.getByRole('button', { name: 'Send' }));
33
33
  expect(react_2.screen.getByRole('tooltip', { name: 'Send' })).toBeTruthy();
34
34
  expect(spy).toHaveBeenCalledTimes(1);
35
35
  }));
36
36
  it('should handle custom tooltip correctly', () => __awaiter(void 0, void 0, void 0, function* () {
37
37
  (0, react_2.render)(react_1.default.createElement(SendButton_1.SendButton, { onClick: jest.fn, tooltipContent: "Test" }));
38
- yield user_event_1.default.click(react_2.screen.getByRole('button', { name: 'Send button' }));
38
+ yield user_event_1.default.click(react_2.screen.getByRole('button', { name: 'Send' }));
39
39
  expect(react_2.screen.getByRole('tooltip', { name: 'Test' })).toBeTruthy();
40
40
  }));
41
41
  it('should handle className prop', () => {
42
42
  renderSend({ className: 'test' });
43
- expect(react_2.screen.getByRole('button', { name: 'Send button' })).toHaveClass('test');
43
+ expect(react_2.screen.getByRole('button', { name: 'Send' })).toHaveClass('test');
44
44
  });
45
45
  it('should handle spread props, including aria-label', () => {
46
46
  renderSend({ 'aria-label': 'test' });
@@ -48,7 +48,7 @@ describe('Send button', () => {
48
48
  });
49
49
  it('should handle tooltipProps prop', () => __awaiter(void 0, void 0, void 0, function* () {
50
50
  renderSend({ tooltipProps: { id: 'test' } });
51
- yield user_event_1.default.click(react_2.screen.getByRole('button', { name: 'Send button' }));
51
+ yield user_event_1.default.click(react_2.screen.getByRole('button', { name: 'Send' }));
52
52
  expect(react_2.screen.getByRole('tooltip', { name: 'Send' })).toHaveAttribute('id', 'test');
53
53
  }));
54
54
  it('should handle isCompact', () => {
@@ -26,7 +26,7 @@ const StopButton = (_a) => {
26
26
  return (react_1.default.createElement(react_core_1.Tooltip, Object.assign({ id: "pf-chatbot__tooltip--stop", content: tooltipContent, position: (tooltipProps === null || tooltipProps === void 0 ? void 0 : tooltipProps.position) || 'top', entryDelay: (tooltipProps === null || tooltipProps === void 0 ? void 0 : tooltipProps.entryDelay) || 0, exitDelay: (tooltipProps === null || tooltipProps === void 0 ? void 0 : tooltipProps.exitDelay) || 0, distance: (tooltipProps === null || tooltipProps === void 0 ? void 0 : tooltipProps.distance) || 8, animationDuration: (tooltipProps === null || tooltipProps === void 0 ? void 0 : tooltipProps.animationDuration) || 0,
27
27
  // prevents VO announcements of both aria label and tooltip
28
28
  aria: "none" }, tooltipProps),
29
- react_1.default.createElement(react_core_1.Button, Object.assign({ className: `pf-chatbot__button--stop ${isCompact ? 'pf-m-compact' : ''} ${className !== null && className !== void 0 ? className : ''}`, variant: "link", "aria-label": props['aria-label'] || 'Stop button', onClick: onClick, icon: react_1.default.createElement(react_core_1.Icon, { iconSize: isCompact ? 'lg' : 'xl', isInline: true },
29
+ react_1.default.createElement(react_core_1.Button, Object.assign({ className: `pf-chatbot__button--stop ${isCompact ? 'pf-m-compact' : ''} ${className !== null && className !== void 0 ? className : ''}`, variant: "link", "aria-label": props['aria-label'] || 'Stop', onClick: onClick, icon: react_1.default.createElement(react_core_1.Icon, { iconSize: isCompact ? 'lg' : 'xl', isInline: true },
30
30
  react_1.default.createElement("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg" },
31
31
  react_1.default.createElement("path", { d: "M0.5 3C0.5 1.62109 1.62109 0.5 3 0.5H13C14.3789 0.5 15.5 1.62109 15.5 3V13C15.5 14.3789 14.3789 15.5 13 15.5H3C1.62109 15.5 0.5 14.3789 0.5 13V3Z", fill: "currentColor" }))), size: isCompact ? 'sm' : undefined }, props))));
32
32
  };
@@ -24,23 +24,23 @@ const renderStop = (props) => {
24
24
  describe('Stop button', () => {
25
25
  it('should render button correctly', () => {
26
26
  renderStop();
27
- expect(react_2.screen.getByRole('button', { name: 'Stop button' })).toBeTruthy();
27
+ expect(react_2.screen.getByRole('button', { name: 'Stop' })).toBeTruthy();
28
28
  });
29
29
  it('should handle onClick correctly', () => __awaiter(void 0, void 0, void 0, function* () {
30
30
  const spy = jest.fn();
31
31
  (0, react_2.render)(react_1.default.createElement(StopButton_1.StopButton, { onClick: spy }));
32
- yield user_event_1.default.click(react_2.screen.getByRole('button', { name: 'Stop button' }));
32
+ yield user_event_1.default.click(react_2.screen.getByRole('button', { name: 'Stop' }));
33
33
  expect(react_2.screen.getByRole('tooltip', { name: 'Stop' })).toBeTruthy();
34
34
  expect(spy).toHaveBeenCalledTimes(1);
35
35
  }));
36
36
  it('should handle custom tooltip correctly', () => __awaiter(void 0, void 0, void 0, function* () {
37
37
  (0, react_2.render)(react_1.default.createElement(StopButton_1.StopButton, { onClick: jest.fn, tooltipContent: "Test" }));
38
- yield user_event_1.default.click(react_2.screen.getByRole('button', { name: 'Stop button' }));
38
+ yield user_event_1.default.click(react_2.screen.getByRole('button', { name: 'Stop' }));
39
39
  expect(react_2.screen.getByRole('tooltip', { name: 'Test' })).toBeTruthy();
40
40
  }));
41
41
  it('should handle className prop', () => {
42
42
  renderStop({ className: 'test' });
43
- expect(react_2.screen.getByRole('button', { name: 'Stop button' })).toHaveClass('test');
43
+ expect(react_2.screen.getByRole('button', { name: 'Stop' })).toHaveClass('test');
44
44
  });
45
45
  it('should handle spread props, including aria-label', () => {
46
46
  renderStop({ 'aria-label': 'test' });
@@ -48,7 +48,7 @@ describe('Stop button', () => {
48
48
  });
49
49
  it('should handle tooltipProps prop', () => __awaiter(void 0, void 0, void 0, function* () {
50
50
  renderStop({ tooltipProps: { id: 'test' } });
51
- yield user_event_1.default.click(react_2.screen.getByRole('button', { name: 'Stop button' }));
51
+ yield user_event_1.default.click(react_2.screen.getByRole('button', { name: 'Stop' }));
52
52
  expect(react_2.screen.getByRole('tooltip', { name: 'Stop' })).toHaveAttribute('id', 'test');
53
53
  }));
54
54
  it('should handle isCompact', () => {
@@ -12,6 +12,6 @@ const react_core_1 = require("@patternfly/react-core");
12
12
  const arrow_up_icon_1 = require("@patternfly/react-icons/dist/esm/icons/arrow-up-icon");
13
13
  const arrow_down_icon_1 = require("@patternfly/react-icons/dist/esm/icons/arrow-down-icon");
14
14
  const JumpButton = ({ position, isHidden, onClick }) => isHidden ? null : (react_1.default.createElement(react_core_1.Tooltip, { id: `pf-chatbot__tooltip--jump-${position}`, content: `Back to ${position}`, position: "top" },
15
- react_1.default.createElement(react_core_1.Button, { variant: "plain", className: `pf-chatbot__jump pf-chatbot__jump--${position}`, "aria-label": `Jump ${position} button`, onClick: onClick },
15
+ react_1.default.createElement(react_core_1.Button, { variant: "plain", className: `pf-chatbot__jump pf-chatbot__jump--${position}`, "aria-label": `Jump ${position}`, onClick: onClick },
16
16
  react_1.default.createElement(react_core_1.Icon, { iconSize: "lg", isInline: true }, position === 'top' ? react_1.default.createElement(arrow_up_icon_1.ArrowUpIcon, null) : react_1.default.createElement(arrow_down_icon_1.ArrowDownIcon, null)))));
17
17
  exports.default = JumpButton;
@@ -20,20 +20,20 @@ const user_event_1 = __importDefault(require("@testing-library/user-event"));
20
20
  describe('JumpButton', () => {
21
21
  it('should render top button correctly', () => {
22
22
  (0, react_2.render)(react_1.default.createElement(JumpButton_1.default, { position: "top", onClick: jest.fn() }));
23
- expect(react_2.screen.getByRole('button', { name: /Jump top button/i })).toBeTruthy();
23
+ expect(react_2.screen.getByRole('button', { name: /Jump top/i })).toBeTruthy();
24
24
  });
25
25
  it('should render bottom button correctly', () => {
26
26
  (0, react_2.render)(react_1.default.createElement(JumpButton_1.default, { position: "bottom", onClick: jest.fn() }));
27
- expect(react_2.screen.getByRole('button', { name: /Jump bottom button/i })).toBeTruthy();
27
+ expect(react_2.screen.getByRole('button', { name: /Jump bottom/i })).toBeTruthy();
28
28
  });
29
29
  it('should call onClick appropriately', () => __awaiter(void 0, void 0, void 0, function* () {
30
30
  const spy = jest.fn();
31
31
  (0, react_2.render)(react_1.default.createElement(JumpButton_1.default, { position: "bottom", onClick: spy }));
32
- yield user_event_1.default.click(react_2.screen.getByRole('button', { name: /Jump bottom button/i }));
32
+ yield user_event_1.default.click(react_2.screen.getByRole('button', { name: /Jump bottom/i }));
33
33
  expect(spy).toHaveBeenCalledTimes(1);
34
34
  }));
35
35
  it('should be hidden if isHidden prop is used', () => __awaiter(void 0, void 0, void 0, function* () {
36
36
  (0, react_2.render)(react_1.default.createElement(JumpButton_1.default, { position: "bottom", onClick: jest.fn(), isHidden: true }));
37
- expect(react_2.screen.queryByRole('button', { name: /Jump bottom button/i })).toBeFalsy();
37
+ expect(react_2.screen.queryByRole('button', { name: /Jump bottom/i })).toBeFalsy();
38
38
  }));
39
39
  });
@@ -40,7 +40,7 @@ describe('MessageBox', () => {
40
40
  Object.defineProperty(region, 'scrollTop', { configurable: true, value: 0 });
41
41
  region.dispatchEvent(new Event('scroll'));
42
42
  yield (0, react_2.waitFor)(() => {
43
- user_event_1.default.click(react_2.screen.getByRole('button', { name: /Jump bottom button/i }));
43
+ user_event_1.default.click(react_2.screen.getByRole('button', { name: /Jump bottom/i }));
44
44
  expect(spy).toHaveBeenCalled();
45
45
  });
46
46
  }));
@@ -58,7 +58,7 @@ describe('MessageBox', () => {
58
58
  });
59
59
  region.dispatchEvent(new Event('scroll'));
60
60
  yield (0, react_2.waitFor)(() => {
61
- user_event_1.default.click(react_2.screen.getByRole('button', { name: /Jump top button/i }));
61
+ user_event_1.default.click(react_2.screen.getByRole('button', { name: /Jump top/i }));
62
62
  expect(spy).toHaveBeenCalled();
63
63
  });
64
64
  }));
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
- import { TooltipProps } from '@patternfly/react-core';
3
- export interface ResponseActionButtonProps {
2
+ import { ButtonProps, TooltipProps } from '@patternfly/react-core';
3
+ export interface ResponseActionButtonProps extends ButtonProps {
4
4
  /** Aria-label for the button. Defaults to the value of the tooltipContent if none provided */
5
5
  ariaLabel?: string;
6
6
  /** Aria-label for the button, shown when the button is clicked. Defaults to the value of ariaLabel or tooltipContent if not provided. */
@@ -26,9 +26,12 @@ export interface ActionProps extends Omit<ButtonProps, 'ref'> {
26
26
  /** Id for content controlled by the button, such as the feedback form */
27
27
  'aria-controls'?: string;
28
28
  }
29
+ type ExtendedActionProps = ActionProps & {
30
+ [key: string]: any;
31
+ };
29
32
  export interface ResponseActionProps {
30
33
  /** Props for message actions, such as feedback (positive or negative), copy button, share, and listen */
31
- actions: Record<string, ActionProps | undefined> & {
34
+ actions: Record<string, ExtendedActionProps | undefined> & {
32
35
  positive?: ActionProps;
33
36
  negative?: ActionProps;
34
37
  copy?: ActionProps;
@@ -39,14 +39,14 @@ const ResponseActions = ({ actions }) => {
39
39
  onClick && onClick(e);
40
40
  };
41
41
  return (react_1.default.createElement("div", { ref: responseActions, className: "pf-chatbot__response-actions" },
42
- positive && (react_1.default.createElement(ResponseActionButton_1.default, { ariaLabel: (_a = positive.ariaLabel) !== null && _a !== void 0 ? _a : 'Good response', clickedAriaLabel: (_b = positive.ariaLabel) !== null && _b !== void 0 ? _b : 'Response recorded', onClick: (e) => handleClick(e, 'positive', positive.onClick), className: positive.className, isDisabled: positive.isDisabled, tooltipContent: (_c = positive.tooltipContent) !== null && _c !== void 0 ? _c : 'Good response', clickedTooltipContent: (_d = positive.clickedTooltipContent) !== null && _d !== void 0 ? _d : 'Response recorded', tooltipProps: positive.tooltipProps, icon: react_1.default.createElement(react_icons_1.OutlinedThumbsUpIcon, null), isClicked: activeButton === 'positive', ref: positive.ref, "aria-expanded": positive['aria-expanded'], "aria-controls": positive['aria-controls'] })),
43
- negative && (react_1.default.createElement(ResponseActionButton_1.default, { ariaLabel: (_e = negative.ariaLabel) !== null && _e !== void 0 ? _e : 'Bad response', clickedAriaLabel: (_f = negative.ariaLabel) !== null && _f !== void 0 ? _f : 'Response recorded', onClick: (e) => handleClick(e, 'negative', negative.onClick), className: negative.className, isDisabled: negative.isDisabled, tooltipContent: (_g = negative.tooltipContent) !== null && _g !== void 0 ? _g : 'Bad response', clickedTooltipContent: (_h = negative.clickedTooltipContent) !== null && _h !== void 0 ? _h : 'Response recorded', tooltipProps: negative.tooltipProps, icon: react_1.default.createElement(react_icons_1.OutlinedThumbsDownIcon, null), isClicked: activeButton === 'negative', ref: negative.ref, "aria-expanded": negative['aria-expanded'], "aria-controls": negative['aria-controls'] })),
44
- copy && (react_1.default.createElement(ResponseActionButton_1.default, { ariaLabel: (_j = copy.ariaLabel) !== null && _j !== void 0 ? _j : 'Copy', clickedAriaLabel: (_k = copy.ariaLabel) !== null && _k !== void 0 ? _k : 'Copied', onClick: (e) => handleClick(e, 'copy', copy.onClick), className: copy.className, isDisabled: copy.isDisabled, tooltipContent: (_l = copy.tooltipContent) !== null && _l !== void 0 ? _l : 'Copy', clickedTooltipContent: (_m = copy.clickedTooltipContent) !== null && _m !== void 0 ? _m : 'Copied', tooltipProps: copy.tooltipProps, icon: react_1.default.createElement(react_icons_1.OutlinedCopyIcon, null), isClicked: activeButton === 'copy', ref: copy.ref, "aria-expanded": copy['aria-expanded'], "aria-controls": copy['aria-controls'] })),
45
- share && (react_1.default.createElement(ResponseActionButton_1.default, { ariaLabel: (_o = share.ariaLabel) !== null && _o !== void 0 ? _o : 'Share', clickedAriaLabel: (_p = share.ariaLabel) !== null && _p !== void 0 ? _p : 'Shared', onClick: (e) => handleClick(e, 'share', share.onClick), className: share.className, isDisabled: share.isDisabled, tooltipContent: (_q = share.tooltipContent) !== null && _q !== void 0 ? _q : 'Share', clickedTooltipContent: (_r = share.clickedTooltipContent) !== null && _r !== void 0 ? _r : 'Shared', tooltipProps: share.tooltipProps, icon: react_1.default.createElement(react_icons_1.ExternalLinkAltIcon, null), isClicked: activeButton === 'share', ref: share.ref, "aria-expanded": share['aria-expanded'], "aria-controls": share['aria-controls'] })),
46
- listen && (react_1.default.createElement(ResponseActionButton_1.default, { ariaLabel: (_s = listen.ariaLabel) !== null && _s !== void 0 ? _s : 'Listen', clickedAriaLabel: (_t = listen.ariaLabel) !== null && _t !== void 0 ? _t : 'Listening', onClick: (e) => handleClick(e, 'listen', listen.onClick), className: listen.className, isDisabled: listen.isDisabled, tooltipContent: (_u = listen.tooltipContent) !== null && _u !== void 0 ? _u : 'Listen', clickedTooltipContent: (_v = listen.clickedTooltipContent) !== null && _v !== void 0 ? _v : 'Listening', tooltipProps: listen.tooltipProps, icon: react_1.default.createElement(react_icons_1.VolumeUpIcon, null), isClicked: activeButton === 'listen', ref: listen.ref, "aria-expanded": listen['aria-expanded'], "aria-controls": listen['aria-controls'] })),
42
+ positive && (react_1.default.createElement(ResponseActionButton_1.default, Object.assign({}, positive, { ariaLabel: (_a = positive.ariaLabel) !== null && _a !== void 0 ? _a : 'Good response', clickedAriaLabel: (_b = positive.ariaLabel) !== null && _b !== void 0 ? _b : 'Response recorded', onClick: (e) => handleClick(e, 'positive', positive.onClick), className: positive.className, isDisabled: positive.isDisabled, tooltipContent: (_c = positive.tooltipContent) !== null && _c !== void 0 ? _c : 'Good response', clickedTooltipContent: (_d = positive.clickedTooltipContent) !== null && _d !== void 0 ? _d : 'Response recorded', tooltipProps: positive.tooltipProps, icon: react_1.default.createElement(react_icons_1.OutlinedThumbsUpIcon, null), isClicked: activeButton === 'positive', ref: positive.ref, "aria-expanded": positive['aria-expanded'], "aria-controls": positive['aria-controls'] }))),
43
+ negative && (react_1.default.createElement(ResponseActionButton_1.default, Object.assign({}, negative, { ariaLabel: (_e = negative.ariaLabel) !== null && _e !== void 0 ? _e : 'Bad response', clickedAriaLabel: (_f = negative.ariaLabel) !== null && _f !== void 0 ? _f : 'Response recorded', onClick: (e) => handleClick(e, 'negative', negative.onClick), className: negative.className, isDisabled: negative.isDisabled, tooltipContent: (_g = negative.tooltipContent) !== null && _g !== void 0 ? _g : 'Bad response', clickedTooltipContent: (_h = negative.clickedTooltipContent) !== null && _h !== void 0 ? _h : 'Response recorded', tooltipProps: negative.tooltipProps, icon: react_1.default.createElement(react_icons_1.OutlinedThumbsDownIcon, null), isClicked: activeButton === 'negative', ref: negative.ref, "aria-expanded": negative['aria-expanded'], "aria-controls": negative['aria-controls'] }))),
44
+ copy && (react_1.default.createElement(ResponseActionButton_1.default, Object.assign({}, copy, { ariaLabel: (_j = copy.ariaLabel) !== null && _j !== void 0 ? _j : 'Copy', clickedAriaLabel: (_k = copy.ariaLabel) !== null && _k !== void 0 ? _k : 'Copied', onClick: (e) => handleClick(e, 'copy', copy.onClick), className: copy.className, isDisabled: copy.isDisabled, tooltipContent: (_l = copy.tooltipContent) !== null && _l !== void 0 ? _l : 'Copy', clickedTooltipContent: (_m = copy.clickedTooltipContent) !== null && _m !== void 0 ? _m : 'Copied', tooltipProps: copy.tooltipProps, icon: react_1.default.createElement(react_icons_1.OutlinedCopyIcon, null), isClicked: activeButton === 'copy', ref: copy.ref, "aria-expanded": copy['aria-expanded'], "aria-controls": copy['aria-controls'] }))),
45
+ share && (react_1.default.createElement(ResponseActionButton_1.default, Object.assign({}, share, { ariaLabel: (_o = share.ariaLabel) !== null && _o !== void 0 ? _o : 'Share', clickedAriaLabel: (_p = share.ariaLabel) !== null && _p !== void 0 ? _p : 'Shared', onClick: (e) => handleClick(e, 'share', share.onClick), className: share.className, isDisabled: share.isDisabled, tooltipContent: (_q = share.tooltipContent) !== null && _q !== void 0 ? _q : 'Share', clickedTooltipContent: (_r = share.clickedTooltipContent) !== null && _r !== void 0 ? _r : 'Shared', tooltipProps: share.tooltipProps, icon: react_1.default.createElement(react_icons_1.ExternalLinkAltIcon, null), isClicked: activeButton === 'share', ref: share.ref, "aria-expanded": share['aria-expanded'], "aria-controls": share['aria-controls'] }))),
46
+ listen && (react_1.default.createElement(ResponseActionButton_1.default, Object.assign({}, listen, { ariaLabel: (_s = listen.ariaLabel) !== null && _s !== void 0 ? _s : 'Listen', clickedAriaLabel: (_t = listen.ariaLabel) !== null && _t !== void 0 ? _t : 'Listening', onClick: (e) => handleClick(e, 'listen', listen.onClick), className: listen.className, isDisabled: listen.isDisabled, tooltipContent: (_u = listen.tooltipContent) !== null && _u !== void 0 ? _u : 'Listen', clickedTooltipContent: (_v = listen.clickedTooltipContent) !== null && _v !== void 0 ? _v : 'Listening', tooltipProps: listen.tooltipProps, icon: react_1.default.createElement(react_icons_1.VolumeUpIcon, null), isClicked: activeButton === 'listen', ref: listen.ref, "aria-expanded": listen['aria-expanded'], "aria-controls": listen['aria-controls'] }))),
47
47
  Object.keys(additionalActions).map((action) => {
48
48
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
49
- return (react_1.default.createElement(ResponseActionButton_1.default, { key: action, ariaLabel: (_a = additionalActions[action]) === null || _a === void 0 ? void 0 : _a.ariaLabel, clickedAriaLabel: (_b = additionalActions[action]) === null || _b === void 0 ? void 0 : _b.clickedAriaLabel, onClick: (e) => { var _a; return handleClick(e, action, (_a = additionalActions[action]) === null || _a === void 0 ? void 0 : _a.onClick); }, className: (_c = additionalActions[action]) === null || _c === void 0 ? void 0 : _c.className, isDisabled: (_d = additionalActions[action]) === null || _d === void 0 ? void 0 : _d.isDisabled, tooltipContent: (_e = additionalActions[action]) === null || _e === void 0 ? void 0 : _e.tooltipContent, tooltipProps: (_f = additionalActions[action]) === null || _f === void 0 ? void 0 : _f.tooltipProps, clickedTooltipContent: (_g = additionalActions[action]) === null || _g === void 0 ? void 0 : _g.clickedTooltipContent, icon: (_h = additionalActions[action]) === null || _h === void 0 ? void 0 : _h.icon, isClicked: activeButton === action, ref: (_j = additionalActions[action]) === null || _j === void 0 ? void 0 : _j.ref, "aria-expanded": (_k = additionalActions[action]) === null || _k === void 0 ? void 0 : _k['aria-expanded'], "aria-controls": (_l = additionalActions[action]) === null || _l === void 0 ? void 0 : _l['aria-controls'] }));
49
+ return (react_1.default.createElement(ResponseActionButton_1.default, Object.assign({}, additionalActions[action], { key: action, ariaLabel: (_a = additionalActions[action]) === null || _a === void 0 ? void 0 : _a.ariaLabel, clickedAriaLabel: (_b = additionalActions[action]) === null || _b === void 0 ? void 0 : _b.clickedAriaLabel, onClick: (e) => { var _a; return handleClick(e, action, (_a = additionalActions[action]) === null || _a === void 0 ? void 0 : _a.onClick); }, className: (_c = additionalActions[action]) === null || _c === void 0 ? void 0 : _c.className, isDisabled: (_d = additionalActions[action]) === null || _d === void 0 ? void 0 : _d.isDisabled, tooltipContent: (_e = additionalActions[action]) === null || _e === void 0 ? void 0 : _e.tooltipContent, tooltipProps: (_f = additionalActions[action]) === null || _f === void 0 ? void 0 : _f.tooltipProps, clickedTooltipContent: (_g = additionalActions[action]) === null || _g === void 0 ? void 0 : _g.clickedTooltipContent, icon: (_h = additionalActions[action]) === null || _h === void 0 ? void 0 : _h.icon, isClicked: activeButton === action, ref: (_j = additionalActions[action]) === null || _j === void 0 ? void 0 : _j.ref, "aria-expanded": (_k = additionalActions[action]) === null || _k === void 0 ? void 0 : _k['aria-expanded'], "aria-controls": (_l = additionalActions[action]) === null || _l === void 0 ? void 0 : _l['aria-controls'] })));
50
50
  })));
51
51
  };
52
52
  exports.ResponseActions = ResponseActions;
@@ -52,6 +52,13 @@ const CUSTOM_ACTIONS = [
52
52
  }
53
53
  }
54
54
  ];
55
+ const ALL_ACTIONS_DATA_TEST = [
56
+ { type: 'positive', label: 'Good response', dataTestId: 'positive' },
57
+ { type: 'negative', label: 'Bad response', dataTestId: 'negative' },
58
+ { type: 'copy', label: 'Copy', dataTestId: 'copy' },
59
+ { type: 'share', label: 'Share', dataTestId: 'share' },
60
+ { type: 'listen', label: 'Listen', dataTestId: 'listen' }
61
+ ];
55
62
  describe('ResponseActions', () => {
56
63
  afterEach(() => {
57
64
  jest.clearAllMocks();
@@ -161,6 +168,12 @@ describe('ResponseActions', () => {
161
168
  expect(react_2.screen.getByRole('button', { name: label })).toHaveClass('test');
162
169
  });
163
170
  });
171
+ it('should be able to add custom attributes to buttons', () => {
172
+ ALL_ACTIONS_DATA_TEST.forEach(({ type, dataTestId }) => {
173
+ (0, react_2.render)(react_1.default.createElement(ResponseActions_1.default, { actions: { [type]: { onClick: jest.fn(), 'data-testid': dataTestId } } }));
174
+ expect(react_2.screen.getByTestId(dataTestId)).toBeTruthy();
175
+ });
176
+ });
164
177
  it('should be able to add custom actions', () => {
165
178
  CUSTOM_ACTIONS.forEach((action) => {
166
179
  const key = Object.keys(action)[0];
@@ -170,10 +183,12 @@ describe('ResponseActions', () => {
170
183
  onClick: action[key].onClick,
171
184
  // doing this just because it's easier to test without a regex for the button name
172
185
  ariaLabel: action[key].ariaLabel.toLowerCase(),
173
- icon: action[key].icon
186
+ icon: action[key].icon,
187
+ 'data-testid': action[key]
174
188
  }
175
189
  } }));
176
190
  expect(react_2.screen.getByRole('button', { name: key })).toBeTruthy();
191
+ expect(react_2.screen.getByTestId(action[key])).toBeTruthy();
177
192
  });
178
193
  });
179
194
  });
@@ -47,7 +47,7 @@ const CodeBlockMessage = (_a) => {
47
47
  const actions = (React.createElement(React.Fragment, null,
48
48
  React.createElement(CodeBlockAction, null,
49
49
  language && React.createElement("div", { className: "pf-chatbot__message-code-block-language" }, language),
50
- React.createElement(Button, { ref: buttonRef, "aria-label": ariaLabel !== null && ariaLabel !== void 0 ? ariaLabel : 'Copy code button', variant: "plain", className: "pf-chatbot__button--copy", onClick: (event) => handleCopy(event, children) }, copied ? React.createElement(CheckIcon, null) : React.createElement(CopyIcon, null)),
50
+ React.createElement(Button, { ref: buttonRef, "aria-label": ariaLabel !== null && ariaLabel !== void 0 ? ariaLabel : 'Copy code', variant: "plain", className: "pf-chatbot__button--copy", onClick: (event) => handleCopy(event, children) }, copied ? React.createElement(CheckIcon, null) : React.createElement(CopyIcon, null)),
51
51
  React.createElement(Tooltip, { id: tooltipID, content: "Copy", position: "top", triggerRef: buttonRef }))));
52
52
  return (React.createElement("div", { className: "pf-chatbot__message-code-block" },
53
53
  React.createElement(CodeBlock, { actions: actions },
@@ -391,7 +391,7 @@ describe('Message', () => {
391
391
  it('should render code correctly', () => {
392
392
  render(React.createElement(Message, { avatar: "./img", role: "user", name: "User", content: CODE_MESSAGE }));
393
393
  expect(screen.getByText('Here is some YAML code:')).toBeTruthy();
394
- expect(screen.getByRole('button', { name: 'Copy code button' })).toBeTruthy();
394
+ expect(screen.getByRole('button', { name: 'Copy code' })).toBeTruthy();
395
395
  expect(screen.getByText(/yaml/)).toBeTruthy();
396
396
  expect(screen.getByText(/apiVersion:/i)).toBeTruthy();
397
397
  expect(screen.getByText(/helm.openshift.io\/v1beta1/i)).toBeTruthy();
@@ -407,8 +407,8 @@ describe('Message', () => {
407
407
  // need explicit setup since RTL stubs clipboard if you do this
408
408
  const user = userEvent.setup();
409
409
  render(React.createElement(Message, { avatar: "./img", role: "user", name: "User", content: CODE_MESSAGE }));
410
- expect(screen.getByRole('button', { name: 'Copy code button' })).toBeTruthy();
411
- yield user.click(screen.getByRole('button', { name: 'Copy code button' }));
410
+ expect(screen.getByRole('button', { name: 'Copy code' })).toBeTruthy();
411
+ yield user.click(screen.getByRole('button', { name: 'Copy code' }));
412
412
  const clipboardText = yield navigator.clipboard.readText();
413
413
  expect(clipboardText.trim()).toEqual(CODE.trim());
414
414
  }));
@@ -28,7 +28,7 @@ const AttachButtonBase = (_a) => {
28
28
  React.createElement(Tooltip, Object.assign({ id: "pf-chatbot__tooltip--attach", content: tooltipContent, position: "top", entryDelay: (tooltipProps === null || tooltipProps === void 0 ? void 0 : tooltipProps.entryDelay) || 0, exitDelay: (tooltipProps === null || tooltipProps === void 0 ? void 0 : tooltipProps.exitDelay) || 0, distance: (tooltipProps === null || tooltipProps === void 0 ? void 0 : tooltipProps.distance) || 8, animationDuration: (tooltipProps === null || tooltipProps === void 0 ? void 0 : tooltipProps.animationDuration) || 0,
29
29
  // prevents VO announcements of both aria label and tooltip
30
30
  aria: "none" }, tooltipProps),
31
- React.createElement(Button, Object.assign({ variant: "plain", ref: innerRef, className: `pf-chatbot__button--attach ${isCompact ? 'pf-m-compact' : ''} ${className !== null && className !== void 0 ? className : ''}`, "aria-label": props['aria-label'] || 'Attach button', isDisabled: isDisabled, onClick: onClick !== null && onClick !== void 0 ? onClick : open, icon: React.createElement(Icon, { iconSize: isCompact ? 'lg' : 'xl', isInline: true },
31
+ React.createElement(Button, Object.assign({ variant: "plain", ref: innerRef, className: `pf-chatbot__button--attach ${isCompact ? 'pf-m-compact' : ''} ${className !== null && className !== void 0 ? className : ''}`, "aria-label": props['aria-label'] || 'Attach', isDisabled: isDisabled, onClick: onClick !== null && onClick !== void 0 ? onClick : open, icon: React.createElement(Icon, { iconSize: isCompact ? 'lg' : 'xl', isInline: true },
32
32
  React.createElement(PaperclipIcon, null)), size: isCompact ? 'sm' : undefined }, props)))));
33
33
  };
34
34
  export const AttachButton = React.forwardRef((props, ref) => (React.createElement(AttachButtonBase, Object.assign({ innerRef: ref }, props))));