@patternfly/chatbot 6.4.0-prerelease.14 → 6.4.0-prerelease.16

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 (30) hide show
  1. package/dist/cjs/ChatbotConversationHistoryNav/ChatbotConversationHistoryDropdown.js +1 -1
  2. package/dist/cjs/ChatbotConversationHistoryNav/ChatbotConversationHistoryDropdown.test.js +6 -6
  3. package/dist/cjs/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.d.ts +13 -12
  4. package/dist/cjs/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.js +17 -5
  5. package/dist/cjs/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.test.js +24 -20
  6. package/dist/cjs/SourcesCard/SourcesCard.d.ts +13 -1
  7. package/dist/cjs/SourcesCard/SourcesCard.js +6 -6
  8. package/dist/cjs/SourcesCard/SourcesCard.test.js +49 -0
  9. package/dist/css/main.css +43 -30
  10. package/dist/css/main.css.map +1 -1
  11. package/dist/esm/ChatbotConversationHistoryNav/ChatbotConversationHistoryDropdown.js +1 -1
  12. package/dist/esm/ChatbotConversationHistoryNav/ChatbotConversationHistoryDropdown.test.js +6 -6
  13. package/dist/esm/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.d.ts +13 -12
  14. package/dist/esm/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.js +18 -6
  15. package/dist/esm/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.test.js +24 -20
  16. package/dist/esm/SourcesCard/SourcesCard.d.ts +13 -1
  17. package/dist/esm/SourcesCard/SourcesCard.js +6 -6
  18. package/dist/esm/SourcesCard/SourcesCard.test.js +50 -1
  19. package/package.json +2 -2
  20. package/patternfly-docs/content/extensions/chatbot/examples/Messages/MessageWithSources.tsx +70 -0
  21. package/patternfly-docs/content/extensions/chatbot/examples/Messages/Messages.md +1 -1
  22. package/patternfly-docs/patternfly-docs.config.js +1 -1
  23. package/src/ChatbotConversationHistoryNav/ChatbotConversationHistoryDropdown.test.tsx +6 -6
  24. package/src/ChatbotConversationHistoryNav/ChatbotConversationHistoryDropdown.tsx +1 -0
  25. package/src/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.scss +28 -36
  26. package/src/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.test.tsx +32 -18
  27. package/src/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.tsx +74 -60
  28. package/src/SourcesCard/SourcesCard.scss +17 -0
  29. package/src/SourcesCard/SourcesCard.test.tsx +93 -0
  30. package/src/SourcesCard/SourcesCard.tsx +116 -80
@@ -42,61 +42,53 @@
42
42
  }
43
43
  // Drawer menu
44
44
  // ----------------------------------------------------------------------------
