fix: keep conversation history visible
This commit is contained in:
1 parent
712226cd43
commit
b7fcc7db05
4 files changed
+19
-6
No files matched your search
@@ -7,7 +7,7 @@ import userEvent from '@testing-library/user-event';
|
||||
import { HttpResponse, http } from 'msw';
|
||||
import { setupServer } from 'msw/node';
|
||||
import { MemoryRouter } from 'react-router-dom';
|
||||
import { afterAll, afterEach, beforeAll, describe, expect, it } from 'vitest';
|
||||
import { afterAll, afterEach, beforeAll, describe, expect, it, vi } from 'vitest';
|
||||
import { ConversationsPage } from '../../apps/dashboard/src/features/conversations/conversations-page.js';
|
||||
import { resetComposerDrafts } from '../../apps/dashboard/src/features/conversations/composer-drafts.js';
|
||||
|
||||
@@ -83,6 +83,7 @@ const server = setupServer(
|
||||
http.post('/api/conversations/bulk-read', () =>
|
||||
HttpResponse.json({ success: true, updated: 1, failed: [] })),
|
||||
);
|
||||
const originalScrollIntoView = Object.getOwnPropertyDescriptor(HTMLElement.prototype, 'scrollIntoView');
|
||||
|
||||
function installConversationList() {
|
||||
server.use(
|
||||
@@ -110,6 +111,8 @@ afterEach(() => {
|
||||
cleanup();
|
||||
server.resetHandlers();
|
||||
resetComposerDrafts();
|
||||
if (originalScrollIntoView) Object.defineProperty(HTMLElement.prototype, 'scrollIntoView', originalScrollIntoView);
|
||||
else delete HTMLElement.prototype.scrollIntoView;
|
||||
});
|
||||
afterAll(() => server.close());
|
||||
|
||||
@@ -495,6 +498,11 @@ describe('ConversationsPage', () => {
|
||||
}),
|
||||
);
|
||||
const user = userEvent.setup();
|
||||
const scrollIntoView = vi.fn();
|
||||
Object.defineProperty(HTMLElement.prototype, 'scrollIntoView', {
|
||||
configurable: true,
|
||||
value: scrollIntoView,
|
||||
});
|
||||
renderConversations();
|
||||
|
||||
await user.click(await screen.findByRole('button', { name: /u\/alice/ }));
|
||||
@@ -502,6 +510,7 @@ describe('ConversationsPage', () => {
|
||||
expect(await screen.findByRole('img', { name: 'Green-screen source green-phone.jpg' })).toHaveClass('is-blurred');
|
||||
await user.click(screen.getByRole('button', { name: 'Reveal source images' }));
|
||||
await user.click(screen.getByRole('radio', { name: /green-phone\.jpg/ }));
|
||||
await waitFor(() => expect(scrollIntoView).toHaveBeenCalledWith({ behavior: 'smooth', block: 'nearest' }));
|
||||
await user.click(screen.getByRole('button', { name: 'Reveal conversation choices' }));
|
||||
await user.click(screen.getByRole('radio', { name: 'Original post image' }));
|
||||
await user.click(screen.getByRole('button', { name: 'Create image' }));
|
||||
|
||||
Reference in new issue
Block a user