Loading e2e/app.e2e-spec.ts +15 −35 Original line number Diff line number Diff line import { browser, element, by, protractor } from 'protractor'; import { element, by, protractor } from 'protractor'; import { AngularMentionsPage } from './app.po'; describe('angular-mentions App', function() { var EC = protractor.ExpectedConditions; describe('angular-mentions app', function() { let page: AngularMentionsPage; beforeEach(() => { page = new AngularMentionsPage(); }) let elements = it('test mentions text field', () => { page.navigateTo(); expect(page.getHeadingText()).toEqual('Angular Mentions'); Loading Loading @@ -50,7 +47,7 @@ describe('angular-mentions App', function() { el.getTagName().then(function(tagName){ let menu = element(by.css('.dropdown-menu')); el.click(); expect(getValue(el, tagName)).toEqual(''); expect(page.getValue(el, tagName)).toEqual(''); // test for git issue #59 el.sendKeys('@'); Loading @@ -60,12 +57,12 @@ describe('angular-mentions App', function() { el.sendKeys('xa'); expect(menu.isDisplayed()).toBe(false); el.sendKeys(protractor.Key.BACK_SPACE, protractor.Key.BACK_SPACE); expect(getValue(el, tagName)).toEqual(''); expect(page.getValue(el, tagName)).toEqual(''); // popup menu el.sendKeys('Hello @'); expect(menu.isDisplayed()).toBe(true); expect(getValue(el, tagName)).toEqual('Hello @'); expect(page.getValue(el, tagName)).toEqual('Hello @'); // select mention using arrow keys and pressing enter // el.sendKeys(protractor.Key.ARROW_DOWN, protractor.Key.ENTER); Loading @@ -73,65 +70,48 @@ describe('angular-mentions App', function() { // select mention by clicking mouse on second item in menu element(by.css('.dropdown-menu li:nth-child(2) a')).click(); expect(menu.isDisplayed()).toBe(false); expect(getValue(el, tagName)).toEqual('Hello @Aaron'); expect(page.getValue(el, tagName)).toEqual('Hello @Aaron'); // select another mention el.sendKeys(' and @gav', protractor.Key.ENTER); expect(menu.isDisplayed()).toBe(false); expect(getValue(el, tagName)).toEqual('Hello @Aaron and @Gavin'); expect(page.getValue(el, tagName)).toEqual('Hello @Aaron and @Gavin'); // start another mention (with no values) el.sendKeys(' and @u'); expect(menu.isDisplayed()).toBe(false); expect(getValue(el, tagName)).toEqual('Hello @Aaron and @Gavin and @u'); expect(page.getValue(el, tagName)).toEqual('Hello @Aaron and @Gavin and @u'); // remove the mention el.sendKeys(protractor.Key.BACK_SPACE, protractor.Key.BACK_SPACE); expect(getValue(el, tagName)).toEqual('Hello @Aaron and @Gavin and '); expect(page.getValue(el, tagName)).toEqual('Hello @Aaron and @Gavin and '); // start another mention el.sendKeys('@'); expect(menu.isDisplayed()).toBe(true); expect(getValue(el, tagName)).toEqual('Hello @Aaron and @Gavin and @'); expect(page.getValue(el, tagName)).toEqual('Hello @Aaron and @Gavin and @'); // continue the mention el.sendKeys('e'); expect(menu.isDisplayed()).toBe(true); expect(getValue(el, tagName)).toEqual('Hello @Aaron and @Gavin and @e'); expect(page.getValue(el, tagName)).toEqual('Hello @Aaron and @Gavin and @e'); // but press escape instead el.sendKeys(protractor.Key.ESCAPE); expect(menu.isDisplayed()).toBe(false); expect(getValue(el, tagName)).toEqual('Hello @Aaron and @Gavin and @e'); expect(page.getValue(el, tagName)).toEqual('Hello @Aaron and @Gavin and @e'); // remove the escaped entry el.sendKeys('!!', protractor.Key.ARROW_LEFT, protractor.Key.ARROW_LEFT); el.sendKeys(protractor.Key.BACK_SPACE, protractor.Key.BACK_SPACE); expect(getValue(el, tagName)).toEqual('Hello @Aaron and @Gavin and !!'); expect(page.getValue(el, tagName)).toEqual('Hello @Aaron and @Gavin and !!'); // and insert another mention el.sendKeys('@HE', protractor.Key.ENTER); expect(menu.isDisplayed()).toBe(false); expect(getValue(el, tagName)).toEqual('Hello @Aaron and @Gavin and @Henry!!'); expect(page.getValue(el, tagName)).toEqual('Hello @Aaron and @Gavin and @Henry!!'); }); } function getValue(el, tagName) { if (tagName=="input" || tagName=="textarea") { return el.getAttribute('value'); } else if (tagName.length>0 && tagName[0]=='iframe') { let iframe = browser.findElement(by.tagName("iframe")); return browser.switchTo().frame(iframe).then( () => { let el = browser.driver.findElement(by.id('tinymce')); let text = el.getText(); return browser.switchTo().defaultContent().then(()=>{ return browser.waitForAngular().then(()=>{return text}); }); }); } else { return el.getText(); } } }); e2e/app.po.ts +19 −0 Original line number Diff line number Diff line Loading @@ -8,4 +8,23 @@ export class AngularMentionsPage { getHeadingText() { return element(by.css('app-root h1')).getText(); } getValue(el, tagName) { if (tagName=="input" || tagName=="textarea") { return el.getAttribute('value'); } else if (tagName.length>0 && tagName[0]=='iframe') { let iframe = browser.findElement(by.tagName("iframe")); return browser.switchTo().frame(iframe).then( () => { let el = browser.driver.findElement(by.id('tinymce')); let text = el.getText(); return browser.switchTo().defaultContent().then(()=>{ return browser.waitForAngular().then(()=>{return text}); }); }); } else { return el.getText(); } } } Loading
e2e/app.e2e-spec.ts +15 −35 Original line number Diff line number Diff line import { browser, element, by, protractor } from 'protractor'; import { element, by, protractor } from 'protractor'; import { AngularMentionsPage } from './app.po'; describe('angular-mentions App', function() { var EC = protractor.ExpectedConditions; describe('angular-mentions app', function() { let page: AngularMentionsPage; beforeEach(() => { page = new AngularMentionsPage(); }) let elements = it('test mentions text field', () => { page.navigateTo(); expect(page.getHeadingText()).toEqual('Angular Mentions'); Loading Loading @@ -50,7 +47,7 @@ describe('angular-mentions App', function() { el.getTagName().then(function(tagName){ let menu = element(by.css('.dropdown-menu')); el.click(); expect(getValue(el, tagName)).toEqual(''); expect(page.getValue(el, tagName)).toEqual(''); // test for git issue #59 el.sendKeys('@'); Loading @@ -60,12 +57,12 @@ describe('angular-mentions App', function() { el.sendKeys('xa'); expect(menu.isDisplayed()).toBe(false); el.sendKeys(protractor.Key.BACK_SPACE, protractor.Key.BACK_SPACE); expect(getValue(el, tagName)).toEqual(''); expect(page.getValue(el, tagName)).toEqual(''); // popup menu el.sendKeys('Hello @'); expect(menu.isDisplayed()).toBe(true); expect(getValue(el, tagName)).toEqual('Hello @'); expect(page.getValue(el, tagName)).toEqual('Hello @'); // select mention using arrow keys and pressing enter // el.sendKeys(protractor.Key.ARROW_DOWN, protractor.Key.ENTER); Loading @@ -73,65 +70,48 @@ describe('angular-mentions App', function() { // select mention by clicking mouse on second item in menu element(by.css('.dropdown-menu li:nth-child(2) a')).click(); expect(menu.isDisplayed()).toBe(false); expect(getValue(el, tagName)).toEqual('Hello @Aaron'); expect(page.getValue(el, tagName)).toEqual('Hello @Aaron'); // select another mention el.sendKeys(' and @gav', protractor.Key.ENTER); expect(menu.isDisplayed()).toBe(false); expect(getValue(el, tagName)).toEqual('Hello @Aaron and @Gavin'); expect(page.getValue(el, tagName)).toEqual('Hello @Aaron and @Gavin'); // start another mention (with no values) el.sendKeys(' and @u'); expect(menu.isDisplayed()).toBe(false); expect(getValue(el, tagName)).toEqual('Hello @Aaron and @Gavin and @u'); expect(page.getValue(el, tagName)).toEqual('Hello @Aaron and @Gavin and @u'); // remove the mention el.sendKeys(protractor.Key.BACK_SPACE, protractor.Key.BACK_SPACE); expect(getValue(el, tagName)).toEqual('Hello @Aaron and @Gavin and '); expect(page.getValue(el, tagName)).toEqual('Hello @Aaron and @Gavin and '); // start another mention el.sendKeys('@'); expect(menu.isDisplayed()).toBe(true); expect(getValue(el, tagName)).toEqual('Hello @Aaron and @Gavin and @'); expect(page.getValue(el, tagName)).toEqual('Hello @Aaron and @Gavin and @'); // continue the mention el.sendKeys('e'); expect(menu.isDisplayed()).toBe(true); expect(getValue(el, tagName)).toEqual('Hello @Aaron and @Gavin and @e'); expect(page.getValue(el, tagName)).toEqual('Hello @Aaron and @Gavin and @e'); // but press escape instead el.sendKeys(protractor.Key.ESCAPE); expect(menu.isDisplayed()).toBe(false); expect(getValue(el, tagName)).toEqual('Hello @Aaron and @Gavin and @e'); expect(page.getValue(el, tagName)).toEqual('Hello @Aaron and @Gavin and @e'); // remove the escaped entry el.sendKeys('!!', protractor.Key.ARROW_LEFT, protractor.Key.ARROW_LEFT); el.sendKeys(protractor.Key.BACK_SPACE, protractor.Key.BACK_SPACE); expect(getValue(el, tagName)).toEqual('Hello @Aaron and @Gavin and !!'); expect(page.getValue(el, tagName)).toEqual('Hello @Aaron and @Gavin and !!'); // and insert another mention el.sendKeys('@HE', protractor.Key.ENTER); expect(menu.isDisplayed()).toBe(false); expect(getValue(el, tagName)).toEqual('Hello @Aaron and @Gavin and @Henry!!'); expect(page.getValue(el, tagName)).toEqual('Hello @Aaron and @Gavin and @Henry!!'); }); } function getValue(el, tagName) { if (tagName=="input" || tagName=="textarea") { return el.getAttribute('value'); } else if (tagName.length>0 && tagName[0]=='iframe') { let iframe = browser.findElement(by.tagName("iframe")); return browser.switchTo().frame(iframe).then( () => { let el = browser.driver.findElement(by.id('tinymce')); let text = el.getText(); return browser.switchTo().defaultContent().then(()=>{ return browser.waitForAngular().then(()=>{return text}); }); }); } else { return el.getText(); } } });
e2e/app.po.ts +19 −0 Original line number Diff line number Diff line Loading @@ -8,4 +8,23 @@ export class AngularMentionsPage { getHeadingText() { return element(by.css('app-root h1')).getText(); } getValue(el, tagName) { if (tagName=="input" || tagName=="textarea") { return el.getAttribute('value'); } else if (tagName.length>0 && tagName[0]=='iframe') { let iframe = browser.findElement(by.tagName("iframe")); return browser.switchTo().frame(iframe).then( () => { let el = browser.driver.findElement(by.id('tinymce')); let text = el.getText(); return browser.switchTo().defaultContent().then(()=>{ return browser.waitForAngular().then(()=>{return text}); }); }); } else { return el.getText(); } } }