From b76dd0dd23d3498b88d2735733da984e927390f5 Mon Sep 17 00:00:00 2001 From: Adam Thompson Date: Fri, 10 Oct 2025 16:31:41 -0400 Subject: [PATCH 01/13] adds lgids --- packages/wizard/src/Wizard/Wizard.tsx | 10 +++++++++- packages/wizard/src/Wizard/Wizard.types.ts | 4 +++- packages/wizard/src/WizardFooter/WizardFooter.tsx | 6 +++++- packages/wizard/src/WizardStep/WizardStep.tsx | 4 +++- packages/wizard/src/utils/getLgIds.ts | 2 ++ 5 files changed, 22 insertions(+), 4 deletions(-) diff --git a/packages/wizard/src/Wizard/Wizard.tsx b/packages/wizard/src/Wizard/Wizard.tsx index ad5ed5d165..a04f71d3bc 100644 --- a/packages/wizard/src/Wizard/Wizard.tsx +++ b/packages/wizard/src/Wizard/Wizard.tsx @@ -9,6 +9,7 @@ import { Direction } from '@leafygreen-ui/descendants'; import { useControlled } from '@leafygreen-ui/hooks'; import { WizardSubComponentProperties } from '../constants'; +import { getLgIds } from '../utils/getLgIds'; import { WizardProvider } from '../WizardContext/WizardContext'; import { WizardFooter } from '../WizardFooter'; import { WizardStep } from '../WizardStep'; @@ -21,8 +22,10 @@ export const Wizard = CompoundComponent( activeStep: activeStepProp, onStepChange, children, + 'data-lgid': dataLgid, ...rest }: WizardProps) => { + const LGIDs = getLgIds(dataLgid); const stepChildren = findChildren( children, WizardSubComponentProperties.Step, @@ -70,7 +73,12 @@ export const Wizard = CompoundComponent( return ( -
+
{currentStep}
{footerChild}
diff --git a/packages/wizard/src/Wizard/Wizard.types.ts b/packages/wizard/src/Wizard/Wizard.types.ts index 7fc1a3901a..865527a4ec 100644 --- a/packages/wizard/src/Wizard/Wizard.types.ts +++ b/packages/wizard/src/Wizard/Wizard.types.ts @@ -1,9 +1,11 @@ import { ComponentPropsWithRef, ReactNode } from 'react'; +import { LgIdProps } from '@leafygreen-ui/lib'; + import { WizardFooter } from '../WizardFooter'; import { WizardStep } from '../WizardStep'; -export interface WizardProps extends ComponentPropsWithRef<'div'> { +export interface WizardProps extends LgIdProps, ComponentPropsWithRef<'div'> { /** * The current active step index (0-based). If provided, the component operates in controlled mode. */ diff --git a/packages/wizard/src/WizardFooter/WizardFooter.tsx b/packages/wizard/src/WizardFooter/WizardFooter.tsx index 2a46c9201a..31c7425fb2 100644 --- a/packages/wizard/src/WizardFooter/WizardFooter.tsx +++ b/packages/wizard/src/WizardFooter/WizardFooter.tsx @@ -6,6 +6,7 @@ import { FormFooter } from '@leafygreen-ui/form-footer'; import { consoleOnce } from '@leafygreen-ui/lib'; import { WizardSubComponentProperties } from '../constants'; +import { getLgIds } from '../utils/getLgIds'; import { useWizardContext } from '../WizardContext'; import { WizardFooterProps } from './WizardFooter.types'; @@ -18,6 +19,7 @@ export const WizardFooter = CompoundSubComponent( className, ...rest }: WizardFooterProps) => { + const LGIDs = getLgIds(); const { isWizardContext, activeStep, updateStep } = useWizardContext(); const handleBackButtonClick: MouseEventHandler = e => { @@ -41,8 +43,10 @@ export const WizardFooter = CompoundSubComponent( return ( 0 ? { diff --git a/packages/wizard/src/WizardStep/WizardStep.tsx b/packages/wizard/src/WizardStep/WizardStep.tsx index 4af5eba958..09ef21c922 100644 --- a/packages/wizard/src/WizardStep/WizardStep.tsx +++ b/packages/wizard/src/WizardStep/WizardStep.tsx @@ -6,6 +6,7 @@ import { consoleOnce } from '@leafygreen-ui/lib'; import { Description, H3 } from '@leafygreen-ui/typography'; import { WizardSubComponentProperties } from '../constants'; +import { getLgIds } from '../utils/getLgIds'; import { useWizardContext } from '../WizardContext'; import { TextNode } from './TextNode'; @@ -15,6 +16,7 @@ import { WizardStepProps } from './WizardStep.types'; export const WizardStep = CompoundSubComponent( ({ title, description, children, className, ...rest }: WizardStepProps) => { const { isWizardContext } = useWizardContext(); + const LGIDs = getLgIds(); if (!isWizardContext) { consoleOnce.error( @@ -24,7 +26,7 @@ export const WizardStep = CompoundSubComponent( } return ( -
+
{title} {description && {description}}
{children}
diff --git a/packages/wizard/src/utils/getLgIds.ts b/packages/wizard/src/utils/getLgIds.ts index 9590c84563..99c7375560 100644 --- a/packages/wizard/src/utils/getLgIds.ts +++ b/packages/wizard/src/utils/getLgIds.ts @@ -5,6 +5,8 @@ export const DEFAULT_LGID_ROOT = 'lg-wizard'; export const getLgIds = (root: LgIdString = DEFAULT_LGID_ROOT) => { const ids = { root, + step: `${root}-step`, + footer: `${root}-footer` } as const; return ids; }; From 3e63ee8ffccd361928a7d84dc62eaf73bb44cad4 Mon Sep 17 00:00:00 2001 From: Adam Thompson Date: Fri, 10 Oct 2025 16:40:49 -0400 Subject: [PATCH 02/13] creates test utils --- packages/wizard/src/Wizard/Wizard.tsx | 6 +- .../src/WizardContext/WizardContext.tsx | 4 + .../wizard/src/WizardFooter/WizardFooter.tsx | 5 +- packages/wizard/src/WizardStep/WizardStep.tsx | 11 +- .../wizard/src/testing/getTestUtils.spec.tsx | 316 +++++++++++++++++- packages/wizard/src/testing/getTestUtils.tsx | 137 +++++++- .../wizard/src/testing/getTestUtils.types.ts | 84 ++++- packages/wizard/src/testing/index.ts | 5 +- 8 files changed, 555 insertions(+), 13 deletions(-) diff --git a/packages/wizard/src/Wizard/Wizard.tsx b/packages/wizard/src/Wizard/Wizard.tsx index a04f71d3bc..1a66bff5d0 100644 --- a/packages/wizard/src/Wizard/Wizard.tsx +++ b/packages/wizard/src/Wizard/Wizard.tsx @@ -72,7 +72,11 @@ export const Wizard = CompoundComponent( const currentStep = stepChildren[activeStep] || null; return ( - +
void; + lgId?: LgIdString; } export const WizardContext = createContext({ @@ -18,6 +20,7 @@ export const WizardProvider = ({ children, activeStep, updateStep, + lgId, }: PropsWithChildren>) => { return ( {children} diff --git a/packages/wizard/src/WizardFooter/WizardFooter.tsx b/packages/wizard/src/WizardFooter/WizardFooter.tsx index 31c7425fb2..ea3c2e212e 100644 --- a/packages/wizard/src/WizardFooter/WizardFooter.tsx +++ b/packages/wizard/src/WizardFooter/WizardFooter.tsx @@ -19,8 +19,9 @@ export const WizardFooter = CompoundSubComponent( className, ...rest }: WizardFooterProps) => { - const LGIDs = getLgIds(); - const { isWizardContext, activeStep, updateStep } = useWizardContext(); + const { isWizardContext, activeStep, updateStep, lgId } = + useWizardContext(); + const LGIDs = getLgIds(lgId); const handleBackButtonClick: MouseEventHandler = e => { updateStep(Direction.Prev); diff --git a/packages/wizard/src/WizardStep/WizardStep.tsx b/packages/wizard/src/WizardStep/WizardStep.tsx index 09ef21c922..328db7fd0c 100644 --- a/packages/wizard/src/WizardStep/WizardStep.tsx +++ b/packages/wizard/src/WizardStep/WizardStep.tsx @@ -15,8 +15,8 @@ import { WizardStepProps } from './WizardStep.types'; export const WizardStep = CompoundSubComponent( ({ title, description, children, className, ...rest }: WizardStepProps) => { - const { isWizardContext } = useWizardContext(); - const LGIDs = getLgIds(); + const { isWizardContext, lgId } = useWizardContext(); + const LGIDs = getLgIds(lgId); if (!isWizardContext) { consoleOnce.error( @@ -26,7 +26,12 @@ export const WizardStep = CompoundSubComponent( } return ( -
+
{title} {description && {description}}
{children}
diff --git a/packages/wizard/src/testing/getTestUtils.spec.tsx b/packages/wizard/src/testing/getTestUtils.spec.tsx index 6e928dca63..076448b83b 100644 --- a/packages/wizard/src/testing/getTestUtils.spec.tsx +++ b/packages/wizard/src/testing/getTestUtils.spec.tsx @@ -1,8 +1,320 @@ import React from 'react'; import { render } from '@testing-library/react'; +import userEvent from '@testing-library/user-event'; -import { Wizard } from '.'; +import { Wizard } from '../Wizard'; + +import { getTestUtils } from './getTestUtils'; + +function renderWizard() { + render( + + +

Content for step 1

+
+ +

Content for step 2

+
+ +

Content for step 3

+
+ +
, + ); + return getTestUtils(); +} + +function renderWizardWithoutFooter() { + render( + + +

Content for step 1

+
+ +

Content for step 2

+
+
, + ); + return getTestUtils(); +} + +function renderMultipleWizards() { + render( + <> + + +

Content

+
+ +
+ + +

Content

+
+ +
+ , + ); +} describe('packages/wizard/getTestUtils', () => { - test('condition', () => {}); + describe('throws error if Wizard is not found', () => { + test('getWizard', () => { + render(
); + + try { + const utils = getTestUtils(); + utils.getWizard(); + } catch (error) { + expect(error).toBeInstanceOf(Error); + expect(error).toHaveProperty( + 'message', + expect.stringMatching( + /Unable to find an element by: \[data-lgid="lg-wizard"\]/, + ), + ); + } + }); + }); + + describe('single Wizard', () => { + describe('wizard root element', () => { + test('getWizard returns the wizard element', () => { + const { getWizard } = renderWizard(); + expect(getWizard()).toBeInTheDocument(); + }); + + test('queryWizard returns the wizard element', () => { + const { queryWizard } = renderWizard(); + expect(queryWizard()).toBeInTheDocument(); + }); + + test('queryWizard returns null when wizard is not found', () => { + render(
); + const { queryWizard } = getTestUtils(); + expect(queryWizard()).toBeNull(); + }); + + test('findWizard returns a promise that resolves to the wizard element', async () => { + const { findWizard } = renderWizard(); + const wizard = await findWizard(); + expect(wizard).toBeInTheDocument(); + }); + }); + + describe('current step', () => { + test('getCurrentStep returns the current step element', () => { + const { getCurrentStep } = renderWizard(); + const step = getCurrentStep(); + expect(step).toBeInTheDocument(); + expect(step).toHaveTextContent('Step 1'); + }); + + test('queryCurrentStep returns the current step element', () => { + const { queryCurrentStep } = renderWizard(); + const step = queryCurrentStep(); + expect(step).toBeInTheDocument(); + expect(step).toHaveTextContent('Step 1'); + }); + + test('findCurrentStep returns a promise that resolves to the current step', async () => { + const { findCurrentStep } = renderWizard(); + const step = await findCurrentStep(); + expect(step).toBeInTheDocument(); + expect(step).toHaveTextContent('Step 1'); + }); + + test('current step updates after clicking next', () => { + const { getCurrentStep, getPrimaryButtonUtils } = renderWizard(); + const initialStep = getCurrentStep(); + expect(initialStep).toHaveTextContent('Step 1'); + + const primaryButton = getPrimaryButtonUtils().getButton(); + userEvent.click(primaryButton); + + const nextStep = getCurrentStep(); + expect(nextStep).toHaveTextContent('Step 2'); + }); + }); + + describe('footer', () => { + test('getFooter returns the footer element', () => { + const { getFooter } = renderWizard(); + expect(getFooter()).toBeInTheDocument(); + }); + + test('queryFooter returns the footer element', () => { + const { queryFooter } = renderWizard(); + expect(queryFooter()).toBeInTheDocument(); + }); + + test('queryFooter returns null when footer is not present', () => { + const { queryFooter } = renderWizardWithoutFooter(); + expect(queryFooter()).toBeNull(); + }); + + test('findFooter returns a promise that resolves to the footer element', async () => { + const { findFooter } = renderWizard(); + const footer = await findFooter(); + expect(footer).toBeInTheDocument(); + }); + }); + + describe('primary button', () => { + test('getPrimaryButtonUtils returns button utilities', () => { + const { getPrimaryButtonUtils } = renderWizard(); + const utils = getPrimaryButtonUtils(); + expect(utils.getButton()).toBeInTheDocument(); + }); + + test('primary button can be clicked', () => { + const { getPrimaryButtonUtils, getCurrentStep } = renderWizard(); + const button = getPrimaryButtonUtils().getButton(); + + expect(getCurrentStep()).toHaveTextContent('Step 1'); + userEvent.click(button); + expect(getCurrentStep()).toHaveTextContent('Step 2'); + }); + + test('isDisabled works for primary button', () => { + render( + + Content + + , + ); + + const { getPrimaryButtonUtils } = getTestUtils(); + expect(getPrimaryButtonUtils().isDisabled()).toBe(true); + }); + }); + + describe('back button', () => { + test('back button is not present on first step', () => { + const { getBackButtonUtils } = renderWizard(); + expect(getBackButtonUtils().queryButton()).toBeNull(); + }); + + test('back button appears after navigating to second step', () => { + const { getPrimaryButtonUtils, getBackButtonUtils } = renderWizard(); + + // Navigate to step 2 + const primaryButton = getPrimaryButtonUtils().getButton(); + userEvent.click(primaryButton); + + // Back button should now be visible + expect(getBackButtonUtils().queryButton()).toBeInTheDocument(); + }); + + test('back button navigates to previous step', () => { + const { getPrimaryButtonUtils, getBackButtonUtils, getCurrentStep } = + renderWizard(); + + // Navigate to step 2 + userEvent.click(getPrimaryButtonUtils().getButton()); + expect(getCurrentStep()).toHaveTextContent('Step 2'); + + // Navigate back to step 1 + const backButton = getBackButtonUtils().getButton(); + userEvent.click(backButton); + expect(getCurrentStep()).toHaveTextContent('Step 1'); + }); + }); + + describe('cancel button', () => { + test('getCancelButtonUtils returns button utilities', () => { + const { getCancelButtonUtils } = renderWizard(); + const utils = getCancelButtonUtils(); + expect(utils.getButton()).toBeInTheDocument(); + expect(utils.getButton()).toHaveTextContent('Cancel'); + }); + + test('cancel button can be clicked', () => { + const handleCancel = jest.fn(); + render( + + Content + + , + ); + + const { getCancelButtonUtils } = getTestUtils(); + const button = getCancelButtonUtils().getButton(); + userEvent.click(button); + expect(handleCancel).toHaveBeenCalled(); + }); + + test('cancel button is not present when cancelButtonProps is undefined', () => { + render( + + Content + + , + ); + + const { getCancelButtonUtils } = getTestUtils(); + expect(getCancelButtonUtils().queryButton()).toBeNull(); + }); + }); + }); + + describe('multiple Wizard instances', () => { + test('can query different wizards by lgId', () => { + renderMultipleWizards(); + + const utils1 = getTestUtils('lg-wizard-1'); + const utils2 = getTestUtils('lg-wizard-2'); + + expect(utils1.getWizard()).toBeInTheDocument(); + expect(utils2.getWizard()).toBeInTheDocument(); + + expect(utils1.getCurrentStep()).toHaveTextContent('Wizard 1 Step'); + expect(utils2.getCurrentStep()).toHaveTextContent('Wizard 2 Step'); + }); + + test('can query different wizard buttons by lgId', () => { + renderMultipleWizards(); + + const utils1 = getTestUtils('lg-wizard-1'); + const utils2 = getTestUtils('lg-wizard-2'); + + const button1 = utils1.getPrimaryButtonUtils().getButton(); + const button2 = utils2.getPrimaryButtonUtils().getButton(); + + expect(button1).toHaveTextContent('Next'); + expect(button2).toHaveTextContent('Continue'); + }); + }); }); diff --git a/packages/wizard/src/testing/getTestUtils.tsx b/packages/wizard/src/testing/getTestUtils.tsx index ad89a6e99d..d7ce5e3361 100644 --- a/packages/wizard/src/testing/getTestUtils.tsx +++ b/packages/wizard/src/testing/getTestUtils.tsx @@ -1,15 +1,146 @@ import { findByLgId, getByLgId, queryByLgId } from '@lg-tools/test-harnesses'; +import { screen } from '@testing-library/react'; import { LgIdString } from '@leafygreen-ui/lib'; import { DEFAULT_LGID_ROOT, getLgIds } from '../utils/getLgIds'; -import { TestUtilsReturnType } from './getTestUtils.types'; +import { + WizardButtonUtils, + WizardTestUtilsReturnType, +} from './getTestUtils.types'; + +// FormFooter button test IDs (since Wizard.Footer uses FormFooter internally) +const getFormFooterTestIds = (wizardLgId: LgIdString) => { + const footerLgId = `${wizardLgId}-footer`; + return { + backButton: `${footerLgId}-back_button`, + cancelButton: `${footerLgId}-cancel_button`, + primaryButton: `${footerLgId}-primary_button`, + } as const; +}; + +/** + * Creates button utilities that query by testid (since FormFooter uses testids for buttons) + */ +const createButtonUtils = (testId: string): WizardButtonUtils => { + const findButton = async () => { + return screen.findByTestId(testId) as Promise; + }; + + const getButton = () => { + return screen.getByTestId(testId) as HTMLButtonElement; + }; + + const queryButton = () => { + return screen.queryByTestId(testId) as HTMLButtonElement | null; + }; + + const isDisabled = () => { + const button = getButton(); + return button.getAttribute('aria-disabled') === 'true'; + }; + + return { + findButton, + getButton, + queryButton, + isDisabled, + }; +}; export const getTestUtils = ( lgId: LgIdString = DEFAULT_LGID_ROOT, -): TestUtilsReturnType => { +): WizardTestUtilsReturnType => { const lgIds = getLgIds(lgId); + const footerButtonTestIds = getFormFooterTestIds(lgId); + + /** + * @returns a promise that resolves to the wizard root element using the `data-lgid` data attribute. + * The promise is rejected if no elements match or if more than one match is found. + */ + const findWizard = () => findByLgId!(lgIds.root); + + /** + * @returns the wizard root element using the `data-lgid` data attribute. + * Will throw if no elements match or if more than one match is found. + */ + const getWizard = () => getByLgId!(lgIds.root); + + /** + * @returns the wizard root element using the `data-lgid` data attribute or `null` if no elements match. + * Will throw if more than one match is found. + */ + const queryWizard = () => queryByLgId!(lgIds.root); + + /** + * @returns a promise that resolves to the current step element using the `data-lgid` data attribute. + * The promise is rejected if no elements match or if more than one match is found. + */ + const findCurrentStep = () => findByLgId!(lgIds.step); + + /** + * @returns the current step element using the `data-lgid` data attribute. + * Will throw if no elements match or if more than one match is found. + */ + const getCurrentStep = () => getByLgId!(lgIds.step); + + /** + * @returns the current step element using the `data-lgid` data attribute or `null` if no elements match. + * Will throw if more than one match is found. + */ + const queryCurrentStep = () => queryByLgId!(lgIds.step); + + /** + * @returns a promise that resolves to the footer element using the `data-testid` data attribute. + * The promise is rejected if no elements match or if more than one match is found. + */ + const findFooter = () => + screen.findByTestId(lgIds.footer) as Promise; + + /** + * @returns the footer element using the `data-testid` data attribute. + * Will throw if no elements match or if more than one match is found. + */ + const getFooter = () => screen.getByTestId(lgIds.footer) as HTMLElement; + + /** + * @returns the footer element using the `data-testid` data attribute or `null` if no elements match. + * Will throw if more than one match is found. + */ + const queryFooter = () => + screen.queryByTestId(lgIds.footer) as HTMLElement | null; + + /** + * Returns test utilities for the back button in the footer + */ + const getBackButtonUtils = () => + createButtonUtils(footerButtonTestIds.backButton); + + /** + * Returns test utilities for the cancel button in the footer + */ + const getCancelButtonUtils = () => + createButtonUtils(footerButtonTestIds.cancelButton); + + /** + * Returns test utilities for the primary button in the footer + */ + const getPrimaryButtonUtils = () => + createButtonUtils(footerButtonTestIds.primaryButton); - return {}; + return { + findWizard, + getWizard, + queryWizard, + findCurrentStep, + getCurrentStep, + queryCurrentStep, + findFooter, + getFooter, + queryFooter, + getBackButtonUtils, + getCancelButtonUtils, + getPrimaryButtonUtils, + }; }; diff --git a/packages/wizard/src/testing/getTestUtils.types.ts b/packages/wizard/src/testing/getTestUtils.types.ts index 4b2df87c73..7ed732fb9d 100644 --- a/packages/wizard/src/testing/getTestUtils.types.ts +++ b/packages/wizard/src/testing/getTestUtils.types.ts @@ -1 +1,83 @@ -export interface TestUtilsReturnType {} +export interface WizardButtonUtils { + /** + * Returns a promise that resolves to the button element + */ + findButton: () => Promise; + + /** + * Returns the button element. Will throw if not found + */ + getButton: () => HTMLButtonElement; + + /** + * Returns the button element or null if not found + */ + queryButton: () => HTMLButtonElement | null; + + /** + * Returns whether the button is disabled + */ + isDisabled: () => boolean; +} + +export interface WizardTestUtilsReturnType { + /** + * Returns a promise that resolves to the wizard root element + */ + findWizard: () => Promise; + + /** + * Returns the wizard root element. Will throw if not found + */ + getWizard: () => HTMLElement; + + /** + * Returns the wizard root element or null if not found + */ + queryWizard: () => HTMLElement | null; + + /** + * Returns a promise that resolves to the current step element + */ + findCurrentStep: () => Promise; + + /** + * Returns the current step element. Will throw if not found + */ + getCurrentStep: () => HTMLElement; + + /** + * Returns the current step element or null if not found + */ + queryCurrentStep: () => HTMLElement | null; + + /** + * Returns a promise that resolves to the footer element + */ + findFooter: () => Promise; + + /** + * Returns the footer element. Will throw if not found + */ + getFooter: () => HTMLElement; + + /** + * Returns the footer element or null if not found + */ + queryFooter: () => HTMLElement | null; + + /** + * Returns test utilities for the back button + */ + getBackButtonUtils: () => WizardButtonUtils; + + /** + * Returns test utilities for the cancel button + */ + getCancelButtonUtils: () => WizardButtonUtils; + + /** + * Returns test utilities for the primary button + */ + getPrimaryButtonUtils: () => WizardButtonUtils; +} diff --git a/packages/wizard/src/testing/index.ts b/packages/wizard/src/testing/index.ts index 4c102995fa..a66d8e284a 100644 --- a/packages/wizard/src/testing/index.ts +++ b/packages/wizard/src/testing/index.ts @@ -1,2 +1,5 @@ export { getTestUtils } from './getTestUtils'; -export { type TestUtilsReturnType } from './getTestUtils.types'; +export { + type WizardButtonUtils, + type WizardTestUtilsReturnType, +} from './getTestUtils.types'; From 950cf6926c2f8393a8e2bbb97323237395c241e7 Mon Sep 17 00:00:00 2001 From: Adam Thompson Date: Fri, 10 Oct 2025 17:10:47 -0400 Subject: [PATCH 03/13] lint --- packages/wizard/src/utils/getLgIds.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/wizard/src/utils/getLgIds.ts b/packages/wizard/src/utils/getLgIds.ts index 99c7375560..263769bc31 100644 --- a/packages/wizard/src/utils/getLgIds.ts +++ b/packages/wizard/src/utils/getLgIds.ts @@ -6,7 +6,7 @@ export const getLgIds = (root: LgIdString = DEFAULT_LGID_ROOT) => { const ids = { root, step: `${root}-step`, - footer: `${root}-footer` + footer: `${root}-footer`, } as const; return ids; }; From fb93ebb9587b927480ed20c3c48e4d5bf9efd8ae Mon Sep 17 00:00:00 2001 From: Stephen Lee Date: Mon, 13 Oct 2025 08:12:26 -0700 Subject: [PATCH 04/13] chore(modal): upgrade modal packages to use @leafygreen-ui/modal@20.1.1 (#3209) --- .changeset/upgrade-modals.md | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 .changeset/upgrade-modals.md diff --git a/.changeset/upgrade-modals.md b/.changeset/upgrade-modals.md new file mode 100644 index 0000000000..d7e9b5d1a4 --- /dev/null +++ b/.changeset/upgrade-modals.md @@ -0,0 +1,7 @@ +--- +'@leafygreen-ui/confirmation-modal': patch +'@leafygreen-ui/marketing-modal': patch +--- + +Update `@leafygreen-ui/modal` dependency to use version 20.1.1 + From 47af0cdbbecbc0906b07ea5a647a27b831497da0 Mon Sep 17 00:00:00 2001 From: Stephen Lee Date: Mon, 13 Oct 2025 08:13:19 -0700 Subject: [PATCH 05/13] chore(test): exclude deprecated packages from tests (#3207) * fix(box): silence test lint warnings * chore(test): skip tests in deprecated-packages * chore: update emotion version and ALL_PACKAGES list --- deprecated-packages/box/src/Box.spec.tsx | 1 + tools/install/src/ALL_PACKAGES.ts | 1 + tools/test/config/jest.config.js | 2 +- tools/test/config/react17/jest.config.js | 2 +- 4 files changed, 4 insertions(+), 2 deletions(-) diff --git a/deprecated-packages/box/src/Box.spec.tsx b/deprecated-packages/box/src/Box.spec.tsx index ff5839f131..650c9e1a90 100644 --- a/deprecated-packages/box/src/Box.spec.tsx +++ b/deprecated-packages/box/src/Box.spec.tsx @@ -1,3 +1,4 @@ +/* eslint-disable jest/expect-expect */ import React from 'react'; import { cleanup, render } from '@testing-library/react'; import { axe } from 'jest-axe'; diff --git a/tools/install/src/ALL_PACKAGES.ts b/tools/install/src/ALL_PACKAGES.ts index 0b921287d8..976ce721cb 100644 --- a/tools/install/src/ALL_PACKAGES.ts +++ b/tools/install/src/ALL_PACKAGES.ts @@ -14,6 +14,7 @@ export const ALL_PACKAGES = [ '@leafygreen-ui/code', '@leafygreen-ui/code-editor', '@leafygreen-ui/combobox', + '@leafygreen-ui/compound-component', '@leafygreen-ui/confirmation-modal', '@leafygreen-ui/context-drawer', '@leafygreen-ui/copyable', diff --git a/tools/test/config/jest.config.js b/tools/test/config/jest.config.js index 3213e2bb57..feaed6d5f7 100644 --- a/tools/test/config/jest.config.js +++ b/tools/test/config/jest.config.js @@ -49,7 +49,7 @@ module.exports = { testEnvironment: 'jsdom', // An array of regexp pattern strings that are matched against all test paths, matched tests are skipped - testPathIgnorePatterns: ['/node_modules/'], + testPathIgnorePatterns: ['/node_modules/', '/deprecated-packages/'], // The regexp pattern Jest uses to detect test files testRegex: '.spec.[jt]sx?$', diff --git a/tools/test/config/react17/jest.config.js b/tools/test/config/react17/jest.config.js index af4ad01e1d..37f84bcf85 100644 --- a/tools/test/config/react17/jest.config.js +++ b/tools/test/config/react17/jest.config.js @@ -42,7 +42,7 @@ module.exports = { testEnvironment: 'jsdom', // An array of regexp pattern strings that are matched against all test paths, matched tests are skipped - testPathIgnorePatterns: ['/node_modules/'], + testPathIgnorePatterns: ['/node_modules/', '/deprecated-packages/'], // The regexp pattern Jest uses to detect test files testRegex: '.spec.[jt]sx?$', From 9a61957ea11f0e94a0883a3dbfaf015d96aa05af Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 13 Oct 2025 17:02:37 +0000 Subject: [PATCH 06/13] Version Packages (#3204) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- .changeset/tidy-sloths-nail.md | 6 ------ .changeset/upgrade-modals.md | 7 ------- .changeset/useControlled-inferred-types.md | 5 ----- chat/message-prompts/CHANGELOG.md | 7 +++++++ chat/message-prompts/package.json | 2 +- packages/confirmation-modal/CHANGELOG.md | 6 ++++++ packages/confirmation-modal/package.json | 2 +- packages/hooks/CHANGELOG.md | 6 ++++++ packages/hooks/package.json | 2 +- packages/marketing-modal/CHANGELOG.md | 6 ++++++ packages/marketing-modal/package.json | 2 +- 11 files changed, 29 insertions(+), 22 deletions(-) delete mode 100644 .changeset/tidy-sloths-nail.md delete mode 100644 .changeset/upgrade-modals.md delete mode 100644 .changeset/useControlled-inferred-types.md diff --git a/.changeset/tidy-sloths-nail.md b/.changeset/tidy-sloths-nail.md deleted file mode 100644 index 9c3c530673..0000000000 --- a/.changeset/tidy-sloths-nail.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -'@lg-chat/message-prompts': minor ---- - -- [LG-5438](https://jira.mongodb.org/browse/LG-5438) add `onClickRefresh` prop which conditionally renders refresh button -- [LG-5440](https://jira.mongodb.org/browse/LG-5440) add `enableHideOnSelect` prop which causes fade/shrink transition when a prompt is selected. This is set to `true` by default. diff --git a/.changeset/upgrade-modals.md b/.changeset/upgrade-modals.md deleted file mode 100644 index d7e9b5d1a4..0000000000 --- a/.changeset/upgrade-modals.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -'@leafygreen-ui/confirmation-modal': patch -'@leafygreen-ui/marketing-modal': patch ---- - -Update `@leafygreen-ui/modal` dependency to use version 20.1.1 - diff --git a/.changeset/useControlled-inferred-types.md b/.changeset/useControlled-inferred-types.md deleted file mode 100644 index 824c233cfc..0000000000 --- a/.changeset/useControlled-inferred-types.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@leafygreen-ui/hooks': patch ---- - -The type of the returned `value` is now inferred from the types of the parameters in `useControlled` diff --git a/chat/message-prompts/CHANGELOG.md b/chat/message-prompts/CHANGELOG.md index c404d325c1..b3c5065d44 100644 --- a/chat/message-prompts/CHANGELOG.md +++ b/chat/message-prompts/CHANGELOG.md @@ -1,5 +1,12 @@ # @lg-chat/message-prompts +## 4.1.0 + +### Minor Changes + +- 9c44076: - [LG-5438](https://jira.mongodb.org/browse/LG-5438) add `onClickRefresh` prop which conditionally renders refresh button + - [LG-5440](https://jira.mongodb.org/browse/LG-5440) add `enableHideOnSelect` prop which causes fade/shrink transition when a prompt is selected. This is set to `true` by default. + ## 4.0.6 ### Patch Changes diff --git a/chat/message-prompts/package.json b/chat/message-prompts/package.json index c4663364e0..cf230becf7 100644 --- a/chat/message-prompts/package.json +++ b/chat/message-prompts/package.json @@ -1,6 +1,6 @@ { "name": "@lg-chat/message-prompts", - "version": "4.0.6", + "version": "4.1.0", "description": "LeafyGreen UI Kit Message Prompts", "main": "./dist/umd/index.js", "module": "./dist/esm/index.js", diff --git a/packages/confirmation-modal/CHANGELOG.md b/packages/confirmation-modal/CHANGELOG.md index a2a58b1eae..7259eff981 100644 --- a/packages/confirmation-modal/CHANGELOG.md +++ b/packages/confirmation-modal/CHANGELOG.md @@ -1,5 +1,11 @@ # @leafygreen-ui/confirmation-modal +## 10.1.1 + +### Patch Changes + +- fb93ebb: Update `@leafygreen-ui/modal` dependency to use version 20.1.1 + ## 10.1.0 ### Minor Changes diff --git a/packages/confirmation-modal/package.json b/packages/confirmation-modal/package.json index d16c6f7e41..262c4ed8bd 100644 --- a/packages/confirmation-modal/package.json +++ b/packages/confirmation-modal/package.json @@ -1,6 +1,6 @@ { "name": "@leafygreen-ui/confirmation-modal", - "version": "10.1.0", + "version": "10.1.1", "description": "leafyGreen UI Kit Confirmation Modal", "main": "./dist/umd/index.js", "module": "./dist/esm/index.js", diff --git a/packages/hooks/CHANGELOG.md b/packages/hooks/CHANGELOG.md index cef519429a..f88b953b4b 100644 --- a/packages/hooks/CHANGELOG.md +++ b/packages/hooks/CHANGELOG.md @@ -1,5 +1,11 @@ # @leafygreen-ui/hooks +## 9.2.1 + +### Patch Changes + +- bab8e2a: The type of the returned `value` is now inferred from the types of the parameters in `useControlled` + ## 9.2.0 ### Minor Changes diff --git a/packages/hooks/package.json b/packages/hooks/package.json index 6da4b096fb..9dc284cd0e 100644 --- a/packages/hooks/package.json +++ b/packages/hooks/package.json @@ -1,6 +1,6 @@ { "name": "@leafygreen-ui/hooks", - "version": "9.2.0", + "version": "9.2.1", "description": "LeafyGreen UI Kit Custom Hooks", "main": "./dist/umd/index.js", "module": "./dist/esm/index.js", diff --git a/packages/marketing-modal/CHANGELOG.md b/packages/marketing-modal/CHANGELOG.md index 5749627aea..b9abff9d9c 100644 --- a/packages/marketing-modal/CHANGELOG.md +++ b/packages/marketing-modal/CHANGELOG.md @@ -1,5 +1,11 @@ # @leafygreen-ui/marketing-modal +## 8.1.1 + +### Patch Changes + +- fb93ebb: Update `@leafygreen-ui/modal` dependency to use version 20.1.1 + ## 8.1.0 ### Minor Changes diff --git a/packages/marketing-modal/package.json b/packages/marketing-modal/package.json index 1fe8f863d3..1e2d95cd27 100644 --- a/packages/marketing-modal/package.json +++ b/packages/marketing-modal/package.json @@ -1,6 +1,6 @@ { "name": "@leafygreen-ui/marketing-modal", - "version": "8.1.0", + "version": "8.1.1", "description": "leafyGreen UI Kit Marketing Modal", "main": "./dist/umd/index.js", "module": "./dist/esm/index.js", From 5d8f337e79514829a8c75a800e75e4c0185c5625 Mon Sep 17 00:00:00 2001 From: Brooke Scarlett Yalof Date: Mon, 13 Oct 2025 14:31:37 -0400 Subject: [PATCH 07/13] Fixes TextInput component types (#3197) * fix text input * runs fix * fix mistake * reset file --- .changeset/eleven-cars-obey.md | 5 +++++ packages/text-area/src/TextArea/TextArea.spec.tsx | 11 ++++++++--- packages/text-input/src/TextInput/TextInput.spec.tsx | 9 ++++++--- packages/text-input/src/TextInput/TextInput.types.ts | 2 +- 4 files changed, 20 insertions(+), 7 deletions(-) create mode 100644 .changeset/eleven-cars-obey.md diff --git a/.changeset/eleven-cars-obey.md b/.changeset/eleven-cars-obey.md new file mode 100644 index 0000000000..8b2c6711ab --- /dev/null +++ b/.changeset/eleven-cars-obey.md @@ -0,0 +1,5 @@ +--- +'@leafygreen-ui/text-input': patch +--- + +Fixes props such that component now accepts a properly typed `ref` diff --git a/packages/text-area/src/TextArea/TextArea.spec.tsx b/packages/text-area/src/TextArea/TextArea.spec.tsx index 4f981577dc..23a96caf33 100644 --- a/packages/text-area/src/TextArea/TextArea.spec.tsx +++ b/packages/text-area/src/TextArea/TextArea.spec.tsx @@ -182,9 +182,14 @@ describe('packages/text-area', () => { }); }); - /* eslint-disable jest/no-disabled-tests */ - describe.skip('types behave as expected', () => { - test('TextArea throws error when neither aria-labelledby or label is supplied', () => { + describe('types behave as expected', () => { + test('TextArea takes a ref for a HTMLTextAreaElement', () => { + const ref = React.createRef(); + render(