Files
cameleer-server/ui/src/components/MustacheEditor/MustacheEditor.test.tsx
hsiegeln 019e79a362 feat(ui/alerts): MustacheEditor component (CM6 shell with completion + linter)
Wires the mustache-completion source and mustache-linter into a CodeMirror 6
EditorView. Accepts kind (filters variables) and reducedContext (env-only for
connection URLs). singleLine prevents newlines for URL/header fields. Host
ref syncs when the parent replaces value (promotion prefill).
2026-04-20 13:41:46 +02:00

35 lines
1.0 KiB
TypeScript

import { describe, it, expect, vi } from 'vitest';
import { render, screen } from '@testing-library/react';
import { MustacheEditor } from './MustacheEditor';
describe('MustacheEditor', () => {
it('renders the initial value', () => {
render(
<MustacheEditor
value="Hello {{rule.name}}"
onChange={() => {}}
kind="ROUTE_METRIC"
label="Title template"
/>,
);
expect(screen.getByText(/Hello/)).toBeInTheDocument();
});
it('renders a textbox and does not call onChange before user interaction', () => {
const onChange = vi.fn();
render(
<MustacheEditor
value=""
onChange={onChange}
kind="ROUTE_METRIC"
label="Title template"
/>,
);
const editor = screen.getByRole('textbox', { name: 'Title template' });
expect(editor).toBeInTheDocument();
// CM6 fires onChange via transactions, not DOM input events; without a real
// user interaction the callback must remain untouched.
expect(onChange).not.toHaveBeenCalled();
});
});