Skip to content
This repository was archived by the owner on Dec 4, 2017. It is now read-only.

chore(test): add protractor4 #2233

Merged
merged 5 commits into from
Oct 6, 2016
Merged

Conversation

filipesilva
Copy link
Contributor

@filipesilva filipesilva commented Aug 31, 2016

This PR updates Protractor to from version 3 to 4, which is made inTypescript and includes typings.

Since Protractor4 includes typings, this solves an issue we had with the Upgrade Adapter chapter where Jquery's $ typings conflicted with Protractors $. This issue prevented us from having them in the same node package and was the main motivator for the _protractor folder.

Thus, this PR removes the _protractor folder and adds Protractor configuration and helpers directly to _examples, which solves some editor tooling issues we had because of the indirect path structure for e2e tests.

Boilerplate files were moved from _examples to _examples/_boilerplate as well, so that they are contained there and also to be able to use a tsconfig.json for Protractor in _examples (this was needed for editor tooling purposes). Gulp tasks and plunker generation were adjusted to use this directory.

Some of the custom logic we had in protractor.config.js was moved into protractor-helpers.ts since we were attaching it to the browser variable, which is now typed and thus threw errors when accessing these custom members. Our custom sendKeys was also removed since it's not needed anymore.

End result is that we should have full type safety and editor tooling support in Protractor.

Note: previous tooling added a git ignored tsconfig.json besides each e2e-spec.ts file, which should now be removed otherwise editor tooling will not work properly. Overall, after this PR it is a good to run git clean -fdx to 'reset' the repo and re-setup our infrastructure.

/cc @wardbell @chalin @Foxandxss this PR includes some structural changes that I'd like you to look at and see if you approve.

@filipesilva filipesilva force-pushed the protractor4 branch 9 times, most recently from f534964 to 5542954 Compare September 6, 2016 15:36
@filipesilva filipesilva changed the title [WIP] chore(test): add protractor4 chore(test): add protractor4 Sep 6, 2016
@filipesilva filipesilva force-pushed the protractor4 branch 2 times, most recently from a8bb299 to 1e889c8 Compare September 6, 2016 16:56
'use strict'; // necessary for es6 output in node

import { browser, element, by } from 'protractor/globals';
import { sendKeys } from '../protractor-helpers';
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sendKeys is not exported on the protractor-helpers file.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@filipesilva
Copy link
Contributor Author

Thanks for the review @cnishina! I added in all your notes.

function getBoundingClientWidth(el: protractor.ElementFinder): protractor.promise.Promise<number> {
return browser.executeScript(
function getBoundingClientWidth(el: ElementFinder): Promise<number> {
return browser.driver.executeScript(

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

browser.executeScript should work now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

function getOffsetWidth(el: protractor.ElementFinder): protractor.promise.Promise<number> {
return browser.executeScript(
function getOffsetWidth(el: ElementFinder): Promise<number> {
return browser.driver.executeScript(

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

browser.executeScript should work now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

@@ -71,7 +74,7 @@ describe('Dependency Injection Cookbook', function () {
let yellow = 'rgba(255, 255, 0, 1)';

expect(target.getCssValue('background-color')).not.toEqual(yellow);
browser.actions().mouseMove(target as any as webdriver.WebElement).perform();
browser.actions().mouseMove(target as any as WebElement).perform();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use target.getWebElement()

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

@@ -54,7 +57,7 @@ describe('TypeScript to Javascript tests', function () {
expect(h1.getAttribute('class')).toBe('active');

h1.click();
browser.actions().doubleClick(h1 as any as webdriver.WebElement).perform();
browser.actions().doubleClick(h1 as any as WebElement).perform();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use h1.getWebElement()

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

@filipesilva filipesilva force-pushed the protractor4 branch 5 times, most recently from 7bc7b0d to 2bf1b46 Compare September 22, 2016 23:23
@filipesilva filipesilva force-pushed the protractor4 branch 5 times, most recently from f2a18d0 to 134d1d1 Compare October 5, 2016 11:56
@filipesilva filipesilva changed the title [WIP] chore(test): add protractor4 chore(test): add protractor4 Oct 5, 2016
@Foxandxss
Copy link
Member

I like it but there are some changes:

  • Do we need a example-config.json? We had that since day 1, but I don't see why we need it, perhaps we can get rid of it.
  • The karma conf and karma shim are not copied everywhere anymore, so we don't need it inside _boilerplate.
  • a2docs.css gets autogenerated, so we don't need it inside the repo. Just make it to be generated there.

My concerns:

Now we have a few boilerplate inside a _boilerplate folder and a few of them outside it. I don't like that, because now I have two different places to look for boilerplate and even more confusing, I have two package.json (one full, one with tasks only, and needing to maintain both).

On the other hand, we also have two tsconfig, one for protractor and one for the demos.

Can't we have _boilerplate to have everything and perhaps a inner protractor folder with the protractor ones? Or they need to exist in the root _examples folder?

@filipesilva
Copy link
Contributor Author

Points discussed offline, addressed in commits above.

@Foxandxss
Copy link
Member

It has a tslint in _examples and _boilerplate. I guess we should get rid of the _examples one.

Also, a2docs.css at _boilerplate needs to be ignored.

@filipesilva
Copy link
Contributor Author

We should keep the tslint in _examples because it'll also affect the e2e specs. The a2docs.css at _boilerplate should be ignored, agree.

@Foxandxss
Copy link
Member

So to summarize for @wardbell, we are creating a _boilerplate folder where we have everything we share across al the examples.

The important bit in here is that the package.json that we are spreading right now only have the npm scripts (just what we need) and there is a package.json at _examples that is the one with all the dependencies but not script tags.

We now have a less cluttered _examples folder.

@wardbell
Copy link
Contributor

wardbell commented Oct 6, 2016

LGTM. Assume it works :-) I like the cleanup. I'm not entirely sure yet about the package.json split of scripts from dependencies but if it doesn't work out, we can fix.

@wardbell wardbell merged commit 5042b30 into angular:master Oct 6, 2016
@wardbell wardbell deleted the protractor4 branch October 6, 2016 22:25
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants