mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-29 08:00:06 +00:00
d6ce33c51c
typescript-eslint 8.74 no longer takes the classic JSX pragma for the automatic runtime, so an unused default React import is reported now. The no-unused-vars baseline of the app code drops by the one it already counted.
67 lines
2.5 KiB
TypeScript
67 lines
2.5 KiB
TypeScript
import { describe, it, expect, beforeEach } from 'vitest';
|
|
import userEvent from '@testing-library/user-event';
|
|
import { render, screen, waitFor } from '../../../helpers/render';
|
|
import { resetAllStores } from '../../../helpers/store';
|
|
import MNotifications from '../../../../src/mobile/screens/notifications/MNotifications';
|
|
|
|
// FE-MOB-NOTIF-001 onwards
|
|
|
|
beforeEach(() => {
|
|
resetAllStores();
|
|
});
|
|
|
|
describe('MNotifications', () => {
|
|
it('FE-MOB-NOTIF-001: loads the first page with unread badge and bulk actions', async () => {
|
|
render(<MNotifications />);
|
|
|
|
// Default handler: 25 notifications (page of 20), unread_count 5.
|
|
await waitFor(() => {
|
|
expect(screen.getAllByText('notif.title')).toHaveLength(20);
|
|
});
|
|
expect(screen.getByText('5')).toBeInTheDocument();
|
|
expect(screen.getByRole('button', { name: 'Mark all read' })).toBeInTheDocument();
|
|
expect(screen.getByRole('button', { name: 'Delete all' })).toBeInTheDocument();
|
|
expect(screen.getByRole('button', { name: 'Back' })).toBeInTheDocument();
|
|
});
|
|
|
|
it('FE-MOB-NOTIF-001b: Delete all asks for confirmation before it clears the list', async () => {
|
|
const user = userEvent.setup();
|
|
render(<MNotifications />);
|
|
await waitFor(() => {
|
|
expect(screen.getAllByText('notif.title')).toHaveLength(20);
|
|
});
|
|
|
|
await user.click(screen.getByRole('button', { name: 'Delete all' }));
|
|
expect(screen.getAllByText('notif.title')).toHaveLength(20);
|
|
|
|
await user.click(screen.getByRole('button', { name: 'Cancel' }));
|
|
expect(screen.getAllByText('notif.title')).toHaveLength(20);
|
|
|
|
await user.click(screen.getByRole('button', { name: 'Delete all' }));
|
|
await user.click(screen.getAllByRole('button', { name: 'Delete all' }).slice(-1)[0]);
|
|
await waitFor(() => {
|
|
expect(screen.queryAllByText('notif.title')).toHaveLength(0);
|
|
});
|
|
});
|
|
|
|
it('FE-MOB-NOTIF-002: the unread segment filters out read notifications', async () => {
|
|
const user = userEvent.setup();
|
|
render(<MNotifications />);
|
|
|
|
await waitFor(() => {
|
|
expect(screen.getAllByText('notif.title')).toHaveLength(20);
|
|
});
|
|
|
|
// First 5 rows of the default handler are unread.
|
|
await user.click(screen.getByRole('tab', { name: 'Unread' }));
|
|
await waitFor(() => {
|
|
expect(screen.getAllByText('notif.title')).toHaveLength(5);
|
|
});
|
|
|
|
await user.click(screen.getByRole('tab', { name: 'All' }));
|
|
await waitFor(() => {
|
|
expect(screen.getAllByText('notif.title')).toHaveLength(20);
|
|
});
|
|
});
|
|
});
|