-
Notifications
You must be signed in to change notification settings - Fork 376
(fix) O3-5831: Fix patient banner building blocks at narrow widths #1820
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?
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 | ||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -73,4 +73,36 @@ describe('PatientBannerPatientIdentifiers', () => { | |||||||||||||||||||||||||||||||||||||||||||||||||
| expect(screen.getByText(/openmrs id/i)).toBeInTheDocument(); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| expect(screen.queryByText(/national id/i)).not.toBeInTheDocument(); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| it('falls back to showing the first identifier when showAllIdentifiers is false but the primary identifier code is unresolved', () => { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| mockUsePrimaryIdentifierCode.mockReturnValue({ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| primaryIdentifierCode: undefined, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| isLoading: false, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| error: undefined, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| render( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| <PatientBannerPatientIdentifiers identifiers={mockIdentifiers} showIdentifierLabel showAllIdentifiers={false} />, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| expect(screen.getByText(/openmrs id/i)).toBeInTheDocument(); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| expect(screen.getByText(/100gej/i)).toBeInTheDocument(); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| expect(screen.queryByText(/national id/i)).not.toBeInTheDocument(); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| it('shows only the primary identifier when showAllIdentifiers is false and the primary identifier code resolves', () => { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| mockUsePrimaryIdentifierCode.mockReturnValue({ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| primaryIdentifierCode: '4281ec43-388b-4c25-8bb2-deaff0867b2c', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| isLoading: false, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| error: undefined, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| render( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| <PatientBannerPatientIdentifiers identifiers={mockIdentifiers} showIdentifierLabel showAllIdentifiers={false} />, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| expect(screen.getByText(/national id/i)).toBeInTheDocument(); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| expect(screen.getByText(/123456789/i)).toBeInTheDocument(); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| expect(screen.queryByText(/openmrs id/i)).not.toBeInTheDocument(); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+93
to
+107
Member
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.
Suggested change
This one can't fail as written. The primary identifier is also |
||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -13,13 +13,10 @@ export interface PatientPhotoProps { | |||||||||||||||||||||
| alt?: string; | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| function getInitials(name: string, maxInitials = 3): string { | ||||||||||||||||||||||
| return name | ||||||||||||||||||||||
| .split(/\s+/) | ||||||||||||||||||||||
| .filter(Boolean) | ||||||||||||||||||||||
| .slice(0, maxInitials) | ||||||||||||||||||||||
| .map((part) => part[0]) | ||||||||||||||||||||||
| .join(''); | ||||||||||||||||||||||
| function getInitials(name: string, maxInitials = 2): string { | ||||||||||||||||||||||
| const parts = name.split(/\s+/).filter(Boolean); | ||||||||||||||||||||||
| const selected = parts.length > maxInitials ? [parts[0], parts.at(-1)] : parts; | ||||||||||||||||||||||
| return selected.map((part) => part![0]).join(''); | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
Comment on lines
+16
to
20
Member
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.
Suggested change
Identical output for every input, so take it or leave it. |
||||||||||||||||||||||
|
|
||||||||||||||||||||||
| /** | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
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.
Both components go out through
@openmrs/esm-framework, so this becomes public API that only its sibling component would ever set. The destructured default below and the conditional class can go with it: