File tree Expand file tree Collapse file tree 1 file changed +23
-1
lines changed
src/test-utils/dom/tooltip Expand file tree Collapse file tree 1 file changed +23
-1
lines changed Original file line number Diff line number Diff line change 11// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
22// SPDX-License-Identifier: Apache-2.0
3- import { ComponentWrapper } from '@cloudscape-design/test-utils-core/dom' ;
3+ import { ComponentWrapper , ElementWrapper } from '@cloudscape-design/test-utils-core/dom' ;
44
5+ import createWrapper from '../index.js' ;
6+
7+ import popoverStyles from '../../../popover/styles.selectors.js' ;
58import styles from '../../../tooltip/styles.selectors.js' ;
69
710export default class TooltipWrapper extends ComponentWrapper {
811 static rootSelector : string = styles . root ;
12+
13+ /**
14+ * Returns the tooltip content element.
15+ * Searches within this tooltip's scope to avoid conflicts with popovers.
16+ */
17+ findContent ( ) : ElementWrapper | null {
18+ return this . findByClassName ( popoverStyles . content ) ;
19+ }
20+
21+ /**
22+ * Returns the tooltip element by its trackKey (data-testid attribute).
23+ * Useful when multiple tooltips are rendered and you need to find a specific one.
24+ *
25+ * @param trackKey - The trackKey value used when creating the tooltip
26+ */
27+ static findByTrackKey ( trackKey : string ) : TooltipWrapper | null {
28+ const element = createWrapper ( ) . find ( `[data-testid="${ trackKey } "]` ) ;
29+ return element ? new TooltipWrapper ( element . getElement ( ) ) : null ;
30+ }
931}
You can’t perform that action at this time.
0 commit comments