Skip to content

Commit

Permalink
feat: remove username from profile page.
Browse files Browse the repository at this point in the history
  • Loading branch information
attiyaIshaque committed Feb 13, 2024
1 parent 3fdd68b commit 9612bfa
Show file tree
Hide file tree
Showing 3 changed files with 791 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/profile/ProfilePage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,10 @@ class ProfilePage extends React.Component {
// Inserted into the DOM in two places (for responsive layout)
renderHeadingLockup() {
const { dateJoined } = this.props;

const hideUserName = !!this.props.params?.hide_username;
return (
<span data-hj-suppress>
<h1 className="h2 mb-0 font-weight-bold text-truncate">{this.props.params.username}</h1>
{!hideUserName && <h1 className="h2 mb-0 font-weight-bold text-truncate">{this.props.params.username}</h1>}
<DateJoined date={dateJoined} />
{this.isYOBDisabled() && <UsernameDescription />}
<hr className="d-none d-md-block" />
Expand Down Expand Up @@ -400,6 +400,7 @@ ProfilePage.propTypes = {
// Router
params: PropTypes.shape({
username: PropTypes.string.isRequired,
hide_username: PropTypes.bool,
}).isRequired,

// i18n
Expand Down
19 changes: 19 additions & 0 deletions src/profile/ProfilePage.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,25 @@ describe('<ProfilePage />', () => {
expect(tree).toMatchSnapshot();
});

it('renders the component without the username field when hide_username is true', () => {
const contextValue = {
authenticatedUser: { userId: 123, username: 'staff', administrator: true },
config: getConfig(),
};

// Render the component with hide_username set to true
const component = (
<ProfilePageWrapper
contextValue={contextValue}
store={mockStore(storeMocks.viewOwnProfile)}
params={{ hide_username: true }}
/>
);

const { container: tree } = render(component);
expect(tree).toMatchSnapshot();
});

it('viewing other profile with all fields', () => {
const contextValue = {
authenticatedUser: { userId: 123, username: 'staff', administrator: true },
Expand Down
Loading

0 comments on commit 9612bfa

Please sign in to comment.