Skip to content
This repository has been archived by the owner on Sep 5, 2020. It is now read-only.

More spectron ETH-01 tests. #1689

Merged
merged 59 commits into from
Mar 27, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
9a9ae7b
Spectron iteration
evertonfraga Dec 19, 2016
fd26841
Updating spectron
evertonfraga Dec 19, 2016
4d03260
Creating switch for mist.lokidb for automated tests
evertonfraga Dec 20, 2016
43ebaf3
Adding chai-as-expected
evertonfraga Dec 22, 2016
4482a2c
Changing IPC flag
evertonfraga Dec 22, 2016
a69f944
Pairing spectron and electron versions
evertonfraga Dec 29, 2016
a13fe1a
[ESLint] Minor fixes
evertonfraga Jan 2, 2017
9e55aa6
Adding chai-string
evertonfraga Jan 4, 2017
380d6fa
Couple of tests passing
evertonfraga Jan 4, 2017
3c7a403
update .eslintrc.yml
Jan 6, 2017
e33638e
Simplifying code
evertonfraga Jan 10, 2017
0dfeef3
Removing delay in favor of better window management
evertonfraga Jan 13, 2017
8c2bb3a
Adding tests for URL bar
evertonfraga Jan 13, 2017
a6e30ad
Focusing window before each test
evertonfraga Jan 13, 2017
9fca756
Minor fixes
evertonfraga Jan 16, 2017
38e4943
Improving mist setup and teardown
evertonfraga Jan 16, 2017
de9c50e
Fixing wallet test
evertonfraga Jan 16, 2017
a14f8d0
adding html fixture
evertonfraga Jan 17, 2017
e021dcb
Improving test helpers
evertonfraga Jan 17, 2017
04510e5
Tests for ETH-01-002
evertonfraga Jan 17, 2017
155aec6
Updating tests
evertonfraga Jan 17, 2017
65b1379
Starting local HTTP server to deal with html fixtures
evertonfraga Jan 19, 2017
bf44704
Updating tests setup
evertonfraga Jan 23, 2017
58c4a63
Adding more tests
evertonfraga Jan 23, 2017
dd3f299
Updating travis file to run spectron tests
evertonfraga Jan 24, 2017
0cb40e6
Refactoring tests
evertonfraga Jan 26, 2017
8990b40
Tests for ETH-01-007
evertonfraga Jan 26, 2017
c78bc39
Downloading geth on the fly
evertonfraga Jan 30, 2017
5981ef5
Fine-tuning geth download during tests
evertonfraga Jan 30, 2017
7885ded
Merge branch 'develop' into ev_spectron
evertonfraga Jan 30, 2017
d965c42
Changing linux binary dir
evertonfraga Jan 30, 2017
18f9bf8
Fixing binary path on linux
evertonfraga Jan 30, 2017
86b45d9
Travis debug
evertonfraga Jan 30, 2017
6f49db9
Travis debug
evertonfraga Jan 30, 2017
5ad3883
Changing fixtures
evertonfraga Jan 30, 2017
5ebbe40
Fixing tests
evertonfraga Jan 30, 2017
862aee0
Fixing travis file
evertonfraga Jan 30, 2017
fc87c3d
More tests
evertonfraga Jan 30, 2017
cc20517
Adjusting timeouts
evertonfraga Jan 31, 2017
a9f96ae
Adjusting GULP_PLATFORM test env variable
evertonfraga Jan 31, 2017
73125b0
Adjusting timeouts
evertonfraga Jan 31, 2017
8eb4b9d
Disabling some tests for now
evertonfraga Jan 31, 2017
bc74c42
Merge branch 'develop' into ev_spectron
evertonfraga Jan 31, 2017
3637838
Disabling a test
evertonfraga Feb 1, 2017
d59fad4
Merge branch 'develop' into ev_spectron
evertonfraga Mar 1, 2017
f4c75a5
updating yarn
evertonfraga Mar 2, 2017
67552a0
Tests for ETH-01-009
evertonfraga Mar 3, 2017
159fc78
More tests
evertonfraga Mar 6, 2017
698af0a
Adding test for ETH-01-008
evertonfraga Mar 13, 2017
244a6e9
Merge branch 'develop' into ev_spectron
frozeman Mar 16, 2017
b87a9e0
simplify '--test' flag evaluation
Mar 16, 2017
e02d66d
revert unnecessary changes to yarn.lock (no changes to package.json)
Mar 16, 2017
73e520e
Minor comment changes
evertonfraga Mar 16, 2017
be828b3
Merge branch 'ev_spectron' of https://github.com/ethereum/mist into e…
evertonfraga Mar 16, 2017
27047a3
Merge branch 'develop' into ev_spectron
frozeman Mar 17, 2017
525d5c9
consistent use of 'protocol' in test titles
Mar 20, 2017
a279a29
Merge branch 'develop' into ev_spectron
evertonfraga Mar 20, 2017
e9a0e57
Update js-redirect.html
VictorTaelin Mar 21, 2017
f0836e1
Merge branch 'develop' into ev_spectron
evertonfraga Mar 27, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,11 @@ const cmp = require('semver-compare');
const parseJson = require('xml2js').parseString;

