Clients UI: show several sessions of one user
- API: /api/v1/stats returns sessions_count and sessions per client - UI: badge "xN", "N devices", expandable session list, Active Sessions KPI - deploy/ui-dist rebuilt, docs: plan, summary, API reference, UI architecture Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
4815821f17
commit
1bbf9b7cc1
24 files changed
+229
-19
No files matched your search
@@ -0,0 +1,21 @@
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { sessionsBadge, toggleExpanded, visibleSessions } from './sessions';
|
||||
|
||||
describe('multi-session display', () => {
|
||||
const multi = { common_name: 'alice', sessions_count: 2, sessions: [{ real_address: 'a' }, { real_address: 'b' }] };
|
||||
const single = { common_name: 'bob', sessions_count: 1, sessions: [{ real_address: 'c' }] };
|
||||
|
||||
it('shows the badge only for more than one session', () => {
|
||||
expect(sessionsBadge(multi)).toBe('×2');
|
||||
expect(sessionsBadge(single)).toBeNull();
|
||||
expect(sessionsBadge({ common_name: 'old' })).toBeNull();
|
||||
});
|
||||
|
||||
it('expands and collapses the session list on click', () => {
|
||||
expect(visibleSessions(multi, [])).toEqual([]);
|
||||
const open = toggleExpanded([], 'alice');
|
||||
expect(visibleSessions(multi, open)).toHaveLength(2);
|
||||
expect(visibleSessions(multi, toggleExpanded(open, 'alice'))).toEqual([]);
|
||||
expect(visibleSessions(single, ['bob'])).toEqual([]);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user