@agent-relay/dashboard 2.0.80 → 2.0.82
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/out/404.html +1 -1
- package/out/_next/static/chunks/{118-4c8241b0218335de.js → 118-ae2b650136a5a5fc.js} +1 -1
- package/out/_next/static/chunks/407-0c82986cf79c8ecb.js +1 -0
- package/out/_next/static/chunks/app/app/[[...slug]]/{page-1e81c047cff17212.js → page-f7eca1b66fb4249b.js} +1 -1
- package/out/_next/static/chunks/app/{page-6892fe2dd07fb48b.js → page-0ee604f7070d14c0.js} +1 -1
- package/out/_next/static/css/8968d98ed4c4d33f.css +1 -0
- package/out/about.html +2 -2
- package/out/about.txt +1 -1
- package/out/app/onboarding.html +1 -1
- package/out/app/onboarding.txt +1 -1
- package/out/app.html +1 -1
- package/out/app.txt +2 -2
- package/out/blog/go-to-bed-wake-up-to-a-finished-product.html +2 -2
- package/out/blog/go-to-bed-wake-up-to-a-finished-product.txt +1 -1
- package/out/blog/let-them-cook-multi-agent-orchestration.html +2 -2
- package/out/blog/let-them-cook-multi-agent-orchestration.txt +2 -2
- package/out/blog.html +2 -2
- package/out/blog.txt +1 -1
- package/out/careers.html +2 -2
- package/out/careers.txt +1 -1
- package/out/changelog.html +2 -2
- package/out/changelog.txt +1 -1
- package/out/cloud/link.html +1 -1
- package/out/cloud/link.txt +2 -2
- package/out/complete-profile.html +2 -2
- package/out/complete-profile.txt +1 -1
- package/out/connect-repos.html +1 -1
- package/out/connect-repos.txt +1 -1
- package/out/contact.html +2 -2
- package/out/contact.txt +1 -1
- package/out/docs.html +2 -2
- package/out/docs.txt +1 -1
- package/out/history.html +1 -1
- package/out/history.txt +2 -2
- package/out/index.html +1 -1
- package/out/index.txt +2 -2
- package/out/login.html +2 -2
- package/out/login.txt +1 -1
- package/out/metrics.html +1 -1
- package/out/metrics.txt +2 -2
- package/out/pricing.html +2 -2
- package/out/pricing.txt +1 -1
- package/out/privacy.html +2 -2
- package/out/privacy.txt +1 -1
- package/out/providers/setup/claude.html +1 -1
- package/out/providers/setup/claude.txt +1 -1
- package/out/providers/setup/codex.html +1 -1
- package/out/providers/setup/codex.txt +1 -1
- package/out/providers/setup/cursor.html +1 -1
- package/out/providers/setup/cursor.txt +1 -1
- package/out/providers.html +1 -1
- package/out/providers.txt +1 -1
- package/out/security.html +2 -2
- package/out/security.txt +1 -1
- package/out/signup.html +2 -2
- package/out/signup.txt +1 -1
- package/out/terms.html +2 -2
- package/out/terms.txt +1 -1
- package/package.json +7 -1
- package/src/app/about/page.tsx +7 -0
- package/src/app/app/[[...slug]]/DashboardPageClient.tsx +853 -0
- package/src/app/app/[[...slug]]/page.tsx +23 -0
- package/src/app/app/onboarding/page.tsx +394 -0
- package/src/app/apple-icon.png +0 -0
- package/src/app/blog/go-to-bed-wake-up-to-a-finished-product/page.tsx +88 -0
- package/src/app/blog/let-them-cook-multi-agent-orchestration/page.tsx +93 -0
- package/src/app/blog/page.tsx +15 -0
- package/src/app/careers/page.tsx +7 -0
- package/src/app/changelog/page.tsx +7 -0
- package/src/app/cloud/link/page.tsx +464 -0
- package/src/app/complete-profile/page.tsx +204 -0
- package/src/app/connect-repos/page.tsx +410 -0
- package/src/app/contact/page.tsx +7 -0
- package/src/app/docs/page.tsx +7 -0
- package/src/app/favicon.png +0 -0
- package/src/app/globals.css +200 -0
- package/src/app/history/page.tsx +658 -0
- package/src/app/layout.tsx +25 -0
- package/src/app/login/page.tsx +424 -0
- package/src/app/metrics/page.tsx +781 -0
- package/src/app/page.tsx +59 -0
- package/src/app/pricing/page.tsx +7 -0
- package/src/app/privacy/page.tsx +7 -0
- package/src/app/providers/page.tsx +193 -0
- package/src/app/providers/setup/[provider]/ProviderSetupClient.tsx +197 -0
- package/src/app/providers/setup/[provider]/constants.ts +35 -0
- package/src/app/providers/setup/[provider]/page.tsx +42 -0
- package/src/app/security/page.tsx +7 -0
- package/src/app/signup/page.tsx +533 -0
- package/src/app/terms/page.tsx +7 -0
- package/src/components/ActivityFeed.tsx +216 -0
- package/src/components/AddWorkspaceModal.tsx +170 -0
- package/src/components/AgentCard.test.tsx +134 -0
- package/src/components/AgentCard.tsx +585 -0
- package/src/components/AgentList.test.tsx +147 -0
- package/src/components/AgentList.tsx +419 -0
- package/src/components/AgentLogPreview.tsx +173 -0
- package/src/components/AgentProfilePanel.tsx +569 -0
- package/src/components/App.tsx +3424 -0
- package/src/components/BillingPanel.tsx +922 -0
- package/src/components/BillingResult.tsx +447 -0
- package/src/components/BroadcastComposer.tsx +690 -0
- package/src/components/ChannelAdminPanel.tsx +773 -0
- package/src/components/ChannelBrowser.tsx +385 -0
- package/src/components/ChannelChat.tsx +261 -0
- package/src/components/ChannelSidebar.tsx +399 -0
- package/src/components/CloudSessionProvider.tsx +130 -0
- package/src/components/CommandPalette.tsx +815 -0
- package/src/components/ConfirmationDialog.tsx +133 -0
- package/src/components/ConversationHistory.tsx +518 -0
- package/src/components/CoordinatorPanel.tsx +956 -0
- package/src/components/DecisionQueue.tsx +717 -0
- package/src/components/DirectMessageView.tsx +164 -0
- package/src/components/FileAutocomplete.tsx +368 -0
- package/src/components/FleetOverview.tsx +278 -0
- package/src/components/LogViewer.tsx +310 -0
- package/src/components/LogViewerPanel.tsx +482 -0
- package/src/components/Logo.tsx +284 -0
- package/src/components/MentionAutocomplete.tsx +384 -0
- package/src/components/MessageComposer.tsx +473 -0
- package/src/components/MessageList.tsx +725 -0
- package/src/components/MessageSenderName.tsx +91 -0
- package/src/components/MessageStatusIndicator.tsx +142 -0
- package/src/components/NewConversationModal.tsx +400 -0
- package/src/components/NotificationToast.tsx +488 -0
- package/src/components/OnlineUsersIndicator.tsx +164 -0
- package/src/components/Pagination.tsx +124 -0
- package/src/components/PricingPlans.tsx +386 -0
- package/src/components/ProjectList.tsx +711 -0
- package/src/components/ProviderAuthFlow.tsx +343 -0
- package/src/components/ProviderConnectionList.tsx +375 -0
- package/src/components/ProvisioningProgress.tsx +730 -0
- package/src/components/ReactionChips.tsx +70 -0
- package/src/components/ReactionPicker.tsx +121 -0
- package/src/components/RepoAccessPanel.tsx +787 -0
- package/src/components/RepositoriesPanel.tsx +901 -0
- package/src/components/ServerCard.tsx +202 -0
- package/src/components/SessionExpiredModal.tsx +128 -0
- package/src/components/SpawnModal.test.tsx +190 -0
- package/src/components/SpawnModal.tsx +1001 -0
- package/src/components/TaskAssignmentUI.tsx +375 -0
- package/src/components/TerminalProviderSetup.tsx +517 -0
- package/src/components/ThemeProvider.tsx +159 -0
- package/src/components/ThinkingIndicator.tsx +231 -0
- package/src/components/ThreadList.tsx +198 -0
- package/src/components/ThreadPanel.tsx +405 -0
- package/src/components/TrajectoryViewer.tsx +698 -0
- package/src/components/TypingIndicator.tsx +69 -0
- package/src/components/UsageBanner.tsx +231 -0
- package/src/components/UserProfilePanel.tsx +233 -0
- package/src/components/WorkspaceContext.tsx +95 -0
- package/src/components/WorkspaceSelector.tsx +234 -0
- package/src/components/WorkspaceStatusIndicator.tsx +396 -0
- package/src/components/XTermInteractive.tsx +516 -0
- package/src/components/XTermLogViewer.tsx +719 -0
- package/src/components/channels/ChannelDialogs.tsx +1411 -0
- package/src/components/channels/ChannelHeader.tsx +317 -0
- package/src/components/channels/ChannelMessageList.tsx +463 -0
- package/src/components/channels/ChannelViewV1.tsx +146 -0
- package/src/components/channels/MessageInput.tsx +302 -0
- package/src/components/channels/SearchInput.tsx +172 -0
- package/src/components/channels/SearchResults.tsx +336 -0
- package/src/components/channels/api.test.ts +1527 -0
- package/src/components/channels/api.ts +703 -0
- package/src/components/channels/index.ts +76 -0
- package/src/components/channels/mockApi.ts +344 -0
- package/src/components/channels/types.ts +566 -0
- package/src/components/hooks/index.ts +58 -0
- package/src/components/hooks/useAgentLogs.ts +504 -0
- package/src/components/hooks/useAgents.ts +127 -0
- package/src/components/hooks/useBroadcastDedup.test.ts +371 -0
- package/src/components/hooks/useBroadcastDedup.ts +86 -0
- package/src/components/hooks/useChannelAdmin.ts +329 -0
- package/src/components/hooks/useChannelBrowser.ts +239 -0
- package/src/components/hooks/useChannelCommands.ts +138 -0
- package/src/components/hooks/useChannels.ts +367 -0
- package/src/components/hooks/useDebounce.ts +29 -0
- package/src/components/hooks/useDirectMessage.test.ts +952 -0
- package/src/components/hooks/useDirectMessage.ts +141 -0
- package/src/components/hooks/useMessages.ts +310 -0
- package/src/components/hooks/useOrchestrator.test.ts +165 -0
- package/src/components/hooks/useOrchestrator.ts +424 -0
- package/src/components/hooks/usePinnedAgents.test.ts +356 -0
- package/src/components/hooks/usePinnedAgents.ts +140 -0
- package/src/components/hooks/usePresence.test.ts +245 -0
- package/src/components/hooks/usePresence.ts +377 -0
- package/src/components/hooks/useRecentRepos.ts +130 -0
- package/src/components/hooks/useSession.ts +209 -0
- package/src/components/hooks/useThread.ts +138 -0
- package/src/components/hooks/useTrajectory.ts +265 -0
- package/src/components/hooks/useWebSocket.ts +290 -0
- package/src/components/hooks/useWorkspaceMembers.ts +132 -0
- package/src/components/hooks/useWorkspaceRepos.ts +73 -0
- package/src/components/hooks/useWorkspaceStatus.ts +237 -0
- package/src/components/index.ts +81 -0
- package/src/components/layout/Header.tsx +311 -0
- package/src/components/layout/RepoContextHeader.tsx +361 -0
- package/src/components/layout/Sidebar.archive.test.tsx +126 -0
- package/src/components/layout/Sidebar.test.tsx +691 -0
- package/src/components/layout/Sidebar.tsx +900 -0
- package/src/components/layout/index.ts +7 -0
- package/src/components/settings/BillingSettingsPanel.tsx +564 -0
- package/src/components/settings/SettingsPage.tsx +683 -0
- package/src/components/settings/TeamSettingsPanel.tsx +560 -0
- package/src/components/settings/WorkspaceSettingsPanel.tsx +1368 -0
- package/src/components/settings/index.ts +11 -0
- package/src/components/settings/types.ts +79 -0
- package/src/components/utils/messageFormatting.test.tsx +331 -0
- package/src/components/utils/messageFormatting.tsx +597 -0
- package/src/index.ts +63 -0
- package/src/landing/AboutPage.tsx +77 -0
- package/src/landing/BlogContent.tsx +187 -0
- package/src/landing/BlogPage.tsx +47 -0
- package/src/landing/CareersPage.tsx +53 -0
- package/src/landing/ChangelogPage.tsx +33 -0
- package/src/landing/ContactPage.tsx +41 -0
- package/src/landing/DocsPage.tsx +43 -0
- package/src/landing/LandingPage.tsx +702 -0
- package/src/landing/PricingPage.tsx +549 -0
- package/src/landing/PrivacyPage.tsx +117 -0
- package/src/landing/SecurityPage.tsx +42 -0
- package/src/landing/StaticPage.tsx +165 -0
- package/src/landing/TermsPage.tsx +125 -0
- package/src/landing/blogData.ts +312 -0
- package/src/landing/index.ts +18 -0
- package/src/landing/styles.css +3673 -0
- package/src/lib/agent-merge.test.ts +43 -0
- package/src/lib/agent-merge.ts +35 -0
- package/src/lib/api.ts +1294 -0
- package/src/lib/cloudApi.ts +893 -0
- package/src/lib/colors.test.ts +175 -0
- package/src/lib/colors.ts +218 -0
- package/src/lib/config.ts +109 -0
- package/src/lib/hierarchy.ts +242 -0
- package/src/lib/stuckDetection.ts +142 -0
- package/src/lib/useUrlRouting.ts +190 -0
- package/src/types/index.ts +317 -0
- package/src/types/threading.ts +7 -0
- package/out/_next/static/chunks/285-dc644487a8d6500d.js +0 -1
- package/out/_next/static/css/4c58d9cf493aa626.css +0 -1
- /package/out/_next/static/{AqelRhy1vr2nBUcU0Iqcp → IxfA6RZu4trcsEMYlkQra}/_buildManifest.js +0 -0
- /package/out/_next/static/{AqelRhy1vr2nBUcU0Iqcp → IxfA6RZu4trcsEMYlkQra}/_ssgManifest.js +0 -0
- /package/out/_next/static/chunks/{528-d375bc8b46912d2c.js → 528-f5f676996d613c25.js} +0 -0
- /package/out/_next/static/chunks/app/blog/let-them-cook-multi-agent-orchestration/{page-a58308f43557b908.js → page-b194f207fbd91862.js} +0 -0
|
@@ -0,0 +1,691 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tests for Sidebar component channel functionality.
|
|
3
|
+
*
|
|
4
|
+
* Tests channel rendering, selection, interactions, and state management.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import React from 'react';
|
|
8
|
+
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
|
|
9
|
+
import { render, screen, fireEvent, within } from '@testing-library/react';
|
|
10
|
+
import { Sidebar, type SidebarProps, type SidebarChannel } from './Sidebar';
|
|
11
|
+
|
|
12
|
+
// Mock localStorage with proper reset between tests
|
|
13
|
+
let localStorageStore: Record<string, string> = {};
|
|
14
|
+
|
|
15
|
+
const mockLocalStorage = {
|
|
16
|
+
getItem: vi.fn((key: string) => localStorageStore[key] ?? null),
|
|
17
|
+
setItem: vi.fn((key: string, value: string) => {
|
|
18
|
+
localStorageStore[key] = value;
|
|
19
|
+
}),
|
|
20
|
+
removeItem: vi.fn((key: string) => {
|
|
21
|
+
delete localStorageStore[key];
|
|
22
|
+
}),
|
|
23
|
+
clear: vi.fn(() => {
|
|
24
|
+
localStorageStore = {};
|
|
25
|
+
}),
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
Object.defineProperty(window, 'localStorage', {
|
|
29
|
+
value: mockLocalStorage,
|
|
30
|
+
writable: true,
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
describe('Sidebar', () => {
|
|
34
|
+
const defaultProps: SidebarProps = {
|
|
35
|
+
agents: [],
|
|
36
|
+
viewMode: 'channels',
|
|
37
|
+
isFleetAvailable: false,
|
|
38
|
+
isConnected: true,
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
beforeEach(() => {
|
|
42
|
+
localStorageStore = {};
|
|
43
|
+
vi.clearAllMocks();
|
|
44
|
+
// Reset mock implementations to default behavior
|
|
45
|
+
mockLocalStorage.getItem.mockImplementation((key: string) => localStorageStore[key] ?? null);
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
describe('Channel Rendering', () => {
|
|
49
|
+
it('should render channels section header', () => {
|
|
50
|
+
render(<Sidebar {...defaultProps} />);
|
|
51
|
+
|
|
52
|
+
expect(screen.getByText('Channels')).toBeInTheDocument();
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
it('should render channel list when channels provided', () => {
|
|
56
|
+
const channels: SidebarChannel[] = [
|
|
57
|
+
{ id: 'ch-1', name: 'general', unreadCount: 0 },
|
|
58
|
+
{ id: 'ch-2', name: 'engineering', unreadCount: 0 },
|
|
59
|
+
];
|
|
60
|
+
|
|
61
|
+
render(<Sidebar {...defaultProps} channels={channels} />);
|
|
62
|
+
|
|
63
|
+
// Expand channels section first (collapsed by default)
|
|
64
|
+
fireEvent.click(screen.getByText('Channels'));
|
|
65
|
+
|
|
66
|
+
expect(screen.getByText('general')).toBeInTheDocument();
|
|
67
|
+
expect(screen.getByText('engineering')).toBeInTheDocument();
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
it('should show # prefix for channel names', () => {
|
|
71
|
+
const channels: SidebarChannel[] = [
|
|
72
|
+
{ id: 'ch-1', name: 'general', unreadCount: 0 },
|
|
73
|
+
];
|
|
74
|
+
|
|
75
|
+
render(<Sidebar {...defaultProps} channels={channels} />);
|
|
76
|
+
fireEvent.click(screen.getByText('Channels'));
|
|
77
|
+
|
|
78
|
+
// The # is in a separate span
|
|
79
|
+
const hashSymbols = screen.getAllByText('#');
|
|
80
|
+
expect(hashSymbols.length).toBeGreaterThan(0);
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
it('should render empty state with create button when no channels', () => {
|
|
84
|
+
const onCreateChannel = vi.fn();
|
|
85
|
+
|
|
86
|
+
render(
|
|
87
|
+
<Sidebar
|
|
88
|
+
{...defaultProps}
|
|
89
|
+
channels={[]}
|
|
90
|
+
onCreateChannel={onCreateChannel}
|
|
91
|
+
/>
|
|
92
|
+
);
|
|
93
|
+
|
|
94
|
+
expect(screen.getByText('Create your first channel')).toBeInTheDocument();
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
it('should show "Add channel" when channels exist', () => {
|
|
98
|
+
const channels: SidebarChannel[] = [
|
|
99
|
+
{ id: 'ch-1', name: 'general', unreadCount: 0 },
|
|
100
|
+
];
|
|
101
|
+
const onCreateChannel = vi.fn();
|
|
102
|
+
|
|
103
|
+
render(
|
|
104
|
+
<Sidebar
|
|
105
|
+
{...defaultProps}
|
|
106
|
+
channels={channels}
|
|
107
|
+
onCreateChannel={onCreateChannel}
|
|
108
|
+
/>
|
|
109
|
+
);
|
|
110
|
+
fireEvent.click(screen.getByText('Channels'));
|
|
111
|
+
|
|
112
|
+
expect(screen.getByText('Add channel')).toBeInTheDocument();
|
|
113
|
+
});
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
describe('Channel Selection', () => {
|
|
117
|
+
it('should call onChannelSelect when channel clicked', () => {
|
|
118
|
+
const channels: SidebarChannel[] = [
|
|
119
|
+
{ id: 'ch-1', name: 'general', unreadCount: 0 },
|
|
120
|
+
];
|
|
121
|
+
const onChannelSelect = vi.fn();
|
|
122
|
+
|
|
123
|
+
render(
|
|
124
|
+
<Sidebar
|
|
125
|
+
{...defaultProps}
|
|
126
|
+
channels={channels}
|
|
127
|
+
onChannelSelect={onChannelSelect}
|
|
128
|
+
/>
|
|
129
|
+
);
|
|
130
|
+
fireEvent.click(screen.getByText('Channels'));
|
|
131
|
+
fireEvent.click(screen.getByText('general'));
|
|
132
|
+
|
|
133
|
+
expect(onChannelSelect).toHaveBeenCalledWith(channels[0]);
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
it('should highlight selected channel', () => {
|
|
137
|
+
const channels: SidebarChannel[] = [
|
|
138
|
+
{ id: 'ch-1', name: 'general', unreadCount: 0 },
|
|
139
|
+
{ id: 'ch-2', name: 'random', unreadCount: 0 },
|
|
140
|
+
];
|
|
141
|
+
|
|
142
|
+
render(
|
|
143
|
+
<Sidebar
|
|
144
|
+
{...defaultProps}
|
|
145
|
+
channels={channels}
|
|
146
|
+
selectedChannelId="ch-1"
|
|
147
|
+
/>
|
|
148
|
+
);
|
|
149
|
+
fireEvent.click(screen.getByText('Channels'));
|
|
150
|
+
|
|
151
|
+
const generalButton = screen.getByText('general').closest('button');
|
|
152
|
+
expect(generalButton).toHaveClass('bg-accent-cyan/10');
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
it('should not highlight unselected channels', () => {
|
|
156
|
+
const channels: SidebarChannel[] = [
|
|
157
|
+
{ id: 'ch-1', name: 'general', unreadCount: 0 },
|
|
158
|
+
{ id: 'ch-2', name: 'random', unreadCount: 0 },
|
|
159
|
+
];
|
|
160
|
+
|
|
161
|
+
render(
|
|
162
|
+
<Sidebar
|
|
163
|
+
{...defaultProps}
|
|
164
|
+
channels={channels}
|
|
165
|
+
selectedChannelId="ch-1"
|
|
166
|
+
/>
|
|
167
|
+
);
|
|
168
|
+
fireEvent.click(screen.getByText('Channels'));
|
|
169
|
+
|
|
170
|
+
const randomButton = screen.getByText('random').closest('button');
|
|
171
|
+
expect(randomButton).not.toHaveClass('bg-accent-cyan/10');
|
|
172
|
+
});
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
describe('Unread Badges', () => {
|
|
176
|
+
it('should show unread count badge when channel has unreads', () => {
|
|
177
|
+
const channels: SidebarChannel[] = [
|
|
178
|
+
{ id: 'ch-1', name: 'general', unreadCount: 5 },
|
|
179
|
+
];
|
|
180
|
+
|
|
181
|
+
render(<Sidebar {...defaultProps} channels={channels} />);
|
|
182
|
+
fireEvent.click(screen.getByText('Channels'));
|
|
183
|
+
|
|
184
|
+
// Should find two badges: one in header (total), one in channel row
|
|
185
|
+
const badges = screen.getAllByText('5');
|
|
186
|
+
expect(badges.length).toBeGreaterThanOrEqual(1);
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
it('should not show badge when unread count is 0', () => {
|
|
190
|
+
const channels: SidebarChannel[] = [
|
|
191
|
+
{ id: 'ch-1', name: 'general', unreadCount: 0 },
|
|
192
|
+
];
|
|
193
|
+
|
|
194
|
+
render(<Sidebar {...defaultProps} channels={channels} />);
|
|
195
|
+
fireEvent.click(screen.getByText('Channels'));
|
|
196
|
+
|
|
197
|
+
// Should not find a standalone "0" as a badge
|
|
198
|
+
const generalRow = screen.getByText('general').closest('button');
|
|
199
|
+
expect(within(generalRow!).queryByText('0')).not.toBeInTheDocument();
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
it('should show total unread count in section header', () => {
|
|
203
|
+
const channels: SidebarChannel[] = [
|
|
204
|
+
{ id: 'ch-1', name: 'general', unreadCount: 3 },
|
|
205
|
+
{ id: 'ch-2', name: 'random', unreadCount: 5 },
|
|
206
|
+
];
|
|
207
|
+
|
|
208
|
+
render(<Sidebar {...defaultProps} channels={channels} />);
|
|
209
|
+
|
|
210
|
+
// Total should be 8
|
|
211
|
+
expect(screen.getByText('8')).toBeInTheDocument();
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
it('should style mentions differently from regular unreads', () => {
|
|
215
|
+
const channels: SidebarChannel[] = [
|
|
216
|
+
{ id: 'ch-1', name: 'alerts', unreadCount: 2, hasMentions: true },
|
|
217
|
+
];
|
|
218
|
+
|
|
219
|
+
render(<Sidebar {...defaultProps} channels={channels} />);
|
|
220
|
+
fireEvent.click(screen.getByText('Channels'));
|
|
221
|
+
|
|
222
|
+
// Find all badges with "2" - the channel row badge should have mention styling
|
|
223
|
+
const badges = screen.getAllByText('2');
|
|
224
|
+
const mentionBadge = badges.find(badge => badge.className.includes('bg-red-500/20'));
|
|
225
|
+
expect(mentionBadge).toBeTruthy();
|
|
226
|
+
});
|
|
227
|
+
|
|
228
|
+
it('should bold channel name when has unread messages', () => {
|
|
229
|
+
const channels: SidebarChannel[] = [
|
|
230
|
+
{ id: 'ch-1', name: 'general', unreadCount: 5 },
|
|
231
|
+
];
|
|
232
|
+
|
|
233
|
+
render(<Sidebar {...defaultProps} channels={channels} />);
|
|
234
|
+
fireEvent.click(screen.getByText('Channels'));
|
|
235
|
+
|
|
236
|
+
const channelName = screen.getByText('general');
|
|
237
|
+
expect(channelName).toHaveClass('font-semibold');
|
|
238
|
+
});
|
|
239
|
+
});
|
|
240
|
+
|
|
241
|
+
describe('Collapsed State', () => {
|
|
242
|
+
it('should be collapsed by default', () => {
|
|
243
|
+
const channels: SidebarChannel[] = [
|
|
244
|
+
{ id: 'ch-1', name: 'general', unreadCount: 0 },
|
|
245
|
+
];
|
|
246
|
+
|
|
247
|
+
render(<Sidebar {...defaultProps} channels={channels} />);
|
|
248
|
+
|
|
249
|
+
// Channel name should not be visible when collapsed
|
|
250
|
+
expect(screen.queryByText('general')).not.toBeInTheDocument();
|
|
251
|
+
});
|
|
252
|
+
|
|
253
|
+
it('should expand when header clicked', () => {
|
|
254
|
+
const channels: SidebarChannel[] = [
|
|
255
|
+
{ id: 'ch-1', name: 'general', unreadCount: 0 },
|
|
256
|
+
];
|
|
257
|
+
|
|
258
|
+
render(<Sidebar {...defaultProps} channels={channels} />);
|
|
259
|
+
|
|
260
|
+
// Click to expand
|
|
261
|
+
fireEvent.click(screen.getByText('Channels'));
|
|
262
|
+
|
|
263
|
+
expect(screen.getByText('general')).toBeInTheDocument();
|
|
264
|
+
});
|
|
265
|
+
|
|
266
|
+
it('should collapse when header clicked again', () => {
|
|
267
|
+
const channels: SidebarChannel[] = [
|
|
268
|
+
{ id: 'ch-1', name: 'general', unreadCount: 0 },
|
|
269
|
+
];
|
|
270
|
+
|
|
271
|
+
render(<Sidebar {...defaultProps} channels={channels} />);
|
|
272
|
+
|
|
273
|
+
// Expand
|
|
274
|
+
fireEvent.click(screen.getByText('Channels'));
|
|
275
|
+
expect(screen.getByText('general')).toBeInTheDocument();
|
|
276
|
+
|
|
277
|
+
// Collapse
|
|
278
|
+
fireEvent.click(screen.getByText('Channels'));
|
|
279
|
+
expect(screen.queryByText('general')).not.toBeInTheDocument();
|
|
280
|
+
});
|
|
281
|
+
|
|
282
|
+
it('should persist collapsed state to localStorage', () => {
|
|
283
|
+
const channels: SidebarChannel[] = [
|
|
284
|
+
{ id: 'ch-1', name: 'general', unreadCount: 0 },
|
|
285
|
+
];
|
|
286
|
+
|
|
287
|
+
render(<Sidebar {...defaultProps} channels={channels} />);
|
|
288
|
+
|
|
289
|
+
// Expand
|
|
290
|
+
fireEvent.click(screen.getByText('Channels'));
|
|
291
|
+
|
|
292
|
+
expect(mockLocalStorage.setItem).toHaveBeenCalledWith(
|
|
293
|
+
'agent-relay-channels-collapsed',
|
|
294
|
+
'false'
|
|
295
|
+
);
|
|
296
|
+
});
|
|
297
|
+
|
|
298
|
+
it('should restore collapsed state from localStorage', () => {
|
|
299
|
+
mockLocalStorage.getItem.mockImplementation((key: string) => {
|
|
300
|
+
if (key === 'agent-relay-channels-collapsed') return 'false';
|
|
301
|
+
return null;
|
|
302
|
+
});
|
|
303
|
+
|
|
304
|
+
const channels: SidebarChannel[] = [
|
|
305
|
+
{ id: 'ch-1', name: 'general', unreadCount: 0 },
|
|
306
|
+
];
|
|
307
|
+
|
|
308
|
+
render(<Sidebar {...defaultProps} channels={channels} />);
|
|
309
|
+
|
|
310
|
+
// Should be expanded based on localStorage
|
|
311
|
+
expect(screen.getByText('general')).toBeInTheDocument();
|
|
312
|
+
});
|
|
313
|
+
});
|
|
314
|
+
|
|
315
|
+
describe('Channel Actions Menu', () => {
|
|
316
|
+
it('should show actions button on hover', () => {
|
|
317
|
+
const channels: SidebarChannel[] = [
|
|
318
|
+
{ id: 'ch-1', name: 'general', unreadCount: 0 },
|
|
319
|
+
];
|
|
320
|
+
const onInviteToChannel = vi.fn();
|
|
321
|
+
|
|
322
|
+
render(
|
|
323
|
+
<Sidebar
|
|
324
|
+
{...defaultProps}
|
|
325
|
+
channels={channels}
|
|
326
|
+
onInviteToChannel={onInviteToChannel}
|
|
327
|
+
/>
|
|
328
|
+
);
|
|
329
|
+
fireEvent.click(screen.getByText('Channels'));
|
|
330
|
+
|
|
331
|
+
// The more button should exist (visible on hover via CSS)
|
|
332
|
+
const moreButton = screen.getByTitle('Channel actions');
|
|
333
|
+
expect(moreButton).toBeInTheDocument();
|
|
334
|
+
});
|
|
335
|
+
|
|
336
|
+
it('should open menu when actions button clicked', () => {
|
|
337
|
+
const channels: SidebarChannel[] = [
|
|
338
|
+
{ id: 'ch-1', name: 'general', unreadCount: 0 },
|
|
339
|
+
];
|
|
340
|
+
const onInviteToChannel = vi.fn();
|
|
341
|
+
|
|
342
|
+
render(
|
|
343
|
+
<Sidebar
|
|
344
|
+
{...defaultProps}
|
|
345
|
+
channels={channels}
|
|
346
|
+
onInviteToChannel={onInviteToChannel}
|
|
347
|
+
/>
|
|
348
|
+
);
|
|
349
|
+
fireEvent.click(screen.getByText('Channels'));
|
|
350
|
+
fireEvent.click(screen.getByTitle('Channel actions'));
|
|
351
|
+
|
|
352
|
+
expect(screen.getByText('Invite members')).toBeInTheDocument();
|
|
353
|
+
});
|
|
354
|
+
|
|
355
|
+
it('should call onInviteToChannel when invite clicked', () => {
|
|
356
|
+
const channels: SidebarChannel[] = [
|
|
357
|
+
{ id: 'ch-1', name: 'general', unreadCount: 0 },
|
|
358
|
+
];
|
|
359
|
+
const onInviteToChannel = vi.fn();
|
|
360
|
+
|
|
361
|
+
render(
|
|
362
|
+
<Sidebar
|
|
363
|
+
{...defaultProps}
|
|
364
|
+
channels={channels}
|
|
365
|
+
onInviteToChannel={onInviteToChannel}
|
|
366
|
+
/>
|
|
367
|
+
);
|
|
368
|
+
fireEvent.click(screen.getByText('Channels'));
|
|
369
|
+
fireEvent.click(screen.getByTitle('Channel actions'));
|
|
370
|
+
fireEvent.click(screen.getByText('Invite members'));
|
|
371
|
+
|
|
372
|
+
expect(onInviteToChannel).toHaveBeenCalledWith(channels[0]);
|
|
373
|
+
});
|
|
374
|
+
|
|
375
|
+
it('should show archive option in menu', () => {
|
|
376
|
+
const channels: SidebarChannel[] = [
|
|
377
|
+
{ id: 'ch-1', name: 'general', unreadCount: 0 },
|
|
378
|
+
];
|
|
379
|
+
const onArchiveChannel = vi.fn();
|
|
380
|
+
|
|
381
|
+
render(
|
|
382
|
+
<Sidebar
|
|
383
|
+
{...defaultProps}
|
|
384
|
+
channels={channels}
|
|
385
|
+
onArchiveChannel={onArchiveChannel}
|
|
386
|
+
/>
|
|
387
|
+
);
|
|
388
|
+
fireEvent.click(screen.getByText('Channels'));
|
|
389
|
+
fireEvent.click(screen.getByTitle('Channel actions'));
|
|
390
|
+
|
|
391
|
+
expect(screen.getByText('Archive')).toBeInTheDocument();
|
|
392
|
+
});
|
|
393
|
+
|
|
394
|
+
it('should call onArchiveChannel when archive clicked', () => {
|
|
395
|
+
const channels: SidebarChannel[] = [
|
|
396
|
+
{ id: 'ch-1', name: 'general', unreadCount: 0 },
|
|
397
|
+
];
|
|
398
|
+
const onArchiveChannel = vi.fn();
|
|
399
|
+
|
|
400
|
+
render(
|
|
401
|
+
<Sidebar
|
|
402
|
+
{...defaultProps}
|
|
403
|
+
channels={channels}
|
|
404
|
+
onArchiveChannel={onArchiveChannel}
|
|
405
|
+
/>
|
|
406
|
+
);
|
|
407
|
+
fireEvent.click(screen.getByText('Channels'));
|
|
408
|
+
fireEvent.click(screen.getByTitle('Channel actions'));
|
|
409
|
+
fireEvent.click(screen.getByText('Archive'));
|
|
410
|
+
|
|
411
|
+
expect(onArchiveChannel).toHaveBeenCalledWith(channels[0]);
|
|
412
|
+
});
|
|
413
|
+
|
|
414
|
+
it('should close menu after action selected', () => {
|
|
415
|
+
const channels: SidebarChannel[] = [
|
|
416
|
+
{ id: 'ch-1', name: 'general', unreadCount: 0 },
|
|
417
|
+
];
|
|
418
|
+
const onInviteToChannel = vi.fn();
|
|
419
|
+
|
|
420
|
+
render(
|
|
421
|
+
<Sidebar
|
|
422
|
+
{...defaultProps}
|
|
423
|
+
channels={channels}
|
|
424
|
+
onInviteToChannel={onInviteToChannel}
|
|
425
|
+
/>
|
|
426
|
+
);
|
|
427
|
+
fireEvent.click(screen.getByText('Channels'));
|
|
428
|
+
fireEvent.click(screen.getByTitle('Channel actions'));
|
|
429
|
+
fireEvent.click(screen.getByText('Invite members'));
|
|
430
|
+
|
|
431
|
+
expect(screen.queryByText('Invite members')).not.toBeInTheDocument();
|
|
432
|
+
});
|
|
433
|
+
|
|
434
|
+
it('should close menu when channel selection changes', () => {
|
|
435
|
+
const channels: SidebarChannel[] = [
|
|
436
|
+
{ id: 'ch-1', name: 'general', unreadCount: 0 },
|
|
437
|
+
{ id: 'ch-2', name: 'random', unreadCount: 0 },
|
|
438
|
+
];
|
|
439
|
+
const onInviteToChannel = vi.fn();
|
|
440
|
+
const onChannelSelect = vi.fn();
|
|
441
|
+
|
|
442
|
+
const { rerender } = render(
|
|
443
|
+
<Sidebar
|
|
444
|
+
{...defaultProps}
|
|
445
|
+
channels={channels}
|
|
446
|
+
onInviteToChannel={onInviteToChannel}
|
|
447
|
+
onChannelSelect={onChannelSelect}
|
|
448
|
+
selectedChannelId="ch-1"
|
|
449
|
+
/>
|
|
450
|
+
);
|
|
451
|
+
fireEvent.click(screen.getByText('Channels'));
|
|
452
|
+
// Click the first Channel actions button (for 'general')
|
|
453
|
+
const actionButtons = screen.getAllByTitle('Channel actions');
|
|
454
|
+
fireEvent.click(actionButtons[0]);
|
|
455
|
+
|
|
456
|
+
// Menu should be open
|
|
457
|
+
expect(screen.getByText('Invite members')).toBeInTheDocument();
|
|
458
|
+
|
|
459
|
+
// Change selection
|
|
460
|
+
rerender(
|
|
461
|
+
<Sidebar
|
|
462
|
+
{...defaultProps}
|
|
463
|
+
channels={channels}
|
|
464
|
+
onInviteToChannel={onInviteToChannel}
|
|
465
|
+
onChannelSelect={onChannelSelect}
|
|
466
|
+
selectedChannelId="ch-2"
|
|
467
|
+
/>
|
|
468
|
+
);
|
|
469
|
+
|
|
470
|
+
// Menu should be closed
|
|
471
|
+
expect(screen.queryByText('Invite members')).not.toBeInTheDocument();
|
|
472
|
+
});
|
|
473
|
+
});
|
|
474
|
+
|
|
475
|
+
describe('Archived Channels', () => {
|
|
476
|
+
it('should render archived section when archived channels exist', () => {
|
|
477
|
+
const archivedChannels: SidebarChannel[] = [
|
|
478
|
+
{ id: 'ch-archived', name: 'old-project', unreadCount: 0 },
|
|
479
|
+
];
|
|
480
|
+
|
|
481
|
+
render(<Sidebar {...defaultProps} archivedChannels={archivedChannels} />);
|
|
482
|
+
|
|
483
|
+
expect(screen.getByText('Archived')).toBeInTheDocument();
|
|
484
|
+
});
|
|
485
|
+
|
|
486
|
+
it('should not render archived section when no archived channels', () => {
|
|
487
|
+
render(<Sidebar {...defaultProps} archivedChannels={[]} />);
|
|
488
|
+
|
|
489
|
+
expect(screen.queryByText('Archived')).not.toBeInTheDocument();
|
|
490
|
+
});
|
|
491
|
+
|
|
492
|
+
it('should show archived count in section header', () => {
|
|
493
|
+
const archivedChannels: SidebarChannel[] = [
|
|
494
|
+
{ id: 'ch-1', name: 'old-project', unreadCount: 0 },
|
|
495
|
+
{ id: 'ch-2', name: 'deprecated', unreadCount: 0 },
|
|
496
|
+
];
|
|
497
|
+
|
|
498
|
+
render(<Sidebar {...defaultProps} archivedChannels={archivedChannels} />);
|
|
499
|
+
|
|
500
|
+
expect(screen.getByText('(2)')).toBeInTheDocument();
|
|
501
|
+
});
|
|
502
|
+
|
|
503
|
+
it('should be collapsed by default', () => {
|
|
504
|
+
const archivedChannels: SidebarChannel[] = [
|
|
505
|
+
{ id: 'ch-archived', name: 'old-project', unreadCount: 0 },
|
|
506
|
+
];
|
|
507
|
+
|
|
508
|
+
render(<Sidebar {...defaultProps} archivedChannels={archivedChannels} />);
|
|
509
|
+
|
|
510
|
+
expect(screen.queryByText('old-project')).not.toBeInTheDocument();
|
|
511
|
+
});
|
|
512
|
+
|
|
513
|
+
it('should expand when clicked', () => {
|
|
514
|
+
const archivedChannels: SidebarChannel[] = [
|
|
515
|
+
{ id: 'ch-archived', name: 'old-project', unreadCount: 0 },
|
|
516
|
+
];
|
|
517
|
+
|
|
518
|
+
render(<Sidebar {...defaultProps} archivedChannels={archivedChannels} />);
|
|
519
|
+
fireEvent.click(screen.getByText('Archived'));
|
|
520
|
+
|
|
521
|
+
expect(screen.getByText('old-project')).toBeInTheDocument();
|
|
522
|
+
});
|
|
523
|
+
|
|
524
|
+
it('should show "Archived" badge on archived channels', () => {
|
|
525
|
+
const archivedChannels: SidebarChannel[] = [
|
|
526
|
+
{ id: 'ch-archived', name: 'old-project', unreadCount: 0 },
|
|
527
|
+
];
|
|
528
|
+
|
|
529
|
+
render(<Sidebar {...defaultProps} archivedChannels={archivedChannels} />);
|
|
530
|
+
fireEvent.click(screen.getByText('Archived'));
|
|
531
|
+
|
|
532
|
+
// Find the "Archived" badge within the channel row
|
|
533
|
+
const archiveBadges = screen.getAllByText('Archived');
|
|
534
|
+
expect(archiveBadges.length).toBeGreaterThanOrEqual(1);
|
|
535
|
+
});
|
|
536
|
+
|
|
537
|
+
it('should call onUnarchiveChannel when unarchive clicked', () => {
|
|
538
|
+
const archivedChannels: SidebarChannel[] = [
|
|
539
|
+
{ id: 'ch-archived', name: 'old-project', unreadCount: 0 },
|
|
540
|
+
];
|
|
541
|
+
const onUnarchiveChannel = vi.fn();
|
|
542
|
+
|
|
543
|
+
render(
|
|
544
|
+
<Sidebar
|
|
545
|
+
{...defaultProps}
|
|
546
|
+
archivedChannels={archivedChannels}
|
|
547
|
+
onUnarchiveChannel={onUnarchiveChannel}
|
|
548
|
+
/>
|
|
549
|
+
);
|
|
550
|
+
fireEvent.click(screen.getByText('Archived'));
|
|
551
|
+
fireEvent.click(screen.getByTitle('Unarchive channel'));
|
|
552
|
+
|
|
553
|
+
expect(onUnarchiveChannel).toHaveBeenCalledWith(archivedChannels[0]);
|
|
554
|
+
});
|
|
555
|
+
|
|
556
|
+
it('should allow selecting archived channels', () => {
|
|
557
|
+
const archivedChannels: SidebarChannel[] = [
|
|
558
|
+
{ id: 'ch-archived', name: 'old-project', unreadCount: 0 },
|
|
559
|
+
];
|
|
560
|
+
const onChannelSelect = vi.fn();
|
|
561
|
+
|
|
562
|
+
render(
|
|
563
|
+
<Sidebar
|
|
564
|
+
{...defaultProps}
|
|
565
|
+
archivedChannels={archivedChannels}
|
|
566
|
+
onChannelSelect={onChannelSelect}
|
|
567
|
+
/>
|
|
568
|
+
);
|
|
569
|
+
fireEvent.click(screen.getByText('Archived'));
|
|
570
|
+
fireEvent.click(screen.getByText('old-project'));
|
|
571
|
+
|
|
572
|
+
expect(onChannelSelect).toHaveBeenCalledWith(archivedChannels[0]);
|
|
573
|
+
});
|
|
574
|
+
});
|
|
575
|
+
|
|
576
|
+
describe('Create Channel', () => {
|
|
577
|
+
it('should call onCreateChannel when create button clicked', () => {
|
|
578
|
+
const onCreateChannel = vi.fn();
|
|
579
|
+
|
|
580
|
+
render(
|
|
581
|
+
<Sidebar
|
|
582
|
+
{...defaultProps}
|
|
583
|
+
channels={[]}
|
|
584
|
+
onCreateChannel={onCreateChannel}
|
|
585
|
+
/>
|
|
586
|
+
);
|
|
587
|
+
fireEvent.click(screen.getByText('Create your first channel'));
|
|
588
|
+
|
|
589
|
+
expect(onCreateChannel).toHaveBeenCalled();
|
|
590
|
+
});
|
|
591
|
+
|
|
592
|
+
it('should call onCreateChannel when add button clicked with existing channels', () => {
|
|
593
|
+
const channels: SidebarChannel[] = [
|
|
594
|
+
{ id: 'ch-1', name: 'general', unreadCount: 0 },
|
|
595
|
+
];
|
|
596
|
+
const onCreateChannel = vi.fn();
|
|
597
|
+
|
|
598
|
+
render(
|
|
599
|
+
<Sidebar
|
|
600
|
+
{...defaultProps}
|
|
601
|
+
channels={channels}
|
|
602
|
+
onCreateChannel={onCreateChannel}
|
|
603
|
+
/>
|
|
604
|
+
);
|
|
605
|
+
fireEvent.click(screen.getByText('Channels'));
|
|
606
|
+
fireEvent.click(screen.getByText('Add channel'));
|
|
607
|
+
|
|
608
|
+
expect(onCreateChannel).toHaveBeenCalled();
|
|
609
|
+
});
|
|
610
|
+
});
|
|
611
|
+
|
|
612
|
+
describe('Connection Status', () => {
|
|
613
|
+
it('should show connected indicator when connected', () => {
|
|
614
|
+
render(<Sidebar {...defaultProps} isConnected={true} />);
|
|
615
|
+
|
|
616
|
+
expect(screen.getByText('Live')).toBeInTheDocument();
|
|
617
|
+
});
|
|
618
|
+
|
|
619
|
+
it('should show offline indicator when disconnected', () => {
|
|
620
|
+
render(<Sidebar {...defaultProps} isConnected={false} />);
|
|
621
|
+
|
|
622
|
+
expect(screen.getByText('Offline')).toBeInTheDocument();
|
|
623
|
+
});
|
|
624
|
+
});
|
|
625
|
+
|
|
626
|
+
describe('Multiple Channels', () => {
|
|
627
|
+
it('should render all channels in correct order', () => {
|
|
628
|
+
const channels: SidebarChannel[] = [
|
|
629
|
+
{ id: 'ch-1', name: 'alpha', unreadCount: 0 },
|
|
630
|
+
{ id: 'ch-2', name: 'beta', unreadCount: 0 },
|
|
631
|
+
{ id: 'ch-3', name: 'gamma', unreadCount: 0 },
|
|
632
|
+
];
|
|
633
|
+
|
|
634
|
+
render(<Sidebar {...defaultProps} channels={channels} />);
|
|
635
|
+
fireEvent.click(screen.getByText('Channels'));
|
|
636
|
+
|
|
637
|
+
const channelButtons = screen.getAllByRole('button').filter(btn =>
|
|
638
|
+
['alpha', 'beta', 'gamma'].some(name => btn.textContent?.includes(name))
|
|
639
|
+
);
|
|
640
|
+
|
|
641
|
+
expect(channelButtons[0]).toHaveTextContent('alpha');
|
|
642
|
+
expect(channelButtons[1]).toHaveTextContent('beta');
|
|
643
|
+
expect(channelButtons[2]).toHaveTextContent('gamma');
|
|
644
|
+
});
|
|
645
|
+
|
|
646
|
+
it('should allow selecting different channels', () => {
|
|
647
|
+
const channels: SidebarChannel[] = [
|
|
648
|
+
{ id: 'ch-1', name: 'alpha', unreadCount: 0 },
|
|
649
|
+
{ id: 'ch-2', name: 'beta', unreadCount: 0 },
|
|
650
|
+
];
|
|
651
|
+
const onChannelSelect = vi.fn();
|
|
652
|
+
|
|
653
|
+
render(
|
|
654
|
+
<Sidebar
|
|
655
|
+
{...defaultProps}
|
|
656
|
+
channels={channels}
|
|
657
|
+
onChannelSelect={onChannelSelect}
|
|
658
|
+
/>
|
|
659
|
+
);
|
|
660
|
+
fireEvent.click(screen.getByText('Channels'));
|
|
661
|
+
|
|
662
|
+
fireEvent.click(screen.getByText('alpha'));
|
|
663
|
+
expect(onChannelSelect).toHaveBeenCalledWith(channels[0]);
|
|
664
|
+
|
|
665
|
+
fireEvent.click(screen.getByText('beta'));
|
|
666
|
+
expect(onChannelSelect).toHaveBeenCalledWith(channels[1]);
|
|
667
|
+
});
|
|
668
|
+
});
|
|
669
|
+
|
|
670
|
+
describe('Accessibility', () => {
|
|
671
|
+
it('should have accessible channel buttons', () => {
|
|
672
|
+
const channels: SidebarChannel[] = [
|
|
673
|
+
{ id: 'ch-1', name: 'general', unreadCount: 0 },
|
|
674
|
+
];
|
|
675
|
+
|
|
676
|
+
render(<Sidebar {...defaultProps} channels={channels} />);
|
|
677
|
+
fireEvent.click(screen.getByText('Channels'));
|
|
678
|
+
|
|
679
|
+
const channelButton = screen.getByText('general').closest('button');
|
|
680
|
+
expect(channelButton).toBeInTheDocument();
|
|
681
|
+
expect(channelButton?.tagName).toBe('BUTTON');
|
|
682
|
+
});
|
|
683
|
+
|
|
684
|
+
it('should have accessible section toggle buttons', () => {
|
|
685
|
+
render(<Sidebar {...defaultProps} />);
|
|
686
|
+
|
|
687
|
+
const channelsHeader = screen.getByText('Channels').closest('button');
|
|
688
|
+
expect(channelsHeader?.tagName).toBe('BUTTON');
|
|
689
|
+
});
|
|
690
|
+
});
|
|
691
|
+
});
|