@patternfly/chatbot 6.4.0-prerelease.23 → 6.4.0-prerelease.24

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 (32) hide show
  1. package/dist/cjs/SourcesCard/SourcesCard.js +6 -30
  2. package/dist/cjs/SourcesCard/SourcesCard.test.js +2 -211
  3. package/dist/cjs/SourcesCardBase/SourcesCardBase.d.ts +57 -0
  4. package/dist/cjs/SourcesCardBase/SourcesCardBase.js +49 -0
  5. package/dist/cjs/SourcesCardBase/SourcesCardBase.test.d.ts +1 -0
  6. package/dist/cjs/SourcesCardBase/SourcesCardBase.test.js +171 -0
  7. package/dist/cjs/SourcesCardBase/index.d.ts +2 -0
  8. package/dist/cjs/SourcesCardBase/index.js +23 -0
  9. package/dist/cjs/index.d.ts +2 -0
  10. package/dist/cjs/index.js +4 -1
  11. package/dist/css/main.css +4 -2
  12. package/dist/css/main.css.map +1 -1
  13. package/dist/dynamic/SourcesCardBase/package.json +1 -0
  14. package/dist/esm/SourcesCard/SourcesCard.js +4 -31
  15. package/dist/esm/SourcesCard/SourcesCard.test.js +3 -212
  16. package/dist/esm/SourcesCardBase/SourcesCardBase.d.ts +57 -0
  17. package/dist/esm/SourcesCardBase/SourcesCardBase.js +47 -0
  18. package/dist/esm/SourcesCardBase/SourcesCardBase.test.d.ts +1 -0
  19. package/dist/esm/SourcesCardBase/SourcesCardBase.test.js +166 -0
  20. package/dist/esm/SourcesCardBase/index.d.ts +2 -0
  21. package/dist/esm/SourcesCardBase/index.js +2 -0
  22. package/dist/esm/index.d.ts +2 -0
  23. package/dist/esm/index.js +2 -0
  24. package/dist/tsconfig.tsbuildinfo +1 -1
  25. package/package.json +1 -1
  26. package/src/SourcesCard/SourcesCard.scss +4 -1
  27. package/src/SourcesCard/SourcesCard.test.tsx +2 -327
  28. package/src/SourcesCard/SourcesCard.tsx +8 -171
  29. package/src/SourcesCardBase/SourcesCardBase.test.tsx +236 -0
  30. package/src/SourcesCardBase/SourcesCardBase.tsx +242 -0
  31. package/src/SourcesCardBase/index.ts +3 -0
  32. package/src/index.ts +3 -0
