File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed
packages/react-core/src/components/ClipboardCopy/__tests__ Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change 1+ import { render , screen } from '@testing-library/react' ;
2+ import userEvent from '@testing-library/user-event' ;
3+ import { ClipboardCopy , ClipboardCopyVariant } from '../ClipboardCopy' ;
4+
5+ // This test file uses the real Truncate component for integration testing, instead of a mock
6+
7+ test ( 'Tooltip appears on keyboard focus when using inline-compact variant with truncation' , async ( ) => {
8+ const user = userEvent . setup ( ) ;
9+ const longText = 'This is a very long piece of content that should be truncated when the container is too small' ;
10+
11+ render (
12+ < ClipboardCopy
13+ variant = { ClipboardCopyVariant . inlineCompact }
14+ truncation = { { maxCharsDisplayed : 20 } }
15+ data-testid = "clipboard-copy"
16+ >
17+ { longText }
18+ </ ClipboardCopy >
19+ ) ;
20+
21+ expect ( screen . queryByText ( longText ) ) . not . toBeInTheDocument ( ) ;
22+ expect ( screen . queryByRole ( 'tooltip' ) ) . not . toBeInTheDocument ( ) ;
23+
24+ await user . tab ( ) ;
25+
26+ const clipboardCopy = screen . getByTestId ( 'clipboard-copy' ) ;
27+ expect ( clipboardCopy ) . toHaveFocus ( ) ;
28+
29+ const tooltip = screen . getByRole ( 'tooltip' ) ;
30+ expect ( tooltip ) . toBeInTheDocument ( ) ;
31+ expect ( tooltip ) . toHaveTextContent ( longText ) ;
32+ } ) ;
You can’t perform that action at this time.
0 commit comments