diff --git a/e2e/protractor.conf.js b/e2e/protractor.conf.js index 86776a39..440ef8fa 100644 --- a/e2e/protractor.conf.js +++ b/e2e/protractor.conf.js @@ -25,4 +25,4 @@ exports.config = { }); jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } })); } -}; \ No newline at end of file +}; diff --git a/e2e/src/app.e2e-spec.ts b/e2e/src/app.e2e-spec.ts index 0538586b..7e14de06 100644 --- a/e2e/src/app.e2e-spec.ts +++ b/e2e/src/app.e2e-spec.ts @@ -27,7 +27,7 @@ describe( 'workspace-project App', () => { expect( page.getParagraphText() ).toEqual( 'CKEditor 4 integration with Angular' ); } ); - it( 'should display editor with initial content', async () => { + it( 'should display editor with initial content', () => { editables.forEach( editable => expect( page.getHtmlString( editable ) ) .toBe( '

Getting used to an entirely different culture can be challeng' + 'ing. While it’s also nice to learn about cultures online or from books, nothing comes close to experiencing cultural d' + @@ -37,8 +37,8 @@ describe( 'workspace-project App', () => { } ); describe( 'typing', () => { - it( `in editor1 should update editors content`, testTyping( editables, 0 ) ); - it( `in editor2 should update editors content`, testTyping( editables, 1 ) ); + it( `in editor1 should update editors content`, testTyping( 0 ) ); + it( `in editor2 should update editors content`, testTyping( 1 ) ); } ); } ); @@ -51,27 +51,23 @@ describe( 'workspace-project App', () => { editables = [ await page.getEditable() ]; } ); - it( 'should display editor with initial content', async () => { + it( 'should display editor with initial content', () => { expect( page.getHtmlString( editables[ 0 ] ) ) .toBe( '

A really nice fellow.

' ); } ); - it( `typing should update editor content`, testTyping( editables, 0 ) ); + it( `typing should update editor content`, testTyping( 0 ) ); } ); - function testTyping( elements, elementIndex: number ) { + function testTyping( elementIndex: number ) { return async function() { - const keys = [ - 'Foo! ', - protractor.Key.chord( protractor.Key.CONTROL, 'b' ), - 'Bar?' - ]; + const text = 'Foo! Bar?'; - await page.updateValue( editables[ elementIndex ], keys ); + await page.updateValue( editables[ elementIndex ], text ); editables.forEach( item => { expect( page.getHtmlString( item ) ) - .toBe( '

Foo! Bar?

' ); + .toBe( '

Foo! Bar?

' ); } ); }; } diff --git a/e2e/src/app.po.ts b/e2e/src/app.po.ts index e537d506..30a272c7 100644 --- a/e2e/src/app.po.ts +++ b/e2e/src/app.po.ts @@ -14,7 +14,7 @@ export class AppPage { return element( by.css( 'app-root h1' ) ).getText(); } - waitForElement( el: ElementFinder ) { + async waitForElement( el: ElementFinder ) { return browser.wait( protractor.ExpectedConditions.presenceOf( el ) ).then( () => el ); } @@ -22,7 +22,7 @@ export class AppPage { return this.getElementByCss( '.cke_editable:not(.cke_editable_inline)' ); } - getInlineEditable() { + async getInlineEditable() { return this.getElementByCss( '.cke_editable_inline' ); } @@ -32,24 +32,16 @@ export class AppPage { return el; } - getHtmlString( el: WebElement ) { - return el.getAttribute( 'innerHTML' ).then( str => str.replace( /\u200B/g, '' ) ); + async getHtmlString( el: WebElement ) { + return el.getAttribute( 'innerHTML' ); } - async updateValue( el: WebElement, keys: string[] ) { + async updateValue( el: WebElement, text: string ) { + await el.clear(); await el.click(); - await this.selectAll(); - // Since Chrome 77 with webdirver-manager@12.1.7 protractor.sendKeys() doesn't - // clear current selection, we have to clean it manually (#51). - await this.delete(); - await el.sendKeys( ...keys ); - } - - selectAll() { - return browser.executeScript( 'document.execCommand( "selectAll", false, null )' ); - } - delete() { - return browser.executeScript( 'document.execCommand( "delete", false, null )' ); + for ( let i = 0; i < text.length; i++ ) { + await el.sendKeys( text.charAt( i ) ); + } } } diff --git a/src/app/demo-form/demo-form.component.html b/src/app/demo-form/demo-form.component.html index 958f53be..b141d27b 100644 --- a/src/app/demo-form/demo-form.component.html +++ b/src/app/demo-form/demo-form.component.html @@ -17,7 +17,8 @@

User profile form

+ name="description" + type="divarea">

Description is "dirty".