💄(app-desk) do not count the owner in item list icon
In every team, the owner is always included in it, so we shouldn't count the owner when we display the icon to say if a team has members.
This commit is contained in:
@@ -30,7 +30,7 @@ describe('PanelTeams', () => {
|
||||
).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('renders with empty team to display', async () => {
|
||||
it('renders an empty team', async () => {
|
||||
fetchMock.mock(`/api/teams/?page=1&ordering=-created_at`, {
|
||||
count: 1,
|
||||
results: [
|
||||
@@ -51,7 +51,33 @@ describe('PanelTeams', () => {
|
||||
).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('renders with not team to display', async () => {
|
||||
it('renders a team with only 1 member', async () => {
|
||||
fetchMock.mock(`/api/teams/?page=1&ordering=-created_at`, {
|
||||
count: 1,
|
||||
results: [
|
||||
{
|
||||
id: '1',
|
||||
name: 'Team 1',
|
||||
accesses: [
|
||||
{
|
||||
id: '1',
|
||||
role: 'owner',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
render(<PanelTeams />, { wrapper: AppWrapper });
|
||||
|
||||
expect(screen.getByRole('status')).toBeInTheDocument();
|
||||
|
||||
expect(
|
||||
await screen.findByLabelText('Empty teams icon'),
|
||||
).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('renders a non-empty team', async () => {
|
||||
fetchMock.mock(`/api/teams/?page=1&ordering=-created_at`, {
|
||||
count: 1,
|
||||
results: [
|
||||
@@ -63,6 +89,10 @@ describe('PanelTeams', () => {
|
||||
id: '1',
|
||||
role: 'admin',
|
||||
},
|
||||
{
|
||||
id: '2',
|
||||
role: 'member',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
|
||||
@@ -16,6 +16,9 @@ export const PanelTeam = ({ team }: TeamProps) => {
|
||||
const { t } = useTranslation();
|
||||
const { colorsTokens } = useCunninghamTheme();
|
||||
|
||||
// There is at least 1 owner in the team
|
||||
const hasMembers = team.accesses.length > 1;
|
||||
|
||||
const commonProps = {
|
||||
className: 'p-t',
|
||||
width: 52,
|
||||
@@ -27,7 +30,7 @@ export const PanelTeam = ({ team }: TeamProps) => {
|
||||
|
||||
return (
|
||||
<Box as="li" $direction="row" $align="center" $gap="0.5rem">
|
||||
{team.accesses.length ? (
|
||||
{hasMembers ? (
|
||||
<IconGroup
|
||||
aria-label={t(`Teams icon`)}
|
||||
color={colorsTokens()['primary-500']}
|
||||
|
||||
Reference in New Issue
Block a user