test: update AgentFooter tests to use document.querySelector for spinner checks

test: mock window.matchMedia in setupTests.js for consistent test environment
This commit is contained in:
Danny Avila 2025-07-16 00:38:42 -04:00 committed by Marco Beretta
parent bac6e499b7
commit 63d0c301a0
No known key found for this signature in database
GPG key ID: D918033D8E74CC11
2 changed files with 18 additions and 3 deletions

View file

@ -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(
<AgentFooter {...defaultProps} createMutation={createBaseMutation(true)} />,
);
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(<AgentFooter {...defaultProps} updateMutation={createBaseMutation(true)} />);
expect(screen.getByTestId('spinner')).toBeInTheDocument();
expect(document.querySelector('.spinner')).toBeInTheDocument();
expect(screen.queryByText('Save')).not.toBeInTheDocument();
});
});