🐛(frontend) fix create team button
The button to create a new team was not displayed properly anymore.
This commit is contained in:
@@ -18,6 +18,11 @@ jest.mock('next/router', () => ({
|
||||
}),
|
||||
}));
|
||||
|
||||
jest.mock('next/navigation', () => ({
|
||||
...jest.requireActual('next/navigation'),
|
||||
useRouter: () => jest.fn(),
|
||||
}));
|
||||
|
||||
describe('PanelTeams', () => {
|
||||
afterEach(() => {
|
||||
fetchMock.restore();
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import { useRouter as useNavigate } from 'next/navigation';
|
||||
import React from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
import IconAdd from '@/assets/icons/icon-add.svg';
|
||||
import IconSort from '@/assets/icons/icon-sort.svg';
|
||||
import { Box, BoxButton, StyledLink } from '@/components';
|
||||
import { Box, BoxButton } from '@/components';
|
||||
import { useAuthStore } from '@/core/auth';
|
||||
import { useCunninghamTheme } from '@/cunningham';
|
||||
import { TeamsOrdering } from '@/features/teams/team-management/api';
|
||||
@@ -15,6 +16,7 @@ export const PanelActions = () => {
|
||||
const { changeOrdering, ordering } = useTeamStore();
|
||||
const { colorsTokens } = useCunninghamTheme();
|
||||
const { userData } = useAuthStore();
|
||||
const navigate = useNavigate();
|
||||
|
||||
const can_create = userData?.abilities?.teams.can_create ?? false;
|
||||
|
||||
@@ -48,17 +50,14 @@ export const PanelActions = () => {
|
||||
<IconSort width={30} height={30} aria-hidden="true" />
|
||||
</BoxButton>
|
||||
{can_create && (
|
||||
<StyledLink href="/teams/create">
|
||||
<BoxButton
|
||||
as="span"
|
||||
$margin={{ all: 'auto' }}
|
||||
aria-label={t('Add a team')}
|
||||
$color={colorsTokens()['primary-600']}
|
||||
tabIndex={-1}
|
||||
>
|
||||
<IconAdd width={27} height={27} aria-hidden="true" />
|
||||
</BoxButton>
|
||||
</StyledLink>
|
||||
<BoxButton
|
||||
$margin={{ all: 'auto' }}
|
||||
aria-label={t('Add a team')}
|
||||
$color={colorsTokens()['primary-600']}
|
||||
onClick={() => void navigate.push('/teams/create')}
|
||||
>
|
||||
<IconAdd width={27} height={27} aria-hidden="true" />
|
||||
</BoxButton>
|
||||
)}
|
||||
</Box>
|
||||
);
|
||||
|
||||
@@ -48,7 +48,7 @@ export const createTeam = async (
|
||||
const randomTeams = randomName(teamName, browserName, length);
|
||||
|
||||
for (let i = 0; i < randomTeams.length; i++) {
|
||||
await panel.getByRole('link', { name: 'Add a team' }).click();
|
||||
await panel.getByRole('button', { name: 'Add a team' }).click();
|
||||
await page.getByText('Team name').fill(randomTeams[i]);
|
||||
await expect(buttonCreate).toBeEnabled();
|
||||
await buttonCreate.click();
|
||||
|
||||
@@ -63,7 +63,7 @@ test.describe('Teams Create', () => {
|
||||
}) => {
|
||||
const panel = page.getByLabel('Teams panel').first();
|
||||
|
||||
await panel.getByRole('link', { name: 'Add a team' }).click();
|
||||
await panel.getByRole('button', { name: 'Add a team' }).click();
|
||||
|
||||
const teamName = `My routing team ${browserName}-${Math.floor(Math.random() * 1000)}`;
|
||||
await page.getByText('Team name').fill(teamName);
|
||||
@@ -72,7 +72,7 @@ test.describe('Teams Create', () => {
|
||||
const elTeam = page.getByRole('heading', { name: teamName });
|
||||
await expect(elTeam).toBeVisible();
|
||||
|
||||
await panel.getByRole('link', { name: 'Add a team' }).click();
|
||||
await panel.getByRole('button', { name: 'Add a team' }).click();
|
||||
await expect(elTeam).toBeHidden();
|
||||
|
||||
await panel.locator('li').getByText(teamName).click();
|
||||
|
||||
@@ -20,7 +20,7 @@ test.describe('Teams Panel', () => {
|
||||
).toBeVisible();
|
||||
|
||||
await expect(
|
||||
panel.getByRole('link', {
|
||||
panel.getByRole('button', {
|
||||
name: 'Add a team',
|
||||
}),
|
||||
).toBeVisible();
|
||||
@@ -67,11 +67,11 @@ test.describe('Teams Panel', () => {
|
||||
const selectedTeam = panel.locator('li').nth(0);
|
||||
await expect(selectedTeam).toHaveCSS(
|
||||
'background-color',
|
||||
'rgb(202, 202, 251)',
|
||||
'rgb(133, 133, 246)',
|
||||
);
|
||||
|
||||
const hoverTeam = panel.locator('li').nth(1);
|
||||
await hoverTeam.hover();
|
||||
await expect(hoverTeam).toHaveCSS('background-color', 'rgb(227, 227, 253)');
|
||||
await expect(hoverTeam).toHaveCSS('background-color', 'rgb(202, 202, 251)');
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user