Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
93fc916
Component compat
TheSonOfThomp Sep 2, 2025
5bea85b
.ts compat
TheSonOfThomp Sep 2, 2025
2f4af53
PolymorphicRenderFunctionReturnType
TheSonOfThomp Sep 2, 2025
cb8319e
sync spec files
TheSonOfThomp Sep 3, 2025
49796b6
update Link & BackLink specs
TheSonOfThomp Sep 3, 2025
ef97c40
Update useEchart.spec.ts
TheSonOfThomp Sep 3, 2025
8eb42ba
Update index.ts
TheSonOfThomp Sep 3, 2025
a57705c
Update FormField.spec.tsx
TheSonOfThomp Sep 3, 2025
55d365d
restore Popover.spec.tsx ts expect error
TheSonOfThomp Sep 3, 2025
24482a8
Update PasswordInput.spec.tsx
TheSonOfThomp Sep 3, 2025
d6664af
select spec
TheSonOfThomp Sep 3, 2025
b5f76d8
packages/table/src/utils/stories.testutils.tsx
TheSonOfThomp Sep 3, 2025
2b0d305
sync ts files
TheSonOfThomp Sep 3, 2025
5200781
@ts-ignore React18
TheSonOfThomp Sep 3, 2025
0ba1a61
packages/popover/src/Popover/Popover.spec.tsx
TheSonOfThomp Sep 3, 2025
77b9458
Refresh RTLOverrides
TheSonOfThomp Sep 3, 2025
597381a
packages/toast/src/InternalToast/InternalToast.stories.tsx
TheSonOfThomp Sep 3, 2025
dceeb75
fix render hook
TheSonOfThomp Sep 3, 2025
02c8ffe
Update ExpandedContent.spec.tsx
TheSonOfThomp Sep 3, 2025
98af086
charts/core/src/ChartContext/ChartContext.spec.tsx
TheSonOfThomp Sep 3, 2025
1779751
Merge branch 'main' into a/r17-compat
TheSonOfThomp Sep 3, 2025
ec2058f
changesets
TheSonOfThomp Sep 3, 2025
6a31be9
renderDescendantsTestContext
TheSonOfThomp Sep 3, 2025
b7cdd64
cleanup tooltip tests
TheSonOfThomp Sep 3, 2025
35abe62
bump popover-polyfill
TheSonOfThomp Sep 3, 2025
3b005c4
Merge branch 'main' into a/r17-compat
TheSonOfThomp Sep 5, 2025
1d2abbb
Merge branch 'a/r17-compat' of https://github.com/mongodb/leafygreen-…
TheSonOfThomp Sep 5, 2025
36d5f61
fix ToggleEvent type import
TheSonOfThomp Sep 5, 2025
05920d5
test(date-picker): wrap timer advancement in waitFor
TheSonOfThomp Sep 5, 2025
73108e8
test(getAllPackages): ensure temporary directories
TheSonOfThomp Sep 5, 2025
bbb27eb
Merge branch 'main' into a/r17-compat
TheSonOfThomp Sep 5, 2025
8a160fd
Merge branch 'main' into a/r17-compat
TheSonOfThomp Sep 8, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/drawer-component-props.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@lg-chat/drawer': patch
---

Updates `DrawerLayoutProps` to extend `ComponentPropsWithoutRef<'div'>`
5 changes: 5 additions & 0 deletions .changeset/react-component-props.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@leafygreen-ui/lib': patch
---

Deprecates `HTMLElementProps`. Prefer the built-in React type `ComponentProps`
5 changes: 5 additions & 0 deletions .changeset/rich-links-component-props.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@lg-chat/rich-links': patch
---

Updates `RichLinkProps` to extend `ComponentPropsWithoutRef<'a'>`
6 changes: 6 additions & 0 deletions .changeset/rtl-overrides.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@leafygreen-ui/testing-lib': minor
---

Exports types `RenderHookOptions` & `RenderHookResult`.
Updates type signature of `renderHook`
9 changes: 4 additions & 5 deletions charts/core/src/Echart/useEchart.spec.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { act } from 'react-dom/test-utils';

import { renderHook } from '@leafygreen-ui/testing-lib';
import { renderHook, RenderHookResult } from '@leafygreen-ui/testing-lib';

