diff --git a/client/src/components/SidePanel/Agents/__tests__/AgentFooter.spec.tsx b/client/src/components/SidePanel/Agents/__tests__/AgentFooter.spec.tsx index 9a73f94a57..8cb8460eaf 100644 --- a/client/src/components/SidePanel/Agents/__tests__/AgentFooter.spec.tsx +++ b/client/src/components/SidePanel/Agents/__tests__/AgentFooter.spec.tsx @@ -198,14 +198,14 @@ describe('AgentFooter', () => { expect(screen.queryByTestId('admin-settings')).not.toBeInTheDocument(); expect(screen.queryByTestId('share-agent')).not.toBeInTheDocument(); expect(screen.queryByTestId('duplicate-agent')).not.toBeInTheDocument(); - expect(screen.queryByTestId('spinner')).not.toBeInTheDocument(); + expect(document.querySelector('.spinner')).not.toBeInTheDocument(); }); test('handles loading states for createMutation', () => { const { unmount } = render( , ); - expect(screen.getByTestId('spinner')).toBeInTheDocument(); + expect(document.querySelector('.spinner')).toBeInTheDocument(); expect(screen.queryByText('Save')).not.toBeInTheDocument(); expect(screen.getByRole('button')).toBeDisabled(); expect(screen.getByRole('button')).toHaveAttribute('aria-busy', 'true'); @@ -214,7 +214,7 @@ describe('AgentFooter', () => { test('handles loading states for updateMutation', () => { render(); - expect(screen.getByTestId('spinner')).toBeInTheDocument(); + expect(document.querySelector('.spinner')).toBeInTheDocument(); expect(screen.queryByText('Save')).not.toBeInTheDocument(); }); }); diff --git a/client/test/setupTests.js b/client/test/setupTests.js index 043c7cdf67..c489fc8b5b 100644 --- a/client/test/setupTests.js +++ b/client/test/setupTests.js @@ -20,6 +20,21 @@ import 'jest-canvas-mock'; // Mock ResizeObserver import './resizeObserver.mock'; +// Mock window.matchMedia +Object.defineProperty(window, 'matchMedia', { + writable: true, + value: jest.fn().mockImplementation((query) => ({ + matches: false, + media: query, + onchange: null, + addListener: jest.fn(), // deprecated + removeListener: jest.fn(), // deprecated + addEventListener: jest.fn(), + removeEventListener: jest.fn(), + dispatchEvent: jest.fn(), + })), +}); + beforeEach(() => { jest.clearAllMocks(); });