Hide add FAB at task limit
This commit is contained in:
@@ -1555,17 +1555,19 @@ export default function MobileEventTasksPage() {
|
|||||||
</AlertDialog.Portal>
|
</AlertDialog.Portal>
|
||||||
</AlertDialog>
|
</AlertDialog>
|
||||||
|
|
||||||
<FloatingActionButton
|
{canAddTasks ? (
|
||||||
onPress={() => {
|
<FloatingActionButton
|
||||||
if (!canAddTasks) {
|
onPress={() => {
|
||||||
toast.error(limitReachedMessage);
|
if (!canAddTasks) {
|
||||||
return;
|
toast.error(limitReachedMessage);
|
||||||
}
|
return;
|
||||||
setShowFabMenu(true);
|
}
|
||||||
}}
|
setShowFabMenu(true);
|
||||||
label={t('events.tasks.add', 'Add')}
|
}}
|
||||||
icon={Plus}
|
label={t('events.tasks.add', 'Add')}
|
||||||
/>
|
icon={Plus}
|
||||||
|
/>
|
||||||
|
) : null}
|
||||||
|
|
||||||
<MobileSheet
|
<MobileSheet
|
||||||
open={showFabMenu}
|
open={showFabMenu}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { describe, expect, it, vi } from 'vitest';
|
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';
|
import * as api from '../../api';
|
||||||
|
|
||||||
const fixtures = vi.hoisted(() => ({
|
const fixtures = vi.hoisted(() => ({
|
||||||
@@ -309,4 +309,23 @@ describe('MobileEventTasksPage', () => {
|
|||||||
|
|
||||||
expect((await screen.findAllByText('Auswahl löschen')).length).toBeGreaterThan(0);
|
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();
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user