# extendify/3.1.1/tests/unit/Agent/components/ChatInput.test.jsx

Extendify, version 3.1.1. 75 lines.

- Page: https://pluginprobe.com/plugins/extendify/3.1.1/code/tests/unit/Agent/components/ChatInput.test.jsx
- Raw: https://pluginprobe.com/plugins/extendify/3.1.1/raw/tests/unit/Agent/components/ChatInput.test.jsx
- Modified: 2026-06-11T18:37:12+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/extendify/3.1.1/code/tests/unit/Agent/components/ChatInput.test.jsx#L10-L20`.

```jsx
import { ChatInput } from '@agent/components/ChatInput';
import { render, screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event';

jest.mock('@agent/state/global', () => ({
	useGlobalStore: () => ({ isMobile: false }),
}));
jest.mock('@agent/state/workflows', () => ({
	useWorkflowStore: () => ({
		getWorkflowsByFeature: () => [],
	}),
}));
jest.mock('@quick-edit/state/store', () => ({
	useQuickEditStore: (selector) => selector({ agentBlock: null }),
}));
jest.mock('@agent/components/ChatTools', () => ({
	ChatTools: () => null,
	__esModule: true,
}));

beforeAll(() => {
	Object.defineProperty(HTMLElement.prototype, 'offsetHeight', {
		configurable: true,
		get() {
			if (this.id === 'extendify-agent-chat') return 600;
			return 100;
		},
	});
});

describe('ChatInput — input limit', () => {
	const setup = (props = {}) => {
		const handleSubmit = jest.fn();
		render(
			<div id="extendify-agent-chat">
				<ChatInput disabled={false} handleSubmit={handleSubmit} {...props} />
			</div>,
		);
		const textarea = screen.getByRole('textbox');
		const sendBtn = screen.getByRole('button', { name: /send message/i });
		const user = userEvent.setup();
		return { textarea, sendBtn, handleSubmit, user };
	};

	test('disables sending and shows a warning when exceeding 1500 chars', async () => {
		const { textarea, sendBtn, handleSubmit, user } = setup();

		const longText = 'x'.repeat(1501);
		await user.type(textarea, longText);

		expect(screen.getByText(/message too long/i)).toBeInTheDocument();
		expect(sendBtn).toBeDisabled();

		await user.type(textarea, '{enter}');
		expect(handleSubmit).not.toHaveBeenCalled();
	});

	test('sends normally when below the limit', async () => {
		const { textarea, sendBtn, handleSubmit, user } = setup();

		await user.type(textarea, 'hello world');
		expect(sendBtn).toBeEnabled();

		await user.click(sendBtn);
		expect(handleSubmit).toHaveBeenCalledWith('hello world');
	});

	test('pressing Enter sends when within the limit', async () => {
		const { textarea, handleSubmit, user } = setup();

		await user.type(textarea, 'short message{enter}');
		expect(handleSubmit).toHaveBeenCalledWith('short message');
	});
});

```
