Files
iios/packages/iios-messaging-ui/src/components/conversation-settings.test.tsx
T
maaz519 416cf59dc2 feat(messaging-ui): message timestamps + group/channel settings panel (0.1.5)
- Every message now shows a Slack-style time (clock today, then 'Yesterday',
  weekday, else a date; full timestamp on hover).
- New ConversationSettings panel for groups AND channels (public + private):
  rename, member list, add people (from the directory), remove, and leave.
  Opened from a new thread header gear; DMs show no gear. Adapter gains
  addMember/removeMember/renameConversation (optional, OPA still gates writes).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-23 13:03:06 +05:30

41 lines
1.6 KiB
TypeScript

import { describe, it, expect } from 'vitest';
import { render, screen, fireEvent, waitFor } from '@testing-library/react';
import { MessagingProvider } from '../provider';
import { MockAdapter } from '../adapters/mock';
import { ConversationSettings } from './conversation-settings';
function mount(adapter = new MockAdapter()) {
render(
<MessagingProvider adapter={adapter}>
<ConversationSettings threadId="th_mock_2" title="Storm crew" membership="group" onClose={() => {}} />
</MessagingProvider>,
);
return adapter;
}
describe('MockAdapter member management', () => {
it('adds and removes a member, and renames', async () => {
const a = new MockAdapter();
await a.addMember('th_mock_2', 'pp_sofia');
expect((await a.listMembers('th_mock_2')).some((m) => m.id === 'pp_sofia')).toBe(true);
await a.removeMember('th_mock_2', 'pp_sofia');
expect((await a.listMembers('th_mock_2')).some((m) => m.id === 'pp_sofia')).toBe(false);
await a.renameConversation('th_mock_2', 'Renamed');
expect((await a.listConversations()).find((c) => c.threadId === 'th_mock_2')?.title).toBe('Renamed');
});
});
describe('<ConversationSettings />', () => {
it('lists members and adds one from the directory', async () => {
const a = mount();
// A current member is shown.
await screen.findByText('Dan Whitaker');
// Add an addable person from the directory.
const sofia = await screen.findByText('Sofia Ramirez');
fireEvent.click(sofia);
await waitFor(async () => {
expect((await a.listMembers('th_mock_2')).some((m) => m.id === 'pp_sofia')).toBe(true);
});
});
});