Add tests for window title
This commit is contained in:
parent
8c19c33911
commit
6fe23cb136
|
@ -1,5 +1,9 @@
|
||||||
<html>
|
<html>
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<title>Mattermost Desktop testing html</title>
|
||||||
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<h1>window.open() test</h1>
|
<h1>window.open() test</h1>
|
||||||
<p>
|
<p>
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const path = require('path');
|
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
|
const http = require('http');
|
||||||
|
const path = require('path');
|
||||||
|
|
||||||
const env = require('../../modules/environment');
|
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() {
|
beforeEach(function() {
|
||||||
fs.writeFileSync(env.configFilePath, JSON.stringify(config));
|
fs.writeFileSync(env.configFilePath, JSON.stringify(config));
|
||||||
this.app = env.getSpectronApp();
|
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() {
|
it('should NOT show tabs when there is one team', function() {
|
||||||
fs.writeFileSync(env.configFilePath, JSON.stringify({
|
fs.writeFileSync(env.configFilePath, JSON.stringify({
|
||||||
url: env.mattermostURL
|
url: env.mattermostURL
|
||||||
|
@ -78,4 +94,81 @@ describe('browser/index.html', function() {
|
||||||
.waitForVisible('#mattermostView0-fail', 20000)
|
.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');
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue