mirror of
https://github.com/Studio-Saelix/sencho.git
synced 2026-08-30 03:59:41 +00:00
fix(editor): dispose compose DiffEditor models after widget reset (#1828)
Closing the compose or git diff dialog threw a Monaco console error because the library disposed TextModels while DiffEditorWidget still held them.
This commit is contained in:
@@ -3,8 +3,8 @@ import { render, screen } from '@testing-library/react';
|
||||
import { ComposeDiffPreviewDialog } from '../ComposeDiffPreviewDialog';
|
||||
import { resolveComposeDiffActionLabel } from '../resolveComposeDiffActionLabel';
|
||||
|
||||
vi.mock('@/lib/monacoLoader', () => ({
|
||||
DiffEditor: () => <div data-testid="diff-editor" />,
|
||||
vi.mock('@/lib/SafeDiffEditor', () => ({
|
||||
SafeDiffEditor: () => <div data-testid="diff-editor" />,
|
||||
}));
|
||||
|
||||
describe('resolveComposeDiffActionLabel', () => {
|
||||
@@ -45,4 +45,24 @@ describe('ComposeDiffPreviewDialog', () => {
|
||||
);
|
||||
expect(screen.getByRole('button', { name: 'Save & reapply' })).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('unmounts the diff editor without throwing', () => {
|
||||
const { unmount } = render(
|
||||
<ComposeDiffPreviewDialog
|
||||
open
|
||||
onOpenChange={vi.fn()}
|
||||
stackName="sencho"
|
||||
fileName="docker-compose.yml"
|
||||
language="yaml"
|
||||
original="a"
|
||||
modified="b"
|
||||
actionLabel="Save"
|
||||
confirming={false}
|
||||
isDarkMode={false}
|
||||
onConfirm={vi.fn()}
|
||||
/>,
|
||||
);
|
||||
expect(screen.getByTestId('diff-editor')).toBeInTheDocument();
|
||||
expect(() => unmount()).not.toThrow();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user