Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
|
||
| it('throws or returns undefined for an unknown ID', () => { | ||
| // @ts-expect-error - This is a test for an unknown ID | ||
| expect(() => getAvatarLocal('not-a-real-id')).toThrow(); |
There was a problem hiding this comment.
❌ Test Logic Issue (docs)
The test is using @ts-expect-error to suppress TypeScript errors but then expects the function to throw. However, getAvatarLocal and getAvatarURL don't actually validate their input or throw errors for invalid IDs - they just return undefined if the ID doesn't exist in the record.
This test will fail because accessing a non-existent property on an object returns undefined, not throws an error.
it('returns undefined for an unknown ID', () => {
// @ts-expect-error - This is a test for an unknown ID
expect(getAvatarLocal('not-a-real-id')).toBeUndefined();
// @ts-expect-error - This is a test for an unknown ID
expect(getAvatarURL('not-a-real-id')).toBeUndefined();
});| const SAMPLE_SEASON_ID = 'car-blue100'; | ||
|
|
||
| describe('CustomAvatarCatalog', () => { | ||
| it('resolves a local component for a default avatar ID', () => { |
There was a problem hiding this comment.
NAB I'd say this case is bit redundant
| it('renders a default avatar component', () => { | ||
| const AvatarComponent = getAvatarLocal(SAMPLE_DEFAULT_ID); | ||
| const {toJSON} = render(<Icon src={AvatarComponent} />); | ||
| expect(toJSON()).toBeTruthy(); | ||
| }); | ||
|
|
||
| it('matches snapshot for a default avatar', () => { | ||
| const AvatarComponent = getAvatarLocal(SAMPLE_DEFAULT_ID); | ||
| const {toJSON} = render(<Icon src={AvatarComponent} />); | ||
| expect(toJSON()).toMatchSnapshot(); | ||
| }); |
There was a problem hiding this comment.
Same with those 2, the sanpshots case covers the first one
| it('matches snapshot for a letter avatar', () => { | ||
| const AvatarComponent = getInitialAvatarSvg('J'); | ||
| const {toJSON} = render(<Icon src={AvatarComponent} />); | ||
| expect(toJSON()).toMatchSnapshot(); |
There was a problem hiding this comment.
curious about snapshot testing in E/App haven't seen it done much in the codebase ?
It makes sense in this case, but wondering if we have any guidelines / recommendations for them ?
There was a problem hiding this comment.
Yeah it hasn't been used much. I figured I would give it a try for this case. It seems a good way to detect UI regressions. I'm looking for a way to add avatar regression tests, so this might be a good solution. Will add more docs as I find out more
Reviewer Checklist
Screenshots/VideosAndroid: HybridAppAndroid: mWeb ChromeiOS: HybridAppiOS: mWeb SafariMacOS: Chrome / SafariMacOS: Desktop |
|
@grgia looks like this was merged without a test passing. Please add a note explaining why this was done and remove the |
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🚀 Deployed to staging by https://github.com/grgia in version: 9.2.24-0 🚀
|
|
🚀 Deployed to staging by https://github.com/grgia in version: 9.2.26-0 🚀
|
|
🚀 Deployed to production by https://github.com/lakchote in version: 9.2.26-7 🚀
|
Explanation of Change
CustomAvatarCatalog.ts, so:InitialAvatars.tsthat reuses workspace letter SVGs, so we can generate letter-based avatars with consistent fill/background colors.Fixed Issues
part of #71653
Tests
Offline tests
QA Steps
// TODO: These must be filled out, or the issue title must include "[No QA]."
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectioncanBeMissingparam foruseOnyxtoggleReportand notonIconClick)src/languages/*files and using the translation methodSTYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))npm run compress-svg)Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.ScrollViewcomponent to make it scrollable when more elements are added to the page.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps./** comment above it */thisproperly so there are no scoping issues (i.e. foronClick={this.submit}the methodthis.submitshould be bound tothisin the constructor)thisare necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);ifthis.submitis never passed to a component event handler likeonClick)/** comment above it */thisproperly so there are no scoping issues (i.e. foronClick={this.submit}the methodthis.submitshould be bound tothisin the constructor)thisare necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);ifthis.submitis never passed to a component event handler likeonClick)Screenshots/Videos
Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari
MacOS: Desktop