-
Notifications
You must be signed in to change notification settings - Fork 267
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
06dd286
commit ec704fa
Showing
22 changed files
with
1,237 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
node_modules | ||
/tmp/ | ||
/cucumber/ | ||
/npm-debug.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
var express = require("express"); | ||
|
||
var app = express(); | ||
app.use('/', express.static(__dirname + '/')); | ||
|
||
app.listen(8080, function(){ | ||
console.log('Running app on port 8080'); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
<!doctype html> | ||
<html lang="en" data-framework="angularjs"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>AngularJS • TodoMVC</title> | ||
<link rel="stylesheet" href="node_modules/todomvc-common/base.css"> | ||
<link rel="stylesheet" href="node_modules/todomvc-app-css/index.css"> | ||
<style>[ng-cloak] { display: none; }</style> | ||
</head> | ||
<body ng-app="todomvc"> | ||
<ng-view></ng-view> | ||
|
||
<script type="text/ng-template" id="todomvc-index.html"> | ||
<section class="todoapp"> | ||
<header class="header"> | ||
<h1>todos</h1> | ||
<form class="todo-form" ng-submit="addTodo()"> | ||
<input class="new-todo" placeholder="What needs to be done?" ng-model="newTodo" ng-disabled="saving" autofocus> | ||
</form> | ||
</header> | ||
<section class="main" ng-show="todos.length" ng-cloak> | ||
<input id="toggle-all" class="toggle-all" type="checkbox" ng-model="allChecked" ng-click="markAll(allChecked)"> | ||
<label for="toggle-all">Mark all as complete</label> | ||
<ul class="todo-list"> | ||
<li ng-repeat="todo in todos | filter:statusFilter track by $index" ng-class="{completed: todo.completed, editing: todo == editedTodo}"> | ||
<div class="view"> | ||
<input class="toggle" type="checkbox" ng-model="todo.completed" ng-change="toggleCompleted(todo)"> | ||
<label ng-dblclick="editTodo(todo)">{{todo.title}}</label> | ||
<button class="destroy" ng-click="removeTodo(todo)"></button> | ||
</div> | ||
<form ng-submit="saveEdits(todo, 'submit')"> | ||
<input class="edit" ng-trim="false" ng-model="todo.title" todo-escape="revertEdits(todo)" ng-blur="saveEdits(todo, 'blur')" todo-focus="todo == editedTodo"> | ||
</form> | ||
</li> | ||
</ul> | ||
</section> | ||
<footer class="footer" ng-show="todos.length" ng-cloak> | ||
<span class="todo-count"><strong>{{remainingCount}}</strong> | ||
<ng-pluralize count="remainingCount" when="{ one: 'item left', other: 'items left' }"></ng-pluralize> | ||
</span> | ||
<ul class="filters"> | ||
<li> | ||
<a ng-class="{selected: status == ''} " href="#/">All</a> | ||
</li> | ||
<li> | ||
<a ng-class="{selected: status == 'active'}" href="#/active">Active</a> | ||
</li> | ||
<li> | ||
<a ng-class="{selected: status == 'completed'}" href="#/completed">Completed</a> | ||
</li> | ||
</ul> | ||
<button class="clear-completed" ng-click="clearCompletedTodos()" ng-show="completedCount">Clear completed</button> | ||
</footer> | ||
</section> | ||
<footer class="info"> | ||
<p>Double-click to edit a todo</p> | ||
<p>Credits: | ||
<a href="http://twitter.com/cburgdorf">Christoph Burgdorf</a>, | ||
<a href="http://ericbidelman.com">Eric Bidelman</a>, | ||
<a href="http://jacobmumm.com">Jacob Mumm</a> and | ||
<a href="http://blog.igorminar.com">Igor Minar</a> | ||
</p> | ||
<p>Part of <a href="http://todomvc.com">TodoMVC</a></p> | ||
</footer> | ||
</script> | ||
<script src="node_modules/todomvc-common/base.js"></script> | ||
<script src="node_modules/angular/angular.js"></script> | ||
<script src="node_modules/angular-route/angular-route.js"></script> | ||
<script src="node_modules/angular-resource/angular-resource.js"></script> | ||
<script src="js/app.js"></script> | ||
<script src="js/controllers/todoCtrl.js"></script> | ||
<script src="js/services/todoStorage.js"></script> | ||
<script src="js/directives/todoFocus.js"></script> | ||
<script src="js/directives/todoEscape.js"></script> | ||
</body> | ||
</html> |
202 changes: 202 additions & 0 deletions
202
cucumber-selenium-grid/angularjs/integration-tests/features/step-definitions/todo.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,202 @@ | ||
/** | ||
* Step definitions. | ||
*/ | ||
'use strict'; | ||
|
||
// Require and configure the assertion libraries. | ||
var chai = require('chai'); | ||
var chaiAsPromised = require('chai-as-promised'); // https://github.com/domenic/chai-as-promised/ | ||
chai.use(chaiAsPromised); | ||
|
||
// Convenience. | ||
var expect = chai.expect; | ||
var _ = require('underscore'); | ||
const { setWorldConstructor } = require('cucumber') | ||
|
||
var CustomWorld = function({attach, parameters}) { | ||
this.attach = attach | ||
this.parameters = parameters | ||
}; | ||
|
||
CustomWorld.prototype.clearLocalStorage = function () { | ||
browser.executeScript('localStorage.clear();'); | ||
}; | ||
|
||
CustomWorld.prototype.flattenTable = function (table) { | ||
// Array of arrays e.g. | ||
// [ [ 'First todo' ], [ 'Second todo' ] ] | ||
table = table.raw(); | ||
|
||
// Flatten array | ||
// [ 'First todo', 'Second todo' ] | ||
return _.flatten(table); | ||
}; | ||
|
||
setWorldConstructor(CustomWorld); | ||
|
||
const { Given, When, Then, After, Before, Status } = require('cucumber'); | ||
|
||
//Require page objects. | ||
var homePage = require('../../page-objects/home-page'); | ||
|
||
Before('@home', function () { | ||
var world = this; | ||
|
||
// Load the homepage. | ||
homePage.get(); | ||
//browser.get(''); | ||
|
||
// Clear localStorage. | ||
world.clearLocalStorage(); | ||
|
||
// Reload the page with empty localStorage. | ||
homePage.get(); | ||
//browser.get(''); | ||
|
||
}); | ||
|
||
After(function (testCase) { | ||
var world = this; | ||
if (testCase.result.status === Status.FAILED) { | ||
return browser.takeScreenshot().then(function(screenShot) { | ||
// screenShot is a base-64 encoded PNG | ||
world.attach(screenShot, 'image/png'); | ||
}); | ||
} | ||
}); | ||
|
||
Given(/^I am on the app home page\.?$/, function (done) { | ||
var expectedTitle = 'AngularJS • TodoMVC'; | ||
|
||
// The page loading is async so we need an async expectation | ||
// and an async 'done'. | ||
|
||
expect(homePage.getPageTitle()) | ||
.to.eventually.equal(expectedTitle) | ||
.notify(done); | ||
}); | ||
|
||
|
||
When(/^I add a todo called "([^"]*)"\.?$/, addTodoText); | ||
|
||
|
||
When(/^I add the todos\.?$/, addTodoText); | ||
|
||
|
||
// Use a data table. API here | ||
// https://github.com/cucumber/cucumber-js/blob/master/lib/cucumber/ast/data_table.js | ||
When(/^I add multiple todos:$/, function (table, done) { | ||
var world = this; | ||
|
||
table = world.flattenTable(table); | ||
|
||
table.forEach(function (todoText) { | ||
homePage.createTodo(todoText); | ||
}); | ||
|
||
world.expectedNumberOfTodos = table.length; | ||
|
||
done(); | ||
}); | ||
|
||
|
||
// Deliberately pending step. | ||
// When(/^Something is done\.$/, function (done) { | ||
// Write code here that turns the phrase above into concrete actions | ||
// done.pending(); | ||
// }); | ||
|
||
|
||
Then(/^I should see it added to the todo list\.?$/, function (done) { | ||
checkFirstTodoText(this.expectedTodoText, done); | ||
}); | ||
|
||
|
||
Then(/^I should see a todo called "([^"]*)"\.?$/, function (expectedTodoText, done) { | ||
checkFirstTodoText(expectedTodoText, done); | ||
}); | ||
|
||
|
||
|
||
Then(/^I should see them added to the todo list\.$/, function (done) { | ||
var world = this; | ||
|
||
// Split the expected text string on new line to | ||
// allow comparison to the array of todos taken | ||
// from the UI. | ||
var expectedTodoTextArray = world.expectedTodoText.split(/\r?\n/); | ||
|
||
// Use Chai deep equal to compare arrays. | ||
homePage.getAllTodoText() | ||
.then(function(todoTextArray) { | ||
expect(todoTextArray).to.deep.equal(expectedTodoTextArray); | ||
done(); | ||
}); | ||
}); | ||
|
||
|
||
Then(/^there should be that number of todos in the list\.?$/, function (done) { | ||
var world = this; | ||
checkNumberOfTodos(world.expectedNumberOfTodos, done); | ||
}); | ||
|
||
|
||
Then(/^it should (.*) in the list\.$/, function (appearOrNot, done) { | ||
var expectedNumberOfTodos = (appearOrNot === 'appear') ? 1 : 0; | ||
checkNumberOfTodos(expectedNumberOfTodos, done); | ||
}); | ||
|
||
|
||
// Then(/^there should be a measurable result\.$/, function (done) { | ||
// Write code here that turns the phrase above into concrete actions | ||
// done.pending(); | ||
//}); | ||
|
||
|
||
|
||
|
||
/* Helper functions */ | ||
|
||
|
||
function checkFirstTodoText(expectedTodoText, done) { | ||
// The underlying getText method and and all Protractor DOM | ||
// action methods (i.e. actions on 'elelement' objects) are | ||
// asynchronous, because they wait for the Angular digest | ||
// loop to settle down, and return promises. | ||
// Here the promise is handled explicitly in the check. | ||
homePage.getFirstTodoText() | ||
.then(function(todoText) { | ||
try { | ||
expect(todoText).to.equal(expectedTodoText); | ||
done(); | ||
} | ||
catch(err){ | ||
done(err); | ||
} | ||
|
||
}); | ||
} | ||
|
||
function checkNumberOfTodos(expectedNumberOfTodos, done) { | ||
// If using Chai-as-promised then promises for values can also | ||
// be checked against using the 'eventually' property. Note | ||
// the call to 'notify' with the Cucumber callback as an | ||
// argument in order to signal step completion. | ||
expect(homePage.getNumberOfTodos()) | ||
.to.eventually | ||
.equal(expectedNumberOfTodos) | ||
.notify(done); | ||
} | ||
|
||
function addTodoText(todoText, done) { | ||
// Share state on the world object. Could also have done this with a closure. | ||
/*jshint validthis:true */ | ||
var world = this; | ||
world.expectedTodoText = todoText; | ||
|
||
homePage.createTodo(todoText); | ||
done(); | ||
} | ||
|
||
|
||
|
67 changes: 67 additions & 0 deletions
67
cucumber-selenium-grid/angularjs/integration-tests/features/todo.feature
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
# Example feature, the description is using feature injection syntax. | ||
Feature: Todo list | ||
As a user of the todo list | ||
I want to be able to add and read todos | ||
So that I can remember what I am supposed to do later | ||
|
||
|
||
@home @smoke | ||
Scenario: Adding a todo | ||
Given I am on the app home page. | ||
When I add a todo called "hello world". | ||
Then I should see it added to the todo list. | ||
|
||
|
||
# NB if you are comparing blocks of text beware of the file encoding | ||
# UTF-8 and Unix line-endings are recommended. | ||
@home @block-string | ||
Scenario: Adding multiple todos in a block string | ||
Given I am on the app home page. | ||
When I add the todos | ||
""" | ||
First todo | ||
Second todo | ||
Third todo | ||
""" | ||
Then I should see them added to the todo list. | ||
|
||
|
||
# Data table. | ||
# Data tables: https://www.relishapp.com/cucumber/cucumber-js/docs/cucumber-tck/data-tables | ||
@home @regression @data-table | ||
Scenario: Adding multiple todos in a data table | ||
Given I am on the app home page. | ||
When I add multiple todos: | ||
| First todo | | ||
| Second todo | | ||
Then there should be that number of todos in the list. | ||
|
||
|
||
|
||
# Scenario outline. | ||
# Scenario outlines: supported https://github.com/cucumber/cucumber-js/commit/c2a9916810a224d77c6b7e94260c39bb867aee5b | ||
@home @outline | ||
Scenario Outline: Edge case todos | ||
Given I am on the app home page. | ||
When I add a todo called "<todo text>". | ||
Then it should <appear or not> in the list. | ||
|
||
Examples: | ||
| todo text | appear or not | | ||
| howdy | appear | | ||
| | not appear | | ||
|
||
|
||
# Senario with a pending step. | ||
@home @somePendingTest | ||
Scenario: Anther great scenario | ||
Given I am on the app home page. | ||
When Something is done. | ||
Then there should be a measurable result. | ||
|
||
# Senario with a failing step. | ||
@home @someFailingTest | ||
Scenario: Yet anther great scenario | ||
Given I am on the app home page. | ||
When I add a todo called "expected to fail". | ||
Then I should see a todo called "something totally different". |
1 change: 1 addition & 0 deletions
1
cucumber-selenium-grid/angularjs/integration-tests/page-objects/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Note: this directory is not in the features directory in order to avoid it being parsed by Cucumber as it looks for step definitions and hooks etc. |
Oops, something went wrong.