-
Notifications
You must be signed in to change notification settings - Fork 139
Feat(core/avatar)- Added new prop to wrap username when necessary instead of wrapping by default #2686
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
base: main
Are you sure you want to change the base?
Feat(core/avatar)- Added new prop to wrap username when necessary instead of wrapping by default #2686
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -120,6 +120,96 @@ regressionTest.describe('embedded into header', () => { | |
| } | ||
| ); | ||
|
|
||
| regressionTest( | ||
| 'should apply no-truncate class when wrapUsername is true', | ||
| async ({ page, mount }) => { | ||
| await page.setViewportSize(viewPorts.lg); | ||
| await mount( | ||
| ` | ||
| <ix-application-header name="Test"> | ||
| <ix-avatar username="foo" wrap-username> | ||
| </ix-avatar> | ||
| </ix-application-header> | ||
| ` | ||
| ); | ||
|
|
||
| const avatar = page.locator('ix-avatar'); | ||
| await avatar.click(); | ||
|
|
||
| await expect(avatar.locator('.user-info')).toHaveClass( | ||
| /\buser-info--no-truncate\b/ | ||
| ); | ||
| } | ||
| ); | ||
|
|
||
| regressionTest( | ||
| 'should not apply no-truncate class when wrapUsername is false', | ||
| async ({ page, mount }) => { | ||
| await page.setViewportSize(viewPorts.lg); | ||
| await mount( | ||
| ` | ||
| <ix-application-header name="Test"> | ||
| <ix-avatar username="foo"> | ||
| </ix-avatar> | ||
| </ix-application-header> | ||
| ` | ||
| ); | ||
|
|
||
| const avatar = page.locator('ix-avatar'); | ||
| await avatar.click(); | ||
|
|
||
| await expect(avatar.locator('.user-info')).not.toHaveClass( | ||
| /\buser-info--no-truncate\b/ | ||
| ); | ||
| } | ||
| ); | ||
|
|
||
| regressionTest( | ||
| 'should keep the popup width fixed and wrap long usernames when wrapUsername is true', | ||
| async ({ page, mount }) => { | ||
| await page.setViewportSize(viewPorts.lg); | ||
| await mount( | ||
| ` | ||
| <ix-application-header name="Test"> | ||
| <ix-avatar username="foo" wrap-username> | ||
| </ix-avatar> | ||
| </ix-application-header> | ||
| ` | ||
| ); | ||
|
|
||
| const avatar = page.locator('ix-avatar'); | ||
| await avatar.click(); | ||
|
|
||
| const userInfo = avatar.locator('.user-info'); | ||
|
|
||
| const initialMetrics = await userInfo.evaluate((element) => { | ||
| const rect = element.getBoundingClientRect(); | ||
| return { | ||
| width: Math.round(rect.width), | ||
| height: Math.round(rect.height), | ||
| }; | ||
| }); | ||
|
|
||
| const longUsername = 'verylongstringthatisnotfullydisplayed'; | ||
| await avatar.evaluate((element, value) => { | ||
| element.setAttribute('username', value); | ||
| }, longUsername); | ||
|
|
||
| await expect(userInfo).toHaveText(new RegExp(longUsername)); | ||
|
|
||
| const updatedMetrics = await userInfo.evaluate((element) => { | ||
| const rect = element.getBoundingClientRect(); | ||
| return { | ||
| width: Math.round(rect.width), | ||
| height: Math.round(rect.height), | ||
| }; | ||
| }); | ||
|
|
||
| expect(updatedMetrics.width).toBe(initialMetrics.width); | ||
| expect(updatedMetrics.height).toBeGreaterThan(initialMetrics.height); | ||
| } | ||
|
Comment on lines
+123
to
+210
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ๐ฏ Functional Correctness | ๐ก Minor | โก Quick win Add the required accessibility and hydration coverage. Add a As per coding guidelines, โInclude accessibility coverage using ๐งฐ Tools๐ช ast-grep (0.45.0)[warning] 197-197: Regular expression constructed from variable input detected. This can lead to Regular Expression Denial of Service (ReDoS) attacks if the variable contains malicious patterns. Use libraries like 'recheck' to validate regex safety or use static patterns. (regexp-from-variable) [warning] 197-197: Do not use variable for regular expressions (regexp-non-literal-typescript) ๐ค Prompt for AI AgentsSources: Coding guidelines, Path instructions
Comment on lines
+167
to
+210
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ๐ฏ Functional Correctness | ๐ก Minor | โก Quick win Test the visible dropdown result. The test measures only As per coding guidelines, โUpdate tests ... when user-facing behavior ... changes.โ ๐งฐ Tools๐ช ast-grep (0.45.0)[warning] 197-197: Regular expression constructed from variable input detected. This can lead to Regular Expression Denial of Service (ReDoS) attacks if the variable contains malicious patterns. Use libraries like 'recheck' to validate regex safety or use static patterns. (regexp-from-variable) [warning] 197-197: Do not use variable for regular expressions (regexp-non-literal-typescript) ๐ค Prompt for AI AgentsSource: Coding guidelines |
||
| ); | ||
|
|
||
| regressionTest('should show no tooltip', async ({ page, mount }) => { | ||
| await mount(`<ix-avatar aria-label-tooltip="myTooltip"></ix-avatar>`); | ||
|
|
||
|
|
||
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.
๐ Maintainability & Code Quality | ๐ Major | โก Quick win
Add a changeset for this public API change.
wrapUsernameadds a publicix-avatarproperty and changes username and extra-text rendering. Add a changeset for the affected package with the consumer-facing behavior. If no changeset is intended, state why the change is internal-only.As per path instructions, โChangesets are required for public API updates and behavior changes.โ
Also applies to: 7052-7057, 12014-12014
๐ค Prompt for AI Agents
Source: Path instructions