@@ -0,0 +1,166 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import { jsx as _jsx } from "react/jsx-runtime";
11
+ import { render, screen } from '@testing-library/react';
12
+ import userEvent from '@testing-library/user-event';
13
+ import '@testing-library/jest-dom';
14
+ import SourcesCardBase from './SourcesCardBase';
15
+ describe('SourcesCardBase', () => {
16
+ it('should render card correctly if one source with only a link is passed in', () => {
17
+ render(_jsx(SourcesCardBase, { sources: [{ link: '' }] }));
18
+ expect(screen.getByText('Source 1')).toBeTruthy();
19
+ // no buttons or navigation when there is only 1 source
20
+ expect(screen.queryByRole('button')).toBeFalsy();
21
+ expect(screen.queryByText('1/1')).toBeFalsy();
22
+ });
23
+ it('should render card correctly if one source with a title is passed in', () => {
24
+ render(_jsx(SourcesCardBase, { sources: [{ title: 'How to make an apple pie', link: '' }] }));
25
+ expect(screen.getByText('How to make an apple pie')).toBeTruthy();
26
+ });
27
+ it('should render card correctly if one source with a body is passed in', () => {
28
+ render(_jsx(SourcesCardBase, { sources: [{ link: '', body: 'To make an apple pie, you must first...' }] }));
29
+ expect(screen.getByText('To make an apple pie, you must first...')).toBeTruthy();
30
+ });
31
+ it('should render card correctly if one source with a title and body is passed in', () => {
32
+ render(_jsx(SourcesCardBase, { sources: [{ title: 'How to make an apple pie', link: '', body: 'To make an apple pie, you must first...' }] }));
33
+ expect(screen.getByText('How to make an apple pie')).toBeTruthy();
34
+ expect(screen.getByText('To make an apple pie, you must first...')).toBeTruthy();
35
+ });
36
+ it('should render multiple cards correctly', () => {
37
+ render(_jsx(SourcesCardBase, { sources: [
38
+ { title: 'How to make an apple pie', link: '' },
39
+ { title: 'How to make cookies', link: '' }
40
+ ] }));
41
+ expect(screen.getByText('How to make an apple pie')).toBeTruthy();
42
+ expect(screen.getByText('1/2')).toBeTruthy();
43
+ screen.getByRole('button', { name: /Go to previous page/i });
44
+ screen.getByRole('button', { name: /Go to next page/i });
45
+ });
46
+ it('should navigate between cards correctly', () => __awaiter(void 0, void 0, void 0, function* () {
47
+ render(_jsx(SourcesCardBase, { sources: [
48
+ { title: 'How to make an apple pie', link: '' },
49
+ { title: 'How to make cookies', link: '' }
50
+ ] }));
51
+ expect(screen.getByText('How to make an apple pie')).toBeTruthy();
52
+ expect(screen.getByText('1/2')).toBeTruthy();
53
+ expect(screen.getByRole('button', { name: /Go to previous page/i })).toBeDisabled();
54
+ yield userEvent.click(screen.getByRole('button', { name: /Go to next page/i }));
55
+ expect(screen.queryByText('How to make an apple pie')).toBeFalsy();
56
+ expect(screen.getByText('How to make cookies')).toBeTruthy();
57
+ expect(screen.getByText('2/2')).toBeTruthy();
58
+ expect(screen.getByRole('button', { name: /Go to previous page/i })).toBeEnabled();
59
+ expect(screen.getByRole('button', { name: /Go to next page/i })).toBeDisabled();
60
+ }));
61
+ it('should apply className appropriately', () => {
62
+ render(_jsx(SourcesCardBase, { sources: [
63
+ { title: 'How to make an apple pie', link: '' },
64
+ { title: 'How to make cookies', link: '' }
65
+ ], className: "test" }));
66
+ const element = screen.getByRole('navigation');
67
+ expect(element).toHaveClass('test');
68
+ });
69
+ it('should disable pagination appropriately', () => {
70
+ render(_jsx(SourcesCardBase, { sources: [
71
+ { title: 'How to make an apple pie', link: '' },
72
+ { title: 'How to make cookies', link: '' }
73
+ ], isDisabled: true }));
74
+ expect(screen.getByRole('button', { name: /Go to previous page/i })).toBeDisabled();
75
+ expect(screen.getByRole('button', { name: /Go to next page/i })).toBeDisabled();
76
+ });
77
+ it('should render navigation aria label appropriately', () => {
78
+ render(_jsx(SourcesCardBase, { sources: [
79
+ { title: 'How to make an apple pie', link: '' },
80
+ { title: 'How to make cookies', link: '' }
81
+ ] }));
82
+ expect(screen.getByRole('navigation', { name: /Pagination/i })).toBeTruthy();
83
+ });
84
+ it('should change paginationAriaLabel appropriately', () => {
85
+ render(_jsx(SourcesCardBase, { sources: [
86
+ { title: 'How to make an apple pie', link: '' },
87
+ { title: 'How to make cookies', link: '' }
88
+ ], paginationAriaLabel: "Navegaci\u00F3n" }));
89
+ expect(screen.getByRole('navigation', { name: /Navegación/i })).toBeTruthy();
90
+ });
91
+ it('should change toNextPageAriaLabel appropriately', () => {
92
+ render(_jsx(SourcesCardBase, { sources: [
93
+ { title: 'How to make an apple pie', link: '' },
94
+ { title: 'How to make cookies', link: '' }
95
+ ], toNextPageAriaLabel: "Pase a la siguiente p\u00E1gina" }));
96
+ expect(screen.getByRole('button', { name: /Pase a la siguiente página/i })).toBeTruthy();
97
+ });
98
+ it('should change toPreviousPageAriaLabel appropriately', () => {
99
+ render(_jsx(SourcesCardBase, { sources: [
100
+ { title: 'How to make an apple pie', link: '' },
101
+ { title: 'How to make cookies', link: '' }
102
+ ], toPreviousPageAriaLabel: "Presione para regresar a la p\u00E1gina anterior" }));
103
+ expect(screen.getByRole('button', { name: /Presione para regresar a la página anterior/i })).toBeTruthy();
104
+ });
105
+ it('should call onNextClick appropriately', () => __awaiter(void 0, void 0, void 0, function* () {
106
+ const spy = jest.fn();
107
+ render(_jsx(SourcesCardBase, { sources: [
108
+ { title: 'How to make an apple pie', link: '' },
109
+ { title: 'How to make cookies', link: '' }
110
+ ], onNextClick: spy }));
111
+ yield userEvent.click(screen.getByRole('button', { name: /Go to next page/i }));
112
+ expect(spy).toHaveBeenCalled();
113
+ }));
114
+ it('should call onPreviousClick appropriately', () => __awaiter(void 0, void 0, void 0, function* () {
115
+ const spy = jest.fn();
116
+ render(_jsx(SourcesCardBase, { sources: [
117
+ { title: 'How to make an apple pie', link: '' },
118
+ { title: 'How to make cookies', link: '' }
119
+ ], onPreviousClick: spy }));
120
+ yield userEvent.click(screen.getByRole('button', { name: /Go to next page/i }));
121
+ yield userEvent.click(screen.getByRole('button', { name: /Go to previous page/i }));
122
+ expect(spy).toHaveBeenCalled();
123
+ }));
124
+ it('should call onSetPage appropriately', () => __awaiter(void 0, void 0, void 0, function* () {
125
+ const spy = jest.fn();
126
+ render(_jsx(SourcesCardBase, { sources: [
127
+ { title: 'How to make an apple pie', link: '' },
128
+ { title: 'How to make cookies', link: '' }
129
+ ], onSetPage: spy }));
130
+ yield userEvent.click(screen.getByRole('button', { name: /Go to next page/i }));
131
+ expect(spy).toHaveBeenCalledTimes(1);
132
+ yield userEvent.click(screen.getByRole('button', { name: /Go to previous page/i }));
133
+ expect(spy).toHaveBeenCalledTimes(2);
134
+ }));
135
+ it('should handle showMore appropriately', () => __awaiter(void 0, void 0, void 0, function* () {
136
+ render(_jsx(SourcesCardBase, { sources: [
137
+ {
138
+ title: 'Getting started with Red Hat OpenShift',
139
+ link: '#',
140
+ body: 'Red Hat OpenShift on IBM Cloud is a managed offering to create your own cluster of compute hosts where you can deploy and manage containerized apps on IBM Cloud ...',
141
+ hasShowMore: true
142
+ },
143
+ {
144
+ title: 'Azure Red Hat OpenShift documentation',
145
+ link: '#',
146
+ body: 'Microsoft Azure Red Hat OpenShift allows you to deploy a production ready Red Hat OpenShift cluster in Azure ...'
147
+ },
148
+ {
149
+ title: 'OKD Documentation: Home',
150
+ link: '#',
151
+ body: 'OKD is a distribution of Kubernetes optimized for continuous application development and multi-tenant deployment. OKD also serves as the upstream code base upon ...'
152
+ }
153
+ ] }));
154
+ expect(screen.getByRole('region')).toHaveAttribute('class', 'pf-v6-c-expandable-section__content');
155
+ }));
156
+ it('should call onClick appropriately', () => __awaiter(void 0, void 0, void 0, function* () {
157
+ const spy = jest.fn();
158
+ render(_jsx(SourcesCardBase, { sources: [{ title: 'How to make an apple pie', link: '', onClick: spy }] }));
159
+ yield userEvent.click(screen.getByRole('link', { name: /How to make an apple pie/i }));
160
+ expect(spy).toHaveBeenCalled();
161
+ }));
162
+ it('should apply titleProps appropriately', () => {
163
+ render(_jsx(SourcesCardBase, { sources: [{ title: 'How to make an apple pie', link: '', titleProps: { className: 'test' } }] }));
164
+ expect(screen.getByRole('link', { name: /How to make an apple pie/i })).toHaveClass('test');
165
+ });
166
+ });
@@ -0,0 +1,2 @@
1
+ export { default } from './SourcesCardBase';
2
+ export * from './SourcesCardBase';
@@ -0,0 +1,2 @@
1
+ export { default } from './SourcesCardBase';
2
+ export * from './SourcesCardBase';
@@ -58,6 +58,8 @@ export { default as SourceDetailsMenuItem } from './SourceDetailsMenuItem';
58
58
  export * from './SourceDetailsMenuItem';
