e2e test scenario
authorDobrica Pavlinusic <dpavlin@rot13.org>
Mon, 21 Jan 2013 18:48:39 +0000 (19:48 +0100)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Mon, 21 Jan 2013 18:48:39 +0000 (19:48 +0100)
app/drzb2013.html.ep
app/partials/registration.html.ep
config/testacular-e2e.conf.js
test/e2e/scenarios.js

index 5c3a739..71913b3 100644 (file)
@@ -1,5 +1,6 @@
 <!doctype html>
-<html lang="<%= $lang %>" ng-app="myApp" xmlns:ng="http://angularjs.org">
+% my $test = param('test');
+<html lang="<%= $lang %>" ng-app="<%= $test ? 'testApp' : 'myApp' %>" xmlns:ng="http://angularjs.org">
 <head>
   <meta charset="utf-8">
   <title><%= locale
   <link rel="stylesheet" href="/css/app.css"/>
   <link rel="stylesheet" href="/css/drzb2013.css"/>
 
+       <!--[if IE 7]>
+               <script src="scripts/vendor/es5-shim.min.js"></script>
+               <script src="scripts/vendor/json3.min.js"></script>
+       <![endif]-->
+
     <!--[if lte IE 8]>
       <script>
         document.createElement('ng-include');
   <script src="/js/controllers.js"></script>
   <script src="/js/filters.js"></script>
   <script src="/js/directives.js"></script>
+
+% if ( $test ) {
+  <script src="/test/lib/angular/angular-mocks.js"></script>
+  <script type="text/javascript">
+// https://groups.google.com/forum/?fromgroups=#!searchin/angular/e2e$20mock|sort:date/angular/ObdxCoCObYU/KENkGVfIZYkJ
+
+angular.module('testApp', ['myApp', 'ngMockE2E' ]).
+       run(function ($httpBackend) {
+               console.log('mock $httpBackend', $httpBackend);
+               $httpBackend.whenGET(/partials\/.*/).passThrough();
+               $httpBackend.whenJSONP(/./).passThrough();
+               $httpBackend.whenGET(/registration/).passThrough();
+       }
+);
+
+// mock console for IE
+if(!window.console) {
+        window.console = new function() {
+                this.log = function(str) {};
+                this.info = function(str) {};
+                this.debug = function(str) {};
+        };
+}
+
+
+console.log('mock testApp');
+
+  </script>
+% }
+
 </body>
 </html>
index 8607e0b..e7b6a9a 100644 (file)
@@ -212,14 +212,14 @@ hr => 'Sažetak ({{abstract_length(work)}}  od maks. 2000 znakova s razmacima)'
 
 </fieldset><!-- has_work -->
 
-<div ng-show="user.registration_type == 'symposium'">
+<div ng-show="user.registration_type == 'symposium'" id="symposium-works">
 
 <h2><%= locale
 en=>'Submission of works for the symposium {{work.title}}',
 hr=>'Prijava radova unutar simpozija {{work.title}}' %>
 </h2>
 
-<div ng-repeat="work in work.symposium_works" class="control-row">
+<div ng-repeat="work in work.symposium_works" class="control-row work">
 
 <h3><%= locale
 en=>'{{$index + 1}}. symposium work',
@@ -241,14 +241,14 @@ hr => 'Dodaj još jedan rad na simpoziju' %>
 
 </div><!-- user.registration_type == 'symposium' -->
 
-<button class="controls-row btn btn-primary" ng-click="update(registration,'confirmation')" ng-show="RegistrationForm.$valid"><%= locale en=>'Submit',hr=>'Pošalji' %></button>
+<button class="controls-row btn btn-primary" id="update-registration" ng-click="update(registration,'confirmation')" ng-show="RegistrationForm.$valid"><%= locale en=>'Submit',hr=>'Pošalji' %></button>
 
 <p class="well" style="color: red" ng-show="! RegistrationForm.$valid">
 <%= locale
 en => 'Please fill all required fields correctly. Fields with red border call for your attention.',
 hr => 'Molimo ispunite sva obavezna polja označena crvenim okvirom.'
 %>
-<button class="controls-row btn btn-info" ng-click="update(registration,'draft')" ng-show="RegistrationForm.$dirty"><%= locale en=>'Save draft',hr=>'Spremi privremeno' %></button>
+<button class="controls-row btn btn-info" id="update-draft" ng-click="update(registration,'draft')" ng-show="RegistrationForm.$dirty"><%= locale en=>'Save draft',hr=>'Spremi privremeno' %></button>
 </p>
 
 <input style="float:right" title="validation errors" type=checkbox name=debug ng-click="debug = ! debug">
index 51f51d2..9b95552 100644 (file)
@@ -1,9 +1,10 @@
 basePath = '../';
 
 files = [
-  ANGULAR_SCENARIO,
-  ANGULAR_SCENARIO_ADAPTER,
-  'test/e2e/**/*.js'
+  JASMINE,
+  JASMINE_ADAPTER,
+  'test/lib/angular/angular-scenario.js',
+  'test/e2e/*.js'
 ];
 
 autoWatch = false;
@@ -13,7 +14,7 @@ browsers = ['Chrome'];
 singleRun = true;
 
 proxies = {
-  '/': 'http://localhost:8000/'
+  '/': 'http://localhost:3001/'
 };
 
 junitReporter = {
index 1b63871..731d2a5 100644 (file)
@@ -5,7 +5,7 @@
 describe('my app', function() {
 
   beforeEach(function() {
-    browser().navigateTo('/lang/en/drzb2013.html');
+    browser().navigateTo('/lang/en-dev/drzb2013.html?test=mock');
   });
 
 
@@ -17,7 +17,7 @@ describe('my app', function() {
   describe('registration', function() {
 
     beforeEach(function() {
-      browser().navigateTo('#/registration');
+       browser().navigateTo('#/registration');
     });
 
 
@@ -26,6 +26,29 @@ describe('my app', function() {
         toMatch(/Registration/);
     });
 
+    it('has warning box', function() {
+      expect(element('p.well').text()).toBeTruthy();
+    });
+
+    it('invalid form', function() {
+      expect(binding('RegistrationForm.$valid')).toEqual('false');
+    });
+
+       it('save draft button', function() {
+               expect(input('user.registration_type').select('symposium')).toBeDefined;
+               expect(binding('RegistrationForm.$valid')).toEqual('false');
+               expect(element('input#save-draft')).toBeDefined;
+       });
+
+       it('symposium has 4 works by default', function() {
+               input('user.registration_type').select('symposium');
+               input('user.firstname').enter('name');
+//             expect(element(':input[ng-model="user.registration_type"]').val()).toBe('symposium');
+               var r = using('div#symposium-works').repeater('div.work');
+               expect(r.count()).toBe(4);
+//             expect(r.row(0)).toEqual({});
+       });
+
   });