Permalink
Browse files

Uprava nastaveni e2e testu pro angular

  • Loading branch information...
1 parent b10de9e commit c5aabe72ff6d4ba9ff008ad4c17a4ed22907c387 @JakubMrozek committed Dec 5, 2012
Showing with 42 additions and 17 deletions.
  1. +7 −1 README.md
  2. +19 −7 app.js
  3. +5 −2 config.js
  4. +1 −1 grunt.js
  5. +5 −1 public/partials/layout.html
  6. +1 −1 scripts/e2e-test.bat
  7. +1 −1 scripts/e2e-test.sh
  8. +1 −0 test/frontend/apiary.js
  9. +1 −1 test/frontend/e2e/scenarios.js
  10. +1 −2 testacular-e2e.conf.js
View
@@ -9,9 +9,15 @@
* Spuštění e2e testů na Linuxu: node server.js + scripts/e2e-test.sh
* Generování dokumentace: dox-foundation --source ./ --target docs --ignore node_modules,docs,public,test --title "Zdrojak shop"
+12. díl
+=======
+* Článek: http://www.zdrojak.cz/clanky/angularjs-direktivy-a-testovani/
+* Demo: http://stormy-coast-2090.herokuapp.com/
+* Test runner: http://stormy-coast-2090.herokuapp.com/e2e/runner.html
+
11. díl
=======
-* Článek: http://www.zdrojak.cz/clanky/angularjs/
+* Článek: http://www.zdrojak.cz/clanky/zaciname-s-angularjs/
* Demo: http://peaceful-wildwood-1875.herokuapp.com/
10. díl
View
@@ -27,14 +27,26 @@ var PageController = require('./controllers/PageController');
app.resource('pages', PageController, {base: '/api/v1/'});
+/**
+ * Vyrenderuje layout.
+ *
+ * @param {ServerRequest} req
+ * @param {ServerResponse} res
+ */
+
+function render(req, res){
+ res.render('layout', {
+ env: app.settings.env
+ });
+}
+
+/**
+ * Nacteni layoutu a konkretni stranky az u klienta
+ */
-//TODO docasne reseni pro testy
-app.engine('.html', require('ejs').__express);
-app.set('view engine', 'html');
-app.set('views', __dirname + '/public');
-app.get('/pages*', function (req, res) {
- res.render('index', {});
-});
+app.get('/', render);
+app.get('/pages', render);
+app.get('/pages/*', render);
module.exports = app;
View
@@ -14,11 +14,12 @@ var mongoose = require('mongoose');
exports.configure = function(app) {
app.configure(function(){
+ app.engine('.html', require('ejs').__express);
+ app.set('view engine', 'html');
+ app.set('views', __dirname + '/public/partials');
app.use(express.bodyParser());
app.use(express.methodOverride());
app.use(express.static(process.cwd() + '/public'));
- //pouze pro demo
- app.use(express.static(process.cwd() + '/test/frontend'));
app.use(express.favicon());
app.use(require('./middleware/http406')());
app.use(require('./middleware/http415')());
@@ -28,12 +29,14 @@ exports.configure = function(app) {
});
app.configure('development', function(){
app.set('db uri', 'mongodb://localhost/zdrojak');
+ app.use(express.static(process.cwd() + '/test/frontend'));
});
app.configure('production', function(){
app.set('db uri', 'mongodb://user:pass@host:port/dbname');
});
app.configure('test', function(){
app.set('db uri', 'mongodb://localhost/zdrojaktest');
+ app.use(express.static(process.cwd() + '/test/frontend'));
});
};
View
@@ -28,7 +28,7 @@ module.exports = function (grunt) {
var content = grunt.file.read('apiary.apib');
var blueprint = parser.parse(content);
var json = JSON.stringify(blueprint.sections);
- grunt.file.write('public/js/apiary.js', "var apiary = " + json);
+ grunt.file.write('test/frontend/apiary.js', "var apiary = " + json);
});
};
@@ -38,8 +38,12 @@
<script src="/lib/angular/angular-resource.js"></script>
<!-- todo -->
+ <% if (env === 'development' || env === 'test') { %>
+
<script src="/lib/angular/angular-mocks.js"></script>
- <script src="/js/apiary.js"></script>
+ <script src="/apiary.js"></script>
+
+ <% } %>
<!-- /todo -->
</body>
@@ -8,4 +8,4 @@ REM - NodeJS (http://nodejs.org/)
REM - Testacular (npm install -g testacular)
set BASE_DIR=%~dp0
-testacular start "%BASE_DIR%\..\testacular-e2e.conf.js" %*
+grunt apiary2js && testacular start "%BASE_DIR%\..\testacular-e2e.conf.js" %*
View
@@ -6,4 +6,4 @@ echo ""
echo "Starting Testacular Server (http://vojtajina.github.com/testacular)"
echo "-------------------------------------------------------------------"
-testacular start $BASE_DIR/../testacular-e2e.conf.js $*
+grunt apiary2js && testacular start $BASE_DIR/../testacular-e2e.conf.js $*
@@ -0,0 +1 @@
+var apiary = [{"name":"Stranky","description":"","resources":[{"description":"Vrácení seznamu všech stránek.","method":"GET","url":"/pages","request":{"headers":{},"body":""},"responses":[{"status":200,"headers":{"Content-Type":"application/json"},"body":"[\n{\"id\":\"5098eaef0496600200000001\",\n\"content\":\"Lorem ipsum set dolorem\",\n\"title\":\"Kontakt\",\n\"url\":\"kontakt\"},\n{\"id\":\"5098eaef0496600200000002\",\n\"content\":\"Lorem ipsum set dolorem\",\n\"title\":\"Obchodní podmínky\",\n\"url\":\"obchodni-podminky\"},\n{\"id\":\"5098eaef0496600200000003\",\n\"content\":\"Lorem ipsum set dolorem\",\n\"title\":\"Doprava a platba\",\n\"url\":\"doprava a platba\"}\n]"}]},{"description":"Zobrazení detailu jedné stránky.","method":"GET","url":"/pages/{id}","request":{"headers":{},"body":""},"responses":[{"status":200,"headers":{"Content-Type":"application/json"},"body":"{\"id\":\"5098eaef0496600200000001\",\n\"content\":\"Lorem ipsum set dolorem\",\n\"title\":\"Kontakt\",\n\"url\":\"kontakt\"}"}]},{"description":"Vložení nové stránky do databáze.","method":"POST","url":"/pages","request":{"headers":{"Content-Type":"application/json"},"body":"{\"content\":\"Lorem ipsum set dolorem\", \"title\":\"Nákupní řád\"}"},"responses":[{"status":201,"headers":{"Location":"//api/v1/pages/nakupni-rad"},"body":""}]},{"description":"Editace jedné stránky v databázi.","method":"PUT","url":"/pages/{id}","request":{"headers":{"Content-Type":"application/json"},"body":"{\"content\":\"Lorem ipsum set dolorem\", \n\"title\":\"Nákupní řád e-shopu\"}"},"responses":[{"status":200,"headers":{"Content-Type":"application/json"},"body":"{\"content\":\"Lorem ipsum set dolorem\",\n\"title\":\"Nákupní řád e-shopu\"}"}]},{"description":"Smazání stránky z databáze.","method":"DELETE","url":"/pages/{id}","request":{"headers":{},"body":""},"responses":[{"status":204,"headers":{},"body":""}]}]}]
@@ -42,7 +42,7 @@ describe('zdrojak', function() {
expect(spanElm.css('display')).toBe('none');
expect(inputElm.css('display')).not().toBe('none');
- input('value').enter('test');
+ input('model').enter('test');
expect(h1Elm.text()).toBe('test');
@@ -1,5 +1,3 @@
-basePath = './';
-
files = [
ANGULAR_SCENARIO,
ANGULAR_SCENARIO_ADAPTER,
@@ -10,6 +8,7 @@ proxies = {
'/': 'http://localhost:5000/'
};
+
autoWatch = false;
browsers = ['Chrome'];

0 comments on commit c5aabe7

Please sign in to comment.