59
59
  export { default as SourcesCard } from './SourcesCard';
60
60
  export * from './SourcesCard';
61
+ export { default as SourcesCardBase } from './SourcesCardBase';
62
+ export * from './SourcesCardBase';
61
63
  export { default as TermsOfUse } from './TermsOfUse';
62
64
  export * from './TermsOfUse';
63
65
  export { default as ToolCall } from './ToolCall';
package/dist/esm/index.js CHANGED
@@ -59,6 +59,8 @@ export { default as SourceDetailsMenuItem } from './SourceDetailsMenuItem';
59
59
  export * from './SourceDetailsMenuItem';
60
60
  export { default as SourcesCard } from './SourcesCard';
61
61
  export * from './SourcesCard';
62
+ export { default as SourcesCardBase } from './SourcesCardBase';
63
+ export * from './SourcesCardBase';
62
64
  export { default as TermsOfUse } from './TermsOfUse';
63
65
  export * from './TermsOfUse';
64
66
  export { default as ToolCall } from './ToolCall';
@@ -1 +1 @@
1
- {"root":["../src/index.ts","../src/AttachMenu/AttachMenu.tsx","../src/AttachMenu/index.ts","../src/AttachmentEdit/AttachmentEdit.test.tsx","../src/AttachmentEdit/AttachmentEdit.tsx","../src/AttachmentEdit/index.ts","../src/Chatbot/Chatbot.test.tsx","../src/Chatbot/Chatbot.tsx","../src/Chatbot/index.ts","../src/ChatbotAlert/ChatbotAlert.test.tsx","../src/ChatbotAlert/ChatbotAlert.tsx","../src/ChatbotAlert/index.ts","../src/ChatbotContent/ChatbotContent.test.tsx","../src/ChatbotContent/ChatbotContent.tsx","../src/ChatbotContent/index.ts","../src/ChatbotConversationHistoryNav/ChatbotConversationHistoryDropdown.test.tsx","../src/ChatbotConversationHistoryNav/ChatbotConversationHistoryDropdown.tsx","../src/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.test.tsx","../src/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.tsx","../src/ChatbotConversationHistoryNav/EmptyState.tsx","../src/ChatbotConversationHistoryNav/LoadingState.tsx","../src/ChatbotConversationHistoryNav/index.ts","../src/ChatbotFooter/ChatbotFooter.test.tsx","../src/ChatbotFooter/ChatbotFooter.tsx","../src/ChatbotFooter/ChatbotFooternote.test.tsx","../src/ChatbotFooter/ChatbotFootnote.tsx","../src/ChatbotFooter/index.ts","../src/ChatbotHeader/ChatbotHeader.test.tsx","../src/ChatbotHeader/ChatbotHeader.tsx","../src/ChatbotHeader/ChatbotHeaderActions.test.tsx","../src/ChatbotHeader/ChatbotHeaderActions.tsx","../src/ChatbotHeader/ChatbotHeaderCloseButton.test.tsx","../src/ChatbotHeader/ChatbotHeaderCloseButton.tsx","../src/ChatbotHeader/ChatbotHeaderMain.test.tsx","../src/ChatbotHeader/ChatbotHeaderMain.tsx","../src/ChatbotHeader/ChatbotHeaderMenu.test.tsx","../src/ChatbotHeader/ChatbotHeaderMenu.tsx","../src/ChatbotHeader/ChatbotHeaderNewChatButton.test.tsx","../src/ChatbotHeader/ChatbotHeaderNewChatButton.tsx","../src/ChatbotHeader/ChatbotHeaderOptionsDropdown.test.tsx","../src/ChatbotHeader/ChatbotHeaderOptionsDropdown.tsx","../src/ChatbotHeader/ChatbotHeaderSelectorDropdown.test.tsx","../src/ChatbotHeader/ChatbotHeaderSelectorDropdown.tsx","../src/ChatbotHeader/ChatbotHeaderTitle.test.tsx","../src/ChatbotHeader/ChatbotHeaderTitle.tsx","../src/ChatbotHeader/index.ts","../src/ChatbotModal/ChatbotModal.test.tsx","../src/ChatbotModal/ChatbotModal.tsx","../src/ChatbotModal/index.ts","../src/ChatbotPopover/ChatbotPopover.tsx","../src/ChatbotPopover/index.ts","../src/ChatbotToggle/ChatbotToggle.test.tsx","../src/ChatbotToggle/ChatbotToggle.tsx","../src/ChatbotToggle/index.ts","../src/ChatbotWelcomePrompt/ChatbotWelcomePrompt.test.tsx","../src/ChatbotWelcomePrompt/ChatbotWelcomePrompt.tsx","../src/ChatbotWelcomePrompt/index.ts","../src/CodeModal/CodeModal.test.tsx","../src/CodeModal/CodeModal.tsx","../src/CodeModal/index.ts","../src/Compare/Compare.test.tsx","../src/Compare/Compare.tsx","../src/Compare/index.ts","../src/DeepThinking/DeepThinking.test.tsx","../src/DeepThinking/DeepThinking.tsx","../src/DeepThinking/index.ts","../src/FileDetails/FileDetails.test.tsx","../src/FileDetails/FileDetails.tsx","../src/FileDetails/index.ts","../src/FileDetailsLabel/FileDetailsLabel.test.tsx","../src/FileDetailsLabel/FileDetailsLabel.tsx","../src/FileDetailsLabel/index.ts","../src/FileDropZone/FileDropZone.test.tsx","../src/FileDropZone/FileDropZone.tsx","../src/FileDropZone/index.ts","../src/FilePreview/FilePreview.test.tsx","../src/FilePreview/FilePreview.tsx","../src/FilePreview/index.ts","../src/ImagePreview/ImagePreview.test.tsx","../src/ImagePreview/ImagePreview.tsx","../src/ImagePreview/index.ts","../src/LoadingMessage/LoadingMessage.test.tsx","../src/LoadingMessage/LoadingMessage.tsx","../src/LoadingMessage/index.ts","../src/Message/Message.test.tsx","../src/Message/Message.tsx","../src/Message/MessageInput.tsx","../src/Message/MessageLoading.tsx","../src/Message/index.ts","../src/Message/CodeBlockMessage/CodeBlockMessage.tsx","../src/Message/ErrorMessage/ErrorMessage.tsx","../src/Message/ImageMessage/ImageMessage.tsx","../src/Message/LinkMessage/LinkMessage.tsx","../src/Message/ListMessage/ListItemMessage.tsx","../src/Message/ListMessage/OrderedListMessage.tsx","../src/Message/ListMessage/UnorderedListMessage.tsx","../src/Message/Plugins/index.ts","../src/Message/Plugins/rehypeCodeBlockToggle.ts","../src/Message/Plugins/rehypeMoveImagesOutOfParagraphs.ts","../src/Message/QuickResponse/QuickResponse.tsx","../src/Message/QuickStarts/FallbackImg.tsx","../src/Message/QuickStarts/QuickStartTile.tsx","../src/Message/QuickStarts/QuickStartTileDescription.test.tsx","../src/Message/QuickStarts/QuickStartTileDescription.tsx","../src/Message/QuickStarts/QuickStartTileHeader.tsx","../src/Message/QuickStarts/monitor-sampleapp-quickstart-with-image.ts","../src/Message/QuickStarts/monitor-sampleapp-quickstart.ts","../src/Message/QuickStarts/types.ts","../src/Message/SuperscriptMessage/SuperscriptMessage.tsx","../src/Message/TableMessage/TableMessage.tsx","../src/Message/TableMessage/TbodyMessage.tsx","../src/Message/TableMessage/TdMessage.tsx","../src/Message/TableMessage/ThMessage.tsx","../src/Message/TableMessage/TheadMessage.tsx","../src/Message/TableMessage/TrMessage.tsx","../src/Message/TextMessage/TextMessage.tsx","../src/Message/UserFeedback/CloseButton.tsx","../src/Message/UserFeedback/UserFeedback.test.tsx","../src/Message/UserFeedback/UserFeedback.tsx","../src/Message/UserFeedback/UserFeedbackComplete.test.tsx","../src/Message/UserFeedback/UserFeedbackComplete.tsx","../src/MessageBar/AttachButton.test.tsx","../src/MessageBar/AttachButton.tsx","../src/MessageBar/MessageBar.test.tsx","../src/MessageBar/MessageBar.tsx","../src/MessageBar/MicrophoneButton.tsx","../src/MessageBar/SendButton.test.tsx","../src/MessageBar/SendButton.tsx","../src/MessageBar/StopButton.test.tsx","../src/MessageBar/StopButton.tsx","../src/MessageBar/index.ts","../src/MessageBox/JumpButton.test.tsx","../src/MessageBox/JumpButton.tsx","../src/MessageBox/MessageBox.test.tsx","../src/MessageBox/MessageBox.tsx","../src/MessageBox/index.ts","../src/MessageDivider/MessageDivider.test.tsx","../src/MessageDivider/MessageDivider.tsx","../src/MessageDivider/index.ts","../src/PreviewAttachment/PreviewAttachment.test.tsx","../src/PreviewAttachment/PreviewAttachment.tsx","../src/PreviewAttachment/index.ts","../src/ResponseActions/ResponseActionButton.test.tsx","../src/ResponseActions/ResponseActionButton.tsx","../src/ResponseActions/ResponseActions.test.tsx","../src/ResponseActions/ResponseActions.tsx","../src/ResponseActions/index.ts","../src/Settings/SettingsForm.test.tsx","../src/Settings/SettingsForm.tsx","../src/Settings/index.ts","../src/SourceDetailsMenuItem/SourceDetailsMenuItem.tsx","../src/SourceDetailsMenuItem/index.ts","../src/SourcesCard/SourcesCard.test.tsx","../src/SourcesCard/SourcesCard.tsx","../src/SourcesCard/index.ts","../src/TermsOfUse/TermsOfUse.test.tsx","../src/TermsOfUse/TermsOfUse.tsx","../src/TermsOfUse/index.ts","../src/ToolCall/ToolCall.test.tsx","../src/ToolCall/ToolCall.tsx","../src/ToolCall/index.ts","../src/ToolResponse/ToolResponse.test.tsx","../src/ToolResponse/ToolResponse.tsx","../src/ToolResponse/index.ts","../src/__mocks__/rehype-external-links.ts","../src/__mocks__/rehype-sanitize.ts","../src/__mocks__/rehype-unwrap-images.tsx","../src/tracking/console_tracking_provider.ts","../src/tracking/index.ts","../src/tracking/posthog_tracking_provider.ts","../src/tracking/segment_tracking_provider.ts","../src/tracking/trackingProviderProxy.ts","../src/tracking/tracking_api.ts","../src/tracking/tracking_registry.ts","../src/tracking/tracking_spi.ts","../src/tracking/umami_tracking_provider.ts"],"version":"5.6.3"}
1
+ {"root":["../src/index.ts","../src/AttachMenu/AttachMenu.tsx","../src/AttachMenu/index.ts","../src/AttachmentEdit/AttachmentEdit.test.tsx","../src/AttachmentEdit/AttachmentEdit.tsx","../src/AttachmentEdit/index.ts","../src/Chatbot/Chatbot.test.tsx","../src/Chatbot/Chatbot.tsx","../src/Chatbot/index.ts","../src/ChatbotAlert/ChatbotAlert.test.tsx","../src/ChatbotAlert/ChatbotAlert.tsx","../src/ChatbotAlert/index.ts","../src/ChatbotContent/ChatbotContent.test.tsx","../src/ChatbotContent/ChatbotContent.tsx","../src/ChatbotContent/index.ts","../src/ChatbotConversationHistoryNav/ChatbotConversationHistoryDropdown.test.tsx","../src/ChatbotConversationHistoryNav/ChatbotConversationHistoryDropdown.tsx","../src/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.test.tsx","../src/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.tsx","../src/ChatbotConversationHistoryNav/EmptyState.tsx","../src/ChatbotConversationHistoryNav/LoadingState.tsx","../src/ChatbotConversationHistoryNav/index.ts","../src/ChatbotFooter/ChatbotFooter.test.tsx","../src/ChatbotFooter/ChatbotFooter.tsx","../src/ChatbotFooter/ChatbotFooternote.test.tsx","../src/ChatbotFooter/ChatbotFootnote.tsx","../src/ChatbotFooter/index.ts","../src/ChatbotHeader/ChatbotHeader.test.tsx","../src/ChatbotHeader/ChatbotHeader.tsx","../src/ChatbotHeader/ChatbotHeaderActions.test.tsx","../src/ChatbotHeader/ChatbotHeaderActions.tsx","../src/ChatbotHeader/ChatbotHeaderCloseButton.test.tsx","../src/ChatbotHeader/ChatbotHeaderCloseButton.tsx","../src/ChatbotHeader/ChatbotHeaderMain.test.tsx","../src/ChatbotHeader/ChatbotHeaderMain.tsx","../src/ChatbotHeader/ChatbotHeaderMenu.test.tsx","../src/ChatbotHeader/ChatbotHeaderMenu.tsx","../src/ChatbotHeader/ChatbotHeaderNewChatButton.test.tsx","../src/ChatbotHeader/ChatbotHeaderNewChatButton.tsx","../src/ChatbotHeader/ChatbotHeaderOptionsDropdown.test.tsx","../src/ChatbotHeader/ChatbotHeaderOptionsDropdown.tsx","../src/ChatbotHeader/ChatbotHeaderSelectorDropdown.test.tsx","../src/ChatbotHeader/ChatbotHeaderSelectorDropdown.tsx","../src/ChatbotHeader/ChatbotHeaderTitle.test.tsx","../src/ChatbotHeader/ChatbotHeaderTitle.tsx","../src/ChatbotHeader/index.ts","../src/ChatbotModal/ChatbotModal.test.tsx","../src/ChatbotModal/ChatbotModal.tsx","../src/ChatbotModal/index.ts","../src/ChatbotPopover/ChatbotPopover.tsx","../src/ChatbotPopover/index.ts","../src/ChatbotToggle/ChatbotToggle.test.tsx","../src/ChatbotToggle/ChatbotToggle.tsx","../src/ChatbotToggle/index.ts","../src/ChatbotWelcomePrompt/ChatbotWelcomePrompt.test.tsx","../src/ChatbotWelcomePrompt/ChatbotWelcomePrompt.tsx","../src/ChatbotWelcomePrompt/index.ts","../src/CodeModal/CodeModal.test.tsx","../src/CodeModal/CodeModal.tsx","../src/CodeModal/index.ts","../src/Compare/Compare.test.tsx","../src/Compare/Compare.tsx","../src/Compare/index.ts","../src/DeepThinking/DeepThinking.test.tsx","../src/DeepThinking/DeepThinking.tsx","../src/DeepThinking/index.ts","../src/FileDetails/FileDetails.test.tsx","../src/FileDetails/FileDetails.tsx","../src/FileDetails/index.ts","../src/FileDetailsLabel/FileDetailsLabel.test.tsx","../src/FileDetailsLabel/FileDetailsLabel.tsx","../src/FileDetailsLabel/index.ts","../src/FileDropZone/FileDropZone.test.tsx","../src/FileDropZone/FileDropZone.tsx","../src/FileDropZone/index.ts","../src/FilePreview/FilePreview.test.tsx","../src/FilePreview/FilePreview.tsx","../src/FilePreview/index.ts","../src/ImagePreview/ImagePreview.test.tsx","../src/ImagePreview/ImagePreview.tsx","../src/ImagePreview/index.ts","../src/LoadingMessage/LoadingMessage.test.tsx","../src/LoadingMessage/LoadingMessage.tsx","../src/LoadingMessage/index.ts","../src/Message/Message.test.tsx","../src/Message/Message.tsx","../src/Message/MessageInput.tsx","../src/Message/MessageLoading.tsx","../src/Message/index.ts","../src/Message/CodeBlockMessage/CodeBlockMessage.tsx","../src/Message/ErrorMessage/ErrorMessage.tsx","../src/Message/ImageMessage/ImageMessage.tsx","../src/Message/LinkMessage/LinkMessage.tsx","../src/Message/ListMessage/ListItemMessage.tsx","../src/Message/ListMessage/OrderedListMessage.tsx","../src/Message/ListMessage/UnorderedListMessage.tsx","../src/Message/Plugins/index.ts","../src/Message/Plugins/rehypeCodeBlockToggle.ts","../src/Message/Plugins/rehypeMoveImagesOutOfParagraphs.ts","../src/Message/QuickResponse/QuickResponse.tsx","../src/Message/QuickStarts/FallbackImg.tsx","../src/Message/QuickStarts/QuickStartTile.tsx","../src/Message/QuickStarts/QuickStartTileDescription.test.tsx","../src/Message/QuickStarts/QuickStartTileDescription.tsx","../src/Message/QuickStarts/QuickStartTileHeader.tsx","../src/Message/QuickStarts/monitor-sampleapp-quickstart-with-image.ts","../src/Message/QuickStarts/monitor-sampleapp-quickstart.ts","../src/Message/QuickStarts/types.ts","../src/Message/SuperscriptMessage/SuperscriptMessage.tsx","../src/Message/TableMessage/TableMessage.tsx","../src/Message/TableMessage/TbodyMessage.tsx","../src/Message/TableMessage/TdMessage.tsx","../src/Message/TableMessage/ThMessage.tsx","../src/Message/TableMessage/TheadMessage.tsx","../src/Message/TableMessage/TrMessage.tsx","../src/Message/TextMessage/TextMessage.tsx","../src/Message/UserFeedback/CloseButton.tsx","../src/Message/UserFeedback/UserFeedback.test.tsx","../src/Message/UserFeedback/UserFeedback.tsx","../src/Message/UserFeedback/UserFeedbackComplete.test.tsx","../src/Message/UserFeedback/UserFeedbackComplete.tsx","../src/MessageBar/AttachButton.test.tsx","../src/MessageBar/AttachButton.tsx","../src/MessageBar/MessageBar.test.tsx","../src/MessageBar/MessageBar.tsx","../src/MessageBar/MicrophoneButton.tsx","../src/MessageBar/SendButton.test.tsx","../src/MessageBar/SendButton.tsx","../src/MessageBar/StopButton.test.tsx","../src/MessageBar/StopButton.tsx","../src/MessageBar/index.ts","../src/MessageBox/JumpButton.test.tsx","../src/MessageBox/JumpButton.tsx","../src/MessageBox/MessageBox.test.tsx","../src/MessageBox/MessageBox.tsx","../src/MessageBox/index.ts","../src/MessageDivider/MessageDivider.test.tsx","../src/MessageDivider/MessageDivider.tsx","../src/MessageDivider/index.ts","../src/PreviewAttachment/PreviewAttachment.test.tsx","../src/PreviewAttachment/PreviewAttachment.tsx","../src/PreviewAttachment/index.ts","../src/ResponseActions/ResponseActionButton.test.tsx","../src/ResponseActions/ResponseActionButton.tsx","../src/ResponseActions/ResponseActions.test.tsx","../src/ResponseActions/ResponseActions.tsx","../src/ResponseActions/index.ts","../src/Settings/SettingsForm.test.tsx","../src/Settings/SettingsForm.tsx","../src/Settings/index.ts","../src/SourceDetailsMenuItem/SourceDetailsMenuItem.tsx","../src/SourceDetailsMenuItem/index.ts","../src/SourcesCard/SourcesCard.test.tsx","../src/SourcesCard/SourcesCard.tsx","../src/SourcesCard/index.ts","../src/SourcesCardBase/SourcesCardBase.test.tsx","../src/SourcesCardBase/SourcesCardBase.tsx","../src/SourcesCardBase/index.ts","../src/TermsOfUse/TermsOfUse.test.tsx","../src/TermsOfUse/TermsOfUse.tsx","../src/TermsOfUse/index.ts","../src/ToolCall/ToolCall.test.tsx","../src/ToolCall/ToolCall.tsx","../src/ToolCall/index.ts","../src/ToolResponse/ToolResponse.test.tsx","../src/ToolResponse/ToolResponse.tsx","../src/ToolResponse/index.ts","../src/__mocks__/rehype-external-links.ts","../src/__mocks__/rehype-sanitize.ts","../src/__mocks__/rehype-unwrap-images.tsx","../src/tracking/console_tracking_provider.ts","../src/tracking/index.ts","../src/tracking/posthog_tracking_provider.ts","../src/tracking/segment_tracking_provider.ts","../src/tracking/trackingProviderProxy.ts","../src/tracking/tracking_api.ts","../src/tracking/tracking_registry.ts","../src/tracking/tracking_spi.ts","../src/tracking/umami_tracking_provider.ts"],"version":"5.6.3"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@patternfly/chatbot",
3
- "version": "6.4.0-prerelease.23",
3
+ "version": "6.4.0-prerelease.24",
4
4
  "description": "This library provides React components based on PatternFly 6 that can be used to build chatbots.",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -1,10 +1,13 @@
1
- .pf-chatbot__source {
1
+ .pf-chatbot__source,
2
+ .pf-chatbot__sources-card-base {
2
3
  display: flex;
3
4
  flex-direction: column;
4
5
  gap: var(--pf-t--global--spacer--sm);
5
6
  padding-block-start: var(--pf-t--global--spacer--sm);
6
7
  max-width: 22.5rem;
8
+ }
7
9
 
10
+ .pf-chatbot__sources-card-base {
8
11
  a {
9
12
  color: var(--pf-t--global--text--color--link--default) !important;
10
13
  -webkit-text-decoration: var(--pf-t--global--text-decoration--link--line--default) !important;
@@ -1,42 +1,15 @@
1
1
  import { render, screen } from '@testing-library/react';
2
- import userEvent from '@testing-library/user-event';
3
2
  import '@testing-library/jest-dom';
4
3
  import SourcesCard from './SourcesCard';
5
4
 
6
5
  describe('SourcesCard', () => {
7
- it('should render card correctly if one source with only a link is passed in', () => {
8
- render(<SourcesCard sources={[{ link: '' }]} />);
9
- expect(screen.getByText('1 source')).toBeTruthy();
10
- expect(screen.getByText('Source 1')).toBeTruthy();
11
- // no buttons or navigation when there is only 1 source
12
- expect(screen.queryByRole('button')).toBeFalsy();
13
- expect(screen.queryByText('1/1')).toBeFalsy();
14
- });
15
-
16
- it('should render card correctly if one source with a title is passed in', () => {
6
+ it('should render sources correctly if one source is passed in', () => {
17
7
  render(<SourcesCard sources={[{ title: 'How to make an apple pie', link: '' }]} />);
18
8
  expect(screen.getByText('1 source')).toBeTruthy();
19
9
  expect(screen.getByText('How to make an apple pie')).toBeTruthy();
20
10
  });
21
11
 
22
- it('should render card correctly if one source with a body is passed in', () => {
23
- render(<SourcesCard sources={[{ link: '', body: 'To make an apple pie, you must first...' }]} />);
24
- expect(screen.getByText('1 source')).toBeTruthy();
25
- expect(screen.getByText('To make an apple pie, you must first...')).toBeTruthy();
26
- });
27
-
28
- it('should render card correctly if one source with a title and body is passed in', () => {
29
- render(
30
- <SourcesCard
31
- sources={[{ title: 'How to make an apple pie', link: '', body: 'To make an apple pie, you must first...' }]}
32
- />
33
- );
34
- expect(screen.getByText('1 source')).toBeTruthy();
35
- expect(screen.getByText('How to make an apple pie')).toBeTruthy();
36
- expect(screen.getByText('To make an apple pie, you must first...')).toBeTruthy();
37
- });
38
-
39
- it('should render multiple cards correctly', () => {
12
+ it('should render sources correctly when there is more than one', () => {
40
13
  render(
41
14
  <SourcesCard
42
15
  sources={[
@@ -51,302 +24,4 @@ describe('SourcesCard', () => {
51
24
  screen.getByRole('button', { name: /Go to previous page/i });
52
25
  screen.getByRole('button', { name: /Go to next page/i });
53
26
  });
54
-
55
- it('should navigate between cards correctly', async () => {
56
- render(
57
- <SourcesCard
58
- sources={[
59
- { title: 'How to make an apple pie', link: '' },
60
- { title: 'How to make cookies', link: '' }
61
- ]}
62
- />
63
- );
64
- expect(screen.getByText('How to make an apple pie')).toBeTruthy();
65
- expect(screen.getByText('1/2')).toBeTruthy();
66
- expect(screen.getByRole('button', { name: /Go to previous page/i })).toBeDisabled();
67
- await userEvent.click(screen.getByRole('button', { name: /Go to next page/i }));
68
- expect(screen.queryByText('How to make an apple pie')).toBeFalsy();
69
- expect(screen.getByText('How to make cookies')).toBeTruthy();
70
- expect(screen.getByText('2/2')).toBeTruthy();
71
- expect(screen.getByRole('button', { name: /Go to previous page/i })).toBeEnabled();
72
- expect(screen.getByRole('button', { name: /Go to next page/i })).toBeDisabled();
73
- });
74
-
75
- it('should apply className appropriately', () => {
76
- render(
77
- <SourcesCard
78
- sources={[
79
- { title: 'How to make an apple pie', link: '' },
80
- { title: 'How to make cookies', link: '' }
81
- ]}
82
- className="test"
83
- />
84
- );
85
- const element = screen.getByRole('navigation');
86
- expect(element).toHaveClass('test');
87
- });
88
-
89
- it('should disable pagination appropriately', () => {
90
- render(
91
- <SourcesCard
92
- sources={[
93
- { title: 'How to make an apple pie', link: '' },
94
- { title: 'How to make cookies', link: '' }
95
- ]}
96
- isDisabled
97
- />
98
- );
99
- expect(screen.getByRole('button', { name: /Go to previous page/i })).toBeDisabled();
100
- expect(screen.getByRole('button', { name: /Go to next page/i })).toBeDisabled();
101
- });
102
-
103
- it('should render navigation aria label appropriately', () => {
104
- render(
105
- <SourcesCard
106
- sources={[
107
- { title: 'How to make an apple pie', link: '' },
108
- { title: 'How to make cookies', link: '' }
109
- ]}
110
- />
111
- );
112
- expect(screen.getByRole('navigation', { name: /Pagination/i })).toBeTruthy();
113
- });
114
-
115
- it('should change paginationAriaLabel appropriately', () => {
116
- render(
117
- <SourcesCard
118
- sources={[
119
- { title: 'How to make an apple pie', link: '' },
120
- { title: 'How to make cookies', link: '' }
121
- ]}
122
- paginationAriaLabel="Navegación"
123
- />
124
- );
125
- expect(screen.getByRole('navigation', { name: /Navegación/i })).toBeTruthy();
126
- });
127
-
128
- it('should change sourceWord appropriately', () => {
129
- render(<SourcesCard sources={[{ title: 'How to make an apple pie', link: '' }]} sourceWord={'fuente'} />);
130
- expect(screen.getByText('1 fuente')).toBeTruthy();
131
- });
132
-
133
- it('should sourceWordPlural appropriately', () => {
134
- render(
135
- <SourcesCard
136
- sources={[
137
- { title: 'How to make an apple pie', link: '' },
138
- { title: 'How to make cookies', link: '' }
139
- ]}
140
- sourceWordPlural={'fuentes'}
141
- />
142
- );
143
- expect(screen.getByText('2 fuentes')).toBeTruthy();
144
- });
145
-
146
- it('should change toNextPageAriaLabel appropriately', () => {
147
- render(
148
- <SourcesCard
149
- sources={[
150
- { title: 'How to make an apple pie', link: '' },
151
- { title: 'How to make cookies', link: '' }
152
- ]}
153
- toNextPageAriaLabel="Pase a la siguiente página"
154
- />
155
- );
156
- expect(screen.getByRole('button', { name: /Pase a la siguiente página/i })).toBeTruthy();
157
- });
158
-
159
- it('should change toPreviousPageAriaLabel appropriately', () => {
160
- render(
161
- <SourcesCard
162
- sources={[
163
- { title: 'How to make an apple pie', link: '' },
164
- { title: 'How to make cookies', link: '' }
165
- ]}
166
- toPreviousPageAriaLabel="Presione para regresar a la página anterior"
167
- />
168
- );
169
- expect(screen.getByRole('button', { name: /Presione para regresar a la página anterior/i })).toBeTruthy();
170
- });
171
-
172
- it('should call onNextClick appropriately', async () => {
173
- const spy = jest.fn();
174
- render(
175
- <SourcesCard
176
- sources={[
177
- { title: 'How to make an apple pie', link: '' },
178
- { title: 'How to make cookies', link: '' }
179
- ]}
180
- onNextClick={spy}
181
- />
182
- );
183
- await userEvent.click(screen.getByRole('button', { name: /Go to next page/i }));
184
- expect(spy).toHaveBeenCalled();
185
- });
186
-
187
- it('should call onPreviousClick appropriately', async () => {
188
- const spy = jest.fn();
189
- render(
190
- <SourcesCard
191
- sources={[
192
- { title: 'How to make an apple pie', link: '' },
193
- { title: 'How to make cookies', link: '' }
194
- ]}
195
- onPreviousClick={spy}
196
- />
197
- );
198
- await userEvent.click(screen.getByRole('button', { name: /Go to next page/i }));
199
- await userEvent.click(screen.getByRole('button', { name: /Go to previous page/i }));
200
- expect(spy).toHaveBeenCalled();
201
- });
202
-
203
- it('should call onSetPage appropriately', async () => {
204
- const spy = jest.fn();
205
- render(
206
- <SourcesCard
207
- sources={[
208
- { title: 'How to make an apple pie', link: '' },
209
- { title: 'How to make cookies', link: '' }
210
- ]}
211
- onSetPage={spy}
212
- />
213
- );
214
- await userEvent.click(screen.getByRole('button', { name: /Go to next page/i }));
215
- expect(spy).toHaveBeenCalledTimes(1);
216
- await userEvent.click(screen.getByRole('button', { name: /Go to previous page/i }));
217
- expect(spy).toHaveBeenCalledTimes(2);
218
- });
219
-
220
- it('should handle showMore appropriately', async () => {
221
- render(
222
- <SourcesCard
223
- sources={[
224
- {
225
- title: 'Getting started with Red Hat OpenShift',
226
- link: '#',
227
- body: 'Red Hat OpenShift on IBM Cloud is a managed offering to create your own cluster of compute hosts where you can deploy and manage containerized apps on IBM Cloud ...',
228
- hasShowMore: true
229
- },
230
- {
231
- title: 'Azure Red Hat OpenShift documentation',
232
- link: '#',
233
- body: 'Microsoft Azure Red Hat OpenShift allows you to deploy a production ready Red Hat OpenShift cluster in Azure ...'
234
- },
235
- {
236
- title: 'OKD Documentation: Home',
237
- link: '#',
238
- body: 'OKD is a distribution of Kubernetes optimized for continuous application development and multi-tenant deployment. OKD also serves as the upstream code base upon ...'
239
- }
240
- ]}
241
- />
242
- );
243
- expect(screen.getByRole('region')).toHaveAttribute('class', 'pf-v6-c-expandable-section__content');
244
- });
245
-
246
- it('should call onClick appropriately', async () => {
247
- const spy = jest.fn();
248
- render(<SourcesCard sources={[{ title: 'How to make an apple pie', link: '', onClick: spy }]} />);
249
- await userEvent.click(screen.getByRole('link', { name: /How to make an apple pie/i }));
250
- expect(spy).toHaveBeenCalled();
251
- });
252
-
253
- it('should apply titleProps appropriately', () => {
254
- render(
255
- <SourcesCard sources={[{ title: 'How to make an apple pie', link: '', titleProps: { className: 'test' } }]} />
256
- );
257
- expect(screen.getByRole('link', { name: /How to make an apple pie/i })).toHaveClass('test');
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
- });
352
27
  });