@patternfly/chatbot 6.3.0-prerelease.10 → 6.3.0-prerelease.11
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/dist/cjs/Message/CodeBlockMessage/CodeBlockMessage.js +1 -1
- package/dist/cjs/Message/Message.test.js +3 -3
- package/dist/cjs/MessageBar/AttachButton.js +1 -1
- package/dist/cjs/MessageBar/AttachButton.test.js +7 -7
- package/dist/cjs/MessageBar/MessageBar.test.js +29 -29
- package/dist/cjs/MessageBar/MicrophoneButton.js +1 -1
- package/dist/cjs/MessageBar/SendButton.js +1 -1
- package/dist/cjs/MessageBar/SendButton.test.js +5 -5
- package/dist/cjs/MessageBar/StopButton.js +1 -1
- package/dist/cjs/MessageBar/StopButton.test.js +5 -5
- package/dist/cjs/MessageBox/JumpButton.js +1 -1
- package/dist/cjs/MessageBox/JumpButton.test.js +4 -4
- package/dist/cjs/MessageBox/MessageBox.test.js +2 -2
- package/dist/esm/Message/CodeBlockMessage/CodeBlockMessage.js +1 -1
- package/dist/esm/Message/Message.test.js +3 -3
- package/dist/esm/MessageBar/AttachButton.js +1 -1
- package/dist/esm/MessageBar/AttachButton.test.js +7 -7
- package/dist/esm/MessageBar/MessageBar.test.js +29 -29
- package/dist/esm/MessageBar/MicrophoneButton.js +1 -1
- package/dist/esm/MessageBar/SendButton.js +1 -1
- package/dist/esm/MessageBar/SendButton.test.js +5 -5
- package/dist/esm/MessageBar/StopButton.js +1 -1
- package/dist/esm/MessageBar/StopButton.test.js +5 -5
- package/dist/esm/MessageBox/JumpButton.js +1 -1
- package/dist/esm/MessageBox/JumpButton.test.js +4 -4
- package/dist/esm/MessageBox/MessageBox.test.js +2 -2
- package/package.json +1 -1
- package/src/Message/CodeBlockMessage/CodeBlockMessage.tsx +1 -1
- package/src/Message/Message.test.tsx +3 -3
- package/src/MessageBar/AttachButton.test.tsx +7 -7
- package/src/MessageBar/AttachButton.tsx +1 -1
- package/src/MessageBar/MessageBar.test.tsx +29 -29
- package/src/MessageBar/MicrophoneButton.tsx +2 -1
- package/src/MessageBar/SendButton.test.tsx +5 -5
- package/src/MessageBar/SendButton.tsx +1 -1
- package/src/MessageBar/StopButton.test.tsx +5 -5
- package/src/MessageBar/StopButton.tsx +1 -1
- package/src/MessageBox/JumpButton.test.tsx +4 -4
- package/src/MessageBox/JumpButton.tsx +1 -1
- package/src/MessageBox/MessageBox.test.tsx +2 -2
@@ -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
|
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
|
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
|
416
|
-
yield user.click(react_2.screen.getByRole('button', { name: 'Copy code
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
57
|
-
expect(react_2.screen.queryByRole('button', { name: 'Send
|
58
|
-
expect(react_2.screen.queryByRole('button', { name: '
|
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
|
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
|
100
|
-
expect(react_2.screen.getByRole('button', { name: 'Send
|
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
|
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
|
116
|
-
expect(react_2.screen.getByRole('button', { name: 'Send
|
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
|
121
|
-
expect(react_2.screen.getByRole('button', { name: 'Send
|
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
|
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
|
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
|
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
|
180
|
-
yield user_event_1.default.click(react_2.screen.getByRole('button', { name: 'Attach
|
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
|
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
|
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
|
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
|
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
|
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: '
|
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: '
|
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: '
|
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: '
|
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: '
|
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
|
253
|
-
expect(react_2.screen.getByRole('button', { name: 'Send
|
254
|
-
expect(react_2.screen.queryByRole('button', { name: '
|
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'] || '
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
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}
|
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
|
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
|
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
|
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
|
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
|
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
|
61
|
+
user_event_1.default.click(react_2.screen.getByRole('button', { name: /Jump top/i }));
|
62
62
|
expect(spy).toHaveBeenCalled();
|
63
63
|
});
|
64
64
|
}));
|
@@ -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
|
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
|
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
|
411
|
-
yield user.click(screen.getByRole('button', { name: 'Copy code
|
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
|
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))));
|
@@ -15,11 +15,11 @@ import { AttachButton } from './AttachButton';
|
|
15
15
|
describe('Attach button', () => {
|
16
16
|
it('should render button correctly', () => {
|
17
17
|
render(React.createElement(AttachButton, null));
|
18
|
-
expect(screen.getByRole('button', { name: 'Attach
|
18
|
+
expect(screen.getByRole('button', { name: 'Attach' })).toBeTruthy();
|
19
19
|
});
|
20
20
|
it('should handle isDisabled prop', () => {
|
21
21
|
render(React.createElement(AttachButton, { isDisabled: true }));
|
22
|
-
expect(screen.getByRole('button', { name: 'Attach
|
22
|
+
expect(screen.getByRole('button', { name: 'Attach' })).toBeDisabled();
|
23
23
|
});
|
24
24
|
it('should handle spread props, including aria-label', () => {
|
25
25
|
render(React.createElement(AttachButton, { "aria-label": "test" }));
|
@@ -28,22 +28,22 @@ describe('Attach button', () => {
|
|
28
28
|
it('should handle onClick', () => __awaiter(void 0, void 0, void 0, function* () {
|
29
29
|
const spy = jest.fn();
|
30
30
|
render(React.createElement(AttachButton, { onClick: spy }));
|
31
|
-
yield userEvent.click(screen.getByRole('button', { name: 'Attach
|
31
|
+
yield userEvent.click(screen.getByRole('button', { name: 'Attach' }));
|
32
32
|
expect(screen.getByRole('tooltip', { name: 'Attach' })).toBeTruthy();
|
33
33
|
expect(spy).toHaveBeenCalledTimes(1);
|
34
34
|
}));
|
35
35
|
it('should handle className prop', () => {
|
36
36
|
render(React.createElement(AttachButton, { className: "test" }));
|
37
|
-
expect(screen.getByRole('button', { name: 'Attach
|
37
|
+
expect(screen.getByRole('button', { name: 'Attach' })).toHaveClass('test');
|
38
38
|
});
|
39
39
|
it('should handle custom tooltip correctly', () => __awaiter(void 0, void 0, void 0, function* () {
|
40
40
|
render(React.createElement(AttachButton, { onClick: jest.fn, tooltipContent: "Test" }));
|
41
|
-
yield userEvent.click(screen.getByRole('button', { name: 'Attach
|
41
|
+
yield userEvent.click(screen.getByRole('button', { name: 'Attach' }));
|
42
42
|
expect(screen.getByRole('tooltip', { name: 'Test' })).toBeTruthy();
|
43
43
|
}));
|
44
44
|
it('should handle tooltipProps prop', () => __awaiter(void 0, void 0, void 0, function* () {
|
45
45
|
render(React.createElement(AttachButton, { tooltipProps: { id: 'test' } }));
|
46
|
-
yield userEvent.click(screen.getByRole('button', { name: 'Attach
|
46
|
+
yield userEvent.click(screen.getByRole('button', { name: 'Attach' }));
|
47
47
|
expect(screen.getByRole('tooltip', { name: 'Attach' })).toHaveAttribute('id', 'test');
|
48
48
|
}));
|
49
49
|
// Based on this because I had no idea how to do this and was looking around: https://stackoverflow.com/a/75562651
|
@@ -51,7 +51,7 @@ describe('Attach button', () => {
|
|
51
51
|
it('should handle onAttachAccepted prop', () => __awaiter(void 0, void 0, void 0, function* () {
|
52
52
|
const spy = jest.fn();
|
53
53
|
render(React.createElement(AttachButton, { onAttachAccepted: spy, inputTestId: "input" }));
|
54
|
-
yield userEvent.click(screen.getByRole('button', { name: 'Attach
|
54
|
+
yield userEvent.click(screen.getByRole('button', { name: 'Attach' }));
|
55
55
|
const file = new File(['test'], 'test.json');
|
56
56
|
const input = screen.getByTestId('input');
|
57
57
|
yield userEvent.upload(input, file);
|