From 5195d402ced0c777ba1061cc96d3aa0c1473cd8e Mon Sep 17 00:00:00 2001 From: Florian Hartwich Date: Tue, 21 Mar 2017 04:09:56 +0100 Subject: [PATCH] Remove pre-made tests --- .../e2e/dashboard/dashboard.e2e-spec.ts | 24 --------- .../e2e/helpers/take_screenshot.ts | 12 ----- .../e2e/tasks/edit-task.e2e-spec.ts | 26 --------- project-manager/e2e/tasks/edit-task.po.ts | 34 ------------ .../task-list-no-page-object.e2e-spec.ts | 25 --------- .../e2e/tasks/task-list.e2e-spec.ts | 54 ------------------- project-manager/e2e/tasks/task-list.po.ts | 32 ----------- project-manager/e2e/tsconfig.json | 19 ------- project-manager/karma.conf.js | 44 --------------- .../protractor-html-reporter.conf.js | 52 ------------------ project-manager/protractor.conf.js | 32 ----------- .../src/app/testing/test-helper.ts | 11 ---- project-manager/src/test.ts | 34 ------------ 13 files changed, 399 deletions(-) delete mode 100644 project-manager/e2e/dashboard/dashboard.e2e-spec.ts delete mode 100644 project-manager/e2e/helpers/take_screenshot.ts delete mode 100644 project-manager/e2e/tasks/edit-task.e2e-spec.ts delete mode 100644 project-manager/e2e/tasks/edit-task.po.ts delete mode 100644 project-manager/e2e/tasks/task-list-no-page-object.e2e-spec.ts delete mode 100644 project-manager/e2e/tasks/task-list.e2e-spec.ts delete mode 100644 project-manager/e2e/tasks/task-list.po.ts delete mode 100644 project-manager/e2e/tsconfig.json delete mode 100644 project-manager/karma.conf.js delete mode 100644 project-manager/protractor-html-reporter.conf.js delete mode 100644 project-manager/protractor.conf.js delete mode 100644 project-manager/src/app/testing/test-helper.ts delete mode 100644 project-manager/src/test.ts diff --git a/project-manager/e2e/dashboard/dashboard.e2e-spec.ts b/project-manager/e2e/dashboard/dashboard.e2e-spec.ts deleted file mode 100644 index 36222fa..0000000 --- a/project-manager/e2e/dashboard/dashboard.e2e-spec.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { browser, element, by } from 'protractor'; - -describe('Dashboard', function() { - - beforeEach(() => { - browser.get('/') - }); - - it('should display the correct heading', () => { - const heading = element(by.css('h1')).getText(); - const headings = element.all(by.css('h1')).getText(); - console.log(headings) - heading.then((headingText) => { - console.log(headingText); - }); - expect(heading).toEqual('Dashboard'); - expect(headings).toContain('Dashboard'); - }); - - it('should redirect to /dashboard', () => { - expect(browser.getCurrentUrl()).toContain('/dashboard'); - }); - -}); diff --git a/project-manager/e2e/helpers/take_screenshot.ts b/project-manager/e2e/helpers/take_screenshot.ts deleted file mode 100644 index c2c00c2..0000000 --- a/project-manager/e2e/helpers/take_screenshot.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { browser} from 'protractor'; -import * as fs from 'fs'; - -declare var Buffer, module: any; - -export function takeScreenshot(filename: string) { - return browser.takeScreenshot().then((data) => { - const stream = fs.createWriteStream(filename); - stream.write(new Buffer(data, 'base64')); - stream.end(); - }) -} \ No newline at end of file diff --git a/project-manager/e2e/tasks/edit-task.e2e-spec.ts b/project-manager/e2e/tasks/edit-task.e2e-spec.ts deleted file mode 100644 index 3a25155..0000000 --- a/project-manager/e2e/tasks/edit-task.e2e-spec.ts +++ /dev/null @@ -1,26 +0,0 @@ -import {takeScreenshot} from '../helpers/take_screenshot'; -import { browser } from 'protractor'; -import {EditTaskPage} from './edit-task.po'; - -describe('Edit Tasks', function() { - - let page: EditTaskPage; - beforeEach(() => { - page = new EditTaskPage(); - page.navigateToNewPage(); - }); - - it('should change page when accepting alert', () => { - page.fillForm('New Task', 'BACKLOG'); - page.cancel(); - page.getAlert().accept(); // Klick auf OK - expect(browser.getCurrentUrl()).not.toContain(page.newUrl); - }); - - it('should stay on page when discarding alert', () => { - page.fillForm('New Task', 'IN_PROGRESS'); - page.cancel(); - page.getAlert().dismiss(); // Klick auf Abbrechen - expect(browser.getCurrentUrl()).toContain(page.newUrl); - }); -}); \ No newline at end of file diff --git a/project-manager/e2e/tasks/edit-task.po.ts b/project-manager/e2e/tasks/edit-task.po.ts deleted file mode 100644 index a695a49..0000000 --- a/project-manager/e2e/tasks/edit-task.po.ts +++ /dev/null @@ -1,34 +0,0 @@ -import { browser, element, by, protractor} from 'protractor'; - -export class EditTaskPage { - newUrl = '/tasks/new'; - navigateToNewPage() { - return browser.get(this.newUrl); - } - - navigateToEditPage(id: number) { - return browser.get(`tasks/edit/${id}`); - } - - fillForm(title: string, state: string) { - element(by.name('title')).sendKeys(title); - element(by.name('state')).element(by.css(`[value="${state}"]`)) - .click(); - //Firefox HACK: - browser.actions().sendKeys( protractor.Key.ENTER ).perform(); - } - - save() { - element(by.id('save')).click(); - } - - cancel() { - return element(by.id('cancel')).click(); - } - - getAlert() { - return browser.switchTo().alert(); - } - -} - diff --git a/project-manager/e2e/tasks/task-list-no-page-object.e2e-spec.ts b/project-manager/e2e/tasks/task-list-no-page-object.e2e-spec.ts deleted file mode 100644 index 1d104f4..0000000 --- a/project-manager/e2e/tasks/task-list-no-page-object.e2e-spec.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { browser, element, by } from 'protractor'; -import {takeScreenshot} from '../helpers/take_screenshot'; - -describe('Task List (without Page Object)', () => { - - beforeEach(() => { - browser.get('/tasks') - }); - - it('should allow searching for tasks', () => { - element(by.css('#search-tasks')).sendKeys('Ersten'); - browser.sleep(500); - const count = element.all(by.className('task-list-entry')).count(); - expect(count).toEqual(1); - }); - - it('should work with no search results', () => { - element(by.css('#search-tasks')).sendKeys('Ich existiere nicht'); - browser.sleep(500); - const count = element.all(by.className('task-list-entry')).count(); - expect(count).toEqual(0); - }); - - -}); diff --git a/project-manager/e2e/tasks/task-list.e2e-spec.ts b/project-manager/e2e/tasks/task-list.e2e-spec.ts deleted file mode 100644 index c24a8d0..0000000 --- a/project-manager/e2e/tasks/task-list.e2e-spec.ts +++ /dev/null @@ -1,54 +0,0 @@ - -import {takeScreenshot} from '../helpers/take_screenshot'; -import {TaskListPage} from './task-list.po'; -import { browser } from 'protractor'; - - -describe('TaskList', function () { - - let page: TaskListPage; - beforeEach(() => { - page = new TaskListPage(); - page.navigateTo(); - }); - - xit('should allow to create new tasks (forgot to press save)', () => { - - const editPage = page.gotoNewTaskView(); - editPage.fillForm('New Task', 'BACKLOG'); - // editPage.save(); - - expect(page.checkTaskDisplayed('New Task')).not.toBeNull(); - - }); - - it('should allow searching for tasks', () => { - page.searchForTasks('Ersten'); - expect(page.getTaskCount()).toEqual(1); - }); - - it('should work with no search results', () => { - page.searchForTasks('Ich existiere nicht.'); - expect(page.getTaskCount()).toEqual(0); - }); - - - it('should allow to create new tasks', () => { - const taskTitle = `New Task ${new Date().getTime()}`; - const editPage = page.gotoNewTaskView(); - editPage.fillForm(taskTitle, 'IN_PROGRESS'); - editPage.save(); - takeScreenshot('createTaskFailure.png'); - page.checkTaskDisplayed(taskTitle); - }); - - it('should add new tasks to the displayed list', () => { - page.getTaskCount().then(count => { - const editPage = page.gotoNewTaskView(); - editPage.fillForm('New Task', 'IN_PROGRESS'); - editPage.save(); - expect(page.getTaskCount()).toEqual(count + 1); - }); - }); - -}); diff --git a/project-manager/e2e/tasks/task-list.po.ts b/project-manager/e2e/tasks/task-list.po.ts deleted file mode 100644 index ef8d311..0000000 --- a/project-manager/e2e/tasks/task-list.po.ts +++ /dev/null @@ -1,32 +0,0 @@ -import { browser, element, by} from 'protractor'; -import { ExpectedConditions as EC} from 'protractor'; -import {EditTaskPage} from './edit-task.po'; - -export class TaskListPage { - - navigateTo() { - return browser.get('/tasks'); - } - - searchForTasks(term: string) { - element(by.css('#search-tasks')).sendKeys(term); - browser.sleep(500); - } - - getTaskCount() { - return element.all(by.className('task-list-entry')).count(); - } - - gotoNewTaskView() { - element(by.linkText('Neue Aufgabe anlegen')).click(); - return new EditTaskPage(); - } - - checkTaskDisplayed(text: string) { - const taskLink = element(by.linkText(text)); - browser.wait(EC.presenceOf(taskLink), 10000); - return taskLink.isDisplayed(); - } - -} - diff --git a/project-manager/e2e/tsconfig.json b/project-manager/e2e/tsconfig.json deleted file mode 100644 index a372020..0000000 --- a/project-manager/e2e/tsconfig.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "compileOnSave": false, - "compilerOptions": { - "declaration": false, - "emitDecoratorMetadata": true, - "experimentalDecorators": true, - "module": "commonjs", - "moduleResolution": "node", - "outDir": "../dist/out-tsc-e2e", - "sourceMap": true, - "target": "es5", - "typeRoots": [ - "../node_modules/@types" - ], - "types": [ - "jasmine", "node" - ] - } -} diff --git a/project-manager/karma.conf.js b/project-manager/karma.conf.js deleted file mode 100644 index a79edd1..0000000 --- a/project-manager/karma.conf.js +++ /dev/null @@ -1,44 +0,0 @@ -// Karma configuration file, see link for more information -// https://karma-runner.github.io/0.13/config/configuration-file.html - -module.exports = function (config) { - config.set({ - basePath: '', - frameworks: ['jasmine', 'angular-cli'], - plugins: [ - require('karma-jasmine'), - require('karma-chrome-launcher'), - require('karma-remap-istanbul'), - require('karma-spec-reporter'), - require('angular-cli/plugins/karma') - ], - files: [ - { pattern: './src/test.ts', watched: false } - ], - preprocessors: { - './src/test.ts': ['angular-cli'] - }, - mime: { - 'text/x-typescript': ['ts','tsx'] - }, - remapIstanbulReporter: { - reports: { - html: 'coverage', - lcovonly: './coverage/coverage.lcov' - } - }, - angularCli: { - config: './angular-cli.json', - environment: 'dev' - }, - reporters: config.angularCli && config.angularCli.codeCoverage - ? ['spec', 'karma-remap-istanbul'] - : ['spec'], - port: 9876, - colors: true, - logLevel: config.LOG_INFO, - autoWatch: true, - browsers: ['Chrome'], - singleRun: false - }); -}; diff --git a/project-manager/protractor-html-reporter.conf.js b/project-manager/protractor-html-reporter.conf.js deleted file mode 100644 index b9360f8..0000000 --- a/project-manager/protractor-html-reporter.conf.js +++ /dev/null @@ -1,52 +0,0 @@ -// Protractor configuration file, see link for more information -// https://github.com/angular/protractor/blob/master/docs/referenceConf.js - -/*global jasmine */ -var SpecReporter = require('jasmine-spec-reporter'); -//var ScreenshotProcessor = require('./e2e/helpers/screen_shot_reporter.ts'); -var HtmlScreenshotReporter = require('protractor-jasmine2-screenshot-reporter'); - -var reporter = new HtmlScreenshotReporter({ - dest: 'tmp/screenshots', - filename: 'test-report.html', - cleanDestination: true, - ignoreSkippedSpecs: true, - captureOnlyFailedSpecs: false -}); - - -exports.config = { - allScriptsTimeout: 11000, - specs: [ - './e2e/**/*.e2e-spec.ts' - ], - capabilities: { - 'browserName': 'firefox' - }, - directConnect: true, - baseUrl: 'http://localhost:4200/', - framework: 'jasmine', - jasmineNodeOpts: { - showColors: true, - defaultTimeoutInterval: 30000, - print: function() {} - }, - useAllAngular2AppRoots: true, - beforeLaunch: function() { - require('ts-node').register({ - project: 'e2e' - }); - return new Promise(function(resolve){ - reporter.beforeLaunch(resolve); - }); - }, - afterLaunch: function(exitCode) { - return new Promise(function(resolve){ - reporter.afterLaunch(resolve.bind(this, exitCode)); - }); - }, - onPrepare: function() { - jasmine.getEnv().addReporter(reporter); - jasmine.getEnv().addReporter(new SpecReporter()); - }, -}; \ No newline at end of file diff --git a/project-manager/protractor.conf.js b/project-manager/protractor.conf.js deleted file mode 100644 index ffded70..0000000 --- a/project-manager/protractor.conf.js +++ /dev/null @@ -1,32 +0,0 @@ -// 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'); - -exports.config = { - allScriptsTimeout: 11000, - specs: [ - './e2e/**/*.e2e-spec.ts' - ], - capabilities: { - 'browserName': 'chrome' - }, - directConnect: true, - baseUrl: 'http://localhost:4200/', - framework: 'jasmine', - jasmineNodeOpts: { - showColors: true, - defaultTimeoutInterval: 30000, - print: function() {} - }, - useAllAngular2AppRoots: true, - beforeLaunch: function() { - require('ts-node').register({ - project: 'e2e' - }); - }, - onPrepare: function() { - jasmine.getEnv().addReporter(new SpecReporter()); - } -}; diff --git a/project-manager/src/app/testing/test-helper.ts b/project-manager/src/app/testing/test-helper.ts deleted file mode 100644 index f5ac2fa..0000000 --- a/project-manager/src/app/testing/test-helper.ts +++ /dev/null @@ -1,11 +0,0 @@ -import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter'; - -export function dispatchEvent(element: any, eventType: any) { - getDOM().dispatchEvent(element, getDOM().createEvent(eventType)); -} - -export function setInputValue(input: any, value: any) { - input.value = value; - dispatchEvent(input, 'input'); - dispatchEvent(input, 'blur'); -} \ No newline at end of file diff --git a/project-manager/src/test.ts b/project-manager/src/test.ts deleted file mode 100644 index abce206..0000000 --- a/project-manager/src/test.ts +++ /dev/null @@ -1,34 +0,0 @@ -import './polyfills.ts'; - -import 'zone.js/dist/long-stack-trace-zone'; -import 'zone.js/dist/proxy.js'; -import 'zone.js/dist/sync-test'; -import 'zone.js/dist/jasmine-patch'; -import 'zone.js/dist/async-test'; -import 'zone.js/dist/fake-async-test'; -import { getTestBed } from '@angular/core/testing'; -import { - BrowserDynamicTestingModule, - platformBrowserDynamicTesting -} from '@angular/platform-browser-dynamic/testing'; -import 'rxjs/Rx'; - - -// Unfortunately there's no typing for the `__karma__` variable. Just declare it as any. -declare var __karma__: any; -declare var require: any; - -// Prevent Karma from running prematurely. -__karma__.loaded = function () {}; - -// First, initialize the Angular testing environment. -getTestBed().initTestEnvironment( - BrowserDynamicTestingModule, - platformBrowserDynamicTesting() -); -// Then we find all the tests. -const context = require.context('./', true, /\.spec\.ts$/); -// And load the modules. -context.keys().map(context); -// Finally, start Karma to run the tests. -__karma__.start();