From 3f7441c8ff0609df541fe29d2fea02e14b198f14 Mon Sep 17 00:00:00 2001 From: bovandersteene Date: Tue, 9 Jan 2018 15:37:02 +0100 Subject: [PATCH 1/3] Update to latest serenity js version --- package.json | 33 +++++++++++++++-------------- protractor.conf.js | 2 +- spec/cross-app.spec.ts | 3 +-- src/app.e2e-spec.ts | 13 ++++++++++++ src/app.po.ts | 11 ++++++++++ src/calculator/ensure.ts | 25 ++++++++++------------ src/calculator/multiply.ts | 34 ++++++++++++++---------------- src/google/google.ts | 26 +++++++++++------------ src/google/select_result.ts | 24 ++++++++++----------- src/google/ui/google_search.d.ts | 5 +++++ src/google/ui/google_search.js | 13 ++++++++++++ src/google/ui/google_search.js.map | 1 + src/google/ui/google_search.ts | 2 +- src/tsconfig.e2e.json | 14 ++++++++++++ tslint.json | 5 +++-- 15 files changed, 130 insertions(+), 81 deletions(-) create mode 100644 src/app.e2e-spec.ts create mode 100644 src/app.po.ts create mode 100644 src/google/ui/google_search.d.ts create mode 100644 src/google/ui/google_search.js create mode 100644 src/google/ui/google_search.js.map create mode 100644 src/tsconfig.e2e.json diff --git a/package.json b/package.json index 7289374..daecbc5 100644 --- a/package.json +++ b/package.json @@ -25,23 +25,24 @@ "url": "https://github.com/serenity-js/tutorial-cross-app-testing/issues" }, "homepage": "https://github.com/serenity-js/tutorial-cross-app-testing#readme", - "devDependencies": { - "@types/chai": "3.5.0", - "@types/chai-as-promised": "0.0.30", - "@types/mocha": "2.2.40", - "@types/node": "7.0.12", - "chai": "3.5.0", - "chai-as-promised": "6.0.0", - "mocha": "3.2.0", + "dependencies": { + "@serenity-js/core": "^1.5.5", + "@types/chai": "4.1.0", + "@types/chai-as-promised": "7.1.0", + "@types/mocha": "2.2.46", + "@types/node": "9.3.0", + "chai": "4.1.2", + "chai-as-promised": "7.1.1", + "mocha": "4.1.0", "npm-failsafe": "0.2.1", - "protractor": "5.1.1", - "rimraf": "2.6.1", - "serenity-cli": "0.2.4", - "serenity-js": "1.3.0", - "ts-node": "3.0.2", - "tslint": "5.1.0", - "tslint-microsoft-contrib": "4.0.1", - "typescript": "2.2.2" + "protractor": "5.2.2", + "rimraf": "2.6.2", + "serenity-cli": "0.7.1", + "serenity-js": "1.10.1", + "ts-node": "4.1.0", + "tslint": "5.8.0", + "tslint-microsoft-contrib": "5.0.1", + "typescript": "2.6.2" }, "engines": { "node": ">= 6.9.x" diff --git a/protractor.conf.js b/protractor.conf.js index 5ead0ea..8430965 100644 --- a/protractor.conf.js +++ b/protractor.conf.js @@ -19,5 +19,5 @@ exports.config = { browserName: 'chrome' }, - restartBrowserBetweenTests: true, + restartBrowserBetweenTests: false, }; diff --git a/spec/cross-app.spec.ts b/spec/cross-app.spec.ts index e2d17fa..31af866 100644 --- a/spec/cross-app.spec.ts +++ b/spec/cross-app.spec.ts @@ -1,7 +1,6 @@ import { protractor } from 'protractor'; -import { BrowseTheWeb } from 'serenity-js/lib/serenity-protractor'; -import { Actor } from 'serenity-js/lib/serenity/screenplay'; +import { Actor, BrowseTheWeb } from 'serenity-js/lib/screenplay-protractor'; import { Ensure, Multiply } from '../src/calculator'; import { Google, SelectResult } from '../src/google'; diff --git a/src/app.e2e-spec.ts b/src/app.e2e-spec.ts new file mode 100644 index 0000000..e6d93d8 --- /dev/null +++ b/src/app.e2e-spec.ts @@ -0,0 +1,13 @@ +import { AppPage } from './app.po'; + +describe('fe-used-equipment-portal App', () => { + let page: AppPage; + + beforeEach(() => { + page = new AppPage(); + }); + + it('should display welcome message', () => { + page.navigateTo(); + }); +}); diff --git a/src/app.po.ts b/src/app.po.ts new file mode 100644 index 0000000..82ea75b --- /dev/null +++ b/src/app.po.ts @@ -0,0 +1,11 @@ +import { browser, by, element } from 'protractor'; + +export class AppPage { + navigateTo() { + return browser.get('/'); + } + + getParagraphText() { + return element(by.css('app-root h1')).getText(); + } +} diff --git a/src/calculator/ensure.ts b/src/calculator/ensure.ts index 1fa3361..ae17a09 100644 --- a/src/calculator/ensure.ts +++ b/src/calculator/ensure.ts @@ -1,20 +1,17 @@ -import { Text } from 'serenity-js/lib/serenity-protractor'; -import { step } from 'serenity-js/lib/serenity/recording'; -import { PerformsTasks, See, Task } from 'serenity-js/lib/serenity/screenplay'; -import { Assertion } from 'serenity-js/lib/serenity/screenplay/expectations'; - +import { Assertion } from '@serenity-js/core/lib/screenplay/expectations'; +import { PerformsTasks, See, step, Task, Text } from 'serenity-js/lib/screenplay-protractor'; import { Calculator } from './ui/calculator'; export class Ensure implements Task { - static result = (assertion: Assertion): Task => new Ensure(assertion); + static result = (assertion: Assertion): Task => new Ensure(assertion); - @step('{0} checks the result') - performAs(actor: PerformsTasks): PromiseLike { - return actor.attemptsTo( - See.if(Text.of(Calculator.Result), this.assertion), - ); - } + @step('{0} checks the result') + performAs(actor: PerformsTasks): PromiseLike { + return actor.attemptsTo( + See.if(Text.of(Calculator.Result), this.assertion), + ); + } - constructor(private assertion: Assertion) { - } + constructor(private assertion: Assertion) { + } } diff --git a/src/calculator/multiply.ts b/src/calculator/multiply.ts index bc28063..8c7575b 100644 --- a/src/calculator/multiply.ts +++ b/src/calculator/multiply.ts @@ -1,25 +1,23 @@ -import { Click, Enter, Select, UseAngular } from 'serenity-js/lib/serenity-protractor'; -import { step } from 'serenity-js/lib/serenity/recording'; -import { PerformsTasks, Task } from 'serenity-js/lib/serenity/screenplay'; +import { Click, Enter, PerformsTasks, Select, step, Task, UseAngular } from 'serenity-js/lib/screenplay-protractor'; import { Calculator } from './ui/calculator'; export class Multiply implements Task { - static number = (multiplier: number) => ({ - by: (multiplicand: number) => new Multiply(multiplier, multiplicand), - }) + static number = (multiplier: number) => ({ + by: (multiplicand: number) => new Multiply(multiplier, multiplicand), + }) - @step('{0} multiplies #multiplier by #multiplicand') - performAs(actor: PerformsTasks): PromiseLike { - return actor.attemptsTo( - UseAngular.enableSynchronisation(), - Enter.theValue(this.multiplier).into(Calculator.Left_Operand), - Select.theValue('*').from(Calculator.Operator), - Enter.theValue(this.multiplicand).into(Calculator.Right_Operand), - Click.on(Calculator.Go), - ); - } + @step('{0} multiplies #multiplier by #multiplicand') + performAs(actor: PerformsTasks): PromiseLike { + return actor.attemptsTo( + UseAngular.enableSynchronisation(), + Enter.theValue(this.multiplier).into(Calculator.Left_Operand), + Select.theValue('*').from(Calculator.Operator), + Enter.theValue(this.multiplicand).into(Calculator.Right_Operand), + Click.on(Calculator.Go), + ); + } - constructor(private multiplier: number, private multiplicand: number) { - } + constructor(private multiplier: number, private multiplicand: number) { + } } diff --git a/src/google/google.ts b/src/google/google.ts index f542ddb..2f287c1 100644 --- a/src/google/google.ts +++ b/src/google/google.ts @@ -1,22 +1,20 @@ import { protractor } from 'protractor'; -import { Enter, Open, UseAngular } from 'serenity-js/lib/serenity-protractor'; -import { step } from 'serenity-js/lib/serenity/recording'; -import { PerformsTasks, Task } from 'serenity-js/lib/serenity/screenplay'; +import { Enter, Open, PerformsTasks, step, Task, UseAngular } from 'serenity-js/lib/screenplay-protractor'; import { GoogleSearch } from './ui/google_search'; export class Google implements Task { - static the = (term: string) => new Google(term); + static the = (term: string) => new Google(term); - @step('{0} googles the "#term"') - performAs(actor: PerformsTasks): PromiseLike { - return actor.attemptsTo( - UseAngular.disableSynchronisation(), - Open.browserOn('http://google.co.uk/'), - Enter.theValue(this.term).into(GoogleSearch.Query).thenHit(protractor.Key.ENTER), - ); - } + @step('{0} googles the "#term"') + performAs(actor: PerformsTasks): PromiseLike { + return actor.attemptsTo( + UseAngular.disableSynchronisation(), + Open.browserOn('http://google.co.uk/'), + Enter.theValue(this.term).into(GoogleSearch.Query).thenHit(protractor.Key.ENTER), + ); + } - constructor(private term: string) { - } + constructor(private term: string) { + } } diff --git a/src/google/select_result.ts b/src/google/select_result.ts index 2b45282..14d6dd3 100644 --- a/src/google/select_result.ts +++ b/src/google/select_result.ts @@ -1,20 +1,18 @@ -import { Click, Is, Wait } from 'serenity-js/lib/serenity-protractor'; -import { step } from 'serenity-js/lib/serenity/recording'; -import { PerformsTasks, Task } from 'serenity-js/lib/serenity/screenplay'; +import { Click, Is, PerformsTasks, step, Task, Wait } from 'serenity-js/lib/screenplay-protractor'; import { GoogleSearch } from './ui/google_search'; export class SelectResult implements Task { - static of = (result: string) => new SelectResult(result); + static of = (result: string) => new SelectResult(result); - @step('{0} selects "#result" from the list of results') - performAs(actor: PerformsTasks): PromiseLike { - return actor.attemptsTo( - Wait.until(GoogleSearch.Result.of(this.result), Is.clickable()), - Click.on(GoogleSearch.Result.of(this.result)), - ); - } + @step('{0} selects "#result" from the list of results') + performAs(actor: PerformsTasks): PromiseLike { + return actor.attemptsTo( + Wait.until(GoogleSearch.Result.of(this.result), Is.clickable()), + Click.on(GoogleSearch.Result.of(this.result)), + ); + } - constructor(private result: string) { - } + constructor(private result: string) { + } } diff --git a/src/google/ui/google_search.d.ts b/src/google/ui/google_search.d.ts new file mode 100644 index 0000000..9c59185 --- /dev/null +++ b/src/google/ui/google_search.d.ts @@ -0,0 +1,5 @@ +import { Target } from 'serenity-js/lib/screenplay-protractor'; +export declare class GoogleSearch { + static Query: Target; + static Result: Target; +} diff --git a/src/google/ui/google_search.js b/src/google/ui/google_search.js new file mode 100644 index 0000000..a02379b --- /dev/null +++ b/src/google/ui/google_search.js @@ -0,0 +1,13 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var protractor_1 = require("protractor"); +var screenplay_protractor_1 = require("serenity-js/lib/screenplay-protractor"); +var GoogleSearch = /** @class */ (function () { + function GoogleSearch() { + } + GoogleSearch.Query = screenplay_protractor_1.Target.the('Query').located(protractor_1.by.name('q')); + GoogleSearch.Result = screenplay_protractor_1.Target.the('Link to "{0}"').located(protractor_1.by.linkText('{0}')); + return GoogleSearch; +}()); +exports.GoogleSearch = GoogleSearch; +//# sourceMappingURL=google_search.js.map \ No newline at end of file diff --git a/src/google/ui/google_search.js.map b/src/google/ui/google_search.js.map new file mode 100644 index 0000000..4ab780d --- /dev/null +++ b/src/google/ui/google_search.js.map @@ -0,0 +1 @@ +{"version":3,"file":"google_search.js","sourceRoot":"","sources":["google_search.ts"],"names":[],"mappings":";;AAAA,yCAAgC;AAChC,+EAA+D;AAE/D;IAAA;IAGA,CAAC;IAFU,kBAAK,GAAI,8BAAM,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,eAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;IACnD,mBAAM,GAAG,8BAAM,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC,OAAO,CAAC,eAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC;IAC5E,mBAAC;CAAA,AAHD,IAGC;AAHY,oCAAY"} \ No newline at end of file diff --git a/src/google/ui/google_search.ts b/src/google/ui/google_search.ts index eb582da..d1624fc 100644 --- a/src/google/ui/google_search.ts +++ b/src/google/ui/google_search.ts @@ -1,5 +1,5 @@ import { by } from 'protractor'; -import { Target } from 'serenity-js/lib/serenity-protractor'; +import { Target } from 'serenity-js/lib/screenplay-protractor'; export class GoogleSearch { static Query = Target.the('Query').located(by.name('q')); diff --git a/src/tsconfig.e2e.json b/src/tsconfig.e2e.json new file mode 100644 index 0000000..1d9e5ed --- /dev/null +++ b/src/tsconfig.e2e.json @@ -0,0 +1,14 @@ +{ + "extends": "../tsconfig.json", + "compilerOptions": { + "outDir": "../out-tsc/e2e", + "baseUrl": "./", + "module": "commonjs", + "target": "es5", + "types": [ + "jasmine", + "jasminewd2", + "node" + ] + } +} diff --git a/tslint.json b/tslint.json index 209fcab..fb11448 100644 --- a/tslint.json +++ b/tslint.json @@ -37,6 +37,7 @@ "only-arrow-functions": false, "arrow-parens": [true, "ban-single-arg-parens" ], "max-classes-per-file": false, - "mocha-avoid-only": true + "mocha-avoid-only": true, + "no-submodule-imports": false } -} +} \ No newline at end of file From 0c0cd01da1483a527a2cfa65ce95f35c2c98777f Mon Sep 17 00:00:00 2001 From: bovandersteene Date: Tue, 9 Jan 2018 15:39:35 +0100 Subject: [PATCH 2/3] Update to latest serenity js version --- src/app.e2e-spec.ts | 13 ------------- src/app.po.ts | 11 ----------- src/google/google.ts | 22 +++++++++++----------- src/google/select_result.ts | 20 ++++++++++---------- src/google/ui/google_search.d.ts | 5 ----- src/google/ui/google_search.js | 13 ------------- src/google/ui/google_search.js.map | 1 - 7 files changed, 21 insertions(+), 64 deletions(-) delete mode 100644 src/app.e2e-spec.ts delete mode 100644 src/app.po.ts delete mode 100644 src/google/ui/google_search.d.ts delete mode 100644 src/google/ui/google_search.js delete mode 100644 src/google/ui/google_search.js.map diff --git a/src/app.e2e-spec.ts b/src/app.e2e-spec.ts deleted file mode 100644 index e6d93d8..0000000 --- a/src/app.e2e-spec.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { AppPage } from './app.po'; - -describe('fe-used-equipment-portal App', () => { - let page: AppPage; - - beforeEach(() => { - page = new AppPage(); - }); - - it('should display welcome message', () => { - page.navigateTo(); - }); -}); diff --git a/src/app.po.ts b/src/app.po.ts deleted file mode 100644 index 82ea75b..0000000 --- a/src/app.po.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { browser, by, element } from 'protractor'; - -export class AppPage { - navigateTo() { - return browser.get('/'); - } - - getParagraphText() { - return element(by.css('app-root h1')).getText(); - } -} diff --git a/src/google/google.ts b/src/google/google.ts index 2f287c1..f350bff 100644 --- a/src/google/google.ts +++ b/src/google/google.ts @@ -4,17 +4,17 @@ import { Enter, Open, PerformsTasks, step, Task, UseAngular } from 'serenity-js/ import { GoogleSearch } from './ui/google_search'; export class Google implements Task { - static the = (term: string) => new Google(term); + static the = (term: string) => new Google(term); - @step('{0} googles the "#term"') - performAs(actor: PerformsTasks): PromiseLike { - return actor.attemptsTo( - UseAngular.disableSynchronisation(), - Open.browserOn('http://google.co.uk/'), - Enter.theValue(this.term).into(GoogleSearch.Query).thenHit(protractor.Key.ENTER), - ); - } + @step('{0} googles the "#term"') + performAs(actor: PerformsTasks): PromiseLike { + return actor.attemptsTo( + UseAngular.disableSynchronisation(), + Open.browserOn('http://google.co.uk/'), + Enter.theValue(this.term).into(GoogleSearch.Query).thenHit(protractor.Key.ENTER), + ); + } - constructor(private term: string) { - } + constructor(private term: string) { + } } diff --git a/src/google/select_result.ts b/src/google/select_result.ts index 14d6dd3..8b52fce 100644 --- a/src/google/select_result.ts +++ b/src/google/select_result.ts @@ -3,16 +3,16 @@ import { Click, Is, PerformsTasks, step, Task, Wait } from 'serenity-js/lib/scre import { GoogleSearch } from './ui/google_search'; export class SelectResult implements Task { - static of = (result: string) => new SelectResult(result); + static of = (result: string) => new SelectResult(result); - @step('{0} selects "#result" from the list of results') - performAs(actor: PerformsTasks): PromiseLike { - return actor.attemptsTo( - Wait.until(GoogleSearch.Result.of(this.result), Is.clickable()), - Click.on(GoogleSearch.Result.of(this.result)), - ); - } + @step('{0} selects "#result" from the list of results') + performAs(actor: PerformsTasks): PromiseLike { + return actor.attemptsTo( + Wait.until(GoogleSearch.Result.of(this.result), Is.clickable()), + Click.on(GoogleSearch.Result.of(this.result)), + ); + } - constructor(private result: string) { - } + constructor(private result: string) { + } } diff --git a/src/google/ui/google_search.d.ts b/src/google/ui/google_search.d.ts deleted file mode 100644 index 9c59185..0000000 --- a/src/google/ui/google_search.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { Target } from 'serenity-js/lib/screenplay-protractor'; -export declare class GoogleSearch { - static Query: Target; - static Result: Target; -} diff --git a/src/google/ui/google_search.js b/src/google/ui/google_search.js deleted file mode 100644 index a02379b..0000000 --- a/src/google/ui/google_search.js +++ /dev/null @@ -1,13 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -var protractor_1 = require("protractor"); -var screenplay_protractor_1 = require("serenity-js/lib/screenplay-protractor"); -var GoogleSearch = /** @class */ (function () { - function GoogleSearch() { - } - GoogleSearch.Query = screenplay_protractor_1.Target.the('Query').located(protractor_1.by.name('q')); - GoogleSearch.Result = screenplay_protractor_1.Target.the('Link to "{0}"').located(protractor_1.by.linkText('{0}')); - return GoogleSearch; -}()); -exports.GoogleSearch = GoogleSearch; -//# sourceMappingURL=google_search.js.map \ No newline at end of file diff --git a/src/google/ui/google_search.js.map b/src/google/ui/google_search.js.map deleted file mode 100644 index 4ab780d..0000000 --- a/src/google/ui/google_search.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"google_search.js","sourceRoot":"","sources":["google_search.ts"],"names":[],"mappings":";;AAAA,yCAAgC;AAChC,+EAA+D;AAE/D;IAAA;IAGA,CAAC;IAFU,kBAAK,GAAI,8BAAM,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,eAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;IACnD,mBAAM,GAAG,8BAAM,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC,OAAO,CAAC,eAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC;IAC5E,mBAAC;CAAA,AAHD,IAGC;AAHY,oCAAY"} \ No newline at end of file From e1aba3633ace03b3d917743c1606bca4eb35a034 Mon Sep 17 00:00:00 2001 From: bovandersteene Date: Tue, 9 Jan 2018 15:40:44 +0100 Subject: [PATCH 3/3] Update to latest serenity js version --- src/calculator/ensure.ts | 18 +++++++++--------- src/calculator/multiply.ts | 30 +++++++++++++++--------------- src/tsconfig.e2e.json | 14 -------------- 3 files changed, 24 insertions(+), 38 deletions(-) delete mode 100644 src/tsconfig.e2e.json diff --git a/src/calculator/ensure.ts b/src/calculator/ensure.ts index ae17a09..39ec8bc 100644 --- a/src/calculator/ensure.ts +++ b/src/calculator/ensure.ts @@ -3,15 +3,15 @@ import { PerformsTasks, See, step, Task, Text } from 'serenity-js/lib/screenplay import { Calculator } from './ui/calculator'; export class Ensure implements Task { - static result = (assertion: Assertion): Task => new Ensure(assertion); + static result = (assertion: Assertion): Task => new Ensure(assertion); - @step('{0} checks the result') - performAs(actor: PerformsTasks): PromiseLike { - return actor.attemptsTo( - See.if(Text.of(Calculator.Result), this.assertion), - ); - } + @step('{0} checks the result') + performAs(actor: PerformsTasks): PromiseLike { + return actor.attemptsTo( + See.if(Text.of(Calculator.Result), this.assertion), + ); + } - constructor(private assertion: Assertion) { - } + constructor(private assertion: Assertion) { + } } diff --git a/src/calculator/multiply.ts b/src/calculator/multiply.ts index 8c7575b..87f3a43 100644 --- a/src/calculator/multiply.ts +++ b/src/calculator/multiply.ts @@ -3,21 +3,21 @@ import { Click, Enter, PerformsTasks, Select, step, Task, UseAngular } from 'ser import { Calculator } from './ui/calculator'; export class Multiply implements Task { - static number = (multiplier: number) => ({ - by: (multiplicand: number) => new Multiply(multiplier, multiplicand), - }) + static number = (multiplier: number) => ({ + by: (multiplicand: number) => new Multiply(multiplier, multiplicand), + }) - @step('{0} multiplies #multiplier by #multiplicand') - performAs(actor: PerformsTasks): PromiseLike { - return actor.attemptsTo( - UseAngular.enableSynchronisation(), - Enter.theValue(this.multiplier).into(Calculator.Left_Operand), - Select.theValue('*').from(Calculator.Operator), - Enter.theValue(this.multiplicand).into(Calculator.Right_Operand), - Click.on(Calculator.Go), - ); - } + @step('{0} multiplies #multiplier by #multiplicand') + performAs(actor: PerformsTasks): PromiseLike { + return actor.attemptsTo( + UseAngular.enableSynchronisation(), + Enter.theValue(this.multiplier).into(Calculator.Left_Operand), + Select.theValue('*').from(Calculator.Operator), + Enter.theValue(this.multiplicand).into(Calculator.Right_Operand), + Click.on(Calculator.Go), + ); + } - constructor(private multiplier: number, private multiplicand: number) { - } + constructor(private multiplier: number, private multiplicand: number) { + } } diff --git a/src/tsconfig.e2e.json b/src/tsconfig.e2e.json deleted file mode 100644 index 1d9e5ed..0000000 --- a/src/tsconfig.e2e.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "extends": "../tsconfig.json", - "compilerOptions": { - "outDir": "../out-tsc/e2e", - "baseUrl": "./", - "module": "commonjs", - "target": "es5", - "types": [ - "jasmine", - "jasminewd2", - "node" - ] - } -}