🚨(frontend) fix CI probs
The CI highlighted some issues with the tests. This commit fixes the issues.
This commit is contained in:
@@ -11,7 +11,7 @@ describe('Page', () => {
|
||||
|
||||
expect(
|
||||
screen.getByRole('button', {
|
||||
name: /Create a new team/i,
|
||||
name: /Create a new pad/i,
|
||||
}),
|
||||
).toBeInTheDocument();
|
||||
});
|
||||
|
||||
@@ -8,8 +8,8 @@ import { ApplicationsMenu } from '@/features/header/ApplicationsMenu';
|
||||
|
||||
import { LanguagePicker } from '../language/';
|
||||
|
||||
import { default as IconImpress } from './assets/icon-impress.svg?url';
|
||||
import { default as IconGouv } from './assets/icon-gouv.svg?url';
|
||||
import { default as IconImpress } from './assets/icon-impress.svg?url';
|
||||
import { default as IconMarianne } from './assets/icon-marianne.svg?url';
|
||||
import IconMyAccount from './assets/icon-my-account.png';
|
||||
|
||||
|
||||
@@ -1,4 +1,17 @@
|
||||
import { Access } from '@/features/members';
|
||||
import { User } from '@/core/auth';
|
||||
|
||||
export interface Access {
|
||||
id: string;
|
||||
role: Role;
|
||||
user: User;
|
||||
abilities: {
|
||||
delete: boolean;
|
||||
get: boolean;
|
||||
patch: boolean;
|
||||
put: boolean;
|
||||
set_role_to: Role[];
|
||||
};
|
||||
}
|
||||
|
||||
export enum Role {
|
||||
MEMBER = 'member',
|
||||
|
||||
@@ -3,10 +3,10 @@ import { render, screen } from '@testing-library/react';
|
||||
import userEvent from '@testing-library/user-event';
|
||||
import fetchMock from 'fetch-mock';
|
||||
|
||||
import { Panel } from '@/features/teams';
|
||||
import { AppWrapper } from '@/tests/utils';
|
||||
|
||||
import { TeamList } from '../components/PadList';
|
||||
import { PadList } from '../components/PadList';
|
||||
import { Panel } from '../components/Panel';
|
||||
|
||||
window.HTMLElement.prototype.scroll = function () {};
|
||||
|
||||
@@ -17,30 +17,30 @@ jest.mock('next/router', () => ({
|
||||
}),
|
||||
}));
|
||||
|
||||
describe('PanelTeams', () => {
|
||||
describe('PanelPads', () => {
|
||||
afterEach(() => {
|
||||
fetchMock.restore();
|
||||
});
|
||||
|
||||
it('renders with no team to display', async () => {
|
||||
fetchMock.mock(`/api/teams/?page=1&ordering=-created_at`, {
|
||||
it('renders with no pad to display', async () => {
|
||||
fetchMock.mock(`/api/pads/?page=1&ordering=-created_at`, {
|
||||
count: 0,
|
||||
results: [],
|
||||
});
|
||||
|
||||
render(<TeamList />, { wrapper: AppWrapper });
|
||||
render(<PadList />, { wrapper: AppWrapper });
|
||||
|
||||
expect(screen.getByRole('status')).toBeInTheDocument();
|
||||
|
||||
expect(
|
||||
await screen.findByText(
|
||||
'Create your first team by clicking on the "Create a new team" button.',
|
||||
'Create your first pad by clicking on the "Create a new pad" button.',
|
||||
),
|
||||
).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('renders an empty team', async () => {
|
||||
fetchMock.mock(`/api/teams/?page=1&ordering=-created_at`, {
|
||||
it('renders an empty pad', async () => {
|
||||
fetchMock.mock(`/api/pads/?page=1&ordering=-created_at`, {
|
||||
count: 1,
|
||||
results: [
|
||||
{
|
||||
@@ -51,17 +51,15 @@ describe('PanelTeams', () => {
|
||||
],
|
||||
});
|
||||
|
||||
render(<TeamList />, { wrapper: AppWrapper });
|
||||
render(<PadList />, { wrapper: AppWrapper });
|
||||
|
||||
expect(screen.getByRole('status')).toBeInTheDocument();
|
||||
|
||||
expect(
|
||||
await screen.findByLabelText('Empty teams icon'),
|
||||
).toBeInTheDocument();
|
||||
expect(await screen.findByLabelText('Empty pads icon')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('renders a team with only 1 member', async () => {
|
||||
fetchMock.mock(`/api/teams/?page=1&ordering=-created_at`, {
|
||||
it('renders a pad with only 1 member', async () => {
|
||||
fetchMock.mock(`/api/pads/?page=1&ordering=-created_at`, {
|
||||
count: 1,
|
||||
results: [
|
||||
{
|
||||
@@ -77,22 +75,20 @@ describe('PanelTeams', () => {
|
||||
],
|
||||
});
|
||||
|
||||
render(<TeamList />, { wrapper: AppWrapper });
|
||||
render(<PadList />, { wrapper: AppWrapper });
|
||||
|
||||
expect(screen.getByRole('status')).toBeInTheDocument();
|
||||
|
||||
expect(
|
||||
await screen.findByLabelText('Empty teams icon'),
|
||||
).toBeInTheDocument();
|
||||
expect(await screen.findByLabelText('Empty pads icon')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('renders a non-empty team', async () => {
|
||||
fetchMock.mock(`/api/teams/?page=1&ordering=-created_at`, {
|
||||
it('renders a non-empty pad', async () => {
|
||||
fetchMock.mock(`/api/pads/?page=1&ordering=-created_at`, {
|
||||
count: 1,
|
||||
results: [
|
||||
{
|
||||
id: '1',
|
||||
name: 'Team 1',
|
||||
name: 'Pad 1',
|
||||
accesses: [
|
||||
{
|
||||
id: '1',
|
||||
@@ -107,19 +103,19 @@ describe('PanelTeams', () => {
|
||||
],
|
||||
});
|
||||
|
||||
render(<TeamList />, { wrapper: AppWrapper });
|
||||
render(<PadList />, { wrapper: AppWrapper });
|
||||
|
||||
expect(screen.getByRole('status')).toBeInTheDocument();
|
||||
|
||||
expect(await screen.findByLabelText('Teams icon')).toBeInTheDocument();
|
||||
expect(await screen.findByLabelText('Pads icon')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('renders the error', async () => {
|
||||
fetchMock.mock(`/api/teams/?page=1&ordering=-created_at`, {
|
||||
fetchMock.mock(`/api/pads/?page=1&ordering=-created_at`, {
|
||||
status: 500,
|
||||
});
|
||||
|
||||
render(<TeamList />, { wrapper: AppWrapper });
|
||||
render(<PadList />, { wrapper: AppWrapper });
|
||||
|
||||
expect(screen.getByRole('status')).toBeInTheDocument();
|
||||
|
||||
@@ -130,8 +126,8 @@ describe('PanelTeams', () => {
|
||||
).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('renders with team panel open', async () => {
|
||||
fetchMock.mock(`/api/teams/?page=1&ordering=-created_at`, {
|
||||
it('renders with pad panel open', async () => {
|
||||
fetchMock.mock(`/api/pads/?page=1&ordering=-created_at`, {
|
||||
count: 1,
|
||||
results: [],
|
||||
});
|
||||
@@ -139,14 +135,14 @@ describe('PanelTeams', () => {
|
||||
render(<Panel />, { wrapper: AppWrapper });
|
||||
|
||||
expect(
|
||||
screen.getByRole('button', { name: 'Close the teams panel' }),
|
||||
screen.getByRole('button', { name: 'Close the pads panel' }),
|
||||
).toBeVisible();
|
||||
|
||||
expect(await screen.findByText('Recents')).toBeVisible();
|
||||
});
|
||||
|
||||
it('closes and opens the team panel', async () => {
|
||||
fetchMock.mock(`/api/teams/?page=1&ordering=-created_at`, {
|
||||
it('closes and opens the pad panel', async () => {
|
||||
fetchMock.mock(`/api/pads/?page=1&ordering=-created_at`, {
|
||||
count: 1,
|
||||
results: [],
|
||||
});
|
||||
@@ -157,7 +153,7 @@ describe('PanelTeams', () => {
|
||||
|
||||
await userEvent.click(
|
||||
screen.getByRole('button', {
|
||||
name: 'Close the teams panel',
|
||||
name: 'Close the pads panel',
|
||||
}),
|
||||
);
|
||||
|
||||
@@ -165,7 +161,7 @@ describe('PanelTeams', () => {
|
||||
|
||||
await userEvent.click(
|
||||
screen.getByRole('button', {
|
||||
name: 'Open the teams panel',
|
||||
name: 'Open the pads panel',
|
||||
}),
|
||||
);
|
||||
|
||||
|
||||
@@ -67,7 +67,7 @@ export const PadItem = ({ pad }: PadItemProps) => {
|
||||
<Box $align="center" $direction="row" $gap="0.5rem">
|
||||
{hasMembers ? (
|
||||
<IconGroup
|
||||
aria-label={t(`Teams icon`)}
|
||||
aria-label={t(`Pads icon`)}
|
||||
color={colorsTokens()['primary-500']}
|
||||
{...commonProps}
|
||||
style={{
|
||||
@@ -77,7 +77,7 @@ export const PadItem = ({ pad }: PadItemProps) => {
|
||||
/>
|
||||
) : (
|
||||
<IconNone
|
||||
aria-label={t(`Empty teams icon`)}
|
||||
aria-label={t(`Empty pads icon`)}
|
||||
color={colorsTokens()['greyscale-500']}
|
||||
{...commonProps}
|
||||
style={{
|
||||
|
||||
@@ -34,12 +34,12 @@ export const Panel = () => {
|
||||
transition: ${transition};
|
||||
`}
|
||||
$height="inherit"
|
||||
aria-label="Teams panel"
|
||||
aria-label="Pads panel"
|
||||
{...closedOverridingStyles}
|
||||
>
|
||||
<BoxButton
|
||||
aria-label={
|
||||
isOpen ? t('Close the teams panel') : t('Open the teams panel')
|
||||
isOpen ? t('Close the pads panel') : t('Open the pads panel')
|
||||
}
|
||||
$color={colorsTokens()['primary-600']}
|
||||
$css={`
|
||||
|
||||
@@ -19,7 +19,9 @@ describe('checks all the frontend translation are made', () => {
|
||||
Object.keys(jsonimpress)
|
||||
.filter((key) => key !== 'en')
|
||||
.forEach((key) => {
|
||||
const listKeysimpress = Object.keys(jsonimpress[key].translation).sort();
|
||||
const listKeysimpress = Object.keys(
|
||||
jsonimpress[key].translation,
|
||||
).sort();
|
||||
const missingKeys = listKeysCrowdin.filter(
|
||||
(element) => !listKeysimpress.includes(element),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user