-
Notifications
You must be signed in to change notification settings - Fork 367
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
upcoming: [M3-7429] - Add Parent/Proxy 'Switch Account' button and drawer to user profile dropdown menu #10031
upcoming: [M3-7429] - Add Parent/Proxy 'Switch Account' button and drawer to user profile dropdown menu #10031
Conversation
5dcd208
to
c520b4b
Compare
…to user profile dropdown menu
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.
Sorry for the diff in this file. I added a describe
; most of the tests were already existing. See the comments below for the test added in this PR.
it('shows the parent company name and Switch Account button in the dropdown menu for a parent user', async () => { | ||
server.use( | ||
rest.get('*/account', (req, res, ctx) => { | ||
return res( | ||
ctx.json(accountFactory.build({ company: 'Parent Company' })) | ||
); | ||
}), | ||
rest.get('*/account/users/*', (req, res, ctx) => { | ||
return res(ctx.json(accountUserFactory.build({ user_type: 'parent' }))); | ||
}) | ||
); | ||
|
||
const { findByLabelText, findByTestId } = renderWithTheme(<UserMenu />, { | ||
flags: { parentChildAccountAccess: true }, | ||
}); | ||
|
||
const userMenuButton = await findByLabelText('Profile & Account'); | ||
fireEvent.click(userMenuButton); | ||
|
||
const userMenuPopover = await findByTestId('user-menu-popover'); | ||
|
||
expect(within(userMenuPopover).getByText('Parent Company')).toBeVisible(); | ||
expect(within(userMenuPopover).getByText('Switch Account')).toBeVisible(); |
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.
This is a new test.
it('shows the child company name and Switch Account button in the dropdown menu for a proxy user', async () => { | ||
server.use( | ||
rest.get('*/account', (req, res, ctx) => { | ||
return res( | ||
ctx.json(accountFactory.build({ company: 'Child Company' })) | ||
); | ||
}), | ||
rest.get('*/account/users/*', (req, res, ctx) => { | ||
return res(ctx.json(accountUserFactory.build({ user_type: 'proxy' }))); | ||
}) | ||
); | ||
|
||
const { findByLabelText, findByTestId } = renderWithTheme(<UserMenu />, { | ||
flags: { parentChildAccountAccess: true }, | ||
}); | ||
|
||
const userMenuButton = await findByLabelText('Profile & Account'); | ||
fireEvent.click(userMenuButton); | ||
|
||
const userMenuPopover = await findByTestId('user-menu-popover'); | ||
|
||
expect(within(userMenuPopover).getByText('Child Company')).toBeVisible(); | ||
expect(within(userMenuPopover).getByText('Switch Account')).toBeVisible(); | ||
}); |
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.
This is a new test.
> | ||
<Stack data-qa-user-menu minWidth={250} spacing={2}> | ||
{isAccountSwitchable && ( | ||
<Typography>You are currently logged in as:</Typography> |
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 diverged from the mocks with this copy because I think it sounds nicer than 'Current account:', but open to feedback if reviewers disagree.
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 SwitchAccountButton will be reused on the Account landing page for parent/proxy users. (M3-7475)
@@ -1177,6 +1177,7 @@ export const handlers = [ | |||
}), | |||
]; | |||
return res(ctx.json(makeResourcePage(childAccounts))); | |||
// return res(ctx.json(makeResourcePage(accountFactory.buildList(101)))); |
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.
Added for ease of testing a long list of child accounts; will clean up later in the project after a follow-up ticket on scrolling is done.
Coverage Report: ✅ |
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.
- Confirmed button appears for both types of users and clicking it opens the drawer and user menu remains open
- Confirmed link appears on proxy account to go back to parent account
- Confirmed these are feature flagged
Description 📝
This PR introduces a more intuitive design for the profile dropdown menu and implements a new drawer specifically for listing child accounts. The profile dropdown menu should now visually distinguish between parent and proxy account types, providing a clearer representation of the user's account hierarchy.
Note
This story focuses solely on enhancing the user interface and does not involve token issuance or the actual switching to the proxy account, which will be handled separately (in M3-7430).
Changes 🔄
Subtle differences between the two drawers are bolded.
Parent View:
Proxy View:
Child View:
Preview 📷
Screenshots
How to test 🧪
Prerequisites
(How to setup test environment)
yarn dev
.Verification steps
(How to verify changes)
Mock Company
name is displayed and a Switch Account button is visible.serverHandlers.ts
and edit theaccount/users/:user
request to the following in order to mock a proxy user:As an Author I have considered 🤔
Check all that apply