mirror of https://github.com/portainer/portainer
chore(app): fix e2e tests (#7154)
parent
89359a21ce
commit
0cd2a4558b
|
@ -4,17 +4,17 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<span class="pull-right myaccount-container" uib-dropdown on-toggle="toggled(open)">
|
<span class="pull-right myaccount-container" uib-dropdown on-toggle="toggled(open)">
|
||||||
<a href class="myaccount-dropdown" uib-dropdown-toggle>
|
<a href class="myaccount-dropdown" uib-dropdown-toggle data-cy="userMenu-button" aria-label="User menu toggle">
|
||||||
<span class="pull-right user-box" ng-if="$ctrl.username">
|
<span class="pull-right user-box" ng-if="$ctrl.username">
|
||||||
<i class="fa fa-user-circle" aria-hidden="true"></i> {{ $ctrl.username }} <i class="fa fa-angle-down myaccount-icon" aria-hidden="true"></i>
|
<i class="fa fa-user-circle" aria-hidden="true"></i> {{ $ctrl.username }} <i class="fa fa-angle-down myaccount-icon" aria-hidden="true"></i>
|
||||||
</span>
|
</span>
|
||||||
</a>
|
</a>
|
||||||
<ul class="dropdown-menu" uib-dropdown-menu>
|
<ul class="dropdown-menu" uib-dropdown-menu aria-label="User Menu" data-cy="userMenu">
|
||||||
<li>
|
<li>
|
||||||
<a ui-sref="portainer.account">My account</a>
|
<a ui-sref="portainer.account" data-cy="userMenu-myAccount">My account</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a ui-sref="portainer.logout({performApiLogout: true})" data-cy="template-logoutButton">Log out</a>
|
<a ui-sref="portainer.logout({performApiLogout: true})" data-cy="userMenu-logOut">Log out</a>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</span>
|
</span>
|
||||||
|
|
|
@ -7,9 +7,10 @@ import {
|
||||||
} from '@reach/menu-button';
|
} from '@reach/menu-button';
|
||||||
import clsx from 'clsx';
|
import clsx from 'clsx';
|
||||||
import { User, ChevronDown } from 'react-feather';
|
import { User, ChevronDown } from 'react-feather';
|
||||||
import { useSref } from '@uirouter/react';
|
import { UISrefProps, useSref } from '@uirouter/react';
|
||||||
|
|
||||||
import { useUser } from '@/portainer/hooks/useUser';
|
import { useUser } from '@/portainer/hooks/useUser';
|
||||||
|
import { AutomationTestingProps } from '@/types';
|
||||||
|
|
||||||
import { useHeaderContext } from './HeaderContainer';
|
import { useHeaderContext } from './HeaderContainer';
|
||||||
import styles from './HeaderTitle.module.css';
|
import styles from './HeaderTitle.module.css';
|
||||||
|
@ -32,37 +33,59 @@ export function HeaderTitle({ title, children }: PropsWithChildren<Props>) {
|
||||||
'pull-right flex items-center gap-1',
|
'pull-right flex items-center gap-1',
|
||||||
styles.menuButton
|
styles.menuButton
|
||||||
)}
|
)}
|
||||||
|
data-cy="userMenu-button"
|
||||||
|
aria-label="User menu toggle"
|
||||||
>
|
>
|
||||||
<User className="icon-nested-gray" />
|
<User className="icon-nested-gray" />
|
||||||
{user && <span>{user.Username}</span>}
|
{user && <span>{user.Username}</span>}
|
||||||
<ChevronDown className={styles.arrowDown} />
|
<ChevronDown className={styles.arrowDown} />
|
||||||
</MenuButton>
|
</MenuButton>
|
||||||
|
|
||||||
<MenuList className={styles.menuList}>
|
<MenuList
|
||||||
|
className={styles.menuList}
|
||||||
|
aria-label="User Menu"
|
||||||
|
data-cy="userMenu"
|
||||||
|
>
|
||||||
{!window.ddExtension && (
|
{!window.ddExtension && (
|
||||||
<MenuLink to="portainer.account" label="My account" />
|
<MenuLink
|
||||||
|
to="portainer.account"
|
||||||
|
label="My account"
|
||||||
|
data-cy="userMenu-myAccount"
|
||||||
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<MenuLink to="portainer.logout" label="Log out" />
|
<MenuLink
|
||||||
|
to="portainer.logout"
|
||||||
|
label="Log out"
|
||||||
|
data-cy="userMenu-logOut"
|
||||||
|
params={{ performApiLogout: true }}
|
||||||
|
/>
|
||||||
</MenuList>
|
</MenuList>
|
||||||
</Menu>
|
</Menu>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
interface MenuLinkProps {
|
interface MenuLinkProps extends AutomationTestingProps, UISrefProps {
|
||||||
to: string;
|
|
||||||
label: string;
|
label: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
function MenuLink({ to, label }: MenuLinkProps) {
|
function MenuLink({
|
||||||
const anchorProps = useSref(to);
|
to,
|
||||||
|
label,
|
||||||
|
params,
|
||||||
|
options,
|
||||||
|
'data-cy': dataCy,
|
||||||
|
}: MenuLinkProps) {
|
||||||
|
const anchorProps = useSref(to, params, options);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ReachMenuLink
|
<ReachMenuLink
|
||||||
href={anchorProps.href}
|
href={anchorProps.href}
|
||||||
onClick={anchorProps.onClick}
|
onClick={anchorProps.onClick}
|
||||||
className={styles.menuLink}
|
className={styles.menuLink}
|
||||||
|
aria-label={label}
|
||||||
|
data-cy={dataCy}
|
||||||
>
|
>
|
||||||
{label}
|
{label}
|
||||||
</ReachMenuLink>
|
</ReachMenuLink>
|
||||||
|
|
Loading…
Reference in New Issue