(frontend) show version number in footer (#461)

In order to see the version number pushed into production
This commit is contained in:
Nathan Panchout
2024-10-14 16:54:21 +02:00
committed by GitHub
parent 017f52a0dc
commit 9c9216bb51
6 changed files with 25 additions and 5 deletions

View File

@@ -16,6 +16,7 @@ and this project adheres to
### Added ### Added
- ✨(backend) manage roles on domain admin view - ✨(backend) manage roles on domain admin view
- ✨(frontend) show version number in footer #369
### Changed ### Changed

View File

@@ -21,7 +21,7 @@ describe('Page', () => {
it('checks Page rendering with team feature', () => { it('checks Page rendering with team feature', () => {
useConfigStore.setState({ useConfigStore.setState({
config: { FEATURES: { TEAMS: true }, LANGUAGES: [] }, config: { RELEASE: '1.0.0', FEATURES: { TEAMS: true }, LANGUAGES: [] },
}); });
render(<Page />, { wrapper: AppWrapper }); render(<Page />, { wrapper: AppWrapper });
@@ -31,7 +31,7 @@ describe('Page', () => {
it('checks Page rendering without team feature', () => { it('checks Page rendering without team feature', () => {
useConfigStore.setState({ useConfigStore.setState({
config: { FEATURES: { TEAMS: false }, LANGUAGES: [] }, config: { RELEASE: '1.0.0', FEATURES: { TEAMS: false }, LANGUAGES: [] },
}); });
render(<Page />, { wrapper: AppWrapper }); render(<Page />, { wrapper: AppWrapper });

View File

@@ -17,7 +17,7 @@ jest.mock('next/navigation', () => ({
describe('MainLayout', () => { describe('MainLayout', () => {
it('checks menu rendering with team feature', () => { it('checks menu rendering with team feature', () => {
useConfigStore.setState({ useConfigStore.setState({
config: { FEATURES: { TEAMS: true }, LANGUAGES: [] }, config: { RELEASE: '1.0.0', FEATURES: { TEAMS: true }, LANGUAGES: [] },
}); });
render(<MainLayout />, { wrapper: AppWrapper }); render(<MainLayout />, { wrapper: AppWrapper });
@@ -37,7 +37,7 @@ describe('MainLayout', () => {
it('checks menu rendering without team feature', () => { it('checks menu rendering without team feature', () => {
useConfigStore.setState({ useConfigStore.setState({
config: { FEATURES: { TEAMS: false }, LANGUAGES: [] }, config: { RELEASE: '1.0.0', FEATURES: { TEAMS: false }, LANGUAGES: [] },
}); });
render(<MainLayout />, { wrapper: AppWrapper }); render(<MainLayout />, { wrapper: AppWrapper });

View File

@@ -1,5 +1,6 @@
export interface Config { export interface Config {
LANGUAGES: [string, string][]; LANGUAGES: [string, string][];
RELEASE: string;
FEATURES: { FEATURES: {
TEAMS: boolean; TEAMS: boolean;
}; };

View File

@@ -3,6 +3,7 @@ import { Trans, useTranslation } from 'react-i18next';
import styled from 'styled-components'; import styled from 'styled-components';
import { Box, LogoGouv, StyledLink, Text } from '@/components'; import { Box, LogoGouv, StyledLink, Text } from '@/components';
import { useConfigStore } from '@/core';
import IconLink from './assets/external-link.svg'; import IconLink from './assets/external-link.svg';
@@ -16,6 +17,7 @@ const BlueStripe = styled.div`
export const Footer = () => { export const Footer = () => {
const { t } = useTranslation(); const { t } = useTranslation();
const { config } = useConfigStore();
return ( return (
<Box $position="relative" as="footer"> <Box $position="relative" as="footer">
@@ -94,7 +96,7 @@ export const Footer = () => {
$padding={{ top: 'tiny' }} $padding={{ top: 'tiny' }}
$css=" $css="
flex-wrap: wrap; flex-wrap: wrap;
border-top: 1px solid var(--c--theme--colors--greyscale-200); border-top: 1px solid var(--c--theme--colors--greyscale-200);
column-gap: 1rem; column-gap: 1rem;
row-gap: .5rem; row-gap: .5rem;
" "
@@ -138,6 +140,7 @@ export const Footer = () => {
</StyledLink> </StyledLink>
))} ))}
</Box> </Box>
<Text <Text
as="p" as="p"
$size="m" $size="m"
@@ -145,6 +148,12 @@ export const Footer = () => {
$variation="600" $variation="600"
$display="inline" $display="inline"
> >
{config?.RELEASE && (
<>
{t(`Version: {{release}}`, { release: config?.RELEASE })} &nbsp;
</>
)}
<Trans> <Trans>
Unless otherwise stated, all content on this site is under Unless otherwise stated, all content on this site is under
<StyledLink <StyledLink

View File

@@ -87,4 +87,13 @@ test.describe('Footer', () => {
await expect(page).toHaveURL(url); await expect(page).toHaveURL(url);
}); });
} }
test('check if the app version is visible', async ({ page }) => {
const footer = page.locator('footer').first();
await expect(
footer.getByText(
'Version: NA • Unless otherwise stated, all content on this site is under',
),
).toBeVisible();
});
}); });