diff --git a/src/main/component/Utils.ts b/src/main/component/Utils.ts index 4f99066..7160a0e 100644 --- a/src/main/component/Utils.ts +++ b/src/main/component/Utils.ts @@ -81,15 +81,4 @@ export const bindHandlers = (editor: Editor, eventHandlers: Partial { - const script = doc.createElement('script'); - script.referrerPolicy = 'origin'; - script.type = 'application/javascript'; - script.src = url; - script.onload = cb; - if (doc.head) { - doc.head.appendChild(script); - } }; \ No newline at end of file diff --git a/src/test/ts/alien/Loader.ts b/src/test/ts/alien/Loader.ts index ccc093d..0773b19 100644 --- a/src/test/ts/alien/Loader.ts +++ b/src/test/ts/alien/Loader.ts @@ -38,6 +38,7 @@ export interface SvelteEditorContext extends Disposable { componentInstance: Record; /** Update any props on the live component instance and flush Svelte reactivity synchronously. */ setProps(patch: Partial): void; + getProps(name: keyof EditorProps): unknown; remove(): void; } @@ -86,6 +87,8 @@ export const render = async (props: EditorProps = {}): Promise reactiveProps[name]; + const remove = () => { unmount(componentInstance).catch((reason) => { // eslint-disable-next-line no-console @@ -99,6 +102,7 @@ export const render = async (props: EditorProps = {}): Promise { + VERSIONS.forEach((version) => + Loader.withVersion(version, (render) => { + const defaultProps: Loader.EditorProps = { apiKey: VALID_API_KEY }; + + it('TINYINT-3435: value prop is bound to the editor\'s content', async () => { + const initialValue = '

Hello, World!

'; + const newValue = '

New Content

'; + using ctx = await render({ ...defaultProps, value: initialValue }); + TinyAssertions.assertContent(ctx.editor, initialValue); + ctx.editor.execCommand('mceSetContent', false, newValue); + Assertions.assertEq('value prop should be updated', newValue, ctx.getProps('value')); + }); + }) + ); +}); diff --git a/src/test/ts/browser/EditorInitTest.ts b/src/test/ts/browser/EditorInitTest.ts index 03cb188..472bf6c 100644 --- a/src/test/ts/browser/EditorInitTest.ts +++ b/src/test/ts/browser/EditorInitTest.ts @@ -51,6 +51,16 @@ describe('EditorInitTest', () => { using ctx = await render({ ...defaultProps, value: '' }); TinyAssertions.assertContent(ctx.editor, ''); }); + + it('TINYINT-3435: cssClass is set to the container if provided', async () => { + using ctx = await render({ ...defaultProps, cssClass: 'test-class' }); + Assertions.assertEq('className of containershould contain test-class', true, ctx.DOMNode.parentElement?.className === 'test-class'); + }); + + it('TINYINT-3435: conf is passed as options to the editor', async () => { + using ctx = await render({ ...defaultProps, conf: { branding: false }}); + Assertions.assertEq('branding option should be false', false, ctx.editor.options.get('branding')); + }); }) ); }); diff --git a/src/test/ts/browser/EventsTest.ts b/src/test/ts/browser/EventsTest.ts new file mode 100644 index 0000000..852d10b --- /dev/null +++ b/src/test/ts/browser/EventsTest.ts @@ -0,0 +1,31 @@ +import { TestStore } from '@ephox/agar'; +import { describe, it } from '@ephox/bedrock-client'; + +import * as Loader from '../alien/Loader'; +import { VALID_API_KEY, VERSIONS } from '../alien/TestHelpers'; + +describe('EventTest', () => { + VERSIONS.forEach((version) => + Loader.withVersion(version, (render) => { + const store = TestStore(); + const eventHandlers = { + init: () => { + store.add('init'); + }, + loadcontent: () => { + store.add('loadcontent'); + } + }; + const defaultProps: Loader.EditorProps = { apiKey: VALID_API_KEY, ...eventHandlers }; + + it('TINYINT-3435: event handlers are handled correctly', async () => { + // eslint-disable-next-line @typescript-eslint/no-unused-vars + using ctx = await render({ ...defaultProps }); + store.assertEq('Events should be fired', [ + 'loadcontent', + 'init', + ]); + }); + }) + ); +});