Skip to content

Commit

Permalink
Merge branch 'main' into iss289-1
Browse files Browse the repository at this point in the history
  • Loading branch information
edonehoo authored Dec 3, 2024
2 parents 7fc2918 + f2c4b99 commit d898760
Show file tree
Hide file tree
Showing 17 changed files with 185 additions and 391 deletions.
479 changes: 90 additions & 389 deletions package-lock.json

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"@babel/preset-react": "^7.23.3",
"@babel/preset-typescript": "^7.23.3",
"@octokit/rest": "^18.0.0",
"@patternfly/documentation-framework": "^6.0.0-alpha.121",
"@patternfly/documentation-framework": "^6.0.6",
"@patternfly/patternfly": "^6.0.0",
"@patternfly/react-icons": "^6.0.0",
"@swc/core": "1.3.96",
Expand Down Expand Up @@ -85,6 +85,10 @@
"wait-on": "^7.2.0",
"whatwg-fetch": "^3.6.20"
},
"overrides": {
"puppeteer": "^23.6.1",
"puppeteer-cluster": "^0.24.0"
},
"dependencies": {
"dompurify": "^3.2.0",
"react-dropzone": "^14.2.3"
Expand Down
4 changes: 4 additions & 0 deletions packages/module/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,5 +75,9 @@
"victory-cursor-container": "^37.1.1",
"victory-tooltip": "^37.1.1",
"victory-bar": "^37.1.1"
},
"overrides": {
"puppeteer": "^23.6.1",
"puppeteer-cluster": "^0.24.0"
}
}
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
import React from 'react';
import '@testing-library/jest-dom';
import { DropdownItem } from '@patternfly/react-core';
import { fireEvent, render, screen, waitFor } from '@testing-library/react';
import ChatbotConversationHistoryDropdown from './ChatbotConversationHistoryDropdown';

describe('ChatbotConversationHistoryDropdown', () => {
const onSelect = jest.fn();
const menuItems = (
<>
<DropdownItem>Rename</DropdownItem>
<DropdownItem>Delete</DropdownItem>
</>
);

it('should render the dropdown', () => {
render(<ChatbotConversationHistoryDropdown menuItems={menuItems} menuClassName="custom-class" />);
expect(screen.queryByRole('menuitem', { name: /Conversation options/i })).toBeInTheDocument();
});

it('should display the dropdown menuItems', () => {
render(<ChatbotConversationHistoryDropdown menuItems={menuItems} />);

const toggle = screen.queryByRole('menuitem', { name: /Conversation options/i })!;

Check warning on line 24 in packages/module/src/ChatbotConversationHistoryNav/ChatbotConversationHistoryDropdown.test.tsx

View workflow job for this annotation

GitHub Actions / call-build-lint-test-workflow / lint

Forbidden non-null assertion

expect(toggle).toBeInTheDocument();
fireEvent.click(toggle);

waitFor(() => {
expect(screen.getByText('Rename')).toBeInTheDocument();
expect(screen.getByText('Delete')).toBeInTheDocument();
});
});

it('should invoke onSelect callback when menuitem is clicked', () => {
render(<ChatbotConversationHistoryDropdown menuItems={menuItems} onSelect={onSelect} />);
const toggle = screen.queryByRole('menuitem', { name: /Conversation options/i })!;

Check warning on line 37 in packages/module/src/ChatbotConversationHistoryNav/ChatbotConversationHistoryDropdown.test.tsx

View workflow job for this annotation

GitHub Actions / call-build-lint-test-workflow / lint

Forbidden non-null assertion
fireEvent.click(toggle);
fireEvent.click(screen.getByText('Rename'));

expect(onSelect).toHaveBeenCalled();
});

it('should toggle the dropdown when menuitem is clicked', () => {
render(<ChatbotConversationHistoryDropdown menuItems={menuItems} onSelect={onSelect} />);
const toggle = screen.queryByRole('menuitem', { name: /Conversation options/i })!;

Check warning on line 46 in packages/module/src/ChatbotConversationHistoryNav/ChatbotConversationHistoryDropdown.test.tsx

View workflow job for this annotation

GitHub Actions / call-build-lint-test-workflow / lint

Forbidden non-null assertion
fireEvent.click(toggle);
fireEvent.click(screen.getByText('Delete'));

expect(onSelect).toHaveBeenCalled();

expect(screen.queryByText('Delete')).not.toBeInTheDocument();
});

it('should close the dropdown when user clicks outside', () => {
render(<ChatbotConversationHistoryDropdown menuItems={menuItems} onSelect={onSelect} />);
const toggle = screen.queryByRole('menuitem', { name: /Conversation options/i })!;

Check warning on line 57 in packages/module/src/ChatbotConversationHistoryNav/ChatbotConversationHistoryDropdown.test.tsx

View workflow job for this annotation

GitHub Actions / call-build-lint-test-workflow / lint

Forbidden non-null assertion
fireEvent.click(toggle);

expect(screen.queryByText('Delete')).toBeInTheDocument();
fireEvent.click(toggle.parentElement!);

Check warning on line 61 in packages/module/src/ChatbotConversationHistoryNav/ChatbotConversationHistoryDropdown.test.tsx

View workflow job for this annotation

GitHub Actions / call-build-lint-test-workflow / lint

Forbidden non-null assertion

expect(screen.queryByText('Delete')).not.toBeInTheDocument();
});

it('should show the tooltip when the user hovers over the toggle button', async () => {
render(<ChatbotConversationHistoryDropdown menuItems={menuItems} label="Actions dropdown" />);
const toggle = screen.queryByRole('menuitem', { name: /Actions dropdown/i })!;

Check warning on line 68 in packages/module/src/ChatbotConversationHistoryNav/ChatbotConversationHistoryDropdown.test.tsx

View workflow job for this annotation

GitHub Actions / call-build-lint-test-workflow / lint

Forbidden non-null assertion

fireEvent(
toggle,
new MouseEvent('mouseenter', {
bubbles: false,
cancelable: false
})
);

await waitFor(() => {
expect(screen.queryByText('Actions dropdown')).toBeInTheDocument();
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@ export const ChatbotConversationHistoryDropdown: React.FunctionComponent<Chatbot
<Dropdown
className={`pf-chatbot__selections ${menuClassName ?? ''}`}
isOpen={isOpen}
onSelect={onSelect}
onSelect={(props) => {
onSelect?.(props);
setIsOpen((prev) => !prev);
}}
onOpenChange={(isOpen) => setIsOpen(isOpen)}
popperProps={{ position: 'right' }}
shouldFocusToggleOnSelect
Expand Down

0 comments on commit d898760

Please sign in to comment.