const options = minimist(process.argv.slice(2), {
string: ['platform', 'walletSource'],
string: ['platform', 'walletSource', 'test'],
default: {
platform: 'all',
walletSource: 'master',
test: 'basic',
},
});

Expand Down Expand Up @@ -548,8 +549,9 @@ gulp.task('build-nsis', (cb) => {


const testApp = (app) => {
// gulp test-mist [--test TESTFILEPREFIX]
return gulp.src([
`./tests/${app}/*.test.js`,
`./tests/${app}/${options.test}.test.js`,
]).pipe(mocha({
timeout: 60000,
ui: 'exports',
Expand Down
4 changes: 2 additions & 2 deletions tests/fixtures/fixture-popup.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
</head>
<body>
<h1>Fixture Popup</h1>
<a href="/index.html" target="_blank" id="link-01">Target blank</a>
<a href="/index.html" target="_popup" id="link-02">Target popup</a>
<a href="/index.html" target="_blank">Target blank</a>
<a href="/index.html" target="_popup">Target popup</a>
</body>
</html>
17 changes: 17 additions & 0 deletions tests/fixtures/js-redirect.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<html>
<head>
<title>JS redirect fixture</title>
</head>
<body>
<h1>JS redirect fixture</h1>

<script>
window.onerror = function(e){
console.log('e', e);
alert(e);
};

window.location.href = 'file:///Users/ev/Projects/Ethereum/officialMist/tests/fixtures/fixture-popup.html';
</script>
</body>
</html>
9 changes: 9 additions & 0 deletions tests/fixtures/meta-redirect.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<html>
<head>
<title>Meta redirect fixture</title>
<meta http-equiv="refresh" content="0; url=file:///Users/ev/Projects/Ethereum/officialMist/tests/fixtures/fixture-popup.html">
</head>
<body>
<h1>Meta redirect fixture</h1>
</body>
</html>
146 changes: 94 additions & 52 deletions tests/mist/basic.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ test['Sanity Check: main window is focused'] = function* () {
(yield client.getUrl()).should.match(/interface\/index\.html$/);
};

// FAILING ON TRAVIS
test['Browser bar should render urls with separators'] = function* () {
const client = this.client;

Expand Down Expand Up @@ -99,7 +98,7 @@ test['Load fixture page'] = function* () {
yield this.loadFixture();
};

test['"http://" protocol should be allowed on browser bar'] = function* () { // ETH-01-002
test['"http" protocol should be allowed on browser bar'] = function* () { // ETH-01-002
const client = this.client;
yield this.loadFixture();

Expand All @@ -117,7 +116,7 @@ test['"http://" protocol should be allowed on browser bar'] = function* () { //
browserBarText.should.eql('http://localhost:8080 ▸ index.html'); // checks that did change displayed URL
};

test['"javascript:" protocol should be disallowed on browser bar'] = function* () { // ETH-01-002
test['"javascript" protocol should be disallowed on browser bar'] = function* () { // ETH-01-002
const client = this.client;
yield this.loadFixture();
yield client.setValue('#url-input', 'javascript:window.close()');
Expand All @@ -134,7 +133,7 @@ test['"javascript:" protocol should be disallowed on browser bar'] = function* (
browserBarText.should.eql('http://localhost:8080'); // checks that hasn't changed displayed URL
};

test['"data:" protocol should be disallowed on browser bar'] = function* () { // ETH-01-002
test['"data" protocol should be disallowed on browser bar'] = function* () { // ETH-01-002
const client = this.client;
yield this.loadFixture();
yield client.setValue('#url-input', 'data:text/plain;charset=utf-8;base64,dGhpcyB0ZXN0IGlzIG9uIGZpcmU=');
Expand All @@ -151,15 +150,15 @@ test['"data:" protocol should be disallowed on browser bar'] = function* () { //
browserBarText.should.eql('http://localhost:8080'); // checks that hasn't changed displayed URL
};

// test['"file:///" protocol should be disallowed'] = function* () { // ETH-01-002
// const client = this.client;
// const filePath = 'file://' + path.join(__dirname, '..', 'fixtures', 'index.html');
test['"file" protocol should be disallowed on browser bar'] = function* () { // ETH-01-012
const client = this.client;
const filePath = 'file://' + path.join(__dirname, '..', 'fixtures', 'index.html');

// yield this.navigateTo(filePath);
// yield Q.delay(1500);
// const browserBarText = yield this.getBrowserBarText();
// browserBarText.should.match(/errorPages ▸ 400.html$/);
// };
yield this.navigateTo(filePath);
yield Q.delay(1500);
const browserBarText = yield this.getBrowserBarText();
browserBarText.should.match(/errorPages ▸ 400.html$/);
};

test['Pin tab test'] = function* () {
const client = this.client;
Expand All @@ -174,57 +173,100 @@ test['Pin tab test'] = function* () {
sidebarItemsAfterAdd.length.should.eql(3);
};

// test['Browse tab should be changed to pinned tab if the URL is the same'] = function* () { // ETH-01-007
// const client = this.client;
// yield this.selectTab('browser');
test['Browse tab should be changed to pinned tab if URLs are the same'] = function* () { // ETH-01-007
const client = this.client;
yield this.selectTab('browser');

// yield this.navigateTo('https://wallet.ethereum.org' );
// yield Q.delay(1000);
// const el = (yield client.element('.sidebar nav > ul > .selected'));
// console.log('el', el);
yield this.navigateTo('https://wallet.ethereum.org');
yield Q.delay(1000);
const selectedTab = (yield client.execute(() => { // code executed in browser context
return LocalStore.get('selectedTab');
})).value;

// el.getAttribute('data-tab-id').should.eql('wallet');
selectedTab.should.eql('wallet');
};

// };
test['Wallet tab shouldn\'t have the page replaced if URLs does not match'] = function* () { // ETH-01-007
const client = this.client;
const app = this;
yield this.selectTab('wallet');

// test['Wallet tab shouldn\'t have the page replaced if URLs does not match'] = function* () { // ETH-01-007
// const client = this.client;
// const app = this;
// yield this.selectTab('wallet');
yield this.navigateTo(`${this.fixtureBaseUrl}index.html?https://wallet.ethereum.org`);
yield client.waitUntil(() => {
return client.execute(() => {
return LocalStore.get('selectedTab') === 'browser';
});
}, 2000);
};

// yield this.navigateTo(`${this.fixtureBaseUrl}index.html?https://wallet.ethereum.org`);
// yield client.waitUntil(() => {
// return client.element('.sidebar nav > ul > .selected').then((e) => {
// console.log('e', e);
// return e.getAttribute('data-tab-id') === 'browse';
// });
// }, 2000);
// };
test['Wallet tab shouldn\'t have the page replaced if URLs does not match - 2'] = function* () { // ETH-01-007
const client = this.client;
const app = this;
yield this.selectTab('wallet');

// test['Wallet tab shouldn\'t have the page replaced if URLs does not match - 2'] = function* () { // ETH-01-007
// const client = this.client;
// const app = this;
// yield this.selectTab('wallet');
// Now changing address via JS
yield client.setValue('#url-input', `${this.fixtureBaseUrl}index.html?https://wallet.ethereum.org`);
const isProtocolBlocked = yield client.execute(() => { // Code executed in context of browser
$('form.url').submit();
});

// // Now changing address via JS
// yield client.setValue('#url-input', `${this.fixtureBaseUrl}index.html?https://wallet.ethereum.org`);
// const isProtocolBlocked = yield client.execute(() => { // Code executed in context of browser
// $('form.url').submit();
// });
yield client.waitUntil(() => {
return client.execute(() => {
return LocalStore.get('selectedTab') === 'browser';
});
}, 2000);
};

// yield client.waitUntil(() => {
// return client.element('.sidebar nav > ul > .selected').then((e) => {
// console.log('e', e);
// return e.getAttribute('data-tab-id') === 'browser';
// });
// }, 2000);
// };
test['Links with target _blank should open inside Mist'] = function* () {
const client = this.client;
yield this.navigateTo(`${this.fixtureBaseUrl}/fixture-popup.html`);
yield this.getWindowByUrl(e => /fixture-popup.html$/.test(e));

test['Links with target _blank or _popup should open inside Mist'] = function* () {
yield client.click('a[target=_blank]');
yield client.waitUntil(() => {
return client.getUrl((url) => {
return /index.html$/.test(url);
});
});
};

test['Links with target _popup should open inside Mist'] = function* () {
const client = this.client;
yield this.navigateTo(`${this.fixtureBaseUrl}/fixture-popup.html`);
yield this.getWindowByUrl(e => /popup.html$/.test(e));
yield this.getWindowByUrl(e => /fixture-popup.html$/.test(e));

yield client.click('a[target=_popup]');
yield client.waitUntil(() => {
return client.getUrl((url) => {
return /index.html$/.test(url);
})
});
};

// ETH-01-005
test['Mist main webview should not redirect to arbitrary addresses'] = function* () {
const client = this.client;
const initialURL = yield client.getUrl();

yield client.execute(() => { // code executed in context of browser
window.location.href = 'http://google.com';
});

// TODO: click on the fixtures' links and assert if they opened on the same page
yield Q.delay(1000);
(yield client.getUrl()).should.eql(initialURL);
};


// ETH-01-008
test['Mist main webview should not redirect to local files'] = function* () {
const client = this.client;
const initialURL = yield client.getUrl();

yield this.navigateTo('https://cure53.de/exchange/8743653459838/ETH-01-008.php');

yield client.waitUntil(() => {
return client.getText('.url-breadcrumb').then((e) => {
return /400\.html$/.test(e);
});
}, 5000, 'expected a URL not allowed as a result');
};