Skip to content

Commit e744747

Browse files
committed
fix: Update test files
1 parent cca3541 commit e744747

File tree

5 files changed

+184
-9
lines changed

5 files changed

+184
-9
lines changed

src/__tests__/functional-tests/test-utils.test.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,12 @@ afterEach(() => {
3030
});
3131

3232
const componentWithMultipleRootElements = ['top-navigation', 'app-layout', 'app-layout-toolbar'];
33-
const componentsWithExceptions = ['annotation-context', 'icon-provider', ...componentWithMultipleRootElements];
33+
const componentsWithExceptions = [
34+
'annotation-context',
35+
'icon-provider',
36+
'tooltip',
37+
...componentWithMultipleRootElements,
38+
];
3439
const components = getAllComponents().filter(component => !componentsWithExceptions.includes(component));
3540

3641
const RENDER_COMPONENTS_DEFAULT_PROPS: Record<string, unknown>[] = [

src/__tests__/snapshot-tests/__snapshots__/documenter.test.ts.snap

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28569,6 +28569,79 @@ user from modifying the value. A read-only control is still focusable.",
2856928569
}
2857028570
`;
2857128571

28572+
exports[`Components definition for tooltip matches the snapshot: tooltip 1`] = `
28573+
{
28574+
"dashCaseName": "tooltip",
28575+
"events": [
28576+
{
28577+
"cancelable": false,
28578+
"description": "Callback fired when the user presses the Escape key while the tooltip is visible.",
28579+
"name": "onEscape",
28580+
},
28581+
],
28582+
"functions": [],
28583+
"name": "Tooltip",
28584+
"properties": [
28585+
{
28586+
"description": "Function that returns the element to track for positioning the tooltip.
28587+
Can return null if the element is not yet mounted or available.",
28588+
"inlineType": {
28589+
"name": "() => HTMLElement | SVGElement | null",
28590+
"parameters": [],
28591+
"returnType": "HTMLElement | SVGElement | null",
28592+
"type": "function",
28593+
},
28594+
"name": "getTrack",
28595+
"optional": false,
28596+
"type": "() => HTMLElement | SVGElement | null",
28597+
},
28598+
{
28599+
"defaultValue": "'top'",
28600+
"description": "Position of the tooltip relative to the tracked element.",
28601+
"inlineType": {
28602+
"name": "PopoverProps.Position",
28603+
"type": "union",
28604+
"values": [
28605+
"left",
28606+
"top",
28607+
"bottom",
28608+
"right",
28609+
],
28610+
},
28611+
"name": "position",
28612+
"optional": true,
28613+
"type": "string",
28614+
},
28615+
{
28616+
"description": "Unique identifier for the tooltip instance. Changing this value will cause the tooltip
28617+
to recalculate its position, similar to how React's key prop works.
28618+
If not provided and content is a string or number, it will be used as key.
28619+
For complex content (elements, fragments), you should provide an explicit trackKey.",
28620+
"inlineType": {
28621+
"name": "string | number",
28622+
"type": "union",
28623+
"values": [
28624+
"string",
28625+
"number",
28626+
],
28627+
},
28628+
"name": "trackKey",
28629+
"optional": true,
28630+
"type": "string | number",
28631+
},
28632+
],
28633+
"regions": [
28634+
{
28635+
"description": "Content to display in the tooltip.
28636+
Accepts any valid React node including strings, numbers, elements, and fragments.",
28637+
"isDefault": false,
28638+
"name": "content",
28639+
},
28640+
],
28641+
"releaseStatus": "stable",
28642+
}
28643+
`;
28644+
2857228645
exports[`Components definition for top-navigation matches the snapshot: top-navigation 1`] = `
2857328646
{
2857428647
"dashCaseName": "top-navigation",
@@ -40247,6 +40320,26 @@ Returns the current value of the input.",
4024740320
],
4024840321
"name": "TokenGroupWrapper",
4024940322
},
40323+
{
40324+
"methods": [
40325+
{
40326+
"description": "Returns the tooltip content element.
40327+
Searches within this tooltip's scope to avoid conflicts with popovers.",
40328+
"name": "findContent",
40329+
"parameters": [],
40330+
"returnType": {
40331+
"isNullable": true,
40332+
"name": "ElementWrapper",
40333+
"typeArguments": [
40334+
{
40335+
"name": "HTMLElement",
40336+
},
40337+
],
40338+
},
40339+
},
40340+
],
40341+
"name": "TooltipWrapper",
40342+
},
4025040343
{
4025140344
"methods": [
4025240345
{
@@ -48600,6 +48693,21 @@ To find a specific row use the \`findRow(n)\` function as chaining \`findRows().
4860048693
],
4860148694
"name": "TokenGroupWrapper",
4860248695
},
48696+
{
48697+
"methods": [
48698+
{
48699+
"description": "Returns the tooltip content element.
48700+
Searches within this tooltip's scope to avoid conflicts with popovers.",
48701+
"name": "findContent",
48702+
"parameters": [],
48703+
"returnType": {
48704+
"isNullable": false,
48705+
"name": "ElementWrapper",
48706+
},
48707+
},
48708+
],
48709+
"name": "TooltipWrapper",
48710+
},
4860348711
{
4860448712
"methods": [
4860548713
{

src/__tests__/snapshot-tests/__snapshots__/test-utils-selectors.test.tsx.snap

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,6 @@ exports[`test-utils selectors 1`] = `
393393
"awsui_root_1fcus",
394394
"awsui_root_1kjc7",
395395
"awsui_root_1om0h",
396-
"awsui_root_1qprf",
397396
"awsui_root_1t44z",
398397
"awsui_root_qwoo0",
399398
"awsui_root_vrgzu",
@@ -664,6 +663,9 @@ exports[`test-utils selectors 1`] = `
664663
"awsui_root_dm8gx",
665664
"awsui_token_dm8gx",
666665
],
666+
"tooltip": [
667+
"awsui_root_1r4p6",
668+
],
667669
"top-navigation": [
668670
"awsui_hidden_k5dlb",
669671
"awsui_identity_k5dlb",

src/__tests__/snapshot-tests/__snapshots__/test-utils-wrappers.test.tsx.snap

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ import ToggleWrapper from './toggle';
9090
import ToggleButtonWrapper from './toggle-button';
9191
import TokenWrapper from './token';
9292
import TokenGroupWrapper from './token-group';
93+
import TooltipWrapper from './tooltip';
9394
import TopNavigationWrapper from './top-navigation';
9495
import TreeViewWrapper from './tree-view';
9596
import TutorialPanelWrapper from './tutorial-panel';
@@ -177,6 +178,7 @@ export { ToggleWrapper };
177178
export { ToggleButtonWrapper };
178179
export { TokenWrapper };
179180
export { TokenGroupWrapper };
181+
export { TooltipWrapper };
180182
export { TopNavigationWrapper };
181183
export { TreeViewWrapper };
182184
export { TutorialPanelWrapper };
@@ -1724,6 +1726,25 @@ findTokenGroup(selector?: string): TokenGroupWrapper | null;
17241726
* @returns {Array<TokenGroupWrapper>}
17251727
*/
17261728
findAllTokenGroups(selector?: string): Array<TokenGroupWrapper>;
1729+
/**
1730+
* Returns the wrapper of the first Tooltip that matches the specified CSS selector.
1731+
* If no CSS selector is specified, returns the wrapper of the first Tooltip.
1732+
* If no matching Tooltip is found, returns \`null\`.
1733+
*
1734+
* @param {string} [selector] CSS Selector
1735+
* @returns {TooltipWrapper | null}
1736+
*/
1737+
findTooltip(selector?: string): TooltipWrapper | null;
1738+
1739+
/**
1740+
* Returns an array of Tooltip wrapper that matches the specified CSS selector.
1741+
* If no CSS selector is specified, returns all of the Tooltips inside the current wrapper.
1742+
* If no matching Tooltip is found, returns an empty array.
1743+
*
1744+
* @param {string} [selector] CSS Selector
1745+
* @returns {Array<TooltipWrapper>}
1746+
*/
1747+
findAllTooltips(selector?: string): Array<TooltipWrapper>;
17271748
/**
17281749
* Returns the wrapper of the first TopNavigation that matches the specified CSS selector.
17291750
* If no CSS selector is specified, returns the wrapper of the first TopNavigation.
@@ -2857,6 +2878,19 @@ ElementWrapper.prototype.findTokenGroup = function(selector) {
28572878
ElementWrapper.prototype.findAllTokenGroups = function(selector) {
28582879
return this.findAllComponents(TokenGroupWrapper, selector);
28592880
};
2881+
ElementWrapper.prototype.findTooltip = function(selector) {
2882+
let rootSelector = \`.\${TooltipWrapper.rootSelector}\`;
2883+
if("legacyRootSelector" in TooltipWrapper && TooltipWrapper.legacyRootSelector){
2884+
rootSelector = \`:is(.\${TooltipWrapper.rootSelector}, .\${TooltipWrapper.legacyRootSelector})\`;
2885+
}
2886+
// casting to 'any' is needed to avoid this issue with generics
2887+
// https://github.com/microsoft/TypeScript/issues/29132
2888+
return (this as any).findComponent(selector ? appendSelector(selector, rootSelector) : rootSelector, TooltipWrapper);
2889+
};
2890+
2891+
ElementWrapper.prototype.findAllTooltips = function(selector) {
2892+
return this.findAllComponents(TooltipWrapper, selector);
2893+
};
28602894
ElementWrapper.prototype.findTopNavigation = function(selector) {
28612895
let rootSelector = \`.\${TopNavigationWrapper.rootSelector}\`;
28622896
if("legacyRootSelector" in TopNavigationWrapper && TopNavigationWrapper.legacyRootSelector){
@@ -3010,6 +3044,7 @@ import ToggleWrapper from './toggle';
30103044
import ToggleButtonWrapper from './toggle-button';
30113045
import TokenWrapper from './token';
30123046
import TokenGroupWrapper from './token-group';
3047+
import TooltipWrapper from './tooltip';
30133048
import TopNavigationWrapper from './top-navigation';
30143049
import TreeViewWrapper from './tree-view';
30153050
import TutorialPanelWrapper from './tutorial-panel';
@@ -3097,6 +3132,7 @@ export { ToggleWrapper };
30973132
export { ToggleButtonWrapper };
30983133
export { TokenWrapper };
30993134
export { TokenGroupWrapper };
3135+
export { TooltipWrapper };
31003136
export { TopNavigationWrapper };
31013137
export { TreeViewWrapper };
31023138
export { TutorialPanelWrapper };
@@ -4482,6 +4518,23 @@ findTokenGroup(selector?: string): TokenGroupWrapper;
44824518
* @returns {MultiElementWrapper<TokenGroupWrapper>}
44834519
*/
44844520
findAllTokenGroups(selector?: string): MultiElementWrapper<TokenGroupWrapper>;
4521+
/**
4522+
* Returns a wrapper that matches the Tooltips with the specified CSS selector.
4523+
* If no CSS selector is specified, returns a wrapper that matches Tooltips.
4524+
*
4525+
* @param {string} [selector] CSS Selector
4526+
* @returns {TooltipWrapper}
4527+
*/
4528+
findTooltip(selector?: string): TooltipWrapper;
4529+
4530+
/**
4531+
* Returns a multi-element wrapper that matches Tooltips with the specified CSS selector.
4532+
* If no CSS selector is specified, returns a multi-element wrapper that matches Tooltips.
4533+
*
4534+
* @param {string} [selector] CSS Selector
4535+
* @returns {MultiElementWrapper<TooltipWrapper>}
4536+
*/
4537+
findAllTooltips(selector?: string): MultiElementWrapper<TooltipWrapper>;
44854538
/**
44864539
* Returns a wrapper that matches the TopNavigations with the specified CSS selector.
44874540
* If no CSS selector is specified, returns a wrapper that matches TopNavigations.
@@ -5607,6 +5660,19 @@ ElementWrapper.prototype.findTokenGroup = function(selector) {
56075660
ElementWrapper.prototype.findAllTokenGroups = function(selector) {
56085661
return this.findAllComponents(TokenGroupWrapper, selector);
56095662
};
5663+
ElementWrapper.prototype.findTooltip = function(selector) {
5664+
let rootSelector = \`.\${TooltipWrapper.rootSelector}\`;
5665+
if("legacyRootSelector" in TooltipWrapper && TooltipWrapper.legacyRootSelector){
5666+
rootSelector = \`:is(.\${TooltipWrapper.rootSelector}, .\${TooltipWrapper.legacyRootSelector})\`;
5667+
}
5668+
// casting to 'any' is needed to avoid this issue with generics
5669+
// https://github.com/microsoft/TypeScript/issues/29132
5670+
return (this as any).findComponent(selector ? appendSelector(selector, rootSelector) : rootSelector, TooltipWrapper);
5671+
};
5672+
5673+
ElementWrapper.prototype.findAllTooltips = function(selector) {
5674+
return this.findAllComponents(TooltipWrapper, selector);
5675+
};
56105676
ElementWrapper.prototype.findTopNavigation = function(selector) {
56115677
let rootSelector = \`.\${TopNavigationWrapper.rootSelector}\`;
56125678
if("legacyRootSelector" in TopNavigationWrapper && TopNavigationWrapper.legacyRootSelector){

src/button-group/icon-button-item.tsx

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,7 @@ const IconButtonItem = forwardRef(
6464
className={clsx(testUtilStyles.tooltip, testUtilStyles['button-group-tooltip'])}
6565
getTrack={() => containerRef.current}
6666
trackKey={item.id}
67-
content={
68-
canShowFeedback
69-
? typeof item.popoverFeedback === 'string'
70-
? item.popoverFeedback
71-
: item.text
72-
: item.text
73-
}
67+
content={canShowFeedback && item.popoverFeedback ? item.popoverFeedback : item.text}
7468
onEscape={onTooltipDismiss}
7569
/>
7670
)}

0 commit comments

Comments
 (0)