- 
                Notifications
    
You must be signed in to change notification settings  - Fork 71
 
[LG-5567] Wizard Test harnesses #3208
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
          🦋 Changeset detectedLatest commit: c49df33 The changes in this PR will be included in the next version bump. This PR includes changesets to release 92 packages
 Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR  | 
    
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds test harnesses for the Wizard component to enable easier testing of Wizard functionality in consuming applications. The test harnesses provide utilities to query wizard elements by their data attributes and interact with wizard buttons.
Key changes:
- Added test utilities in 
packages/wizard/src/testing/that provide methods to find wizard elements and interact with buttons - Updated utility functions in 
packages/libto better handle mapped/flattened children arrays - Added exports for Direction and Position enums in descendants package
 - Updated package configuration and TypeScript references
 
Reviewed Changes
Copilot reviewed 40 out of 41 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description | 
|---|---|
| packages/wizard/src/testing/ | New test harness implementation with utilities for querying wizard elements and buttons | 
| packages/wizard/tsconfig.json | Added TypeScript configuration with test-harnesses reference | 
| packages/lib/src/childQueries/findChild*.tsx | Updated child query utilities to handle flattened arrays | 
| packages/descendants/src/index.ts | Added Direction and Position enum exports | 
| packages/wizard/package.json | Package configuration with testing export | 
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
 
| "exclude": ["**/*.spec.*", "**/*.stories.*"], | ||
| "references": [ | ||
| { | ||
| "path": "../button" | 
    
      
    
      Copilot
AI
    
    
    
      Oct 10, 2025 
    
  
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Duplicate reference to '../button' package. Remove one of these duplicate entries.
| "path": "../button" | ||
| }, | ||
| { | 
    
      
    
      Copilot
AI
    
    
    
      Oct 10, 2025 
    
  
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Duplicate reference to '../button' package. Remove one of these duplicate entries.
| "path": "../button" | |
| }, | |
| { | 
| * @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<HTMLElement>; | ||
| 
               | 
          ||
| /** | ||
| * @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; | 
    
      
    
      Copilot
AI
    
    
    
      Oct 10, 2025 
    
  
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The documentation incorrectly states that footer methods use data-testid attribute, but the implementation uses data-lgid attribute via getLgIds() function.
| * @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<HTMLElement>; | |
| /** | |
| * @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 a promise that resolves to the footer element using the `data-lgid` data attribute. | |
| * The promise is rejected if no elements match or if more than one match is found. | |
| */ | |
| const findFooter = () => | |
| findByLgId!<HTMLElement>(lgIds.footer); | |
| /** | |
| * @returns the footer element using the `data-lgid` data attribute. | |
| * Will throw if no elements match or if more than one match is found. | |
| */ | |
| const getFooter = () => getByLgId!<HTMLElement>(lgIds.footer); | |
| /** | |
| * @returns the footer element using the `data-lgid` data attribute or `null` if no elements match. | |
| * Will throw if more than one match is found. | |
| */ | |
| const queryFooter = () => | |
| queryByLgId!<HTMLElement>(lgIds.footer); | 
| * @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<HTMLElement>; | ||
| 
               | 
          ||
| /** | ||
| * @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. | 
    
      
    
      Copilot
AI
    
    
    
      Oct 10, 2025 
    
  
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The documentation incorrectly states that footer methods use data-testid attribute, but the implementation uses data-lgid attribute via getLgIds() function.
| * @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<HTMLElement>; | |
| /** | |
| * @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. | |
| * @returns a promise that resolves to the footer element using the `data-lgid` 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<HTMLElement>; | |
| /** | |
| * @returns the footer element using the `data-lgid` 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-lgid` data attribute or `null` if no elements match. | 
| * @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<HTMLElement>; | ||
| 
               | 
          ||
| /** | ||
| * @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; | 
    
      
    
      Copilot
AI
    
    
    
      Oct 10, 2025 
    
  
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The documentation incorrectly states that footer methods use data-testid attribute, but the implementation uses data-lgid attribute via getLgIds() function.
| * @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<HTMLElement>; | |
| /** | |
| * @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 a promise that resolves to the footer element using the `data-lgid` data attribute. | |
| * The promise is rejected if no elements match or if more than one match is found. | |
| */ | |
| const findFooter = () => | |
| findByLgId!<HTMLElement>(lgIds.footer); | |
| /** | |
| * @returns the footer element using the `data-lgid` data attribute. | |
| * Will throw if no elements match or if more than one match is found. | |
| */ | |
| const getFooter = () => getByLgId!<HTMLElement>(lgIds.footer); | |
| /** | |
| * @returns the footer element using the `data-lgid` data attribute or `null` if no elements match. | |
| * Will throw if more than one match is found. | |
| */ | |
| const queryFooter = () => | |
| queryByLgId!<HTMLElement>(lgIds.footer); | 
| 
           Size Change: +63 B (0%) Total Size: 1.6 MB 
 ℹ️ View Unchanged
  | 
    
* fix(box): silence test lint warnings * chore(test): skip tests in deprecated-packages * chore: update emotion version and ALL_PACKAGES list
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
* fix text input * runs fix * fix mistake * reset file
* update type * expand scope of solution
* Add children to Card type * pnpm changeset * Lint fix :-)
* Banner named export * update codemod * codemod tests * changesets * update tests * update readme
* fixed issue * with changeset
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this need a rebase off the integration branch? I think there are some changes I've reviewed from other PRs that are showing up in here
| @@ -0,0 +1,83 @@ | |||
| export interface WizardButtonUtils { | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can use GetTestUtilsReturnType from @leafygreen-ui/button/testing instead of redefining here
| /** | ||
| * @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!<HTMLElement>(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!<HTMLElement>(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!<HTMLElement>(lgIds.step); | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think a different approach will need to be taken for passing a data-lgid attribute to each step. As-is, there will be multiple with the same data-lgid which will cause these to all throw. An alternative is to apply a similar pattern used for Select or Tabs although that would also require using some other property like role to identify which children are Step instances used in a Wizard instance
          
 Probably, not sure how that happened  | 
    
✍️ Proposed changes
Adds Test Harnesses for Wizard component
https://jira.mongodb.org/browse/LG-5562