🚚(app-desk) alias home with teams url path

In order the keep the url path consistent and correctly
structured, the homepage is aliased with the teams page.
This commit is contained in:
Anthony LC
2024-02-22 15:59:25 +01:00
committed by Anthony LC
parent 4bd8095975
commit 8cbfb38cc4
3 changed files with 47 additions and 17 deletions

View File

@@ -1,27 +1,12 @@
import { Button } from '@openfun/cunningham-react';
import type { ReactElement } from 'react';
import { useTranslation } from 'react-i18next';
import styled from 'styled-components';
import { Box, StyledLink } from '@/components';
import { NextPageWithLayout } from '@/types/next';
import Teams from './teams/';
import TeamLayout from './teams/TeamLayout';
const StyledButton = styled(Button)`
width: fit-content;
`;
const Page: NextPageWithLayout = () => {
const { t } = useTranslation();
return (
<Box $align="center" $justify="center" $height="inherit">
<StyledLink href="/teams/create">
<StyledButton>{t('Create a new team')}</StyledButton>
</StyledLink>
</Box>
);
return <Teams />;
};
Page.getLayout = function getLayout(page: ReactElement) {

View File

@@ -0,0 +1,31 @@
import { Button } from '@openfun/cunningham-react';
import type { ReactElement } from 'react';
import { useTranslation } from 'react-i18next';
import styled from 'styled-components';
import { Box, StyledLink } from '@/components';
import { NextPageWithLayout } from '@/types/next';
import TeamLayout from './TeamLayout';
const StyledButton = styled(Button)`
width: fit-content;
`;
const Page: NextPageWithLayout = () => {
const { t } = useTranslation();
return (
<Box $align="center" $justify="center" $height="inherit">
<StyledLink href="/teams/create">
<StyledButton>{t('Create a new team')}</StyledButton>
</StyledLink>
</Box>
);
};
Page.getLayout = function getLayout(page: ReactElement) {
return <TeamLayout>{page}</TeamLayout>;
};
export default Page;

View File

@@ -80,4 +80,18 @@ test.describe('Teams Create', () => {
await panel.locator('li').getByText(teamName).click();
await expect(elTeam).toBeVisible();
});
test('checks alias teams url with homepage', async ({ page }) => {
await expect(page).toHaveURL('/');
const buttonCreateHomepage = page.getByRole('button', {
name: 'Create a new team',
});
await expect(buttonCreateHomepage).toBeVisible();
await page.goto('/teams');
await expect(buttonCreateHomepage).toBeVisible();
await expect(page).toHaveURL(/\/teams$/);
});
});