45
- .pf-chatbot__conversation-list {
46
- --pf-v6-c-list--Gap: var(--pf-t--global--spacer--xs);
47
-
48
- margin-block-start: var(--pf-t--global--spacer--md);
49
- margin-block-end: var(--pf-t--global--spacer--md);
45
+ .pf-v6-c-menu {
46
+ --pf-v6-c-menu--PaddingBlockStart: 0;
47
+ --pf-v6-c-menu--BackgroundColor: var(--pf-t--global--background--color--floating--default);
48
+ overflow: initial;
49
+ position: relative;
50
+ }
51
+ .pf-v6-c-menu__item-main {
52
+ --pf-v6-c-menu__item-main--ColumnGap: var(--pf-t--global--spacer--md);
50
53
  }
51
54
 
52
- .pf-chatbot__conversation-list-header {
55
+ .pf-chatbot__menu-item-header > .pf-v6-c-menu__group-title {
53
56
  color: var(--pf-t--global--text--color--subtle);
54
57
  font-weight: var(--pf-t--global--font--weight--body--bold);
55
58
  font-size: var(--pf-t--global--icon--size--font--sm);
56
- padding-inline-start: var(--pf-t--global--spacer--sm);
57
- padding-inline-end: var(--pf-t--global--spacer--sm);
59
+ --pf-v6-c-menu__group-title--PaddingInlineStart: var(--pf-t--global--spacer--sm);
60
+ --pf-v6-c-menu__group-title--PaddingInlineEnd: var(--pf-t--global--spacer--sm);
58
61
  position: -webkit-sticky;
59
62
  position: sticky;
60
63
  top: 0;
61
64
  background-color: var(--pf-t--global--background--color--floating--default);
62
65
  z-index: var(--pf-t--global--z-index--md);
63
66
  }
64
- .pf-chatbot__conversation-list-item {
65
- & > span {
66
- display: flex;
67
- column-gap: var(--pf-t--global--spacer--sm);
68
- }
69
-
70
- & .pf-chatbot__conversation-history-item {
71
- --pf-v6-c-button--JustifyContent: flex-start;
72
- --pf-v6-c-button--FontSize: var(--pf-t--global--font--size--body--lg);
73
- --pf-v6-c-button--m-link--Color: var(--pf-t--global--text--color--regular);
74
- --pf-v6-c-button--m-link__icon--Color: var(--pf-t--global--icon--color--regular);
75
- --pf-v6-c-button--m-link--hover--Color: var(--pf-t--global--text--color--regular--hover);
76
- --pf-v6-c-button--m-link--hover__icon--Color: var(--pf-t--global--icon--color--regular);
77
- --pf-v6-c-button--m-link--m-clicked--Color: var(--pf-t--global--text--color--regular--clicked);
78
- --pf-v6-c-button--m-link--m-clicked__icon--Color: var(--pf-t--global--icon--color--regular);
79
67
 
80
- column-gap: var(--pf-t--global--spacer--md);
81
- flex-basis: 100%;
82
-
83
- & .pf-v6-c-button__text {
84
- overflow: hidden;
85
- text-overflow: ellipsis;
86
- white-space: nowrap;
87
- }
88
- }
68
+ .pf-chatbot__menu-item {
69
+ --pf-v6-c-menu__item--PaddingInlineStart: var(--pf-t--global--spacer--sm);
70
+ --pf-v6-c-menu__item--PaddingInlineEnd: var(--pf-t--global--spacer--sm);
71
+ padding-block-start: var(--pf-t--global--spacer--xs);
72
+ padding-block-end: var(--pf-t--global--spacer--xs);
73
+ color: var(--pf-t--global--text--color--regular);
74
+ font-size: var(--pf-t--global--font--size--body--lg);
75
+ font-weight: var(--pf-t--global--font--weight--body--default);
76
+ border-radius: var(--pf-t--global--border--radius--small);
77
+ }
78
+ // allows focus state to have border radius
79
+ .pf-v6-c-menu__list-item.pf-chatbot__menu-item {
80
+ overflow: hidden;
89
81
  }
90
82
 
91
83
  .pf-chatbot__history-actions {
92
84
  transform: rotate(90deg);
93
85
  }
94
86
 
95
- .pf-chatbot__conversation-list-item--active {
87
+ .pf-chatbot__menu-item--active {
96
88
  background-color: var(--pf-t--global--background--color--action--plain--clicked);
97
89
  }
98
90
 
99
- button.pf-chatbot__conversation-list-item--active {
91
+ button.pf-chatbot__menu-item--active {
100
92
  background-color: initial;
101
93
  }
102
94
  }
@@ -259,8 +251,8 @@
259
251
  }
260
252
  }
261
253
 
262
- .pf-chatbot__conversation-history-item {
263
- --pf-v6-c-button--FontSize: var(--pf-t--global--font--size--body--md);
254
+ .pf-chatbot__menu-item {
255
+ font-size: var(--pf-t--global--font--size--body--md);
264
256
  }
265
257
 
266
258
  .pf-v6-c-drawer__head {
@@ -492,36 +492,36 @@ describe('ChatbotConversationHistoryNav', () => {
492
492
  expect(iconElement).toBeInTheDocument();
493
493
  });
494
494
 
495
- it('Passes listTitleProps to Title', () => {
495
+ it('Passes menuProps to Menu', () => {
496
496
  render(
497
497
  <ChatbotConversationHistoryNav
498
498
  onDrawerToggle={onDrawerToggle}
499
499
  isDrawerOpen={true}
500
500
  displayMode={ChatbotDisplayMode.fullscreen}
501
501
  setIsDrawerOpen={jest.fn()}
502
- conversations={{ Today: initialConversations }}
503
- listTitleProps={{ className: 'test' }}
502
+ conversations={initialConversations}
503
+ menuProps={{ className: 'test' }}
504
504
  />
505
505
  );
506
- expect(screen.getByRole('heading', { name: /Today/i })).toHaveClass('test');
506
+
507
+ expect(screen.getByRole('menu').parentElement?.parentElement).toHaveClass('test');
507
508
  });
508
509
 
509
- it('Overrides list title heading level when titleProps.headingLevel is passed', () => {
510
+ it('Passes menuContentProps to MenuContent', () => {
510
511
  render(
511
512
  <ChatbotConversationHistoryNav
512
513
  onDrawerToggle={onDrawerToggle}
513
514
  isDrawerOpen={true}
514
515
  displayMode={ChatbotDisplayMode.fullscreen}
515
516
  setIsDrawerOpen={jest.fn()}
516
- conversations={{ Today: initialConversations }}
517
- listTitleProps={{ headingLevel: 'h2' }}
517
+ conversations={initialConversations}
518
+ menuContentProps={{ className: 'test' }}
518
519
  />
519
520
  );
520
- expect(screen.queryByRole('heading', { name: /Today/i, level: 4 })).not.toBeInTheDocument();
521
- expect(screen.getByRole('heading', { name: /Today/i, level: 2 })).toBeInTheDocument();
521
+ expect(screen.getByRole('menu').parentElement).toHaveClass('test');
522
522
  });
523
523
 
524
- it('Passes listProps to List when conversations is an array', () => {
524
+ it('Passes menuListProps to MenuList when conversations is an array', () => {
525
525
  render(
526
526
  <ChatbotConversationHistoryNav
527
527
  onDrawerToggle={onDrawerToggle}
@@ -529,13 +529,27 @@ describe('ChatbotConversationHistoryNav', () => {
529
529
  displayMode={ChatbotDisplayMode.fullscreen}
530
530
  setIsDrawerOpen={jest.fn()}
531
531
  conversations={initialConversations}
532
- listProps={{ className: 'test' }}
532
+ menuListProps={{ className: 'test' }}
533
+ />
534
+ );
535
+ expect(screen.getByRole('menu')).toHaveClass('test');
536
+ });
537
+
538
+ it('Passes menuListProps to MenuList when conversations is an object', () => {
539
+ render(
540
+ <ChatbotConversationHistoryNav
541
+ onDrawerToggle={onDrawerToggle}
542
+ isDrawerOpen={true}
543
+ displayMode={ChatbotDisplayMode.fullscreen}
544
+ setIsDrawerOpen={jest.fn()}
545
+ conversations={{ Today: initialConversations }}
546
+ menuListProps={{ Today: { className: 'test' } }}
533
547
  />
534
548
  );
535
- expect(screen.getByRole('list')).toHaveClass('test');
549
+ expect(screen.getByRole('menu')).toHaveClass('test');
536
550
  });
537
551
 
538
- it('Passes listProps to List when conversations is an object', () => {
552
+ it('Passes menuGroupProps to MenuGroup when conversations is an object', () => {
539
553
  render(
540
554
  <ChatbotConversationHistoryNav
541
555
  onDrawerToggle={onDrawerToggle}
@@ -543,23 +557,23 @@ describe('ChatbotConversationHistoryNav', () => {
543
557
  displayMode={ChatbotDisplayMode.fullscreen}
544
558
  setIsDrawerOpen={jest.fn()}
545
559
  conversations={{ Today: initialConversations }}
546
- listProps={{ Today: { className: 'test' } }}
560
+ menuGroupProps={{ Today: { className: 'test' } }}
547
561
  />
548
562
  );
549
- expect(screen.getByRole('list')).toHaveClass('test');
563
+ expect(screen.getByRole('menu').parentElement).toHaveClass('test');
550
564
  });
551
565
 
552
- it('Passes listItemProps to ListItem', () => {
566
+ it('Passes additionalProps to MenuItem', () => {
553
567
  render(
554
568
  <ChatbotConversationHistoryNav
555
569
  onDrawerToggle={onDrawerToggle}
556
570
  isDrawerOpen={true}
557
571
  displayMode={ChatbotDisplayMode.fullscreen}
558
572
  setIsDrawerOpen={jest.fn()}
559
- conversations={[{ id: '1', text: 'ChatBot documentation', listItemProps: { className: 'test' } }]}
573
+ conversations={[{ id: '1', text: 'ChatBot documentation', additionalProps: { className: 'test' } }]}
560
574
  />
561
575
  );
562
- expect(screen.getByRole('listitem')).toHaveClass('test');
576
+ expect(screen.getByRole('menuitem')).toHaveClass('test');
563
577
  });
564
578
 
565
579
  it('should be able to spread search input props when searchInputProps is passed', () => {
@@ -2,7 +2,6 @@
2
2
  // Chatbot Header - Chatbot Conversation History Nav
3
3
  // ============================================================================
4
4
  import type { KeyboardEvent, FunctionComponent } from 'react';
5
-
6
5
  import { useRef, Fragment } from 'react';
7
6
 
8
7
  // Import PatternFly components
@@ -19,9 +18,6 @@ import {
19
18
  DrawerCloseButton,
20
19
  DrawerContentBody,
21
20
  SearchInput,
22
- List,
23
- ListItem,
24
- ListItemProps,
25
21
  Title,
26
22
  DrawerPanelContentProps,
27
23
  DrawerContentProps,
@@ -32,10 +28,18 @@ import {
32
28
  DrawerPanelBodyProps,
33
29
  SkeletonProps,
34
30
  Icon,
35
- MenuProps, // Remove in next breaking change
31
+ MenuProps,
36
32
  TitleProps,
37
- ListProps,
38
- SearchInputProps
33
+ MenuListProps,
34
+ SearchInputProps,
35
+ MenuList,
36
+ MenuGroup,
37
+ MenuItem,
38
+ Menu,
39
+ MenuContent,
40
+ MenuItemProps,
41
+ MenuGroupProps,
42
+ MenuContentProps
39
43
  } from '@patternfly/react-core';
40
44
 
41
45
  import { OutlinedClockIcon, OutlinedCommentAltIcon, PenToSquareIcon } from '@patternfly/react-icons';
@@ -61,10 +65,8 @@ export interface Conversation {
61
65
  label?: string;
62
66
  /** Callback for when user selects item. */
63
67
  onSelect?: (event?: React.MouseEvent, value?: string | number) => void;
64
- /** Additional props passed to conversation button item */
65
- additionalProps?: ButtonProps;
66
- /** Additional props passed to conversation list item */
67
- listItemProps?: Omit<ListItemProps, 'children'>;
68
+ /** Additional props passed to menu item */
69
+ additionalProps?: MenuItemProps;
68
70
  /** Custom dropdown ID to ensure uniqueness across demo instances */
69
71
  dropdownId?: string;
70
72
  }
@@ -83,10 +85,10 @@ export interface ChatbotConversationHistoryNavProps extends DrawerProps {
83
85
  conversations: Conversation[] | { [key: string]: Conversation[] };
84
86
  /** Additional button props for new chat button. */
85
87
  newChatButtonProps?: ButtonProps;
86
- /** Additional props applied to all conversation list headers */
87
- listTitleProps?: Partial<TitleProps>;
88
- /** Additional props applied to conversation list. If conversations is an object, you should pass an object of ListProps for each group. */
89
- listProps?: ListProps | { [key: string]: ListProps };
88
+ /** Additional props applied to conversation menu group. If conversations is an object, you should pass an object of MenuGroupProps for each group. */
89
+ menuGroupProps?: MenuGroupProps | { [key: string]: MenuGroupProps };
90
+ /** Additional props applied to conversation list. If conversations is an object, you should pass an object of MenuListProps for each group. */
91
+ menuListProps?: Omit<MenuListProps, 'children'> | { [key: string]: Omit<MenuListProps, 'children'> };
90
92
  /** Text shown in blue button */
91
93
  newChatButtonText?: string;
92
94
  /** Callback function for when blue button is clicked. Omit to hide blue "new chat button" */
@@ -107,7 +109,7 @@ export interface ChatbotConversationHistoryNavProps extends DrawerProps {
107
109
  reverseButtonOrder?: boolean;
108
110
  /** Custom test id for the drawer actions */
109
111
  drawerActionsTestId?: string;
110
- /** @deprecated Additional props applied to list container */
112
+ /** Additional props applied to menu */
111
113
  menuProps?: MenuProps;
112
114
  /** Additional props applied to panel */
113
115
  drawerPanelContentProps?: DrawerPanelContentProps;
@@ -143,6 +145,8 @@ export interface ChatbotConversationHistoryNavProps extends DrawerProps {
143
145
  navTitleProps?: Partial<TitleProps>;
144
146
  /** Visually hidden text that gets announced by assistive technologies. Should be used to convey the result count when the search input value changes. */
145
147
  searchInputScreenReaderText?: string;
148
+ /** Additional props passed to MenuContent */
149
+ menuContentProps?: Omit<MenuContentProps, 'ref'>;
146
150
  }
147
151
 
148
152
  export const ChatbotConversationHistoryNav: FunctionComponent<ChatbotConversationHistoryNavProps> = ({
@@ -152,8 +156,7 @@ export const ChatbotConversationHistoryNav: FunctionComponent<ChatbotConversatio
152
156
  activeItemId,
153
157
  onSelectActiveItem,
154
158
  conversations,
155
- listTitleProps,
156
- listProps,
159
+ menuListProps,
157
160
  newChatButtonText = 'New chat',
158
161
  drawerContent,
159
162
  onNewChat,
@@ -182,6 +185,9 @@ export const ChatbotConversationHistoryNav: FunctionComponent<ChatbotConversatio
182
185
  navTitleProps,
183
186
  navTitleIcon = <OutlinedClockIcon />,
184
187
  searchInputScreenReaderText,
188
+ menuProps,
189
+ menuGroupProps,
190
+ menuContentProps,
185
191
  ...props
186
192
  }: ChatbotConversationHistoryNavProps) => {
187
193
  const drawerRef = useRef<HTMLDivElement>(null);
@@ -190,61 +196,65 @@ export const ChatbotConversationHistoryNav: FunctionComponent<ChatbotConversatio
190
196
  drawerRef.current && drawerRef.current.focus();
191
197
  };
192
198
 
199
+ const isConversation = (item: any): item is Conversation =>
200
+ item && typeof item === 'object' && 'id' in item && 'text' in item;
201
+
193
202
  const getNavItem = (conversation: Conversation) => (
194
- <ListItem
195
- className={`pf-chatbot__conversation-list-item ${activeItemId && activeItemId === conversation.id ? 'pf-chatbot__conversation-list-item--active' : ''}`}
196
- key={conversation.id}
197
- {...conversation.listItemProps}
198
- /* eslint-enable indent */
203
+ <MenuItem
204
+ className={`pf-chatbot__menu-item ${activeItemId && activeItemId === conversation.id ? 'pf-chatbot__menu-item--active' : ''}`}
205
+ itemId={conversation.id}
206
+ {...(conversation.noIcon ? {} : { icon: conversation.icon ?? <OutlinedCommentAltIcon /> })}
207
+ /* eslint-disable indent */
208
+ {...(conversation.menuItems
209
+ ? {
210
+ actions: (
211
+ <ConversationHistoryDropdown
212
+ menuClassName={conversation.menuClassName}
213
+ onSelect={conversation.onSelect}
214
+ menuItems={conversation.menuItems}
215
+ label={conversation.label}
216
+ />
217
+ )
218
+ }
219
+ : {})}
220
+ {...conversation.additionalProps}
199
221
  >
200
- <>
201
- <Button
202
- className="pf-chatbot__conversation-history-item"
203
- variant="link"
204
- {...conversation.additionalProps}
205
- {...(conversation.noIcon ? {} : { icon: conversation.icon ?? <OutlinedCommentAltIcon /> })}
206
- onClick={(event) => onSelectActiveItem?.(event, conversation.id)}
207
- >
208
- {conversation.text}
209
- </Button>
210
- {conversation.menuItems && (
211
- <ConversationHistoryDropdown
212
- menuClassName={conversation.menuClassName}
213
- onSelect={conversation.onSelect}
214
- menuItems={conversation.menuItems}
215
- label={conversation.label}
216
- id={conversation.dropdownId}
217
- />
218
- )}
219
- </>
220
- </ListItem>
222
+ {conversation.text}
223
+ </MenuItem>
221
224
  );
222
225
 
223
226
  const buildConversations = () => {
224
227
  if (Array.isArray(conversations)) {
225
228
  return (
226
- <List className="pf-chatbot__conversation-list" isPlain {...listProps}>
227
- {conversations.map((conversation) => (
228
- <Fragment key={conversation.id}>{getNavItem(conversation)}</Fragment>
229
- ))}
230
- </List>
229
+ <MenuList {...menuListProps}>
230
+ {conversations.map((conversation) => {
231
+ if (isConversation(conversation)) {
232
+ return <Fragment key={conversation.id}>{getNavItem(conversation)}</Fragment>;
233
+ } else {
234
+ return conversation;
235
+ }
236
+ })}
237
+ </MenuList>
231
238
  );
232
239
  } else {
233
240
  return (
234
- <div>
241
+ <>
235
242
  {Object.keys(conversations).map((navGroup) => (
236
- <section key={navGroup}>
237
- <Title headingLevel="h4" className="pf-chatbot__conversation-list-header" {...listTitleProps}>
238
- {navGroup}
239
- </Title>
240
- <List className="pf-chatbot__conversation-list" isPlain {...listProps?.[navGroup]}>
241
- {conversations[navGroup].map((conversation) => (
243
+ <MenuGroup
244
+ className="pf-chatbot__menu-item-header"
245
+ label={navGroup}
246
+ key={navGroup}
247
+ labelHeadingLevel="h3"
248
+ {...menuGroupProps?.[navGroup]}
249
+ >
250
+ <MenuList {...menuListProps?.[navGroup]}>
251
+ {conversations[navGroup].map((conversation: Conversation) => (
242
252
  <Fragment key={conversation.id}>{getNavItem(conversation)}</Fragment>
243
253
  ))}
244
- </List>
245
- </section>
254
+ </MenuList>
255
+ </MenuGroup>
246
256
  ))}
247
- </div>
257
+ </>
248
258
  );
249
259
  }
250
260
  };
@@ -264,7 +274,11 @@ export const ChatbotConversationHistoryNav: FunctionComponent<ChatbotConversatio
264
274
  if (noResultsState) {
265
275
  return <HistoryEmptyState {...noResultsState} />;
266
276
  }
267
- return <>{buildConversations()}</>;
277
+ return (
278
+ <Menu isPlain onSelect={onSelectActiveItem} activeItemId={activeItemId} {...menuProps}>
279
+ <MenuContent {...menuContentProps}>{buildConversations()}</MenuContent>
280
+ </Menu>
281
+ );
268
282
  };
269
283
 
270
284
  const renderDrawerContent = () => (
@@ -16,6 +16,17 @@
16
16
  box-shadow: var(--pf-t--global--box-shadow--sm);
17
17
  }
18
18
 
19
+ .pf-chatbot__compact-sources-card-body {
20
+ --pf-v6-c-card--child--PaddingBlockEnd: var(--pf-t--global--spacer--xs);
21
+ }
22
+
23
+ .pf-chatbot__sources-card-subtitle,
24
+ .pf-chatbot__sources-card-subtle {
25
+ color: var(--pf-t--global--text--color--subtle);
26
+ font-size: var(--pf-t--global--font--size--body--sm);
27
+ font-weight: var(--pf-t--global--font--weight--body--default);
28
+ }
29
+
19
30
  .pf-chatbot__sources-card-body-text {
20
31
  display: block;
21
32
  display: -webkit-box;
@@ -27,6 +38,12 @@
27
38
  text-overflow: ellipsis;
28
39
  }
29
40
 
41
+ .pf-chatbot__sources-card-title-container {
42
+ display: flex;
43
+ flex-direction: column;
44
+ gap: var(--pf-t--global--spacer--xs);
45
+ }
46
+
30
47
  .pf-chatbot__sources-card-footer-container {
31
48
  border-top: var(--pf-t--global--border--width--regular) solid var(--pf-t--global--border--color--default);
32
49
  padding: var(--pf-t--global--spacer--sm) var(--pf-t--global--spacer--md) var(--pf-t--global--spacer--sm)
@@ -256,4 +256,97 @@ describe('SourcesCard', () => {
256
256
  );
257
257
  expect(screen.getByRole('link', { name: /How to make an apple pie/i })).toHaveClass('test');
258
258
  });
259
+
260
+ it('should apply cardTitleProps appropriately', () => {
261
+ render(
262
+ <SourcesCard
263
+ cardTitleProps={{ 'data-testid': 'card-title', className: 'test' } as any}
264
+ sources={[{ title: 'How to make an apple pie', link: '' }]}
265
+ />
266
+ );
267
+ expect(screen.getByTestId('card-title')).toHaveClass('test');
268
+ });
269
+
270
+ it('should apply cardBodyProps appropriately', () => {
271
+ render(
272
+ <SourcesCard
273
+ cardBodyProps={
274
+ { 'data-testid': 'card-body', body: 'To make an apple pie, you must first...', className: 'test' } as any
275
+ }
276
+ sources={[{ title: 'How to make an apple pie', link: '', body: 'To make an apple pie, you must first...' }]}
277
+ />
278
+ );
279
+ expect(screen.getByTestId('card-body')).toHaveClass('test');
280
+ });
281
+
282
+ it('should apply cardFooterProps appropriately', () => {
283
+ render(
284
+ <SourcesCard
285
+ cardFooterProps={{ 'data-testid': 'card-footer', className: 'test' } as any}
286
+ sources={[
287
+ { title: 'How to make an apple pie', link: '' },
288
+ { title: 'How to make cookies', link: '' }
289
+ ]}
290
+ />
291
+ );
292
+ expect(screen.getByTestId('card-footer')).toHaveClass('test');
293
+ });
294
+
295
+ it('should apply truncateProps appropriately', () => {
296
+ render(
297
+ <SourcesCard
298
+ sources={[
299
+ {
300
+ title: 'How to make an apple pie',
301
+ link: '',
302
+ truncateProps: { 'data-testid': 'card-truncate', className: 'test' } as any
303
+ }
304
+ ]}
305
+ />
306
+ );
307
+ expect(screen.getByTestId('card-truncate')).toHaveClass('test');
308
+ });
309
+
310
+ it('should apply custom footer appropriately when there is one source', () => {
311
+ render(
312
+ <SourcesCard sources={[{ title: 'How to make an apple pie', link: '', footer: <>I am a custom footer</> }]} />
313
+ );
314
+ expect(screen.getByText('I am a custom footer'));
315
+ expect(screen.queryByText('1/1')).toBeFalsy();
316
+ });
317
+
318
+ it('should apply custom footer appropriately when are multiple sources', () => {
319
+ render(
320
+ <SourcesCard
321
+ sources={[
322
+ { title: 'How to make an apple pie', link: '', footer: <>I am a custom footer</> },
323
+ { title: 'How to bake bread', link: '' }
324
+ ]}
325
+ />
326
+ );
327
+ expect(screen.getByText('I am a custom footer'));
328
+ // does not show navigation bar
329
+ expect(screen.queryByText('1/2')).toBeFalsy();
330
+ });
331
+
332
+ it('should apply footer props to custom footer appropriately', () => {
333
+ render(
334
+ <SourcesCard
335
+ cardFooterProps={{ 'data-testid': 'card-footer', className: 'test' } as any}
336
+ sources={[{ title: 'How to make an apple pie', link: '', footer: <>I am a custom footer</> }]}
337
+ />
338
+ );
339
+ expect(screen.getByText('I am a custom footer'));
340
+ expect(screen.getByTestId('card-footer')).toHaveClass('test');
341
+ });
342
+
343
+ it('should apply subtitle appropriately', () => {
344
+ render(
345
+ <SourcesCard
346
+ sources={[{ title: 'How to make an apple pie', link: '', subtitle: 'You must first create the universe' }]}
347
+ />
348
+ );
349
+ expect(screen.getByText('How to make an apple pie'));
350
+ expect(screen.getByText('You must first create the universe'));
351
+ });
259
352
  });