Berichten: status boven bericht, ongelezen-bolletje, 'markeer als ongelezen' en dashboardtegel met aantal ongelezen (CMS-U12)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-11 13:37:18 +01:00
co-authored by Claude Sonnet 5.5
parent 705f6e34d7
commit daccc6a227
10 changed files with 210 additions and 9 deletions
@@ -407,10 +407,10 @@ describe('Message list', () => {
await openPage();
await screen.findByTestId(`contact-row-${MSG_NEW}`);
expect(
within(screen.getByTestId(`contact-row-${MSG_NEW}`)).getByRole('img'),
within(screen.getByTestId(`contact-row-${MSG_NEW}`)).getByTestId('mail-status-sent'),
).toHaveAccessibleName('Mail sent');
expect(
within(screen.getByTestId(`contact-row-${MSG_READ}`)).getByRole('img'),
within(screen.getByTestId(`contact-row-${MSG_READ}`)).getByTestId('mail-status-failed'),
).toHaveAccessibleName('Mail failed');
});
});
@@ -625,3 +625,74 @@ describe('Resend', () => {
expect(screen.getByTestId('contact-resend-hint')).toBeInTheDocument();
});
});
describe('Unread indication and status placement', () => {
it('marks only unread messages with a dot that has an accessible name', async () => {
await openPage();
await screen.findByTestId(`contact-row-${MSG_NEW}`);
const dot = screen.getByTestId(`contact-unread-dot-${MSG_NEW}`);
expect(dot).toHaveAccessibleName('Unread');
expect(screen.queryByTestId(`contact-unread-dot-${MSG_READ}`)).not.toBeInTheDocument();
});
it('shows the status above the message text in the detail', async () => {
await openPage();
await userEvent.click(await screen.findByTestId(`contact-open-${MSG_READ}`));
const body = await screen.findByTestId('contact-message-body');
const status = await within(screen.getByTestId('contact-message-dialog')).findByTestId(
'status-icon-read',
);
expect(
status.compareDocumentPosition(body) & Node.DOCUMENT_POSITION_FOLLOWING,
).toBeTruthy();
});
it('marks a read message as unread again and does not re-mark it as read', async () => {
await openPage();
await userEvent.click(await screen.findByTestId(`contact-open-${MSG_READ}`));
await userEvent.click(await screen.findByTestId('contact-mark-unread-button'));
await waitFor(() =>
expect(getMockContactMessages().find((m) => m.id === MSG_READ)?.status).toBe('new'),
);
await waitFor(() =>
expect(screen.getByTestId('contact-unread-count')).toHaveTextContent('(2)'),
);
expect(await screen.findByTestId(`contact-unread-dot-${MSG_READ}`)).toBeInTheDocument();
});
});
describe('Dashboard tile', () => {
it('shows the number of unread messages and links to the list', async () => {
capabilities(WITH_CONTACT);
renderApp('/dashboard');
const tile = await screen.findByTestId('messages-tile', {}, LONG);
await waitFor(() =>
expect(screen.getByTestId('messages-tile-count')).toHaveTextContent('1'),
);
expect(tile).toHaveAttribute('href', '/messages');
expect(tile).toHaveTextContent('unread message');
});
it('is not shown when the module is not loaded', async () => {
capabilities(['Availability', 'Identity', 'Offerings']);
renderApp('/dashboard');
await screen.findByTestId('dashboard-title', {}, LONG);
await new Promise((r) => setTimeout(r, 200));
expect(screen.queryByTestId('messages-tile')).not.toBeInTheDocument();
});
it('is not shown while the host switch is off (404)', async () => {
capabilities(WITH_CONTACT);
server.use(
http.get(
`${API_BASE}/api/v1/contact-settings`,
() => new HttpResponse(null, { status: 404 }),
),
);
renderApp('/dashboard');
await screen.findByTestId('dashboard-title', {}, LONG);
await new Promise((r) => setTimeout(r, 200));
expect(screen.queryByTestId('messages-tile')).not.toBeInTheDocument();
});
});