Skip to content

Badge - add BadgeDriver and scope inner testIDs#3993

Open
MIchaelZablianov wants to merge 4 commits into
masterfrom
feat/badge-driver-and-scoped-testIDs
Open

Badge - add BadgeDriver and scope inner testIDs#3993
MIchaelZablianov wants to merge 4 commits into
masterfrom
feat/badge-driver-and-scoped-testIDs

Conversation

@MIchaelZablianov
Copy link
Copy Markdown
Collaborator

@MIchaelZablianov MIchaelZablianov commented May 3, 2026

Description

Badge - add BadgeDriver and scope inner testIDs (${testID}.label, ${testID}.icon)

This PR:

  • Adds BadgeDriver next to the component (badge/badge.driver.ts), composing useComponentDriver, usePressableDriver, TextDriver, and ImageDriver. Exposes getLabel, getIcon, getStyle, getSize.
  • Scopes Badge's inner testIDs:
    • Label: ${testID}.label (falls back to the legacy "badge" when no testID is provided, to preserve backward compatibility for any existing tests).
    • Icon: ${testID}.icon (only when testID is provided).
  • Re-exports BadgeDriver from src/testkit/index.ts.
  • Adds badge.driver.spec.tsx covering label text, icon presence, and size.

This unblocks PR https://github.com/wix-private/wix-react-native-ui-lib/pull/6104 which needs to compose BadgeDriver from the public testkit.

Changelog

Badge - add BadgeDriver and scope inner testIDs (${testID}.label, ${testID}.icon)

Additional info

https://wix.atlassian.net/browse/MADS-4754

Co-authored-by: Cursor <cursoragent@cursor.com>
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 3, 2026

✅ PR Description Validation Passed

All required sections are properly filled out:

  • Description
  • Changelog
  • Additional info

Your PR is good for review! 🚀


This validation ensures all sections from the PR template are properly filled.

@MIchaelZablianov
Copy link
Copy Markdown
Collaborator Author

#rebuild

allowFontScaling={false}
numberOfLines={1}
testID="badge"
testID={testID ? `${testID}.label` : 'badge'}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This could be a breaking change for users who relays on this testID for testing.
For now I would leave it as is.

//@ts-ignore
borderColor={borderColor}
testID={testID ? `${testID}.icon` : undefined}
{...iconProps}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Notice here that the iconProps will override the testID

});

it('should not render icon when icon prop is missing', () => {
const driver = getDriver({label: '5'});
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

do you need to pass label in this case ?


it('should expose default badge size when no size prop is given', () => {
const driver = getDriver({label: '5'});
expect(driver.getSize()).toEqual(20);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

if the default size is set in some constant maybe it's better to use it here.
I didn't checked it.

Copy link
Copy Markdown
Contributor

@adids1221 adids1221 left a comment

Choose a reason for hiding this comment

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

Nice work let few comments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants