@@ -2,9 +2,14 @@ import { Assertions } from '@ephox/agar';
22import '../alien/InitTestEnvironment' ;
33
44import { EditorComponent } from '../../../main/ts/public_api' ;
5- import { describe , it } from '@ephox/bedrock-client' ;
5+ import { after , before , context , describe , it } from '@ephox/bedrock-client' ;
66import { eachVersionContext , editorHook } from '../alien/TestHooks' ;
77import { Editor } from 'tinymce' ;
8+ import { ComponentFixture , TestBed } from '@angular/core/testing' ;
9+ import { Component , ViewChild } from '@angular/core' ;
10+ import { FormsModule } from '@angular/forms' ;
11+ import { VersionLoader } from '@tinymce/miniature' ;
12+ import { deleteTinymce } from '../alien/TestHelpers' ;
813
914describe ( 'DisabledPropertyTest' , ( ) => {
1015 const getMode = ( editor : Editor ) => {
@@ -104,4 +109,55 @@ describe('DisabledPropertyTest', () => {
104109 assertDesignMode ( editor ) ;
105110 } ) ;
106111 } ) ;
112+
113+ context ( 'With version 7' , ( ) => {
114+ @Component ( {
115+ imports : [ FormsModule , EditorComponent ] ,
116+ template : `<editor [(ngModel)]="text" [disabled]="true" />` ,
117+ standalone : true ,
118+ selector : 'test-host-component'
119+ } )
120+ class TestHostComponent {
121+ public text = '<h1>Hello World</h1>' ;
122+ @ViewChild ( EditorComponent ) public editorRef ! : EditorComponent ;
123+ }
124+
125+ const waitForEditorInitialized = ( editor : Editor ) => new Promise < void > ( ( resolve ) => {
126+ if ( editor . initialized ) {
127+ resolve ( ) ;
128+ }
129+ editor . once ( 'init' , ( ) => resolve ( ) ) ;
130+ } ) ;
131+
132+ let fixture : ComponentFixture < TestHostComponent > ;
133+ let testHost : TestHostComponent ;
134+ let tinyEditor : Editor ;
135+
136+ before ( async ( ) => {
137+ await VersionLoader . pLoadVersion ( '7' ) ;
138+
139+ await TestBed . configureTestingModule ( {
140+ imports : [ TestHostComponent ]
141+ } ) . compileComponents ( ) ;
142+
143+ fixture = TestBed . createComponent ( TestHostComponent ) ;
144+ testHost = fixture . componentInstance ;
145+ fixture . detectChanges ( ) ;
146+ tinyEditor = testHost . editorRef . editor ! ;
147+ } ) ;
148+
149+ after ( ( ) => {
150+ deleteTinymce ( ) ;
151+ } ) ;
152+
153+ it ( 'INT-3328: disabled property should work with [ngModel] when TinyMCE has been loaded before editor component has been created' , async ( ) => {
154+ assertDisabledOption ( tinyEditor ! , true ) ;
155+ /*
156+ I have to wait until the editor is fully initialized before using deleteTinymce() in after block.
157+ There's for example theme.js script that starts to load after editor instance has been created.
158+ If I remove tinymce from window too soon the theme.js will fail alongside with this test case.
159+ */
160+ await waitForEditorInitialized ( tinyEditor ! ) ;
161+ } ) ;
162+ } ) ;
107163} ) ;
0 commit comments