Skip to content

Commit

Permalink
Fix e2e tests and remove json_server requirement for them
Browse files Browse the repository at this point in the history
  • Loading branch information
jeromemacias committed Aug 27, 2015
1 parent f35168b commit 0a835a4
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 15 deletions.
16 changes: 12 additions & 4 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,17 @@ module.exports = function (grunt) {
dest: 'src/javascripts/test/fixtures/',
options: {
process: function(content) {
return content.replace(/http\:\/\/localhost\:8080\//g, '/');
return content.replace(/http\:\/\/localhost\:8000\//g, '/');
}
}
},
test_fakerest: {
src: 'node_modules/fakerest/dist/FakeRest.min.js',
dest: 'src/javascripts/test/fixtures/examples/blog/build/fakerest.js'
},
test_sinon_server: {
src: 'node_modules/sinon/pkg/sinon-server-1.14.1.js',
dest: 'src/javascripts/test/fixtures/examples/blog/build/sinon-server.js'
}
},
connect: {
Expand All @@ -31,7 +39,7 @@ module.exports = function (grunt) {
},
test: {
options: {
port: 8000,
port: 8001,
base: 'src/javascripts/test/fixtures/examples/blog/',
keepalive: false,
livereload: false
Expand Down Expand Up @@ -77,10 +85,10 @@ module.exports = function (grunt) {

grunt.registerTask('test', ['karma', 'test:e2e']);
grunt.registerTask('test:e2e', ['test:e2e:prepare', 'json_server', 'connect:test', 'protractor']);
grunt.registerTask('test:e2e:prepare', ['exec:webpack', 'copy:test_sample_app', 'copy:test_build']);
grunt.registerTask('test:e2e:prepare', ['exec:webpack', 'copy:test_sample_app', 'copy:test_build', 'copy:test_fakerest', 'copy:test_sinon_server']);

grunt.registerTask('test:local', ['karma', 'test:local:e2e']);
grunt.registerTask('test:local:e2e', ['test:e2e:prepare', 'json_server', 'connect:test', 'protractor']);
grunt.registerTask('test:local:e2e', ['test:e2e:prepare', 'connect:test', 'protractor']);

grunt.registerTask('default', ['json_server', 'connect:dev', 'exec:webpack_watch']);
};
11 changes: 11 additions & 0 deletions examples/blog/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,17 @@
return { params: params };
});

RestangularProvider.addResponseInterceptor(function(data, operation, what, url, response, deferred) {
if (operation === "getList") {
var headers = response.headers();
if (headers['content-range']) {
response.totalCount = headers['content-range'].split('/').pop();
}
}

return data;
});

var admin = nga.application('ng-admin backend demo') // application main title
.debug(false) // debug disabled
.baseApiUrl('http://localhost:3000/'); // main API endpoint
Expand Down
12 changes: 7 additions & 5 deletions src/javascripts/test/e2e/EditionViewSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ describe('EditionView', function () {
return $$('button[type="submit"]').first().click();
})
.then(function() {
return browser.get(browser.baseUrl + '#/comments/list');
return $$('#page-wrapper .btn-default').first().click();
})
.then(function() {
return browser.get(browser.baseUrl + '#/comments/edit/11');
return $$('.ng-admin-column-actions .btn-xs').first().click();
})
.then(function() {
return $$('.ng-admin-field-author_name input').first();
Expand Down Expand Up @@ -73,9 +73,11 @@ describe('EditionView', function () {
});

it('should redirect to corresponding detail view even for referenced_list entity', function () {
$$('#row-comments td a').first().click();
browser.getLocationAbsUrl().then(function(url){
expect(url).toContain('/comments/edit/');
$$('#row-comments td a').first().click()
.then(function() {
browser.getLocationAbsUrl().then(function(url){
expect(url).toContain('/comments/edit/');
});
});
});
});
Expand Down
10 changes: 5 additions & 5 deletions src/javascripts/test/e2e/filterViewSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ describe('List filter', function () {
var hasToLoad = true;
beforeEach(function() {
if (hasToLoad) {
browser.get(browser.baseUrl + '#/comments/list');
browser.get(browser.baseUrl + '#/comments/list');
}
hasToLoad = true;
});
Expand All @@ -22,7 +22,7 @@ describe('List filter', function () {
return $$('ma-view-actions button').then(function(buttons) {
expect(buttons[0].getText()).toBe(' Add filter');
});
});
});
});

describe('filter button', function() {
Expand Down Expand Up @@ -94,7 +94,7 @@ describe('List filter', function () {
return browser.driver.sleep(600); // debounce delay
})
.then(function() {
return $$('.grid tr td:nth-child(4)');
return $$('.grid tr td:nth-child(4)');
})
.then(function (tdElements) {
expect(tdElements.length).toBe(1);
Expand All @@ -116,7 +116,7 @@ describe('List filter', function () {
return browser.driver.sleep(600); // debounce delay
})
.then(function() {
return $$('.grid tr td:nth-child(4)');
return $$('.grid tr td:nth-child(4)');
})
.then(function (tdElements) {
expect(tdElements.length).toBe(10);
Expand Down Expand Up @@ -165,7 +165,7 @@ describe('List filter', function () {
$$('.filters .filter:nth-child(1) input').sendKeys('be');
browser.driver.sleep(600); // debounce delay
$$('ma-datagrid-pagination .total').then(function (totalElements) {
expect(totalElements[0].getText()).toBe('1 - 5 on 5');
expect(totalElements[0].getText()).toBe('1 - 4 on 4');
});
});
});
Expand Down
2 changes: 1 addition & 1 deletion src/javascripts/test/protractor.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ exports.config = {
sauceKey: process.env.SAUCE_ACCESS_KEY,

specs: ['e2e/*.js'],
baseUrl: 'http://' + (process.env.CI ? 'ngadmin' : 'localhost') + ':8000',
baseUrl: 'http://' + (process.env.CI ? 'ngadmin' : 'localhost') + ':8001',
maxSessions: 1,
multiCapabilities: [
{
Expand Down

0 comments on commit 0a835a4

Please sign in to comment.