Hide add FAB at task limit
Some checks failed
linter / quality (push) Has been cancelled
tests / ci (push) Has been cancelled
tests / ui (push) Has been cancelled

This commit is contained in:
Codex Agent
2026-01-21 10:30:12 +01:00
parent 246e54f970
commit 198fbf6751
2 changed files with 33 additions and 12 deletions

View File

@@ -1555,17 +1555,19 @@ export default function MobileEventTasksPage() {
</AlertDialog.Portal>
</AlertDialog>
<FloatingActionButton
onPress={() => {
if (!canAddTasks) {
toast.error(limitReachedMessage);
return;
}
setShowFabMenu(true);
}}
label={t('events.tasks.add', 'Add')}
icon={Plus}
/>
{canAddTasks ? (
<FloatingActionButton
onPress={() => {
if (!canAddTasks) {
toast.error(limitReachedMessage);
return;
}
setShowFabMenu(true);
}}
label={t('events.tasks.add', 'Add')}
icon={Plus}
/>
) : null}
<MobileSheet
open={showFabMenu}

View File

@@ -1,6 +1,6 @@
import React from 'react';
import { describe, expect, it, vi } from 'vitest';
import { act, fireEvent, render, screen } from '@testing-library/react';
import { act, fireEvent, render, screen, waitFor } from '@testing-library/react';
import * as api from '../../api';
const fixtures = vi.hoisted(() => ({
@@ -309,4 +309,23 @@ describe('MobileEventTasksPage', () => {
expect((await screen.findAllByText('Auswahl löschen')).length).toBeGreaterThan(0);
});
it('hides the add FAB when the task limit is reached', async () => {
(api.getEvent as unknown as { mockResolvedValueOnce: (value: any) => void }).mockResolvedValueOnce({
...fixtures.event,
limits: {
tasks: {
limit: 2,
remaining: 0,
},
},
});
render(<MobileEventTasksPage />);
expect(await screen.findByText('Photo task mode')).toBeInTheDocument();
await waitFor(() => {
expect(screen.queryByLabelText('Add')).not.toBeInTheDocument();
});
});
});