@patternfly/chatbot 2.2.0-prerelease.15 → 2.2.0-prerelease.17
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/AttachmentEdit/AttachmentEdit.test.d.ts +1 -0
- package/dist/cjs/AttachmentEdit/AttachmentEdit.test.js +52 -0
- package/dist/cjs/Chatbot/Chatbot.test.d.ts +1 -0
- package/dist/cjs/Chatbot/Chatbot.test.js +28 -0
- package/dist/cjs/ChatbotAlert/ChatbotAlert.test.d.ts +1 -0
- package/dist/cjs/ChatbotAlert/ChatbotAlert.test.js +27 -0
- package/dist/cjs/ChatbotContent/ChatbotContent.test.d.ts +1 -0
- package/dist/cjs/ChatbotContent/ChatbotContent.test.js +18 -0
- package/dist/cjs/ChatbotFooter/ChatbotFooter.test.d.ts +1 -0
- package/dist/cjs/ChatbotFooter/ChatbotFooter.test.js +18 -0
- package/dist/cjs/ChatbotFooter/ChatbotFooternote.test.d.ts +1 -0
- package/dist/cjs/ChatbotFooter/ChatbotFooternote.test.js +87 -0
- package/dist/cjs/ChatbotHeader/ChatbotHeader.test.d.ts +1 -0
- package/dist/cjs/ChatbotHeader/ChatbotHeader.test.js +18 -0
- package/dist/cjs/ChatbotHeader/ChatbotHeaderActions.test.d.ts +1 -0
- package/dist/cjs/ChatbotHeader/ChatbotHeaderActions.test.js +18 -0
- package/dist/cjs/ChatbotHeader/ChatbotHeaderCloseButton.test.d.ts +1 -0
- package/dist/cjs/ChatbotHeader/ChatbotHeaderCloseButton.test.js +20 -0
- package/dist/cjs/ChatbotHeader/ChatbotHeaderMain.test.d.ts +1 -0
- package/dist/cjs/ChatbotHeader/ChatbotHeaderMain.test.js +18 -0
- package/dist/cjs/ChatbotHeader/ChatbotHeaderMenu.test.d.ts +1 -0
- package/dist/cjs/ChatbotHeader/ChatbotHeaderMenu.test.js +20 -0
- package/dist/cjs/ChatbotHeader/ChatbotHeaderOptionsDropdown.test.d.ts +1 -0
- package/dist/cjs/ChatbotHeader/ChatbotHeaderOptionsDropdown.test.js +43 -0
- package/dist/cjs/ChatbotHeader/ChatbotHeaderSelectorDropdown.test.d.ts +1 -0
- package/dist/cjs/ChatbotHeader/ChatbotHeaderSelectorDropdown.test.js +41 -0
- package/dist/cjs/ChatbotHeader/ChatbotHeaderTitle.test.d.ts +1 -0
- package/dist/cjs/ChatbotHeader/ChatbotHeaderTitle.test.js +47 -0
- package/dist/cjs/Message/Message.js +13 -3
- package/dist/cjs/Message/Message.test.js +38 -3
- package/dist/cjs/Message/TextMessage/TextMessage.d.ts +2 -1
- package/dist/cjs/Message/TextMessage/TextMessage.js +2 -2
- package/dist/cjs/MessageBar/MessageBar.test.js +4 -4
- package/dist/cjs/MessageBox/MessageBox.test.d.ts +1 -0
- package/dist/cjs/MessageBox/MessageBox.test.js +22 -0
- package/dist/cjs/PreviewAttachment/PreviewAttachment.test.d.ts +1 -0
- package/dist/cjs/PreviewAttachment/PreviewAttachment.test.js +28 -0
- package/dist/cjs/Settings/SettingsForm.test.d.ts +1 -0
- package/dist/cjs/Settings/SettingsForm.test.js +26 -0
- package/dist/css/main.css +30 -41
- package/dist/css/main.css.map +1 -1
- package/dist/esm/AttachmentEdit/AttachmentEdit.test.d.ts +1 -0
- package/dist/esm/AttachmentEdit/AttachmentEdit.test.js +47 -0
- package/dist/esm/Chatbot/Chatbot.test.d.ts +1 -0
- package/dist/esm/Chatbot/Chatbot.test.js +23 -0
- package/dist/esm/ChatbotAlert/ChatbotAlert.test.d.ts +1 -0
- package/dist/esm/ChatbotAlert/ChatbotAlert.test.js +22 -0
- package/dist/esm/ChatbotContent/ChatbotContent.test.d.ts +1 -0
- package/dist/esm/ChatbotContent/ChatbotContent.test.js +13 -0
- package/dist/esm/ChatbotFooter/ChatbotFooter.test.d.ts +1 -0
- package/dist/esm/ChatbotFooter/ChatbotFooter.test.js +13 -0
- package/dist/esm/ChatbotFooter/ChatbotFooternote.test.d.ts +1 -0
- package/dist/esm/ChatbotFooter/ChatbotFooternote.test.js +82 -0
- package/dist/esm/ChatbotHeader/ChatbotHeader.test.d.ts +1 -0
- package/dist/esm/ChatbotHeader/ChatbotHeader.test.js +13 -0
- package/dist/esm/ChatbotHeader/ChatbotHeaderActions.test.d.ts +1 -0
- package/dist/esm/ChatbotHeader/ChatbotHeaderActions.test.js +13 -0
- package/dist/esm/ChatbotHeader/ChatbotHeaderCloseButton.test.d.ts +1 -0
- package/dist/esm/ChatbotHeader/ChatbotHeaderCloseButton.test.js +15 -0
- package/dist/esm/ChatbotHeader/ChatbotHeaderMain.test.d.ts +1 -0
- package/dist/esm/ChatbotHeader/ChatbotHeaderMain.test.js +13 -0
- package/dist/esm/ChatbotHeader/ChatbotHeaderMenu.test.d.ts +1 -0
- package/dist/esm/ChatbotHeader/ChatbotHeaderMenu.test.js +15 -0
- package/dist/esm/ChatbotHeader/ChatbotHeaderOptionsDropdown.test.d.ts +1 -0
- package/dist/esm/ChatbotHeader/ChatbotHeaderOptionsDropdown.test.js +38 -0
- package/dist/esm/ChatbotHeader/ChatbotHeaderSelectorDropdown.test.d.ts +1 -0
- package/dist/esm/ChatbotHeader/ChatbotHeaderSelectorDropdown.test.js +36 -0
- package/dist/esm/ChatbotHeader/ChatbotHeaderTitle.test.d.ts +1 -0
- package/dist/esm/ChatbotHeader/ChatbotHeaderTitle.test.js +42 -0
- package/dist/esm/Message/Message.js +14 -4
- package/dist/esm/Message/Message.test.js +38 -3
- package/dist/esm/Message/TextMessage/TextMessage.d.ts +2 -1
- package/dist/esm/Message/TextMessage/TextMessage.js +3 -3
- package/dist/esm/MessageBar/MessageBar.test.js +4 -4
- package/dist/esm/MessageBox/MessageBox.test.d.ts +1 -0
- package/dist/esm/MessageBox/MessageBox.test.js +17 -0
- package/dist/esm/PreviewAttachment/PreviewAttachment.test.d.ts +1 -0
- package/dist/esm/PreviewAttachment/PreviewAttachment.test.js +23 -0
- package/dist/esm/Settings/SettingsForm.test.d.ts +1 -0
- package/dist/esm/Settings/SettingsForm.test.js +21 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/patternfly-docs/content/extensions/chatbot/examples/Messages/BotMessage.tsx +142 -13
- package/patternfly-docs/content/extensions/chatbot/examples/Messages/UserMessage.tsx +182 -12
- package/src/AttachmentEdit/AttachmentEdit.test.tsx +55 -0
- package/src/Chatbot/Chatbot.test.tsx +31 -0
- package/src/ChatbotAlert/ChatbotAlert.test.tsx +31 -0
- package/src/ChatbotContent/ChatbotContent.test.tsx +15 -0
- package/src/ChatbotFooter/ChatbotFooter.test.tsx +15 -0
- package/src/ChatbotFooter/ChatbotFooternote.test.tsx +84 -0
- package/src/ChatbotHeader/ChatbotHeader.test.tsx +15 -0
- package/src/ChatbotHeader/ChatbotHeaderActions.test.tsx +17 -0
- package/src/ChatbotHeader/ChatbotHeaderCloseButton.test.tsx +20 -0
- package/src/ChatbotHeader/ChatbotHeaderMain.test.tsx +17 -0
- package/src/ChatbotHeader/ChatbotHeaderMenu.test.tsx +19 -0
- package/src/ChatbotHeader/ChatbotHeaderOptionsDropdown.test.tsx +45 -0
- package/src/ChatbotHeader/ChatbotHeaderSelectorDropdown.test.tsx +43 -0
- package/src/ChatbotHeader/ChatbotHeaderTitle.test.tsx +59 -0
- package/src/Message/CodeBlockMessage/CodeBlockMessage.scss +3 -3
- package/src/Message/ListMessage/ListMessage.scss +5 -5
- package/src/Message/Message.scss +3 -11
- package/src/Message/Message.test.tsx +40 -3
- package/src/Message/Message.tsx +23 -4
- package/src/Message/MessageLoading.scss +2 -2
- package/src/Message/TextMessage/TextMessage.scss +8 -11
- package/src/Message/TextMessage/TextMessage.tsx +3 -3
- package/src/MessageBar/MessageBar.test.tsx +4 -4
- package/src/MessageBox/MessageBox.test.tsx +26 -0
- package/src/PreviewAttachment/PreviewAttachment.test.tsx +51 -0
- package/src/Settings/SettingsForm.test.tsx +28 -0
@@ -0,0 +1,59 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import { render, screen } from '@testing-library/react';
|
3
|
+
import { ChatbotDisplayMode } from '../Chatbot/Chatbot';
|
4
|
+
import ChatbotHeaderTitle from './ChatbotHeaderTitle';
|
5
|
+
|
6
|
+
describe('ChatbotHeaderTitle', () => {
|
7
|
+
it('should render ChatbotHeaderTitle with children', () => {
|
8
|
+
render(<ChatbotHeaderTitle>Chatbot Header Title</ChatbotHeaderTitle>);
|
9
|
+
expect(screen.getByText('Chatbot Header Title')).toBeTruthy();
|
10
|
+
});
|
11
|
+
|
12
|
+
it('should render ChatbotHeaderTitle with custom classname', () => {
|
13
|
+
const { container } = render(
|
14
|
+
<ChatbotHeaderTitle className="custom-header-class">Chatbot Header Title</ChatbotHeaderTitle>
|
15
|
+
);
|
16
|
+
expect(container.querySelector('.custom-header-class')).toBeTruthy();
|
17
|
+
});
|
18
|
+
|
19
|
+
it('should render title for default display mode', () => {
|
20
|
+
render(<ChatbotHeaderTitle displayMode={ChatbotDisplayMode.default} showOnDefault={'Default header title'} />);
|
21
|
+
expect(screen.getByText('Default header title')).toBeTruthy();
|
22
|
+
});
|
23
|
+
|
24
|
+
it('should render title for docked display mode', () => {
|
25
|
+
render(<ChatbotHeaderTitle displayMode={ChatbotDisplayMode.docked} showOnDocked={'Docked header title'} />);
|
26
|
+
expect(screen.getByText('Docked header title')).toBeTruthy();
|
27
|
+
});
|
28
|
+
|
29
|
+
it('should fallback to default title when docked display mode title is not configured', () => {
|
30
|
+
render(<ChatbotHeaderTitle displayMode={ChatbotDisplayMode.docked} showOnDefault={'Default header title'} />);
|
31
|
+
expect(screen.getByText('Default header title')).toBeTruthy();
|
32
|
+
});
|
33
|
+
|
34
|
+
it('should render title for embedded display mode', () => {
|
35
|
+
render(<ChatbotHeaderTitle displayMode={ChatbotDisplayMode.embedded} showOnEmbedded={'Embedded header title'} />);
|
36
|
+
expect(screen.getByText('Embedded header title')).toBeTruthy();
|
37
|
+
});
|
38
|
+
|
39
|
+
it('should fallback to default title when embedded display mode title is not configured', () => {
|
40
|
+
render(<ChatbotHeaderTitle displayMode={ChatbotDisplayMode.embedded} showOnDefault={'Default header title'} />);
|
41
|
+
expect(screen.getByText('Default header title')).toBeTruthy();
|
42
|
+
});
|
43
|
+
|
44
|
+
it('should render title for fullscreen display mode', () => {
|
45
|
+
render(
|
46
|
+
<ChatbotHeaderTitle
|
47
|
+
displayMode={ChatbotDisplayMode.fullscreen}
|
48
|
+
showOnFullScreen={'Fullscreen header title'}
|
49
|
+
className="custom-header-class"
|
50
|
+
/>
|
51
|
+
);
|
52
|
+
expect(screen.getByText('Fullscreen header title')).toBeTruthy();
|
53
|
+
});
|
54
|
+
|
55
|
+
it('should fallback to default title when fullscreen display mode title is not configured', () => {
|
56
|
+
render(<ChatbotHeaderTitle displayMode={ChatbotDisplayMode.fullscreen} showOnDefault={'Default header title'} />);
|
57
|
+
expect(screen.getByText('Default header title')).toBeTruthy();
|
58
|
+
});
|
59
|
+
});
|
@@ -40,11 +40,11 @@
|
|
40
40
|
}
|
41
41
|
|
42
42
|
.pf-chatbot__button--copy.pf-v6-c-button {
|
43
|
-
color: var(--pf-t--color--white);
|
43
|
+
color: var(--pf-t--color--white); // same in light + dark theme
|
44
44
|
|
45
45
|
&:hover,
|
46
46
|
&:focus {
|
47
|
-
color: var(--pf-t--color--white);
|
47
|
+
color: var(--pf-t--color--white); // same in light + dark theme
|
48
48
|
}
|
49
49
|
}
|
50
50
|
}
|
@@ -77,6 +77,6 @@
|
|
77
77
|
}
|
78
78
|
|
79
79
|
.pf-chatbot__message-inline-code {
|
80
|
-
background-color: var(--pf-t--
|
80
|
+
background-color: var(--pf-t--global--background--color--tertiary--default);
|
81
81
|
font-size: var(--pf-t--global--font--size--body--default);
|
82
82
|
}
|
@@ -5,8 +5,8 @@
|
|
5
5
|
.pf-chatbot__message-ordered-list,
|
6
6
|
.pf-chatbot__message-unordered-list {
|
7
7
|
width: fit-content;
|
8
|
-
padding: var(--pf-t--
|
9
|
-
border-radius: var(--pf-t--
|
8
|
+
padding: var(--pf-t--global--spacer--sm) 0 var(--pf-t--global--spacer--sm) 0;
|
9
|
+
border-radius: var(--pf-t--global--border--radius--small);
|
10
10
|
|
11
11
|
.pf-v6-c-list,
|
12
12
|
ul,
|
@@ -18,8 +18,8 @@
|
|
18
18
|
.pf-chatbot__message--user {
|
19
19
|
.pf-chatbot__message-ordered-list,
|
20
20
|
.pf-chatbot__message-unordered-list {
|
21
|
-
background-color: var(--pf-t--
|
22
|
-
color: var(--pf-t--
|
23
|
-
padding: var(--pf-t--
|
21
|
+
background-color: var(--pf-t--global--color--brand--default);
|
22
|
+
color: var(--pf-t--global--text--color--on-brand--default);
|
23
|
+
padding: var(--pf-t--global--spacer--sm);
|
24
24
|
}
|
25
25
|
}
|
package/src/Message/Message.scss
CHANGED
@@ -2,14 +2,6 @@
|
|
2
2
|
// Chatbot Message
|
3
3
|
// ============================================================================
|
4
4
|
.pf-chatbot__message {
|
5
|
-
--pf-t--chatbot-message--type--background--color--default: var(--pf-t--global--background--color--tertiary--default);
|
6
|
-
--pf-t--chatbot-message--type--background--color--primary: var(--pf-t--global--color--brand--default);
|
7
|
-
--pf-t--chatbot-message--type--padding: var(--pf-t--global--spacer--sm);
|
8
|
-
--pf-t--chatbot-message--type--text--color--default: var(--pf-t--global--text--color--regular);
|
9
|
-
--pf-t--chatbot-message--type--text--color--primary: var(--pf-t--global--text--color--inverse);
|
10
|
-
--pf-t--chatbot-message--type--border--radius: var(--pf-t--global--border--radius--small);
|
11
|
-
--pf-t--chatbot-message--meta--label--color: var(--pf-t--global--border--color--on-secondary);
|
12
|
-
|
13
5
|
display: flex;
|
14
6
|
align-items: flex-start;
|
15
7
|
gap: var(--pf-t--global--spacer--lg);
|
@@ -63,12 +55,12 @@
|
|
63
55
|
|
64
56
|
// Badge
|
65
57
|
.pf-v6-c-label {
|
66
|
-
--pf-v6-c-label--m-outline--BorderColor: var(--pf-t--
|
58
|
+
--pf-v6-c-label--m-outline--BorderColor: var(--pf-t--global--border--color--on-secondary);
|
67
59
|
--pf-v6-c-label--FontSize: var(--pf-t--global--font--size--xs);
|
68
60
|
font-weight: var(--pf-t--global--font--weight--body--bold);
|
69
61
|
|
70
62
|
.pf-v6-c-label__content {
|
71
|
-
--pf-v6-c-label--Color: var(--pf-t--
|
63
|
+
--pf-v6-c-label--Color: var(--pf-t--global--border--color--on-secondary);
|
72
64
|
}
|
73
65
|
}
|
74
66
|
|
@@ -88,7 +80,7 @@
|
|
88
80
|
flex-direction: column;
|
89
81
|
align-items: flex-start;
|
90
82
|
gap: var(--pf-t--global--font--size--sm);
|
91
|
-
color: var(--pf-t--
|
83
|
+
color: var(--pf-t--global--text--color--regular);
|
92
84
|
}
|
93
85
|
|
94
86
|
&-and-actions {
|
@@ -71,6 +71,24 @@ const ORDERED_LIST_WITH_CODE = `
|
|
71
71
|
3. Item 3
|
72
72
|
`;
|
73
73
|
|
74
|
+
const HEADING = `
|
75
|
+
# h1 Heading
|
76
|
+
|
77
|
+
## h2 Heading
|
78
|
+
|
79
|
+
### h3 Heading
|
80
|
+
|
81
|
+
#### h4 Heading
|
82
|
+
|
83
|
+
##### h5 Heading
|
84
|
+
|
85
|
+
###### h6 Heading
|
86
|
+
`;
|
87
|
+
|
88
|
+
const BLOCK_QUOTES = `> Blockquotes can also be nested...
|
89
|
+
>> ...by using additional greater-than signs (>) right next to each other...
|
90
|
+
> > > ...or with spaces between each sign.`;
|
91
|
+
|
74
92
|
const checkListItemsRendered = () => {
|
75
93
|
const items = ['Item 1', 'Item 2', 'Item 3'];
|
76
94
|
expect(screen.getAllByRole('listitem')).toHaveLength(3);
|
@@ -377,13 +395,17 @@ describe('Message', () => {
|
|
377
395
|
render(<Message avatar="./img" role="user" name="User" content={CODE_MESSAGE} />);
|
378
396
|
expect(screen.getByText('Here is some YAML code:')).toBeTruthy();
|
379
397
|
expect(screen.getByRole('button', { name: 'Copy code button' })).toBeTruthy();
|
380
|
-
expect(screen.getByText(/
|
398
|
+
expect(screen.getByText(/yaml/)).toBeTruthy();
|
399
|
+
expect(screen.getByText(/apiVersion:/i)).toBeTruthy();
|
400
|
+
expect(screen.getByText(/helm.openshift.io\/v1beta1/i)).toBeTruthy();
|
381
401
|
expect(screen.getByText(/metadata:/i)).toBeTruthy();
|
382
|
-
expect(screen.getByText(/name
|
402
|
+
expect(screen.getByText(/name:/i)).toBeTruthy();
|
403
|
+
expect(screen.getByText(/azure-sample-repo0oooo00ooo/i)).toBeTruthy();
|
383
404
|
expect(screen.getByText(/spec/i)).toBeTruthy();
|
384
405
|
expect(screen.getByText(/connectionConfig:/i)).toBeTruthy();
|
406
|
+
expect(screen.getByText(/url:/i)).toBeTruthy();
|
385
407
|
expect(
|
386
|
-
screen.getByText(/
|
408
|
+
screen.getByText(/https:\/\/raw.githubusercontent.com\/Azure-Samples\/helm-charts\/master\/docs/i)
|
387
409
|
).toBeTruthy();
|
388
410
|
});
|
389
411
|
it('can click copy code button', async () => {
|
@@ -491,4 +513,19 @@ describe('Message', () => {
|
|
491
513
|
);
|
492
514
|
expect(screen.getAllByRole('img')[1]).toHaveAttribute('src', 'test.png');
|
493
515
|
});
|
516
|
+
it('should handle block quote correctly', () => {
|
517
|
+
render(<Message avatar="./img" role="user" name="User" content={BLOCK_QUOTES} />);
|
518
|
+
expect(screen.getByText(/Blockquotes can also be nested.../)).toBeTruthy();
|
519
|
+
expect(screen.getByText('...by using additional greater-than signs (>) right next to each other...')).toBeTruthy();
|
520
|
+
expect(screen.getByText(/...or with spaces between each sign./)).toBeTruthy();
|
521
|
+
});
|
522
|
+
it('should handle heading correctly', () => {
|
523
|
+
render(<Message avatar="./img" role="user" name="User" content={HEADING} />);
|
524
|
+
expect(screen.getByRole('heading', { name: /h1 Heading/i })).toBeTruthy();
|
525
|
+
expect(screen.getByRole('heading', { name: /h2 Heading/i })).toBeTruthy();
|
526
|
+
expect(screen.getByRole('heading', { name: /h3 Heading/i })).toBeTruthy();
|
527
|
+
expect(screen.getByRole('heading', { name: /h4 Heading/i })).toBeTruthy();
|
528
|
+
expect(screen.getByRole('heading', { name: /h5 Heading/i })).toBeTruthy();
|
529
|
+
expect(screen.getByRole('heading', { name: /h6 Heading/i })).toBeTruthy();
|
530
|
+
});
|
494
531
|
});
|
package/src/Message/Message.tsx
CHANGED
@@ -6,7 +6,15 @@ import React from 'react';
|
|
6
6
|
|
7
7
|
import Markdown from 'react-markdown';
|
8
8
|
import remarkGfm from 'remark-gfm';
|
9
|
-
import {
|
9
|
+
import {
|
10
|
+
Avatar,
|
11
|
+
AvatarProps,
|
12
|
+
ContentVariants,
|
13
|
+
Label,
|
14
|
+
LabelGroupProps,
|
15
|
+
Timestamp,
|
16
|
+
Truncate
|
17
|
+
} from '@patternfly/react-core';
|
10
18
|
import MessageLoading from './MessageLoading';
|
11
19
|
import CodeBlockMessage from './CodeBlockMessage/CodeBlockMessage';
|
12
20
|
import TextMessage from './TextMessage/TextMessage';
|
@@ -173,11 +181,22 @@ export const MessageBase: React.FunctionComponent<MessageProps> = ({
|
|
173
181
|
) : (
|
174
182
|
<Markdown
|
175
183
|
components={{
|
176
|
-
p: TextMessage
|
177
|
-
code: ({ children }) =>
|
184
|
+
p: (props) => <TextMessage component={ContentVariants.p} {...props} />,
|
185
|
+
code: ({ children, ...props }) => (
|
186
|
+
<CodeBlockMessage {...props} {...codeBlockProps}>
|
187
|
+
{children}
|
188
|
+
</CodeBlockMessage>
|
189
|
+
),
|
178
190
|
ul: UnorderedListMessage,
|
179
191
|
ol: (props) => <OrderedListMessage {...props} />,
|
180
|
-
li: ListItemMessage
|
192
|
+
li: ListItemMessage,
|
193
|
+
h1: (props) => <TextMessage component={ContentVariants.h1} {...props} />,
|
194
|
+
h2: (props) => <TextMessage component={ContentVariants.h2} {...props} />,
|
195
|
+
h3: (props) => <TextMessage component={ContentVariants.h3} {...props} />,
|
196
|
+
h4: (props) => <TextMessage component={ContentVariants.h4} {...props} />,
|
197
|
+
h5: (props) => <TextMessage component={ContentVariants.h5} {...props} />,
|
198
|
+
h6: (props) => <TextMessage component={ContentVariants.h6} {...props} />,
|
199
|
+
blockquote: (props) => <TextMessage component={ContentVariants.blockquote} {...props} />
|
181
200
|
}}
|
182
201
|
remarkPlugins={[remarkGfm]}
|
183
202
|
>
|
@@ -3,9 +3,9 @@
|
|
3
3
|
// ============================================================================
|
4
4
|
.pf-chatbot__message-loading {
|
5
5
|
width: 36px;
|
6
|
-
padding: var(--pf-t--
|
6
|
+
padding: var(--pf-t--global--spacer--sm);
|
7
7
|
background-color: var(--pf-t--global--background--color--tertiary--default);
|
8
|
-
border-radius: var(--pf-t--
|
8
|
+
border-radius: var(--pf-t--global--border--radius--small);
|
9
9
|
|
10
10
|
&-dots {
|
11
11
|
position: relative;
|
@@ -13,8 +13,8 @@
|
|
13
13
|
// Need to inline shorter text
|
14
14
|
.pf-chatbot__message-text {
|
15
15
|
width: fit-content;
|
16
|
-
padding: var(--pf-t--
|
17
|
-
border-radius: var(--pf-t--
|
16
|
+
padding: var(--pf-t--global--spacer--sm) 0 var(--pf-t--global--spacer--sm) 0;
|
17
|
+
border-radius: var(--pf-t--global--border--radius--small);
|
18
18
|
|
19
19
|
.pf-v6-c-content,
|
20
20
|
.pf-v6-c-content--small,
|
@@ -25,27 +25,24 @@
|
|
25
25
|
}
|
26
26
|
|
27
27
|
code {
|
28
|
-
background-color: var(--pf-t--
|
28
|
+
background-color: var(--pf-t--global--background--color--tertiary--default);
|
29
29
|
font-size: var(--pf-t--global--font--size--body--default);
|
30
30
|
}
|
31
31
|
}
|
32
32
|
|
33
33
|
.pf-chatbot__message--user {
|
34
34
|
.pf-chatbot__message-text {
|
35
|
-
background-color: var(--pf-t--
|
36
|
-
color: var(--pf-t--
|
37
|
-
|
35
|
+
background-color: var(--pf-t--global--color--brand--default);
|
36
|
+
color: var(--pf-t--global--text--color--on-brand--default);
|
37
|
+
--pf-v6-c-content--Color: var(--pf-t--global--text--color--on-brand--default);
|
38
|
+
padding: var(--pf-t--global--spacer--sm);
|
38
39
|
|
39
40
|
.pf-v6-c-content,
|
40
41
|
.pf-v6-c-content--small,
|
41
42
|
.pf-v6-c-content--blockquote,
|
42
43
|
p,
|
43
44
|
a {
|
44
|
-
color: var(--pf-t--
|
45
|
-
}
|
46
|
-
|
47
|
-
code {
|
48
|
-
background-color: initial;
|
45
|
+
color: var(--pf-t--global--text--color--on-brand--default);
|
49
46
|
}
|
50
47
|
}
|
51
48
|
}
|
@@ -4,11 +4,11 @@
|
|
4
4
|
|
5
5
|
import React from 'react';
|
6
6
|
import { ExtraProps } from 'react-markdown';
|
7
|
-
import { Content,
|
7
|
+
import { Content, ContentProps } from '@patternfly/react-core';
|
8
8
|
|
9
|
-
const TextMessage = ({ children, ...props }:
|
9
|
+
const TextMessage = ({ component, children, ...props }: ContentProps & ExtraProps) => (
|
10
10
|
<span className="pf-chatbot__message-text">
|
11
|
-
<Content component={
|
11
|
+
<Content component={component} {...props}>
|
12
12
|
{children}
|
13
13
|
</Content>
|
14
14
|
</span>
|
@@ -1,11 +1,11 @@
|
|
1
|
+
import '@testing-library/jest-dom';
|
1
2
|
import React from 'react';
|
3
|
+
import { DropdownGroup, DropdownItem, DropdownList } from '@patternfly/react-core';
|
4
|
+
import { BellIcon, CalendarAltIcon, ClipboardIcon, CodeIcon } from '@patternfly/react-icons';
|
2
5
|
import { render, screen } from '@testing-library/react';
|
3
|
-
import '@testing-library/jest-dom';
|
4
6
|
import userEvent from '@testing-library/user-event';
|
5
|
-
import { MessageBar } from './MessageBar';
|
6
|
-
import { DropdownGroup, DropdownItem, DropdownList } from '@patternfly/react-core';
|
7
7
|
import SourceDetailsMenuItem from '../SourceDetailsMenuItem';
|
8
|
-
import {
|
8
|
+
import { MessageBar } from './MessageBar';
|
9
9
|
|
10
10
|
const ATTACH_MENU_ITEMS = [
|
11
11
|
<DropdownList key="list-1">
|
@@ -0,0 +1,26 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import { render, screen } from '@testing-library/react';
|
3
|
+
import { MessageBox } from './MessageBox';
|
4
|
+
|
5
|
+
describe('MessageBox', () => {
|
6
|
+
it('should render Message box', () => {
|
7
|
+
render(
|
8
|
+
<MessageBox>
|
9
|
+
<>Chatbot Messages</>
|
10
|
+
</MessageBox>
|
11
|
+
);
|
12
|
+
expect(screen.getByText('Chatbot Messages')).toBeTruthy();
|
13
|
+
});
|
14
|
+
|
15
|
+
it('should assign ref to Message box', () => {
|
16
|
+
const ref = React.createRef<HTMLDivElement>();
|
17
|
+
render(
|
18
|
+
<MessageBox ref={ref}>
|
19
|
+
<div>Test message content</div>
|
20
|
+
</MessageBox>
|
21
|
+
);
|
22
|
+
|
23
|
+
expect(ref.current).not.toBeNull();
|
24
|
+
expect(ref.current).toBeInstanceOf(HTMLDivElement);
|
25
|
+
});
|
26
|
+
});
|
@@ -0,0 +1,51 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import { fireEvent, render, screen } from '@testing-library/react';
|
3
|
+
import { PreviewAttachment } from './PreviewAttachment';
|
4
|
+
|
5
|
+
describe('PreviewAttachment', () => {
|
6
|
+
it('should render PreviewAttachment', () => {
|
7
|
+
render(
|
8
|
+
<PreviewAttachment
|
9
|
+
code="Hello world"
|
10
|
+
fileName="greetings.txt"
|
11
|
+
isModalOpen={true}
|
12
|
+
onEdit={jest.fn()}
|
13
|
+
handleModalToggle={jest.fn()}
|
14
|
+
/>
|
15
|
+
);
|
16
|
+
expect(screen.getByText('Preview attachment')).toBeTruthy();
|
17
|
+
expect(screen.getByText('greetings')).toBeTruthy();
|
18
|
+
expect(screen.getAllByText('TEXT')).toBeTruthy();
|
19
|
+
});
|
20
|
+
|
21
|
+
it('should call onEdit handler when edit button is pressed', () => {
|
22
|
+
const onEdit = jest.fn();
|
23
|
+
render(
|
24
|
+
<PreviewAttachment
|
25
|
+
code="Hello world"
|
26
|
+
fileName="greetings.txt"
|
27
|
+
isModalOpen={true}
|
28
|
+
onEdit={onEdit}
|
29
|
+
handleModalToggle={jest.fn()}
|
30
|
+
/>
|
31
|
+
);
|
32
|
+
fireEvent.click(screen.getByText('Edit'));
|
33
|
+
|
34
|
+
expect(onEdit).toHaveBeenCalled();
|
35
|
+
});
|
36
|
+
it('should call onDismiss handler when dismiss button is pressed', () => {
|
37
|
+
const onDismiss = jest.fn();
|
38
|
+
render(
|
39
|
+
<PreviewAttachment
|
40
|
+
code="Hello world"
|
41
|
+
fileName="greetings.txt"
|
42
|
+
isModalOpen={true}
|
43
|
+
onEdit={jest.fn()}
|
44
|
+
handleModalToggle={onDismiss}
|
45
|
+
/>
|
46
|
+
);
|
47
|
+
fireEvent.click(screen.getByText('Dismiss'));
|
48
|
+
|
49
|
+
expect(onDismiss).toHaveBeenCalled();
|
50
|
+
});
|
51
|
+
});
|
@@ -0,0 +1,28 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import { Button } from '@patternfly/react-core';
|
3
|
+
import { render, screen } from '@testing-library/react';
|
4
|
+
import { SettingsForm } from './SettingsForm';
|
5
|
+
|
6
|
+
describe('SettingsForm', () => {
|
7
|
+
it('should render settingsForm with custom classname', () => {
|
8
|
+
const { container } = render(<SettingsForm className="custom-settings" />);
|
9
|
+
expect(container.querySelector('.custom-settings')).toBeTruthy();
|
10
|
+
});
|
11
|
+
|
12
|
+
it('should render settingsForm with fields', () => {
|
13
|
+
const fields = [
|
14
|
+
{
|
15
|
+
id: 'archived-chat',
|
16
|
+
label: 'Archive chat',
|
17
|
+
field: (
|
18
|
+
<Button id="archived-chat" variant="secondary">
|
19
|
+
Archive chat
|
20
|
+
</Button>
|
21
|
+
)
|
22
|
+
}
|
23
|
+
];
|
24
|
+
render(<SettingsForm fields={fields} />);
|
25
|
+
|
26
|
+
expect(screen.getByRole('button', { name: 'Archive chat' })).toBeTruthy();
|
27
|
+
});
|
28
|
+
});
|