mirror of
https://github.com/duckietm/Nitro-V3.git
synced 2026-06-19 15:06:20 +00:00
dcbf44aedb
Chat tagging: - Any @user is a visible tag in chat bubbles (the .mention-tag CSS never existed, so highlighting was invisible); self/alias mentions get a gold emphasis. Fixes cross-room tags not being highlighted. Mentions window: - Redesigned: unread count in the header, restyled filter chips + a refresh button, CSS-driven list/date-groups, adaptive height (compact when few, capped + scroll when many), polished empty state. - Rows: framed avatar (friends-list head crop so the face is never clipped), per-row unread dot, type marker, icon action buttons (goto / remove). - Re-requests from the server each time it opens. Autocomplete: - Never suggests the viewer themselves; suggests room users + online friends + aliases. Notifications: - Mention toast removed; mentions flow through the client's standard notification stream via a dedicated mention bubble (avatar + actions) in the default position. EVERY received mention surfaces (independent of the generic info-feed toggle, gated only by mentions_ui.enabled). Refactor (behaviour-preserving): - Centralised @-token classification in api/mentions/mentionTokens. - Moved mentionsFormat -> api/mentions, useMentionActions -> hooks/mentions. - Extracted ChatInputView @-autocomplete into a tested useChatMentions hook + pure helper; removed the dead duplicate useMentionAutocomplete.
53 lines
1.5 KiB
TypeScript
53 lines
1.5 KiB
TypeScript
import { describe, expect, it } from 'vitest';
|
|
import { formatMentionTime, getMentionDateGroup } from './mentionsFormat';
|
|
|
|
// Fixed reference "now": 2026-06-02 14:30 local time.
|
|
const NOW = new Date(2026, 5, 2, 14, 30, 0);
|
|
const at = (y: number, mo: number, d: number, h = 12, mi = 0): number => Math.floor(new Date(y, mo, d, h, mi, 0).getTime() / 1000);
|
|
|
|
describe('getMentionDateGroup', () =>
|
|
{
|
|
it('buckets same-day as today', () =>
|
|
{
|
|
expect(getMentionDateGroup(at(2026, 5, 2, 9, 15), NOW)).toBe('today');
|
|
});
|
|
|
|
it('buckets previous day as yesterday', () =>
|
|
{
|
|
expect(getMentionDateGroup(at(2026, 5, 1, 23, 59), NOW)).toBe('yesterday');
|
|
});
|
|
|
|
it('buckets two+ days ago as older', () =>
|
|
{
|
|
expect(getMentionDateGroup(at(2026, 4, 28, 10, 0), NOW)).toBe('older');
|
|
});
|
|
|
|
it('treats missing/zero timestamp as older', () =>
|
|
{
|
|
expect(getMentionDateGroup(0, NOW)).toBe('older');
|
|
});
|
|
});
|
|
|
|
describe('formatMentionTime', () =>
|
|
{
|
|
it('shows HH:MM (zero-padded) for today', () =>
|
|
{
|
|
expect(formatMentionTime(at(2026, 5, 2, 9, 5), NOW)).toBe('09:05');
|
|
});
|
|
|
|
it('shows HH:MM for yesterday', () =>
|
|
{
|
|
expect(formatMentionTime(at(2026, 5, 1, 18, 45), NOW)).toBe('18:45');
|
|
});
|
|
|
|
it('shows DD-MM for older entries', () =>
|
|
{
|
|
expect(formatMentionTime(at(2026, 4, 28, 10, 0), NOW)).toBe('28-05');
|
|
});
|
|
|
|
it('returns empty string for missing timestamp', () =>
|
|
{
|
|
expect(formatMentionTime(0, NOW)).toBe('');
|
|
});
|
|
});
|