Skip to content

Conversation

@mvolkmann
Copy link
Collaborator

No description provided.

import { useLocation, Link } from 'react-router-dom';
import { AppContext } from '../../context/AppContext';
import { getAvatarURL } from '../../api/api';
import AvatarMenu from '@mui/material/Menu';
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Clicking the avatar no longer displays a menu.

return links;
};

const handleClick = event => {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is now handled by a Link component.

setFeedbackOpen(false);
};

const closeAvatarMenu = () => {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

There's no longer an avatar menu to close.

aria-haspopup="true"
onClick={handleToggle}
>
<Link to={`/profile/${id}`}>
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The avatar is now wrapped in a Link that goes to the Profile page.

>
<Link to={`/profile/${id}`}>
<Avatar
onClick={handleClick}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The click is now handled by the Link that wraps this Avatar component.

textDecoration: 'none'
}}
/>
<AvatarMenu
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No more avatar menu.

<div
aria-haspopup="true"
<a
href="/profile/undefined"
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I wonder if the reason this contains "undefined" is that in the test we don't have a user id.

Copy link
Contributor

@vhscom vhscom Apr 25, 2024

Choose a reason for hiding this comment

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

In Menu.test.jsx currently I see us taking snapshots, but I don't see us making any assertions yet other than something changed. In this case, the ${id} is set at runtime based on the user profile. If we want to test various render scenarios in our tests, and not just that it renders, I think we may find some room for improvement in our test suites.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I added a test to verify that the Link around the Avatar uses the id value.

<div
aria-haspopup="true"
<a
href="/profile/undefined"
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

See the previous comment.

<div
aria-haspopup="true"
<a
href="/profile/undefined"
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

See the previous comment.

S78901
S78901 previously approved these changes Apr 25, 2024
vhscom
vhscom previously approved these changes Apr 25, 2024
Copy link
Contributor

@vhscom vhscom left a comment

Choose a reason for hiding this comment

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

:shipit:

Copy link
Contributor

@vhscom vhscom left a comment

Choose a reason for hiding this comment

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

Love seeing some examples of how we're component testing. I saw we also have Testing Library, which can be useful as its API surface tends to nudge implementations towards semantic markup and use of ARIA where it matters most (e.g. component suspense states).

const link = container.querySelector('header > a');
const href = link.getAttribute('href');
const lastIndex = href.lastIndexOf('/');
const id = href.substring(lastIndex + 1);
Copy link
Contributor

Choose a reason for hiding this comment

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

Another way to grab the id could be to split the string into an array and pop off the last element:

const id = href.split('/').pop()

@mvolkmann mvolkmann merged commit 13820c1 into develop Apr 26, 2024
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.

4 participants