import { type SeriesOption } from '../Chart';

import { EChartsInstance } from './Echart.types';
import { useEchart } from './useEchart';

// Mock echarts instance creation with all required methods
Expand Down Expand Up @@ -48,12 +49,10 @@ jest.mock('echarts/renderers', () => ({
// Helper function to wait for hook initialization and state updates
const setupHook = async () => {
const mockContainer = document.createElement('div');
let result: ReturnType<
typeof renderHook<ReturnType<typeof useEchart>, void>
>['result'];
let result: RenderHookResult<any, EChartsInstance>['result'];

await act(async () => {
const hookResult = renderHook(() =>
const hookResult = renderHook<any, EChartsInstance>(() =>
useEchart({ theme: 'dark', container: mockContainer }),
);
result = hookResult.result;
Expand Down
4 changes: 2 additions & 2 deletions chat/message-feed/src/utils/MessageFeed.testutils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ type MongoMessageFields = MessageFieldsBase & {

export type MessageFields = UserMessageFields | MongoMessageFields;

export const baseMessages: Array<MessageFields> = [
export const baseMessages = [
{
id: 1,
messageBody: 'Hi! Ask me anything.',
Expand Down Expand Up @@ -74,4 +74,4 @@ Refer to [LeafyGreen UI](mongodb.design) or [LeafyGreen UI](mongodb.design) for
console.log(`Message 6 was ${e.target.value}.`),
},
},
] as const;
] as const satisfies Readonly<Array<MessageFields>>;
6 changes: 4 additions & 2 deletions chat/rich-links/src/RichLink/RichLink.types.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import { DarkModeProps, HTMLElementProps } from '@leafygreen-ui/lib';
import { ComponentPropsWithoutRef } from 'react';

import { DarkModeProps } from '@leafygreen-ui/lib';

import { RichLinkBadgeProps } from './RichLinkBadge/RichLinkBadge.types';
import { RichLinkVariantName } from './richLinkVariants';

export interface BaseRichLinkProps
extends DarkModeProps,
HTMLElementProps<'a', never> {
ComponentPropsWithoutRef<'a'> {
/**
* The text that shows on the rich link
*/
Expand Down
4 changes: 2 additions & 2 deletions packages/avatar/src/Avatar/Avatar.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ describe('packages/Avatar', () => {
/**
* TEXT FORMAT
*/
// @ts-expect-error - Requires `text` prop
// @ts-ignore React18-expect-error - Requires `text` prop FIXME: React17 types
<Avatar format="text" />;
// Accepts null text prop
<Avatar format="text" text={null} />;
Expand All @@ -55,7 +55,7 @@ describe('packages/Avatar', () => {
Format.Text,
]) as Format;

// @ts-expect-error - requires defined text prop
// @ts-ignore React18-expect-error - Requires `text` prop FIXME: React17 types
<Avatar format={arbitraryFormat} />;
// Accepts null text prop
<Avatar format={arbitraryFormat} text={null} />;
Expand Down
5 changes: 4 additions & 1 deletion packages/button/src/Button/Button.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ const title = 'Test button title';
const child = 'Button child';

function renderButton(props: ButtonProps = {}) {
const utils = render(<Button {...props} data-testid="button-id" />);
const utils = render(
// @ts-ignore React17 types
<Button {...props} data-testid="button-id" />,
);
const { getButton, isDisabled } = getTestUtils();
const button = getButton();
return { ...utils, button, isDisabled };
Expand Down
11 changes: 2 additions & 9 deletions packages/card/src/Card/Card.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ import React from 'react';
import { render } from '@testing-library/react';
import { axe } from 'jest-axe';

import { InferredPolymorphicProps } from '@leafygreen-ui/polymorphic';

import { Card, CardProps, ContentStyle } from '.';

const defaultClassName = 'card-className';
Expand All @@ -15,20 +13,15 @@ function isVisuallyClickable(element: HTMLElement): boolean {
);
}

type DivLikeProps = InferredPolymorphicProps<'div', CardProps>;

type AnchorLikeProps = InferredPolymorphicProps<'a', CardProps>;

type CardRenderProps = DivLikeProps | AnchorLikeProps;

function renderCard({
children = defaultChildren,
className = defaultClassName,
...rest
}: CardRenderProps = {}) {
}: CardProps = {}) {
const cardId = 'cardID';

const { container, getByTestId } = render(
// @ts-ignore React17 types
<Card data-testid={cardId} className={className} {...rest}>
{children}
</Card>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,9 @@ describe('DatePicker keyboard interaction', () => {
expect(monthSelect).toHaveFocus();

userEvent.keyboard('[Enter]');
await waitFor(() => jest.advanceTimersByTime(transitionDuration.default));
await waitFor(() => {
jest.advanceTimersByTime(transitionDuration.default);
});

const options = await findAllByRole('option');
const firstOption = options[0];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import userEvent from '@testing-library/user-event';
import { CalendarCell, CalendarCellState } from '.';

/** Ensures valid DOM nesting when testing CalendarCells */
const TestCellWrapper = ({ children }: PropsWithChildren) => (
const TestCellWrapper = ({ children }: PropsWithChildren<{}>) => (
<table>
<tbody>
<tr data-testid="tr">{children}</tr>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React from 'react';
import { ChangeEventHandler } from 'react';
import { render } from '@testing-library/react';
import { RenderHookResult } from '@testing-library/react';
import userEvent from '@testing-library/user-event';

import { act, renderHook } from '@leafygreen-ui/testing-lib';
Expand All @@ -12,15 +11,12 @@ const errorSpy = jest.spyOn(console, 'error');

const renderUseControlledValueHook = <T extends any>(
...[valueProp, callback, initial]: Parameters<typeof useControlledValue<T>>
): RenderHookResult<
ReturnType<typeof useControlledValue<T>>,
typeof valueProp
> => {
) => {
const result = renderHook(v => useControlledValue(v, callback, initial), {
initialProps: valueProp,
});

return { ...result };
return result;
};

describe('packages/date-picker/hooks/useControlledValue', () => {
Expand Down
26 changes: 17 additions & 9 deletions packages/descendants/src/Descendants/Descendants.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,8 @@ describe('packages/descendants', () => {
</>,
);

const appleDescendant = hook.result.current.descendants[0];
const current = hook.result.current;
const appleDescendant = current!.descendants?.[0];
expect(appleDescendant).toBeDefined();
});

Expand All @@ -199,7 +200,8 @@ describe('packages/descendants', () => {
</>,
);

const appleDescendant = hook.result.current.descendants[0];
const current = hook.result.current;
const appleDescendant = current!.descendants?.[0];
expect(appleDescendant).toBeDefined();
});

Expand All @@ -211,9 +213,9 @@ describe('packages/descendants', () => {
<TestDescendant>Banana</TestDescendant>
</>,
);

const current = hook.result.current;
const appleElement = renderResult.getByTestId('apple');
const appleDescendant = hook.result.current.descendants[0];
const appleDescendant = current!.descendants?.[0];
expect(appleDescendant).toBeDefined();
expect(appleDescendant.element).toEqual(appleElement);
});
Expand All @@ -226,7 +228,8 @@ describe('packages/descendants', () => {
</>,
);

const appleDescendant = hook.result.current.descendants[0];
const current = hook.result.current;
const appleDescendant = current!.descendants?.[0];
expect(appleDescendant.index).toEqual(0);
});

Expand All @@ -238,7 +241,8 @@ describe('packages/descendants', () => {
</>,
);

const appleDescendant = hook.result.current.descendants[0];
const current = hook.result.current;
const appleDescendant = current!.descendants?.[0];
expect(appleDescendant.props?.group).toEqual('fruit');
});

Expand All @@ -259,7 +263,8 @@ describe('packages/descendants', () => {
</>,
);

const appleDescendant = hook.result.current.descendants[2];
const current = hook.result.current;
const appleDescendant = current!.descendants?.[2];
expect(appleDescendant.element).toHaveTextContent('Apple');
expect(appleDescendant.index).toEqual(2);
});
Expand All @@ -280,8 +285,11 @@ describe('packages/descendants', () => {
</>,
);

for (let i = 0; i < hook.result.current.descendants.length; i++) {
const descendant = hook.result.current.descendants[i];
const current = hook.result.current;
const descendantCount = current!.descendants?.length ?? 0;

for (let i = 0; i < descendantCount; i++) {
const descendant = current!.descendants?.[i];
expect(descendant.index).toEqual(i);
}
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React, { ReactNode } from 'react';
import { render, RenderHookResult, RenderResult } from '@testing-library/react';
import { render, RenderResult } from '@testing-library/react';

import { renderHook } from '@leafygreen-ui/testing-lib';
import { renderHook, RenderHookResult } from '@leafygreen-ui/testing-lib';

import { InitDescendantsReturnObject } from '../Descendants/useInitDescendants';
import { type InitDescendantsReturnObject } from '../Descendants/useInitDescendants';
import { useInitDescendants } from '..';

import { TestDescendantContext } from './components.testutils';
Expand Down
6 changes: 4 additions & 2 deletions packages/drawer/src/DrawerLayout/DrawerLayout.types.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import { DarkModeProps, HTMLElementProps } from '@leafygreen-ui/lib';
import { ComponentPropsWithoutRef } from 'react';

import { DarkModeProps } from '@leafygreen-ui/lib';

import { DrawerProps } from '../Drawer/Drawer.types';
import { DrawerToolbarLayoutProps } from '../DrawerToolbarLayout';

type PickedDrawerProps = Pick<DrawerProps, 'onClose' | 'size'>;

export interface BaseDrawerLayoutPropsWithoutDisplayMode
extends HTMLElementProps<'div'>,
extends ComponentPropsWithoutRef<'div'>,
DarkModeProps,
PickedDrawerProps {
children: React.ReactNode;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const Component = ({
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);

return '🌻';
return <>🌻</>;
};

return (
Expand Down
2 changes: 1 addition & 1 deletion packages/form-field/src/FormField.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -648,7 +648,7 @@ describe('packages/form-field', () => {
// eslint-disable-next-line jest/no-disabled-tests
test.skip('Types', () => {
render(
// @ts-expect-error - label is required
// @ts-ignore React18-expect-error - label is required
<FormField>
<div />
</FormField>,
Expand Down
1 change: 0 additions & 1 deletion packages/hooks/src/useDynamicRefs/useDynamicRefs.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// import { renderHook } from '@testing-library/react-hooks';
import { consoleOnce } from '@leafygreen-ui/lib';
import { renderHook } from '@leafygreen-ui/testing-lib';

Expand Down
2 changes: 1 addition & 1 deletion packages/hooks/src/useFirstRender/useFirstRender.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { renderHook } from '@testing-library/react';
import { renderHook } from '@leafygreen-ui/testing-lib';

import { useFirstRender } from '.';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ describe('useMigrationContext', () => {
test('passes provider props correctly', () => {
const customProps = { forceUseTopLayer: true };
const { result } = renderHook(useMigrationContext, {
wrapper: ({ children }) => (
wrapper: ({ children }: any) => (
<MigrationProvider {...customProps}>{children}</MigrationProvider>
),
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ describe('usePopoverContext', () => {

test('`setIsPopoverOpen` updates the value of `isPopoverOpen`', async () => {
const { result, rerender } = renderHook(usePopoverContext, {
wrapper: ({ children }) => <PopoverProvider>{children}</PopoverProvider>,
wrapper: ({ children }: any) => (
<PopoverProvider>{children}</PopoverProvider>
),
});

act(() => result.current.setIsPopoverOpen(true));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ describe('usePopoverPropsContext', () => {
usePortal: true,
};
const { result } = renderHook(usePopoverPropsContext, {
wrapper: ({ children }) => (
wrapper: ({ children }: any) => (
<PopoverPropsProvider {...customProps}>{children}</PopoverPropsProvider>
),
});
Expand Down
6 changes: 5 additions & 1 deletion packages/lib/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,11 @@ export { isComponentType, validateChildren } from './validateChildren';
export { createUniqueClassName, getNodeTextContent, getTheme, Theme, typeIs };
export type { DarkModeProps, LgIdProps, LgIdString };

/** Helper type to extract an HTML element's valid props */
/**
* Helper type to extract an HTML element's valid props
*
* @deprecated - Prefer the built-in React type {@link React.ComponentProps}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

drive-by change

* */
export type HTMLElementProps<
Element extends keyof JSX.IntrinsicElements,
RefType extends HTMLElement = never,
Expand Down
Loading