Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(UVE): Automatic page refresh after saving content changes #29439

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ const TINYMCE_EDITOR_MOCK: unknown = {
focus: jest.fn(),
getContent: (_data: unknown) => '',
isDirty: () => false,
hasFocus: () => false
hasFocus: () => false,
setContent: jest.fn()
};

const TINYMCE_EDITOR_PROPERTY_MOCK = {
Expand Down Expand Up @@ -134,6 +135,21 @@ describe('DotEditableTextComponent', () => {
jest.spyOn(mockedDotcmsClient, 'isInsideEditor').mockReturnValue(true);
});

it('should set content with the right format when the contentlet changes', () => {
spectator.detectChanges();
mockEditorFn(spectator);

const editorComponent = spectator.query(EditorComponent) as EditorComponent;
const spySetContent = jest.spyOn(editorComponent.editor, 'setContent');

spectator.setInput('contentlet', {
...dotcmsContentletMock,
title: 'New title'
});
spectator.detectChanges();
expect(spySetContent).toHaveBeenCalledWith('New title', { format: 'text' });
});

describe('Configuration', () => {
describe('Editor Configuration', () => {
it('should set a plain mode by default', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export class DotEditableTextComponent implements OnInit, OnChanges {
* @memberof DotEditableTextComponent
*/
get editor() {
return this.editorComponent.editor;
return this.editorComponent?.editor;
}

/**
Expand Down Expand Up @@ -170,6 +170,9 @@ export class DotEditableTextComponent implements OnInit, OnChanges {

ngOnChanges() {
this.content = this.contentlet[this.fieldName] || '';
if (this.editor) {
this.editor.setContent(this.content, { format: this.format });
}
}

/**
Expand Down