Add regional channel routing (closes #42)

This commit is contained in:
Jack Kingsman
2026-03-09 11:09:31 -07:00
parent 0c5b37c07c
commit 811c7e7349
18 changed files with 604 additions and 61 deletions
@@ -16,6 +16,7 @@ const baseProps = {
favorites: [] as Favorite[],
onTrace: noop,
onToggleFavorite: noop,
onSetChannelFloodScopeOverride: noop,
onDeleteChannel: noop,
onDeleteContact: noop,
};
@@ -105,4 +106,40 @@ describe('ChatHeader key visibility', () => {
expect(writeText).toHaveBeenCalledWith(key);
});
it('shows active regional override banner for channels', () => {
const key = 'AB'.repeat(16);
const channel = {
...makeChannel(key, '#flightless', true),
flood_scope_override: '#Esperance',
};
const conversation: Conversation = { type: 'channel', id: key, name: '#flightless' };
render(<ChatHeader {...baseProps} conversation={conversation} channels={[channel]} />);
expect(screen.getByText('Regional override active: #Esperance')).toBeInTheDocument();
});
it('prompts for regional override when globe button is clicked', () => {
const key = 'CD'.repeat(16);
const channel = makeChannel(key, '#flightless', true);
const conversation: Conversation = { type: 'channel', id: key, name: '#flightless' };
const onSetChannelFloodScopeOverride = vi.fn();
const promptSpy = vi.spyOn(window, 'prompt').mockReturnValue('#Esperance');
render(
<ChatHeader
{...baseProps}
conversation={conversation}
channels={[channel]}
onSetChannelFloodScopeOverride={onSetChannelFloodScopeOverride}
/>
);
fireEvent.click(screen.getByTitle('Set regional override'));
expect(promptSpy).toHaveBeenCalled();
expect(onSetChannelFloodScopeOverride).toHaveBeenCalledWith(key, '#Esperance');
promptSpy.mockRestore();
});
});