diff options
author | Mark Haines <mark.haines@matrix.org> | 2014-09-22 18:54:00 +0100 |
---|---|---|
committer | Mark Haines <mark.haines@matrix.org> | 2014-09-22 18:54:00 +0100 |
commit | 09d79b0a9bf7a194383830d2e55530c70f2366b6 (patch) | |
tree | 76573bac3ca48deeca6cd33f91ed2ee3408dffb2 /webclient/test | |
parent | SYN-39: Add documentation explaining how to check a signature (diff) | |
parent | Show display name changes in the message list. (diff) | |
download | synapse-09d79b0a9bf7a194383830d2e55530c70f2366b6.tar.xz |
Merge branch 'develop' into server2server_signing
Diffstat (limited to 'webclient/test')
-rw-r--r-- | webclient/test/README | 33 | ||||
-rw-r--r-- | webclient/test/e2e/home.spec.js | 16 | ||||
-rw-r--r-- | webclient/test/karma.conf.js | 82 | ||||
-rw-r--r-- | webclient/test/protractor.conf.js | 18 | ||||
-rw-r--r-- | webclient/test/unit/user-controller.spec.js | 57 |
5 files changed, 206 insertions, 0 deletions
diff --git a/webclient/test/README b/webclient/test/README new file mode 100644 index 0000000000..1a7bc832c7 --- /dev/null +++ b/webclient/test/README @@ -0,0 +1,33 @@ +Requires: + - nodejs/npm + - npm install karma + - npm install jasmine + - npm install protractor (e2e testing) + +Setting up continuous integration / run the unit tests (make sure you're in +this directory so it can find the config file): + karma start + + +Setting up e2e tests (only if you don't have a selenium server to run the tests +on. If you do, edit the config to point to that url): + + webdriver-manager update + webdriver-manager start + + Create a file "environment-protractor.js" in this directory and type: + module.exports = { + seleniumAddress: 'http://localhost:4444/wd/hub', + baseUrl: "http://localhost:8008", + username: "YOUR_TEST_USERNAME", + password: "YOUR_TEST_PASSWORD" + } + +Running e2e tests: + protractor protractor.conf.js + +NOTE: This will create a public room on the target home server. + + + + diff --git a/webclient/test/e2e/home.spec.js b/webclient/test/e2e/home.spec.js new file mode 100644 index 0000000000..470237d557 --- /dev/null +++ b/webclient/test/e2e/home.spec.js @@ -0,0 +1,16 @@ +var env = require("../environment-protractor.js"); + +describe("home page", function() { + + beforeEach(function() { + ptor = protractor.getInstance(); + // FIXME we use longpoll on the event stream, and I can't get $interval + // playing nicely with it. Patches welcome to fix this. + ptor.ignoreSynchronization = true; + }); + + it("should have a title", function() { + browser.get(env.baseUrl); + expect(browser.getTitle()).toEqual("[matrix]"); + }); +}); diff --git a/webclient/test/karma.conf.js b/webclient/test/karma.conf.js new file mode 100644 index 0000000000..22c4eaaafa --- /dev/null +++ b/webclient/test/karma.conf.js @@ -0,0 +1,82 @@ +// Karma configuration +// Generated on Thu Sep 18 2014 14:25:57 GMT+0100 (BST) + +module.exports = function(config) { + config.set({ + + // base path that will be used to resolve all patterns (eg. files, exclude) + basePath: '', + + + // frameworks to use + // available frameworks: https://npmjs.org/browse/keyword/karma-adapter + frameworks: ['jasmine'], + + + // list of files / patterns to load in the browser + // XXX: Order is important, and doing /js/angular* makes the tests not run :/ + files: [ + '../js/jquery*', + '../js/angular.js', + '../js/angular-mocks.js', + '../js/angular-route.js', + '../js/angular-animate.js', + '../js/angular-sanitize.js', + '../js/ng-infinite-scroll-matrix.js', + '../login/**/*.*', + '../room/**/*.*', + '../components/**/*.*', + '../user/**/*.*', + '../home/**/*.*', + '../recents/**/*.*', + '../settings/**/*.*', + '../app.js', + '../app*', + './unit/**/*.js' + ], + + + // list of files to exclude + exclude: [ + ], + + + // preprocess matching files before serving them to the browser + // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor + preprocessors: { + }, + + + // test results reporter to use + // possible values: 'dots', 'progress' + // available reporters: https://npmjs.org/browse/keyword/karma-reporter + reporters: ['progress'], + + + // web server port + port: 9876, + + + // enable / disable colors in the output (reporters and logs) + colors: true, + + + // level of logging + // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG + logLevel: config.LOG_DEBUG, + + + // enable / disable watching file and executing tests whenever any file changes + autoWatch: true, + + + // start these browsers + // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher + browsers: ['Chrome'], + + + // Continuous Integration mode + // if true, Karma captures browsers, runs the tests and exits + singleRun: false + }); +}; diff --git a/webclient/test/protractor.conf.js b/webclient/test/protractor.conf.js new file mode 100644 index 0000000000..76ae7b712b --- /dev/null +++ b/webclient/test/protractor.conf.js @@ -0,0 +1,18 @@ +var env = require("./environment-protractor.js"); +exports.config = { + seleniumAddress: env.seleniumAddress, + specs: ['e2e/*.spec.js'], + onPrepare: function() { + browser.driver.get(env.baseUrl); + browser.driver.findElement(by.id("user_id")).sendKeys(env.username); + browser.driver.findElement(by.id("password")).sendKeys(env.password); + browser.driver.findElement(by.id("login")).click(); + + // wait till the login is done, detect via url change + browser.driver.wait(function() { + return browser.driver.getCurrentUrl().then(function(url) { + return !(/login/.test(url)) + }); + }); + } +} diff --git a/webclient/test/unit/user-controller.spec.js b/webclient/test/unit/user-controller.spec.js new file mode 100644 index 0000000000..798cc4de48 --- /dev/null +++ b/webclient/test/unit/user-controller.spec.js @@ -0,0 +1,57 @@ +describe("UserCtrl", function() { + var scope, ctrl, matrixService, routeParams, $q, $timeout; + var userId = "@foo:bar"; + var displayName = "Foo"; + var avatarUrl = "avatar.url"; + + beforeEach(module('matrixWebClient')); + + beforeEach(function() { + + inject(function($rootScope, $injector, $controller, _$q_, _$timeout_) { + $q = _$q_; + $timeout = _$timeout_; + + matrixService = { + config: function() { + return { + user_id: userId + }; + }, + + getDisplayName: function(uid) { + var d = $q.defer(); + d.resolve({ + data: { + displayname: displayName + } + }); + return d.promise; + }, + + getProfilePictureUrl: function(uid) { + var d = $q.defer(); + d.resolve({ + data: { + avatar_url: avatarUrl + } + }); + return d.promise; + } + }; + scope = $rootScope.$new(); + routeParams = { + user_matrix_id: userId + }; + ctrl = $controller('UserController', { + '$scope': scope, + '$routeParams': routeParams, + 'matrixService': matrixService + }); + }); + }); + + it('should display your user id', function() { + expect(scope.user_id).toEqual(userId); + }); +}); |