diff options
Diffstat (limited to 'webclient/test')
-rw-r--r-- | webclient/test/README | 28 | ||||
-rw-r--r-- | webclient/test/e2e/home.spec.js | 16 | ||||
-rw-r--r-- | webclient/test/protractor.conf.js | 18 | ||||
-rw-r--r-- | webclient/test/unit/user-controller.spec.js | 6 |
4 files changed, 62 insertions, 6 deletions
diff --git a/webclient/test/README b/webclient/test/README index b1e0d7adea..1a7bc832c7 100644 --- a/webclient/test/README +++ b/webclient/test/README @@ -1,9 +1,33 @@ Requires: - - npm + - nodejs/npm - npm install karma - npm install jasmine + - npm install protractor (e2e testing) -Setting up continuous integration / run the tests: +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/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 index 217559114b..798cc4de48 100644 --- a/webclient/test/unit/user-controller.spec.js +++ b/webclient/test/unit/user-controller.spec.js @@ -21,13 +21,12 @@ describe("UserCtrl", function() { getDisplayName: function(uid) { var d = $q.defer(); - // FIXME: everything goes into fire here d.resolve({ data: { displayname: displayName } }); - return d; + return d.promise; }, getProfilePictureUrl: function(uid) { @@ -37,7 +36,7 @@ describe("UserCtrl", function() { avatar_url: avatarUrl } }); - return d; + return d.promise; } }; scope = $rootScope.$new(); @@ -49,7 +48,6 @@ describe("UserCtrl", function() { '$routeParams': routeParams, 'matrixService': matrixService }); - console.log("end inject"); }); }); |