️(frontend) updates links

- remove buttons inside links in panels and
teams index
- update component and e2e tests
This commit is contained in:
daproclaima
2024-08-12 13:13:20 +02:00
committed by Sebastien Nobour
parent 49c238155c
commit 049d8695be
8 changed files with 23 additions and 14 deletions

View File

@@ -5,6 +5,11 @@ import { AppWrapper } from '@/tests/utils';
import Page from '../pages';
jest.mock('next/navigation', () => ({
...jest.requireActual('next/navigation'),
useRouter: () => ({}),
}));
describe('Page', () => {
it('checks Page rendering', () => {
render(<Page />, { wrapper: AppWrapper });

View File

@@ -15,13 +15,13 @@ describe('MainLayout', () => {
render(<MainLayout />, { wrapper: AppWrapper });
expect(
screen.getByRole('button', {
screen.getByRole('link', {
name: /Teams button/i,
}),
).toBeInTheDocument();
expect(
screen.getByRole('button', {
screen.getByRole('link', {
name: /Mail Domains button/i,
}),
).toBeInTheDocument();

View File

@@ -70,7 +70,7 @@ const MenuItem = ({ Icon, label, href, alias }: MenuItemProps) => {
<BoxButton
aria-label={t(`{{label}} button`, { label })}
$color={color}
tabIndex={-1}
as="span"
>
<Icon
width="2.375rem"

View File

@@ -45,11 +45,13 @@ export const PanelActions = () => {
</BoxButton>
<StyledLink href="/teams/create">
<BoxButton
as="span"
$margin={{ all: 'auto' }}
aria-label={t('Add a team')}
$color={colorsTokens()['primary-600']}
tabIndex={-1}
>
<IconAdd width={30} height={30} aria-hidden="true" />
<IconAdd width={27} height={27} aria-hidden="true" />
</BoxButton>
</StyledLink>
</Box>

View File

@@ -1,9 +1,10 @@
import { Button } from '@openfun/cunningham-react';
import { useRouter as useNavigate } from 'next/navigation';
import type { ReactElement } from 'react';
import { useTranslation } from 'react-i18next';
import styled from 'styled-components';
import { Box, StyledLink } from '@/components';
import { Box } from '@/components';
import { TeamLayout } from '@/features/teams/team-management';
import { NextPageWithLayout } from '@/types/next';
@@ -13,12 +14,13 @@ const StyledButton = styled(Button)`
const Page: NextPageWithLayout = () => {
const { t } = useTranslation();
const router = useNavigate();
return (
<Box $align="center" $justify="center" $height="inherit">
<StyledLink href="/teams/create">
<StyledButton tabIndex={-1}>{t('Create a new team')}</StyledButton>
</StyledLink>
<StyledButton onClick={() => void router.push('/teams/create')}>
{t('Create a new team')}
</StyledButton>
</Box>
);
};