Make conversation queues mutually exclusive

This commit is contained in:
Jamie Brunton committed 2026-08-14 09:25:45 +01:00
1 parent 3bb1dda6bb
commit 2447563c60
20 files changed
+386 -220

No files matched your search

+13 -10
View File
@@ -148,10 +148,12 @@ describe('ConversationsPage', () => {
expect(await screen.findByRole('button', { name: /u\/alice/ })).toBeInTheDocument();
await user.type(screen.getByRole('searchbox', { name: 'Search conversations' }), 'bob');
expect(screen.queryByRole('button', { name: /u\/alice/ })).not.toBeInTheDocument();
await user.click(screen.getByRole('button', { name: /^Waiting/ }));
expect(screen.getByRole('button', { name: /u\/bob/ })).toBeInTheDocument();
await user.clear(screen.getByRole('searchbox', { name: 'Search conversations' }));
await user.click(screen.getByRole('button', { name: /^Unread/ }));
await user.click(screen.getByRole('button', { name: /^Needs attention/ }));
await user.click(screen.getByRole('checkbox', { name: 'Unread only' }));
expect(screen.getByRole('button', { name: /u\/alice/ })).toBeInTheDocument();
expect(screen.queryByRole('button', { name: /u\/bob/ })).not.toBeInTheDocument();
@@ -185,7 +187,7 @@ describe('ConversationsPage', () => {
expect(previewTrigger).toHaveFocus();
});
it('hides detected sellers by default and reveals marked conversations on request', async () => {
it('keeps detected sellers in their dedicated queue', async () => {
const seller = chatFixture({ username: 'seller', roomId: 'room-seller', sellerDetected: true });
server.use(http.get('/api/conversations', () => HttpResponse.json([alice, seller])));
const user = userEvent.setup();
@@ -194,7 +196,7 @@ describe('ConversationsPage', () => {
expect(await screen.findByRole('button', { name: /u\/alice/ })).toBeInTheDocument();
expect(screen.queryByRole('button', { name: /u\/seller/ })).not.toBeInTheDocument();
await user.click(screen.getByRole('checkbox', { name: 'Show sellers' }));
await user.click(screen.getByRole('button', { name: /^Sellers/ }));
expect(screen.getByRole('button', { name: /u\/seller.*Seller/ })).toBeInTheDocument();
expect(screen.getByText('Seller')).toBeInTheDocument();
});
@@ -261,7 +263,7 @@ describe('ConversationsPage', () => {
const aliceItem = await screen.findByRole('button', { name: /u\/alice/ });
expect(screen.getByText('Image received')).toBeInTheDocument();
await user.click(screen.getByRole('button', { name: /^Images/ }));
await user.click(screen.getByRole('checkbox', { name: 'Has images' }));
expect(screen.getByRole('button', { name: /u\/alice/ })).toBeInTheDocument();
expect(screen.queryByRole('button', { name: /u\/bob/ })).not.toBeInTheDocument();
@@ -288,13 +290,14 @@ describe('ConversationsPage', () => {
const user = userEvent.setup();
renderConversations();
await user.click(await screen.findByRole('button', { name: /^Waiting/ }));
await screen.findByRole('button', { name: /u\/alice/ });
expect(screen.getByText('Manual', { selector: '.conversation-chip' })).toHaveAttribute(
'title',
'Manual — you replied — A manual reply was sent in this conversation.',
);
await user.click(screen.getByRole('button', { name: 'Manual, 1' }));
await user.click(screen.getByRole('checkbox', { name: 'Manual only' }));
expect(screen.getByRole('button', { name: /u\/alice/ })).toBeInTheDocument();
expect(screen.queryByRole('button', { name: /u\/bob/ })).not.toBeInTheDocument();
});
@@ -501,12 +504,12 @@ describe('ConversationsPage', () => {
const aliceButton = await screen.findByRole('button', { name: /u\/alice/ });
// alice is inbound and unread; bob is a conversation we replied to last.
expect(screen.getByRole('button', { name: 'Unread, 1' })).toBeInTheDocument();
expect(screen.getByRole('button', { name: 'Needs reply, 1' })).toBeInTheDocument();
expect(screen.getByRole('button', { name: 'Waiting on them, 1' })).toBeInTheDocument();
expect(screen.getByRole('button', { name: 'All, 2' })).toHaveAttribute('aria-pressed', 'true');
expect(aliceButton.getAttribute('aria-label')).toMatch(/^u\/alice, Unread, Needs reply, .+ago/);
expect(screen.getByRole('button', { name: 'Needs attention, 1' })).toHaveAttribute('aria-pressed', 'true');
expect(screen.getByRole('button', { name: 'Waiting, 1' })).toBeInTheDocument();
expect(screen.getByRole('checkbox', { name: 'Unread only' })).not.toBeChecked();
expect(aliceButton.getAttribute('aria-label')).toMatch(/^u\/alice, Needs attention, Unread, .+ago/);
expect(aliceButton.closest('li')).toHaveClass('is-unread');
await userEvent.setup().click(screen.getByRole('button', { name: 'Waiting, 1' }));
expect(screen.getByRole('button', { name: /u\/bob/ }).closest('li')).not.toHaveClass('is-unread');
});