Skip to content

Commit

Permalink
Going to setup a staging server
Browse files Browse the repository at this point in the history
  • Loading branch information
alnutile committed Mar 13, 2014
1 parent 4bc9716 commit d9d9274
Show file tree
Hide file tree
Showing 10 changed files with 182 additions and 42 deletions.
1 change: 1 addition & 0 deletions app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
<script src="lib/angular/angular-route.js"></script>
<script src="lib/angular/angular-sanitize.js"></script>
<script src="lib/angular/angular-resource.js"></script>
<script src="lib/angular/angular-animate.js"></script>
<script src="lib/angular/angular-mocks.js"></script>

<script src="js/app_dev.js"></script>
Expand Down
1 change: 1 addition & 0 deletions app/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ var app = angular.module('behatEditor', [
'ngRoute',
'ui.ace',
'ngSanitize',
'ngAnimate',
'ui.bootstrap',
'sitesServices',
'testsServices',
Expand Down
2 changes: 2 additions & 0 deletions app/js/app_dev.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

43 changes: 39 additions & 4 deletions app/js/controllers/testsController.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ testsController.controller('TestEditController', ['$scope', '$http', '$location'
function($scope, $http, $location, $route, $routeParams, SitesServices, TestsServices, BehatServices, addAlert, runTest, closeAlert){

$scope.steps = {}
$scope.form_tags = {}
$scope.steps.default = "Your Step Here..."

$scope.alerts = [];
Expand Down Expand Up @@ -66,6 +67,18 @@ testsController.controller('TestEditController', ['$scope', '$http', '$location'
addAlert('info', 'Test Saved..', $scope);
}

$scope.addTag = function(tags) {
var text = $scope.test_content.split("\n");
if(text[0].indexOf('@') != -1) {
console.log('found a tag');
var tags = text[0] + " " + tags;
text[0] = tags;
$scope.test_content = text.join("\n");
} else {
$scope.test_content = tags + "\n" + $scope.test_content;
}
}

$scope.addStep = function(step) {
var build = [];
var count = 1;
Expand All @@ -78,12 +91,13 @@ testsController.controller('TestEditController', ['$scope', '$http', '$location'
output = v;
}
}

if(count === 1) {
if(v.indexOf('Feature:') === -1) {
if(v.indexOf('Scenario:') === -1 || v.indexOf('Background:') === -1) {
output = ' ' + output;
} else {
if(k === 'feature') {
if(k === 'background' || k === 'scenario') {
output = ' ' + output;
} else {
output = ' ' + output;
}
}
}
Expand All @@ -105,6 +119,27 @@ testsController.controller('TestEditController', ['$scope', '$http', '$location'
_session.setUndoManager(new ace.UndoManager());
_renderer.setShowGutter(true);
}

$scope.search = '';

$scope.searchForms = function(search) {
$scope.search = search;
}

$scope.showForm = function(form_tags_form) {
if($scope.search !== '') {


if(form_tags_form.indexOf($scope.search.search) !== -1) {
return true;
} else {
return false;
}

} else {
return true;
}
}
}]);

testsController.controller('TestNewController', ['$scope', '$http', '$location', '$route', '$routeParams', 'SitesServices', 'TestsServices',
Expand Down
5 changes: 1 addition & 4 deletions app/templates/dash.html
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ <h3 class="panel-title">
<tbody>
<tr ng-repeat="site in sites">
<td>{{ site.title }}</td>
<td><a href="#/sites/{{ site.nid }}">view</a></td>
<td><a id="site-{{ site.nid }}" href="#/sites/{{ site.nid }}">view</a></td>
</tr>
</tbody>
</table>
Expand Down Expand Up @@ -111,9 +111,6 @@ <h3 class="panel-title">
</h3>
</div>
<div class="panel-body">
<div>
<button type="button" class="btn btn-small btn-default">Create new Test</button>
</div>
<br>
<div>
<button type="button" class="btn btn-small btn-info">Batch Tests</button>
Expand Down
6 changes: 3 additions & 3 deletions app/templates/site-show.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ <h3 class="panel-title">
<td>?</td>
<td>{{ test.name }}</td>
<td>?</td>
<td><a href="#/sites/{{ site.nid }}/tests/{{ test.name_dashed }}">view</a></td>
<td><a href="#/sites/{{ site.nid }}/tests/{{ test.name_dashed }}/edit">edit</a></td>
<td><a id="site-view-{{ site.nid }}" href="#/sites/{{ site.nid }}/tests/{{ test.name_dashed }}">view</a></td>
<td><a id="site-edit-{{ site.nid }}" href="#/sites/{{ site.nid }}/tests/{{ test.name_dashed }}/edit">edit</a></td>
</tr>
</tbody>
</table>
Expand All @@ -34,7 +34,7 @@ <h3 class="panel-title">
<div class="col-md-4 column">
<div class="panel panel-default">
<div class="panel-body">
<a href="#/sites/{{ site.nid }}/tests/new" class="btn btn-success">Create New Test</a>
<a id="create-test" href="#/sites/{{ site.nid }}/tests/new" class="btn btn-success">Create New Test</a>
</div>
<div class="panel-heading">
<h3 class="panel-title">
Expand Down
41 changes: 33 additions & 8 deletions app/templates/test-edit.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,38 @@ <h3>
<div class="col-md-6 column">
<tabset vertical="true" type="navType" clas="test-nav">
<tab heading="Test Details">
Details to the right...
<button type="button" class="btn btn-danger" ng-click="saveTest(test_content)">save test</button>
<form role="form" name="testDetails" ng-submit="addTag(steps.testDetails.tag)">
<div class="form-group">
<input id="tag-input" class="form-control" name="testDetailsTag" ng-model="steps.testDetails.tag" type="text" placeholder="choose a tag">
<br>
<input id="add-details" class="form-control btn btn-success" type="submit" value="Add">
<br>
</div>
</form>

<form role="form" name="backgrounds" ng-submit="addStep(steps.back)">
<div class="form-group">
<input class="form-control" name="backGround" ng-model="steps.back.background" type="text" value="" ng-required="true" placeholder="add a bacgkround. see help for more details">
<br>
<input class="form-control btn btn-success" type="submit" value="Add">
<div class="help-block" ng-model="steps.back.final"> {{ steps.back.background }}</div>
<br>
<br>
<button type="button" class="btn btn-danger" ng-click="saveTest(test_content)">save test</button>
</div>
</form>

</tab>
<tab heading="Scenarios and steps">
<input ng-model="search" ng-change="searchForms(this)" type="text" placeholder="search for steps">

<form role="form" name="cfpForm" ng-submit="addStep(steps.cfp)">

<h5>Radio buttons and checkboxes</h5>
<hr>
<form role="form" name="cfpForm" ng-submit="addStep(steps.cfp)" ng-model="form_tags.cfp" ng-init="form_tags.cfp='Click Press Follow Link'" ng-show="showForm(form_tags.cfp)" class="ng-hide animate-hide">
<div class="form-group">
<div ng-hide="true" ng-model="steps.cfp.intro" ng-init="steps.cfp.intro='And I'"></div>
<label>And I</label>
<h6>And I</h6>
<select class="form-control" name="cfpAction" ng-model="steps.cfp.action" ng-required="true" ng-init="steps.cfp.action='follow'">
<option value="follow">follow</option>
<option value="press">press</option>
Expand All @@ -49,22 +72,24 @@ <h3>
<option value="the xpath">xpath</option>
</select>
<!--by add arg_1 or arg_2 etc to the model item name we will add quotes around it -->
<input class="form-control" name="cfpTarget" ng-model="steps.cfp.arg_1" type="textarea" value="" ng-required="true" placeholder="enter the target either a css path or name|label|id">
<input class="form-control" name="cfpTarget" ng-model="steps.cfp.arg_1" type="textarea" value="" ng-required="true" ng-init="steps.cfp.arg_1='some text'" placeholder="enter the target either a css path or name|label|id">
<br>
<input class="form-control btn btn-success" type="submit" value="Add">
<div class="help-block" ng-model="steps.cfp.final"> {{ steps.cfp.intro }} {{ steps.cfp.action }} {{ steps.cfp.type }} "{{ steps.cfp.target }}" </div>
<div class="help-block" ng-model="steps.cfp.final"> {{ steps.cfp.intro }} {{ steps.cfp.action }} {{ steps.cfp.type }} "{{ steps.cfp.arg_1 }}" </div>
</div>
</form>
<hr>
<form role="form" name="seeForm" ng-submit="addStep(steps.seeForm)">
<form role="form" name="seeForm" ng-submit="addStep(steps.seeForm)" ng-model="form_tags.see" ng-init="form_tags.see='See on page'" ng-show="showForm(form_tags.see)" class="ng-hide animate-hide">
<div class="form-group">
<div ng-hide="true" ng-model="steps.seeForm.intro" ng-init="steps.seeForm.intro='Then I should'"></div>
<label>Then I should</label>
<h6>Then I should</h6>
<select class="form-control" name="seeFormAction" ng-model="steps.seeForm.action" ng-required="true" ng-init="steps.seeForm.action='see'">
<option value="see">see</option>
<option value="not see">not see</option>
</select>
<!--by add arg_1 or arg_2 etc to the model item name we will add quotes around it -->
<input class="form-control" name="seeFormTarget" ng-model="steps.seeForm.arg_1" type="textarea" value="" ng-required="true" ng-init="steps.seeForm.arg_1='some text'" placeholder="some text on the page">
<br>
<input class="form-control btn btn-success" type="submit" value="Add">
<div class="help-block" ng-model="steps.seeForm.final"> {{ steps.seeForm.intro }} {{ steps.seeForm.action }} {{ steps.seeForm.type }} "{{ steps.seeForm.arg_1 }}" </div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion app/templates/test-show.html
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ <h3 class="panel-title">
</h3>
</div>
<div class="panel-body">
<button type="button" class="btn btn-danger" data-ng-click="runTest()">run</button>
<button id="run-test" type="button" class="btn btn-danger" data-ng-click="runTest()">run</button>
</div>
<div class="panel-footer">
Panel footer
Expand Down
1 change: 0 additions & 1 deletion scripts/e2e-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ echo "-------------------------------------------------------------------"

/usr/local/bin/webdriver-manager update


echo ""
echo "Starting Protractor tests"
echo $BASE_DIR
Expand Down
122 changes: 101 additions & 21 deletions test/e2e/scenarios.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,41 +2,121 @@

/* https://github.com/angular/protractor/blob/master/docs/getting-started.md */

describe('my app', function() {
describe('behatEditor', function() {

browser.get('index.html');

it('should automatically redirect to /view1 when location hash/fragment is empty', function() {
expect(browser.getLocationAbsUrl()).toMatch("/view1");
});

describe('Sites all page or the Dashboard', function(){
it('sites page it should see site 2 mock', function(){
var sites = element(by.repeater('site in sites').row(1));
expect(sites.getText()).toEqual('Test 2 working mock view');
});

it('clicking site 2 should bring me to the site\'s page', function(){
var button = element(by.css('a#site-2'));
button.click();
expect(browser.getLocationAbsUrl()).toMatch("/sites/2");
});
});

describe('view1', function() {
describe('Site page and it\'s list of tests', function(){
beforeEach(function() {
browser.get('index.html#/sites/2');
});

it('sites page it should see site 2 mock', function(){
var sites = element(by.repeater('test in site.testFiles').row(1));
expect(sites.getText()).toEqual('? test2.feature ? view edit');
});

//browser.debugger();
it('click create test should take me there', function(){
var button = element(by.css('a#create-test'));
button.click();
expect(browser.getLocationAbsUrl()).toMatch("/sites/2/tests/new");
});

it('click edit test should take me there', function(){
var button = element(by.css('a#site-edit-2'));
button.click();
expect(browser.getLocationAbsUrl()).toMatch("http://localhost:8000/app/index.html#/sites/2/tests/test1_feature/edit");
});

it('click view test should take me there', function(){
var button = element(by.css('a#site-view-2'));
button.click();
expect(browser.getLocationAbsUrl()).toMatch("http://localhost:8000/app/index.html#/sites/2/tests/test1_feature");
});

beforeEach(function() {
browser.get('index.html#/view1');
});

describe('Test View should allow me to run the test', function(){
beforeEach(function() {
browser.get('index.html#/sites/2/tests/test2_feature');
});

it('click run to run a test should see results and alert', function(){
var button = element(by.css('button#run-test'));
button.click();
var alerts = element(by.repeater('alert in alerts').row(1));
expect(alerts.getText()).toContain("Test Completed...");

var alerts = element(by.repeater('alert in alerts').row(0));
expect(alerts.getText()).toContain("Running test...");
});

it('should render view1 when user navigates to /view1', function() {
expect(element.all(by.css('[ng-view] p')).first().getText()).
toMatch(/partial for view 1/);
});

});
describe('Test Edit should allow me to do a lot', function(){
beforeEach(function() {
browser.get('index.html#/sites/2/tests/test2_feature/edit');
});

it('should see tags', function(){
browser.browser.ignoreSynchronization = true;
element(by.model('steps.testDetails.tag')).sendKeys('@tag');

describe('view2', function() {
var button = element(by.css('button#add-details'));
button.click();

beforeEach(function() {
browser.get('index.html#/view2');
});
var test_content = element(by.model('test_content'));
browser.debugger();

expect(test_content).toContain('@tag');
});

it('should render view2 when user navigates to /view2', function() {
expect(element.all(by.css('[ng-view] p')).first().getText()).
toMatch(/partial for view 2/);
});

});
// it('It should show the dash', function() {
// expect(element.(by.repeater('site in sites').row(3).column(1))).
// toMatch(/Test 2 working mock/);
// });

// describe('view1', function() {
//
// beforeEach(function() {
// browser.get('index.html#/view1');
// });
//
//
// it('should render view1 when user navigates to /view1', function() {
// expect(element.all(by.css('[ng-view] p')).first().getText()).
// toMatch(/partial for view 1/);
// });
//
// });
//
//
// describe('view2', function() {
//
// beforeEach(function() {
// browser.get('index.html#/view2');
// });
//
//
// it('should render view2 when user navigates to /view2', function() {
// expect(element.all(by.css('[ng-view] p')).first().getText()).
// toMatch(/partial for view 2/);
// });
//
// });
});

0 comments on commit d9d9274

Please sign in to comment.