From 19f82656f1145884db3f2dcc82b7b007c141888c Mon Sep 17 00:00:00 2001 From: Florian Hartwich Date: Sun, 21 May 2017 02:16:09 +0200 Subject: [PATCH] Add protractor test setup --- static/e2e/test.e2e-spec.ts | 29 +++++++++++++++++++++++++++++ static/e2e/tsconfig.e2e.json | 12 ++++++++++++ static/package.json | 17 ++++++++--------- static/protractor.conf.js | 14 ++++++-------- static/src/app/app.config.ts | 1 - 5 files changed, 55 insertions(+), 18 deletions(-) create mode 100644 static/e2e/test.e2e-spec.ts create mode 100644 static/e2e/tsconfig.e2e.json diff --git a/static/e2e/test.e2e-spec.ts b/static/e2e/test.e2e-spec.ts new file mode 100644 index 0000000..352fd48 --- /dev/null +++ b/static/e2e/test.e2e-spec.ts @@ -0,0 +1,29 @@ +import {browser, element, by} from 'protractor'; + + +describe('Access Projectmanager Homepage', function () { + + beforeEach(() => { + browser.get('/') + }); + + it('should start at Dashboard page and brand link should redirect there again', () => { + const startingPage = 'Dashboard'; + + function validatePage() { + const dashboardNavEntryCssClass = element(by.linkText(startingPage)).element(by.xpath('..')).getAttribute('class'); + expect(dashboardNavEntryCssClass).toContain('active'); + + const heading = element(by.css('h1')); + const headingText = heading.getText(); + expect(headingText).toBe(startingPage); + } + + validatePage(); + const navBarBrand = element(by.className('navbar-brand')); + expect(navBarBrand.getAttribute('href')).toBe(browser.baseUrl + '/#'); + navBarBrand.click(); + validatePage(); + }); + +}); diff --git a/static/e2e/tsconfig.e2e.json b/static/e2e/tsconfig.e2e.json new file mode 100644 index 0000000..5e6ee11 --- /dev/null +++ b/static/e2e/tsconfig.e2e.json @@ -0,0 +1,12 @@ +{ + "extends": "../tsconfig.json", + "compilerOptions": { + "outDir": "../out-tsc/e2e", + "module": "commonjs", + "target": "es6", + "types": [ + "jasmine", + "node" + ] + } +} diff --git a/static/package.json b/static/package.json index 5720c65..3b90bcd 100644 --- a/static/package.json +++ b/static/package.json @@ -7,7 +7,9 @@ "scripts": { "ng": "ng", "start": "ng serve", - "test": "ng test" + "test": "ng test", + "pree2e": "webdriver-manager update --standalone false --gecko false", + "e2e": "ng e2e" }, "dependencies": { "@angular/common": "^4.1.1", @@ -32,21 +34,18 @@ "zone.js": "^0.8.5" }, "devDependencies": { - "@angular/cli": "1.0.2", - "@angular/compiler-cli": "^2.4.3", - "@types/jasmine": "2.5.38", - "@types/node": "^6.0.42", - "@types/socket.io-client": "^1.4.26", + "@types/jasmine": "^2.5.47", + "@types/node": "^7.0.21", + "@types/socket.io-client": "^1.4.29", "codelyzer": "~2.0.0-beta.1", - "concurrently": "^2.0.0", "jasmine-core": "2.5.2", - "jasmine-spec-reporter": "2.5.0", + "jasmine-spec-reporter": "^4.1.0", "karma": "1.2.0", "karma-chrome-launcher": "^2.0.0", "karma-cli": "^1.0.1", "karma-jasmine": "^1.0.2", "karma-remap-istanbul": "^0.2.1", - "karma-spec-reporter": "0.0.26", + "karma-spec-reporter": "0.0.31", "protractor": "~4.0.13", "protractor-jasmine2-screenshot-reporter": "^0.3.2", "ts-node": "1.2.1", diff --git a/static/protractor.conf.js b/static/protractor.conf.js index 00cf700..6613b13 100644 --- a/static/protractor.conf.js +++ b/static/protractor.conf.js @@ -1,10 +1,9 @@ // Protractor configuration file, see link for more information // https://github.com/angular/protractor/blob/master/lib/config.ts -/*global jasmine */ -var SpecReporter = require('jasmine-spec-reporter'); +const { SpecReporter } = require('jasmine-spec-reporter'); -exports.config = { +exports.config= { allScriptsTimeout: 11000, specs: [ './e2e/**/*.e2e-spec.ts' @@ -13,20 +12,19 @@ exports.config = { 'browserName': 'chrome' }, directConnect: true, - baseUrl: 'http://localhost:8091/', + baseUrl: 'http://localhost:8091', framework: 'jasmine', jasmineNodeOpts: { showColors: true, defaultTimeoutInterval: 30000, print: function() {} }, - useAllAngular2AppRoots: true, beforeLaunch: function() { require('ts-node').register({ - project: 'e2e' + project: 'e2e/tsconfig.e2e.json' }); }, - onPrepare: function() { - jasmine.getEnv().addReporter(new SpecReporter()); + onPrepare() { + jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } })); } }; diff --git a/static/src/app/app.config.ts b/static/src/app/app.config.ts index 301f4ab..f156ce5 100644 --- a/static/src/app/app.config.ts +++ b/static/src/app/app.config.ts @@ -1,4 +1,3 @@ -import {Headers} from "@angular/http"; export class AppConfig {