summaryrefslogtreecommitdiffstats
path: root/js
diff options
context:
space:
mode:
authorBernhard Posselt <dev@bernhard-posselt.com>2014-05-19 02:22:02 +0200
committerBernhard Posselt <dev@bernhard-posselt.com>2014-05-19 02:22:02 +0200
commit90584316b8f275fcad904b644676544eb0322636 (patch)
tree35ead28e8f0cdccc1771464442bb83ce5b558cc6 /js
parentded252d29e99e068ea341506129e47a05e053a24 (diff)
add test for firstrun page
Diffstat (limited to 'js')
-rw-r--r--js/Gruntfile.js20
-rw-r--r--js/README.md4
-rw-r--r--js/app/App.js (renamed from js/app/app.js)0
-rw-r--r--js/app/Config.js65
-rw-r--r--js/app/Run.js78
-rw-r--r--js/app/config.js41
-rw-r--r--js/app/run.js36
-rw-r--r--js/build/app.js128
-rw-r--r--js/controller/AppController.js19
-rw-r--r--js/controller/ItemsController.js (renamed from js/service/setup.js)7
-rw-r--r--js/controller/NavigationController.js14
-rw-r--r--js/controller/SettingsController.js14
-rw-r--r--js/protractor.chrome.conf.js8
-rw-r--r--js/protractor.phantomjs.conf.js8
-rw-r--r--js/service/Feed.js (renamed from js/service/feed.js)0
-rw-r--r--js/service/Folder.js (renamed from js/service/folder.js)0
-rw-r--r--js/service/Item.js (renamed from js/service/item.js)0
-rw-r--r--js/service/Loading.js (renamed from js/service/loading.js)3
-rw-r--r--js/service/Model.js (renamed from js/service/model.js)0
-rw-r--r--js/service/Publisher.js (renamed from js/service/publisher.js)2
-rw-r--r--js/service/Settings.js32
-rw-r--r--js/tests/e2e/main.js15
-rw-r--r--js/tests/unit/controller/AppControllerSpec.js45
-rw-r--r--js/tests/unit/service/LoadingSpec.js1
-rw-r--r--js/tests/unit/service/PublisherSpec.js6
-rw-r--r--js/tests/unit/service/SettingsSpec.js30
26 files changed, 465 insertions, 111 deletions
diff --git a/js/Gruntfile.js b/js/Gruntfile.js
index df0afc2ba..5dd29b9fc 100644
--- a/js/Gruntfile.js
+++ b/js/Gruntfile.js
@@ -14,7 +14,9 @@ var globals = [
'angular',
// app
'app',
+ // ownCloud
'OC',
+ 'oc_requesttoken',
// angular
'inject',
'module',
@@ -62,9 +64,10 @@ module.exports = function (grunt) {
},
dist: {
src: [
- 'app/app.js',
- 'app/config.js',
- 'app/run.js',
+ 'app/App.js',
+ 'app/Config.js',
+ 'app/Run.js',
+ 'controller/**/*.js',
'filter/**/*.js',
'service/**/*.js',
'directive/**/*.js'
@@ -84,8 +87,8 @@ module.exports = function (grunt) {
dest: '<%= meta.production %>app.js',
options: {
wrapper: [
- '(function(angular, $, OC, undefined){\n\n\'use strict\';\n\n',
- '\n})(angular, jQuery, OC);'
+ '(function(angular, $, OC, oc_requesttoken, undefined){\n\n\'use strict\';\n\n',
+ '\n})(angular, jQuery, OC, oc_requesttoken);'
]
}
}
@@ -96,6 +99,7 @@ module.exports = function (grunt) {
'app/**/*.js',
'filter/**/*.js',
'service/**/*.js',
+ 'controller/**/*.js',
'directive/**/*.js',
'tests/**/*.js',
'Gruntfile.js',
@@ -119,10 +123,10 @@ module.exports = function (grunt) {
'service/**/*.js',
'../templates/**/*.php'
],
+ tasks: ['default'],
options: {
livereload: true
- },
- tasks: ['default']
+ }
},
phpunit: {
files: [
@@ -189,7 +193,9 @@ module.exports = function (grunt) {
// make tasks available under simpler commands
grunt.registerTask('default', ['jslint', 'concat', 'ngmin', 'wrap']);
+ grunt.registerTask('dev', ['watch:concat']);
grunt.registerTask('test', ['karma:unit']);
+ grunt.registerTask('phpunit', ['watch:phpunit']);
grunt.registerTask('e2e', ['protractor_webdriver', 'connect', 'protractor:chrome']);
grunt.registerTask('ci-unit', ['default', 'karma:continuous']);
grunt.registerTask('ci-e2e', ['protractor_webdriver', 'connect', 'protractor:phantomjs']);
diff --git a/js/README.md b/js/README.md
index a1b5f4139..db6dafc2e 100644
--- a/js/README.md
+++ b/js/README.md
@@ -10,7 +10,7 @@ then run:
## Building
Watch mode:
- grunt watch
+ grunt dev
Single run mode:
@@ -19,7 +19,7 @@ Single run mode:
## Testing
Watch mode:
- grunt watch:phpunit
+ grunt phpunit
grunt test
Single run mode:
diff --git a/js/app/app.js b/js/app/App.js
index 947a68a2e..947a68a2e 100644
--- a/js/app/app.js
+++ b/js/app/App.js
diff --git a/js/app/Config.js b/js/app/Config.js
new file mode 100644
index 000000000..67a5e7215
--- /dev/null
+++ b/js/app/Config.js
@@ -0,0 +1,65 @@
+/**
+ * ownCloud - News
+ *
+ * This file is licensed under the Affero General Public License version 3 or
+ * later. See the COPYING file.
+ *
+ * @author Bernhard Posselt <dev@bernhard-posselt.com>
+ * @copyright Bernhard Posselt 2014
+ */
+app.config(function ($routeProvider, $provide, $httpProvider) {
+ 'use strict';
+
+ // constants
+ $provide.constant('BASE_URL', OC.generateUrl('/apps/news'));
+
+ $provide.constant('FEED_TYPE', {
+ FEED: 0,
+ FOLDER: 1,
+ STARRED: 2,
+ SUBSCRIPTIONS: 3,
+ SHARED: 4
+ });
+
+ // make sure that the CSRF header is only sent to the ownCloud domain
+ $provide.factory('CSRFInterceptor', function ($q, BASE_URL) {
+ return {
+ request: function (config) {
+ if (config.url.indexOf(BASE_URL) === 0) {
+ config.headers.requesttoken = oc_requesttoken;
+ }
+
+ return config || $q.when(config);
+ }
+ };
+ });
+ $httpProvider.interceptors.push('CSRFInterceptor');
+
+ // routing
+ $routeProvider
+ .when('/items', {
+ controller: 'ItemsController',
+ templateUrl: 'content.html',
+ resolve: {}
+ })
+ .when('/items/starred', {
+ controller: 'StarredController',
+ templateUrl: 'content.html',
+ resolve: {}
+ })
+ .when('/items/feeds/:id', {
+ controller: 'FeedController',
+ templateUrl: 'content.html',
+ resolve: {}
+ })
+ .when('/items/folders/:id', {
+ controller: 'FolderController',
+ templateUrl: 'content.html',
+ resolve: {}
+ })
+ .otherwise({
+ redirectTo: '/items'
+ });
+
+});
+
diff --git a/js/app/Run.js b/js/app/Run.js
new file mode 100644
index 000000000..936a03b9d
--- /dev/null
+++ b/js/app/Run.js
@@ -0,0 +1,78 @@
+/**
+ * ownCloud - News
+ *
+ * This file is licensed under the Affero General Public License version 3 or
+ * later. See the COPYING file.
+ *
+ * @author Bernhard Posselt <dev@bernhard-posselt.com>
+ * @copyright Bernhard Posselt 2014
+ */
+app.run(function ($rootScope, $location, $http, $q, Loading, Item, Feed, Folder,
+ Settings, Publisher, BASE_URL, FEED_TYPE) {
+ 'use strict';
+
+ // show Loading screen
+ Loading.setLoading('global', true);
+
+ // listen to keys in returned queries to automatically distribute the
+ // incoming values to models
+ Publisher.subscribe(Item).toChannel('items');
+ Publisher.subscribe(Folder).toChannel('folders');
+ Publisher.subscribe(Feed).toChannel('feeds');
+ Publisher.subscribe(Settings).toChannel('settings');
+
+ // load feeds, settings and last read feed
+ var settingsDeferred,
+ activeFeedDeferred;
+
+ settingsDeferred = $q.defer();
+ $http.get(BASE_URL + '/settings').then(function (data) {
+ Publisher.publishAll(data);
+ settingsDeferred.resolve();
+ });
+
+ activeFeedDeferred = $q.defer();
+ $http.get(BASE_URL + '/feeds/active').then(function (data) {
+ var url;
+
+ switch (data.type) {
+
+ case FEED_TYPE.FEED:
+ url = '/items/feeds/' + data.id;
+ break;
+
+ case FEED_TYPE.FOLDER:
+ url = '/items/folders/' + data.id;
+ break;
+
+ case FEED_TYPE.STARRED:
+ url = '/items/starred';
+ break;
+
+ default:
+ url = '/items';
+ }
+
+ $location.path(url);
+ activeFeedDeferred.resolve();
+ });
+
+
+ $q.all([settingsDeferred.promise, activeFeedDeferred.promise]).then(function () {
+ Loading.setLoading('global', false);
+ });
+
+
+ $rootScope.$on('$routeChangeStart', function () {
+ Loading.setLoading('content', true);
+ });
+
+ $rootScope.$on('$routeChangeSuccess', function () {
+ Loading.setLoading('content', false);
+ });
+
+ // in case of wrong id etc show all items
+ $rootScope.$on('$routeChangeError', function () {
+ $location.path('/items');
+ });
+}); \ No newline at end of file
diff --git a/js/app/config.js b/js/app/config.js
deleted file mode 100644
index 776f4ee92..000000000
--- a/js/app/config.js
+++ /dev/null
@@ -1,41 +0,0 @@
-/**
- * ownCloud - News
- *
- * This file is licensed under the Affero General Public License version 3 or
- * later. See the COPYING file.
- *
- * @author Bernhard Posselt <dev@bernhard-posselt.com>
- * @copyright Bernhard Posselt 2014
- */
-app.config(function ($routeProvider, $provide) {
- 'use strict';
-
- $provide.constant('baseUrl', OC.generateUrl(''));
-
- $routeProvider
- .when('/items', {
- controller: 'AllItemsController',
- templateUrl: 'content.html',
- resolve: {}
- })
- .when('/items/starred', {
- controller: 'StarredItemsController',
- templateUrl: 'content.html',
- resolve: {}
- })
- .when('/items/feeds/:id', {
- controller: 'FeedItemsController',
- templateUrl: 'content.html',
- resolve: {}
- })
- .when('/items/folders/:id', {
- controller: 'FolderItemsController',
- templateUrl: 'content.html',
- resolve: {}
- })
- .otherwise({
- redirectTo: '/items'
- });
-
-});
-
diff --git a/js/app/run.js b/js/app/run.js
deleted file mode 100644
index f91d908f2..000000000
--- a/js/app/run.js
+++ /dev/null
@@ -1,36 +0,0 @@
-/**
- * ownCloud - News
- *
- * This file is licensed under the Affero General Public License version 3 or
- * later. See the COPYING file.
- *
- * @author Bernhard Posselt <dev@bernhard-posselt.com>
- * @copyright Bernhard Posselt 2014
- */
-app.run(function ($rootScope, $location, Loading, Setup, Item, Feed, Folder,
- Publisher, Settings) {
- 'use strict';
-
- // listen to keys in returned queries to automatically distribute the
- // incoming values to models
- Publisher.subscribe(Item).toChannel('items');
- Publisher.subscribe(Folder).toChannel('folders');
- Publisher.subscribe(Feed).toChannel('feeds');
- Publisher.subscribe(Settings).toChannel('settings');
-
- // load feeds, settings and last read feed
- Setup.load();
-
- $rootScope.$on('$routeChangeStart', function () {
- Loading.setLoading('content', true);
- });
-
- $rootScope.$on('$routeChangeSuccess', function () {
- Loading.setLoading('content', false);
- });
-
- // in case of wrong id etc show all items
- $rootScope.$on('$routeChangeError', function () {
- $location.path('/items');
- });
-}); \ No newline at end of file
diff --git a/js/build/app.js b/js/build/app.js
index 3a72dc277..a20648bd5 100644
--- a/js/build/app.js
+++ b/js/build/app.js
@@ -1,4 +1,4 @@
-(function(angular, $, OC, undefined){
+(function(angular, $, OC, oc_requesttoken, undefined){
'use strict';
@@ -11,23 +11,45 @@ var app = angular.module('News', [
app.config([
'$routeProvider',
'$provide',
- function ($routeProvider, $provide) {
+ '$httpProvider',
+ function ($routeProvider, $provide, $httpProvider) {
'use strict';
- $provide.constant('baseUrl', OC.generateUrl(''));
+ // constants
+ $provide.constant('BASE_URL', OC.generateUrl('/apps/news'));
+ $provide.constant('FEED_TYPE', {
+ FEED: 0,
+ FOLDER: 1,
+ STARRED: 2,
+ SUBSCRIPTIONS: 3,
+ SHARED: 4
+ });
+ // make sure that the CSRF header is only sent to the ownCloud domain
+ $provide.factory('CSRFInterceptor', function ($q, BASE_URL) {
+ return {
+ request: function (config) {
+ if (config.url.indexOf(BASE_URL) === 0) {
+ config.headers.requesttoken = oc_requesttoken;
+ }
+ return config || $q.when(config);
+ }
+ };
+ });
+ $httpProvider.interceptors.push('CSRFInterceptor');
+ // routing
$routeProvider.when('/items', {
- controller: 'AllItemsController',
+ controller: 'ItemsController',
templateUrl: 'content.html',
resolve: {}
}).when('/items/starred', {
- controller: 'StarredItemsController',
+ controller: 'StarredController',
templateUrl: 'content.html',
resolve: {}
}).when('/items/feeds/:id', {
- controller: 'FeedItemsController',
+ controller: 'FeedController',
templateUrl: 'content.html',
resolve: {}
}).when('/items/folders/:id', {
- controller: 'FolderItemsController',
+ controller: 'FolderController',
templateUrl: 'content.html',
resolve: {}
}).otherwise({ redirectTo: '/items' });
@@ -36,15 +58,20 @@ app.config([
app.run([
'$rootScope',
'$location',
+ '$http',
+ '$q',
'Loading',
- 'Setup',
'Item',
'Feed',
'Folder',
- 'Publisher',
'Settings',
- function ($rootScope, $location, Loading, Setup, Item, Feed, Folder, Publisher, Settings) {
+ 'Publisher',
+ 'BASE_URL',
+ 'FEED_TYPE',
+ function ($rootScope, $location, $http, $q, Loading, Item, Feed, Folder, Settings, Publisher, BASE_URL, FEED_TYPE) {
'use strict';
+ // show Loading screen
+ Loading.setLoading('global', true);
// listen to keys in returned queries to automatically distribute the
// incoming values to models
Publisher.subscribe(Item).toChannel('items');
@@ -52,7 +79,37 @@ app.run([
Publisher.subscribe(Feed).toChannel('feeds');
Publisher.subscribe(Settings).toChannel('settings');
// load feeds, settings and last read feed
- Setup.load();
+ var settingsDeferred, activeFeedDeferred;
+ settingsDeferred = $q.defer();
+ $http.get(BASE_URL + '/settings').then(function (data) {
+ Publisher.publishAll(data);
+ settingsDeferred.resolve();
+ });
+ activeFeedDeferred = $q.defer();
+ $http.get(BASE_URL + '/feeds/active').then(function (data) {
+ var url;
+ switch (data.type) {
+ case FEED_TYPE.FEED:
+ url = '/items/feeds/' + data.id;
+ break;
+ case FEED_TYPE.FOLDER:
+ url = '/items/folders/' + data.id;
+ break;
+ case FEED_TYPE.STARRED:
+ url = '/items/starred';
+ break;
+ default:
+ url = '/items';
+ }
+ $location.path(url);
+ activeFeedDeferred.resolve();
+ });
+ $q.all([
+ settingsDeferred.promise,
+ activeFeedDeferred.promise
+ ]).then(function () {
+ Loading.setLoading('global', false);
+ });
$rootScope.$on('$routeChangeStart', function () {
Loading.setLoading('content', true);
});
@@ -65,6 +122,30 @@ app.run([
});
}
]);
+app.controller('AppController', [
+ 'Loading',
+ 'Feed',
+ 'Folder',
+ function (Loading, Feed, Folder) {
+ 'use strict';
+ this.loading = Loading;
+ this.isFirstRun = function () {
+ return Feed.size() === 0 && Folder.size() === 0;
+ };
+ }
+]);
+app.controller('ItemsController', function () {
+ 'use strict';
+ console.log('here');
+});
+app.controller('NavigationController', function () {
+ 'use strict';
+ console.log('here');
+});
+app.controller('SettingsController', function () {
+ 'use strict';
+ console.log('here');
+});
app.factory('Feed', [
'Model',
function (Model) {
@@ -102,7 +183,8 @@ app.service('Loading', function () {
'use strict';
this.loading = {
global: false,
- content: false
+ content: false,
+ autopaging: false
};
this.setLoading = function (area, isLoading) {
this.loading[area] = isLoading;
@@ -189,7 +271,7 @@ app.service('Publisher', function () {
this.publishAll = function (data) {
var channel, counter;
for (channel in data) {
- if (data.hasOwnProperty(channel)) {
+ if (data.hasOwnProperty(channel) && this.channels[channel] !== undefined) {
for (counter = 0; counter < this.channels[channel].length; counter += 1) {
this.channels[channel][counter].receive(data[channel]);
}
@@ -197,11 +279,23 @@ app.service('Publisher', function () {
}
};
});
-app.service('Setup', function () {
+app.service('Settings', function () {
'use strict';
- this.load = function () {
- console.log('init');
+ this.settings = {};
+ this.receive = function (data) {
+ var key;
+ for (key in data) {
+ if (data.hasOwnProperty(key)) {
+ this.settings[key] = data[key];
+ }
+ }
+ };
+ this.get = function (key) {
+ return this.settings[key];
+ };
+ this.set = function (key, value) {
+ this.settings[key] = value;
};
});
-})(angular, jQuery, OC); \ No newline at end of file
+})(angular, jQuery, OC, oc_requesttoken); \ No newline at end of file
diff --git a/js/controller/AppController.js b/js/controller/AppController.js
new file mode 100644
index 000000000..ee8115c84
--- /dev/null
+++ b/js/controller/AppController.js
@@ -0,0 +1,19 @@
+/**
+ * ownCloud - News
+ *
+ * This file is licensed under the Affero General Public License version 3 or
+ * later. See the COPYING file.
+ *
+ * @author Bernhard Posselt <dev@bernhard-posselt.com>
+ * @copyright Bernhard Posselt 2014
+ */
+app.controller('AppController', function (Loading, Feed, Folder) {
+ 'use strict';
+
+ this.loading = Loading;
+
+ this.isFirstRun = function () {
+ return Feed.size() === 0 && Folder.size() === 0;
+ };
+
+}); \ No newline at end of file
diff --git a/js/service/setup.js b/js/controller/ItemsController.js
index dcb289643..61ca72fdc 100644
--- a/js/service/setup.js
+++ b/js/controller/ItemsController.js
@@ -7,11 +7,8 @@
* @author Bernhard Posselt <dev@bernhard-posselt.com>
* @copyright Bernhard Posselt 2014
*/
-app.service('Setup', function () {
+app.controller('ItemsController', function () {
'use strict';
- this.load = function () {
- console.log('init');
- };
-
+ console.log('here');
}); \ No newline at end of file
diff --git a/js/controller/NavigationController.js b/js/controller/NavigationController.js
new file mode 100644
index 000000000..700e6bd02
--- /dev/null
+++ b/js/controller/NavigationController.js
@@ -0,0 +1,14 @@
+/**
+ * ownCloud - News
+ *
+ * This file is licensed under the Affero General Public License version 3 or
+ * later. See the COPYING file.
+ *
+ * @author Bernhard Posselt <dev@bernhard-posselt.com>
+ * @copyright Bernhard Posselt 2014
+ */
+app.controller('NavigationController', function () {
+ 'use strict';
+
+ console.log('here');
+}); \ No newline at end of file
diff --git a/js/controller/SettingsController.js b/js/controller/SettingsController.js
new file mode 100644
index 000000000..321b6dff9
--- /dev/null
+++ b/js/controller/SettingsController.js
@@ -0,0 +1,14 @@
+/**
+ * ownCloud - News
+ *
+ * This file is licensed under the Affero General Public License version 3 or
+ * later. See the COPYING file.
+ *
+ * @author Bernhard Posselt <dev@bernhard-posselt.com>
+ * @copyright Bernhard Posselt 2014
+ */
+app.controller('SettingsController', function () {
+ 'use strict';
+
+ console.log('here');
+}); \ No newline at end of file
diff --git a/js/protractor.chrome.conf.js b/js/protractor.chrome.conf.js
index 5d5bdc320..09b597c08 100644
--- a/js/protractor.chrome.conf.js
+++ b/js/protractor.chrome.conf.js
@@ -28,6 +28,14 @@ exports.config = {
return regex.test(url);
});
});
+
+ browser.get(baseUrl + '/owncloud/index.php/apps/news/');
+ browser.driver.wait(function () {
+ return browser.driver.getCurrentUrl().then(function (url) {
+ var regex = /apps\/news/;
+ return regex.test(url);
+ });
+ });
},
baseUrl: baseUrl
}; \ No newline at end of file
diff --git a/js/protractor.phantomjs.conf.js b/js/protractor.phantomjs.conf.js
index 427465808..73ed555cf 100644
--- a/js/protractor.phantomjs.conf.js
+++ b/js/protractor.phantomjs.conf.js
@@ -28,6 +28,14 @@ exports.config = {
return regex.test(url);
});
});
+
+ browser.get(baseUrl + '/owncloud/index.php/apps/news/');
+ browser.driver.wait(function () {
+ return browser.driver.getCurrentUrl().then(function (url) {
+ var regex = /apps\/news/;
+ return regex.test(url);
+ });
+ });
},
capabilities: {
browserName: 'phantomjs',
diff --git a/js/service/feed.js b/js/service/Feed.js
index 9223ca6e7..9223ca6e7 100644
--- a/js/service/feed.js
+++ b/js/service/Feed.js
diff --git a/js/service/folder.js b/js/service/Folder.js
index 101b8ec66..101b8ec66 100644
--- a/js/service/folder.js
+++ b/js/service/Folder.js
diff --git a/js/service/item.js b/js/service/Item.js
index 0dd9b8677..0dd9b8677 100644
--- a/js/service/item.js
+++ b/js/service/Item.js
diff --git a/js/service/loading.js b/js/service/Loading.js
index e6fcb73d1..eb42655a5 100644
--- a/js/service/loading.js
+++ b/js/service/Loading.js
@@ -12,7 +12,8 @@ app.service('Loading', function () {
this.loading = {
global: false,
- content: false
+ content: false,
+ autopaging: false
};
this.setLoading = function (area, isLoading) {
diff --git a/js/service/model.js b/js/service/Model.js
index dddede788..dddede788 100644
--- a/js/service/model.js
+++ b/js/service/Model.js
diff --git a/js/service/publisher.js b/js/service/Publisher.js
index db8a1d5db..da9b0a470 100644
--- a/js/service/publisher.js
+++ b/js/service/Publisher.js
@@ -27,7 +27,7 @@ app.service('Publisher', function () {
counter;
for (channel in data) {
- if (data.hasOwnProperty(channel)) {
+ if (data.hasOwnProperty(channel) && this.channels[channel] !== undefined) {
for (counter = 0; counter < this.channels[channel].length; counter += 1) {
this.channels[channel][counter].receive(data[channel]);
}
diff --git a/js/service/Settings.js b/js/service/Settings.js
new file mode 100644
index 000000000..09a89f6ed
--- /dev/null
+++ b/js/service/Settings.js
@@ -0,0 +1,32 @@
+/**
+ * ownCloud - News
+ *
+ * This file is licensed under the Affero General Public License version 3 or
+ * later. See the COPYING file.
+ *
+ * @author Bernhard Posselt <dev@bernhard-posselt.com>
+ * @copyright Bernhard Posselt 2014
+ */
+app.service('Settings', function () {
+ 'use strict';
+
+ this.settings = {};
+
+ this.receive = function (data) {
+ var key;
+ for (key in data) {
+ if (data.hasOwnProperty(key)) {
+ this.settings[key] = data[key];
+ }
+ }
+ };
+
+ this.get = function (key) {
+ return this.settings[key];
+ };
+
+ this.set = function (key, value) {
+ this.settings[key] = value;
+ };
+
+}); \ No newline at end of file
diff --git a/js/tests/e2e/main.js b/js/tests/e2e/main.js
index 3beb4c8af..328556326 100644
--- a/js/tests/e2e/main.js
+++ b/js/tests/e2e/main.js
@@ -11,7 +11,8 @@ describe('news page', function () {
'use strict';
beforeEach(function () {
- browser.get('http://localhost/owncloud/index.php/apps/news/');
+ browser.ignoreSynchronization = true;
+ browser.waitForAngular();
});
it('should go to the news page', function () {
@@ -20,4 +21,16 @@ describe('news page', function () {
});
});
+
+ it('should show the first run page', function () {
+ var firstRun,
+ greeting;
+
+ firstRun = browser.findElement(By.id('first-run'));
+ greeting = firstRun.findElement(By.tagName('h1'));
+
+ expect(firstRun.isDisplayed()).toBe(true);
+ expect(greeting.getText()).toBe('Welcome to the ownCloud News app!');
+ });
+
}); \ No newline at end of file
diff --git a/js/tests/unit/controller/AppControllerSpec.js b/js/tests/unit/controller/AppControllerSpec.js
new file mode 100644
index 000000000..b7dad7492
--- /dev/null
+++ b/js/tests/unit/controller/AppControllerSpec.js
@@ -0,0 +1,45 @@
+/**
+ * ownCloud - News
+ *
+ * This file is licensed under the Affero General Public License version 3 or
+ * later. See the COPYING file.
+ *
+ * @author Bernhard Posselt <dev@bernhard-posselt.com>
+ * @copyright Bernhard Posselt 2014
+ */
+describe('AppController', function () {
+ 'use strict';
+
+ var controller;
+
+ beforeEach(module('News'));
+
+ beforeEach(inject(function ($controller) {
+ controller = $controller('AppController');
+ }));
+
+
+ it('should expose Loading', inject(function (Loading) {
+ expect(controller.loading).toBe(Loading);
+ }));
+
+
+ it('should expose set firstrun if no feeds and folders', inj