diff --git a/CHANGELOG.md b/CHANGELOG.md index 32c34576..5ada5559 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ Release date: TBD ### Improvements #### All platforms +- Show current channel/team in window title - Changed display of unread messages on the team tabbar, they are now shown as bold text - Reload only the selected tab and keep its URL on "Reload" and "Clear Cache and Reload". - Disabled `eval()` function for security improvements. diff --git a/src/browser/index.html b/src/browser/index.html index 74f81b95..9af40a0b 100644 --- a/src/browser/index.html +++ b/src/browser/index.html @@ -3,7 +3,6 @@
-diff --git a/test/specs/browser/index_test.js b/test/specs/browser/index_test.js index 8147294c..329af298 100644 --- a/test/specs/browser/index_test.js +++ b/test/specs/browser/index_test.js @@ -1,7 +1,8 @@ 'use strict'; -const path = require('path'); const fs = require('fs'); +const http = require('http'); +const path = require('path'); const env = require('../../modules/environment'); @@ -19,6 +20,17 @@ describe('browser/index.html', function() { }] }; + const serverPort = 8181; + + before(function() { + this.server = http.createServer(function(req, res) { + res.writeHead(200, { + 'Content-Type': 'text/html' + }); + res.end(fs.readFileSync(path.resolve(env.sourceRootDir, 'test/modules/test.html'), 'utf-8')); + }).listen(serverPort, '127.0.0.1'); + }); + beforeEach(function() { fs.writeFileSync(env.configFilePath, JSON.stringify(config)); this.app = env.getSpectronApp(); @@ -31,6 +43,10 @@ describe('browser/index.html', function() { } }); + after(function(done) { + this.server.close(done); + }) + it('should NOT show tabs when there is one team', function() { fs.writeFileSync(env.configFilePath, JSON.stringify({ url: env.mattermostURL @@ -78,4 +94,81 @@ describe('browser/index.html', function() { .waitForVisible('#mattermostView0-fail', 20000) }); }); + + it('should set window title by using webview\'s one', function() { + fs.writeFileSync(env.configFilePath, JSON.stringify({ + version: 1, + teams: [{ + name: 'title_test', + url: `http://localhost:${serverPort}` + }] + })); + return this.app.restart().then(() => { + return this.app.client.waitUntilWindowLoaded().pause(500); + }) + .then(() => { + return this.app.browserWindow.getTitle().should.eventually.equal('Mattermost Desktop testing html'); + }); + }); + + it('should update window title when the activated tab\'s title is updated', function() { + fs.writeFileSync(env.configFilePath, JSON.stringify({ + version: 1, + teams: [{ + name: 'title_test_0', + url: `http://localhost:${serverPort}` + }, { + name: 'title_test_1', + url: `http://localhost:${serverPort}` + }] + })); + return this.app.restart().then(() => { + return this.app.client.waitUntilWindowLoaded().pause(500); + }) + .then(() => { + return this.app.client + .windowByIndex(1) + .execute(function() { + document.title = 'Title 0'; + }) + .windowByIndex(0) + .browserWindow.getTitle().should.eventually.equal('Title 0') + .windowByIndex(2) + .execute(function() { + document.title = 'Title 1'; + }) + .windowByIndex(0) + .browserWindow.getTitle().should.eventually.equal('Title 0') + }); + }); + + it('should update window title when a tab is selected', function() { + fs.writeFileSync(env.configFilePath, JSON.stringify({ + version: 1, + teams: [{ + name: 'title_test_0', + url: `http://localhost:${serverPort}` + }, { + name: 'title_test_1', + url: `http://localhost:${serverPort}` + }] + })); + return this.app.restart().then(() => { + return this.app.client + .waitUntilWindowLoaded() + .pause(500) + .windowByIndex(1) + .execute(function() { + document.title = 'Title 0'; + }) + .windowByIndex(2) + .execute(function() { + document.title = 'Title 1'; + }) + .windowByIndex(0) + .browserWindow.getTitle().should.eventually.equal('Title 0') + .click('#teamTabItem1') + .browserWindow.getTitle().should.eventually.equal('Title 1'); + }); + }); });