fix: apply editor fix also to script editor

This commit is contained in:
2026-02-27 17:45:43 +01:00
parent 84376cda01
commit e25a0d85a5
2 changed files with 13 additions and 3 deletions

View File

@@ -13,6 +13,7 @@ const setModelMarkersMock = vi.fn();
vi.mock('@monaco-editor/react', () => ({
default: (props: {
value?: string;
defaultValue?: string;
onChange?: (value?: string) => void;
language?: string;
onMount?: (editor: unknown, monaco: unknown) => void;
@@ -34,7 +35,7 @@ vi.mock('@monaco-editor/react', () => ({
return (
<textarea
aria-label="Script Content"
value={props.value || ''}
defaultValue={props.defaultValue ?? props.value ?? ''}
onChange={(event) => props.onChange?.(event.target.value)}
/>
);
@@ -91,11 +92,13 @@ describe('ScriptsView', () => {
it('loads scripts and allows editing content', async () => {
render(<ScriptsView scriptId="script-1" />);
const textarea = screen.getByLabelText('Script Content') as HTMLTextAreaElement;
// After script loads, Monaco remounts with new key — re-query the textarea
await vi.waitFor(() => {
const textarea = screen.getByLabelText('Script Content') as HTMLTextAreaElement;
expect(textarea.value).toContain('print("hello")');
});
const textarea = screen.getByLabelText('Script Content') as HTMLTextAreaElement;
fireEvent.change(textarea, { target: { value: 'print("updated")' } });
expect(textarea.value).toContain('updated');