diff options
Diffstat (limited to 'test/integration')
-rw-r--r-- | test/integration/index.html | 2 | ||||
-rw-r--r-- | test/integration/lib/first-time.js | 40 | ||||
-rw-r--r-- | test/integration/lib/idStore-migrator-test.js | 65 | ||||
-rw-r--r-- | test/integration/mocks/oldVault.json | 2 |
4 files changed, 55 insertions, 54 deletions
diff --git a/test/integration/index.html b/test/integration/index.html index 8a54cb829..430814a8a 100644 --- a/test/integration/index.html +++ b/test/integration/index.html @@ -15,7 +15,7 @@ <script src="bundle.js"></script> <script src="/testem.js"></script> - <iframe src="/development/test.html" height="500px" width="360px"> + <iframe src="/development/test.html" height="800px" width="500px"> <p>Your browser does not support iframes</p> </iframe> </body> diff --git a/test/integration/lib/first-time.js b/test/integration/lib/first-time.js index 777fcbb7e..6e75eb6d7 100644 --- a/test/integration/lib/first-time.js +++ b/test/integration/lib/first-time.js @@ -8,49 +8,49 @@ QUnit.test('agree to terms', function (assert) { wait().then(function() { app = $('iframe').contents().find('#app-content .mock-app-root') - app.find('.markdown').prop('scrollTop', 100000000) + + // Scroll through terms + var termsHeader = app.find('h3.terms-header')[0] + assert.equal(termsHeader.textContent, 'MetaMask Terms & Conditions', 'Showing TOS') + let termsPage = app.find('.markdown')[0] + assert.ok(termsPage, 'on terms page') + termsPage.scrollTop = termsPage.scrollHeight + return wait() + }).then(function() { + + // Agree to terms + var button = app.find('button')[0] + button.click() + return wait() }).then(function() { var title = app.find('h1').text() assert.equal(title, 'MetaMask', 'title screen') + // enter password var pwBox = app.find('#password-box')[0] var confBox = app.find('#password-box-confirm')[0] - pwBox.value = PASSWORD confBox.value = PASSWORD + return wait() - }).then(function() { + // create vault var createButton = app.find('button.primary')[0] createButton.click() return wait(1500) }).then(function() { - var terms = app.find('h3.terms-header')[0] - assert.equal(terms.textContent, 'MetaMask Terms & Conditions', 'Showing TOS') - - // Scroll through terms - var scrollable = app.find('.markdown')[0] - scrollable.scrollTop = scrollable.scrollHeight - - return wait(10) - }).then(function() { - - var button = app.find('button')[0] // Agree button - button.click() - - return wait(1000) - }).then(function() { - var created = app.find('h3')[0] assert.equal(created.textContent, 'Vault Created', 'Vault created screen') - var button = app.find('button')[0] // Agree button + // Agree button + var button = app.find('button')[0] + assert.ok(button, 'button present') button.click() return wait(1000) diff --git a/test/integration/lib/idStore-migrator-test.js b/test/integration/lib/idStore-migrator-test.js index 4ae30411d..f2a437a7c 100644 --- a/test/integration/lib/idStore-migrator-test.js +++ b/test/integration/lib/idStore-migrator-test.js @@ -1,30 +1,23 @@ -var ConfigManager = require('../../../app/scripts/lib/config-manager') -var IdStoreMigrator = require('../../../app/scripts/lib/idStore-migrator') -var SimpleKeyring = require('../../../app/scripts/keyrings/simple') -var normalize = require('../../../app/scripts/lib/sig-util').normalize +const ObservableStore = require('obs-store') +const ConfigManager = require('../../../app/scripts/lib/config-manager') +const IdStoreMigrator = require('../../../app/scripts/lib/idStore-migrator') +const SimpleKeyring = require('../../../app/scripts/keyrings/simple') +const normalize = require('../../../app/scripts/lib/sig-util').normalize -var oldStyleVault = require('../mocks/oldVault.json') -var badStyleVault = require('../mocks/badVault.json') +const oldStyleVault = require('../mocks/oldVault.json').data +const badStyleVault = require('../mocks/badVault.json').data -var STORAGE_KEY = 'metamask-config' -var PASSWORD = '12345678' -var FIRST_ADDRESS = '0x4dd5d356c5A016A220bCD69e82e5AF680a430d00'.toLowerCase() -var SEED = 'fringe damage bounce extend tunnel afraid alert sound all soldier all dinner' - -var BAD_STYLE_FIRST_ADDRESS = '0xac39b311dceb2a4b2f5d8461c1cdaf756f4f7ae9' +const PASSWORD = '12345678' +const FIRST_ADDRESS = '0x4dd5d356c5A016A220bCD69e82e5AF680a430d00'.toLowerCase() +const BAD_STYLE_FIRST_ADDRESS = '0xac39b311dceb2a4b2f5d8461c1cdaf756f4f7ae9' +const SEED = 'fringe damage bounce extend tunnel afraid alert sound all soldier all dinner' QUnit.module('Old Style Vaults', { beforeEach: function () { - window.localStorage[STORAGE_KEY] = JSON.stringify(oldStyleVault) - - this.configManager = new ConfigManager({ - loadData: () => { return JSON.parse(window.localStorage[STORAGE_KEY]) }, - setData: (data) => { window.localStorage[STORAGE_KEY] = JSON.stringify(data) }, - }) - - this.migrator = new IdStoreMigrator({ - configManager: this.configManager, - }) + let managers = managersFromInitState(oldStyleVault) + + this.configManager = managers.configManager + this.migrator = managers.migrator } }) @@ -37,6 +30,7 @@ QUnit.test('migrator:migratedVaultForPassword', function (assert) { this.migrator.migratedVaultForPassword(PASSWORD) .then((result) => { + assert.ok(result, 'migratedVaultForPassword returned result') const { serialized, lostAccounts } = result assert.equal(serialized.data.mnemonic, SEED, 'seed phrase recovered') assert.equal(lostAccounts.length, 0, 'no lost accounts') @@ -46,16 +40,10 @@ QUnit.test('migrator:migratedVaultForPassword', function (assert) { QUnit.module('Old Style Vaults with bad HD seed', { beforeEach: function () { - window.localStorage[STORAGE_KEY] = JSON.stringify(badStyleVault) - - this.configManager = new ConfigManager({ - loadData: () => { return JSON.parse(window.localStorage[STORAGE_KEY]) }, - setData: (data) => { window.localStorage[STORAGE_KEY] = JSON.stringify(data) }, - }) - - this.migrator = new IdStoreMigrator({ - configManager: this.configManager, - }) + let managers = managersFromInitState(badStyleVault) + + this.configManager = managers.configManager + this.migrator = managers.migrator } }) @@ -64,6 +52,7 @@ QUnit.test('migrator:migratedVaultForPassword', function (assert) { this.migrator.migratedVaultForPassword(PASSWORD) .then((result) => { + assert.ok(result, 'migratedVaultForPassword returned result') const { serialized, lostAccounts } = result assert.equal(lostAccounts.length, 1, 'one lost account') @@ -89,3 +78,15 @@ QUnit.test('migrator:migratedVaultForPassword', function (assert) { }) }) +function managersFromInitState(initState){ + + let configManager = new ConfigManager({ + store: new ObservableStore(initState), + }) + + let migrator = new IdStoreMigrator({ + configManager: configManager, + }) + + return { configManager, migrator } +}
\ No newline at end of file diff --git a/test/integration/mocks/oldVault.json b/test/integration/mocks/oldVault.json index 5861c41d7..b908ed7ca 100644 --- a/test/integration/mocks/oldVault.json +++ b/test/integration/mocks/oldVault.json @@ -13,7 +13,7 @@ "provider": { "type": "testnet" }, - "selectedAccount": "0x4dd5d356c5a016a220bcd69e82e5af680a430d00" + "selectedAddress": "0x4dd5d356c5a016a220bcd69e82e5af680a430d00" }, "showSeedWords": false, "isEthConfirmed": true |