From 8cbfb38cc40c294f74b4d88b65f157427f32f260 Mon Sep 17 00:00:00 2001 From: Anthony LC Date: Thu, 22 Feb 2024 15:59:25 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=9A(app-desk)=20alias=20home=20with=20?= =?UTF-8?q?teams=20url=20path?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In order the keep the url path consistent and correctly structured, the homepage is aliased with the teams page. --- src/frontend/apps/desk/src/pages/index.tsx | 19 ++---------- .../apps/desk/src/pages/teams/index.tsx | 31 +++++++++++++++++++ .../__tests__/app-desk/teams-create.spec.ts | 14 +++++++++ 3 files changed, 47 insertions(+), 17 deletions(-) create mode 100644 src/frontend/apps/desk/src/pages/teams/index.tsx diff --git a/src/frontend/apps/desk/src/pages/index.tsx b/src/frontend/apps/desk/src/pages/index.tsx index f38fbc4..42a0513 100644 --- a/src/frontend/apps/desk/src/pages/index.tsx +++ b/src/frontend/apps/desk/src/pages/index.tsx @@ -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 ( - - - {t('Create a new team')} - - - ); + return ; }; Page.getLayout = function getLayout(page: ReactElement) { diff --git a/src/frontend/apps/desk/src/pages/teams/index.tsx b/src/frontend/apps/desk/src/pages/teams/index.tsx new file mode 100644 index 0000000..3ad82dc --- /dev/null +++ b/src/frontend/apps/desk/src/pages/teams/index.tsx @@ -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 ( + + + {t('Create a new team')} + + + ); +}; + +Page.getLayout = function getLayout(page: ReactElement) { + return {page}; +}; + +export default Page; diff --git a/src/frontend/apps/e2e/__tests__/app-desk/teams-create.spec.ts b/src/frontend/apps/e2e/__tests__/app-desk/teams-create.spec.ts index a2d90e1..ee3f5ce 100644 --- a/src/frontend/apps/e2e/__tests__/app-desk/teams-create.spec.ts +++ b/src/frontend/apps/e2e/__tests__/app-desk/teams-create.spec.ts @@ -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$/); + }); });