From 8012ede12698477692b80769781096b559159a32 Mon Sep 17 00:00:00 2001 From: kumavis Date: Wed, 11 Jan 2017 19:04:19 -0800 Subject: background - introduce ObservableStore --- test/integration/lib/idStore-migrator-test.js | 33 ++++++++++++--------------- 1 file changed, 15 insertions(+), 18 deletions(-) (limited to 'test/integration/lib') diff --git a/test/integration/lib/idStore-migrator-test.js b/test/integration/lib/idStore-migrator-test.js index 4ae30411d..1ceaac442 100644 --- a/test/integration/lib/idStore-migrator-test.js +++ b/test/integration/lib/idStore-migrator-test.js @@ -1,25 +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('../../../app/scripts/lib/observable/') +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') +const badStyleVault = require('../mocks/badVault.json') -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) + let store = new ObservableStore(oldStyleVault) this.configManager = new ConfigManager({ - loadData: () => { return JSON.parse(window.localStorage[STORAGE_KEY]) }, - setData: (data) => { window.localStorage[STORAGE_KEY] = JSON.stringify(data) }, + store: store, }) this.migrator = new IdStoreMigrator({ @@ -46,11 +44,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) + let store = new ObservableStore(badStyleVault) this.configManager = new ConfigManager({ - loadData: () => { return JSON.parse(window.localStorage[STORAGE_KEY]) }, - setData: (data) => { window.localStorage[STORAGE_KEY] = JSON.stringify(data) }, + store: store, }) this.migrator = new IdStoreMigrator({ -- cgit v1.2.3 From 3bc996878b467e1fa5fd63656bd465377daa137d Mon Sep 17 00:00:00 2001 From: kumavis Date: Wed, 11 Jan 2017 22:47:56 -0800 Subject: background - move pojo migrator to outside of metamask controller --- test/integration/lib/idStore-migrator-test.js | 44 +++++++++++++++------------ 1 file changed, 24 insertions(+), 20 deletions(-) (limited to 'test/integration/lib') diff --git a/test/integration/lib/idStore-migrator-test.js b/test/integration/lib/idStore-migrator-test.js index 1ceaac442..d95cfb401 100644 --- a/test/integration/lib/idStore-migrator-test.js +++ b/test/integration/lib/idStore-migrator-test.js @@ -4,8 +4,8 @@ const IdStoreMigrator = require('../../../app/scripts/lib/idStore-migrator') const SimpleKeyring = require('../../../app/scripts/keyrings/simple') const normalize = require('../../../app/scripts/lib/sig-util').normalize -const oldStyleVault = require('../mocks/oldVault.json') -const badStyleVault = require('../mocks/badVault.json') +const oldStyleVault = require('../mocks/oldVault.json').data +const badStyleVault = require('../mocks/badVault.json').data const PASSWORD = '12345678' const FIRST_ADDRESS = '0x4dd5d356c5A016A220bCD69e82e5AF680a430d00'.toLowerCase() @@ -14,15 +14,10 @@ const SEED = 'fringe damage bounce extend tunnel afraid alert sound all soldier QUnit.module('Old Style Vaults', { beforeEach: function () { - let store = new ObservableStore(oldStyleVault) - - this.configManager = new ConfigManager({ - store: store, - }) - - this.migrator = new IdStoreMigrator({ - configManager: this.configManager, - }) + let managers = managersFromInitState(oldStyleVault) + + this.configManager = managers.configManager + this.migrator = managers.migrator } }) @@ -35,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') @@ -44,15 +40,10 @@ QUnit.test('migrator:migratedVaultForPassword', function (assert) { QUnit.module('Old Style Vaults with bad HD seed', { beforeEach: function () { - let store = new ObservableStore(badStyleVault) - - this.configManager = new ConfigManager({ - store: store, - }) - - this.migrator = new IdStoreMigrator({ - configManager: this.configManager, - }) + let managers = managersFromInitState(badStyleVault) + + this.configManager = managers.configManager + this.migrator = managers.migrator } }) @@ -61,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') @@ -86,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 -- cgit v1.2.3 From 76ce348a04b83693eda0e8a40f9888c1f5fe7ef5 Mon Sep 17 00:00:00 2001 From: kumavis Date: Tue, 24 Jan 2017 19:47:00 -0800 Subject: obs-store - use published module --- test/integration/lib/idStore-migrator-test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test/integration/lib') diff --git a/test/integration/lib/idStore-migrator-test.js b/test/integration/lib/idStore-migrator-test.js index d95cfb401..f2a437a7c 100644 --- a/test/integration/lib/idStore-migrator-test.js +++ b/test/integration/lib/idStore-migrator-test.js @@ -1,4 +1,4 @@ -const ObservableStore = require('../../../app/scripts/lib/observable/') +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') -- cgit v1.2.3 From d8a12c2ad0a3244c1e08e650de2e918fdbe3f980 Mon Sep 17 00:00:00 2001 From: kumavis Date: Wed, 1 Feb 2017 16:27:16 -0800 Subject: tests - mockDev - fix first-time flow --- test/integration/lib/first-time.js | 38 ++++++++++++++++++-------------------- 1 file changed, 18 insertions(+), 20 deletions(-) (limited to 'test/integration/lib') diff --git a/test/integration/lib/first-time.js b/test/integration/lib/first-time.js index 777fcbb7e..fc9452045 100644 --- a/test/integration/lib/first-time.js +++ b/test/integration/lib/first-time.js @@ -8,49 +8,47 @@ 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 + 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) -- cgit v1.2.3 From dacbf16fe2b2a865fcbb1fd15236efdba525c015 Mon Sep 17 00:00:00 2001 From: kumavis Date: Wed, 1 Feb 2017 16:41:28 -0800 Subject: test - first-time - re-add terms header check --- test/integration/lib/first-time.js | 2 ++ 1 file changed, 2 insertions(+) (limited to 'test/integration/lib') diff --git a/test/integration/lib/first-time.js b/test/integration/lib/first-time.js index fc9452045..6e75eb6d7 100644 --- a/test/integration/lib/first-time.js +++ b/test/integration/lib/first-time.js @@ -10,6 +10,8 @@ QUnit.test('agree to terms', function (assert) { app = $('iframe').contents().find('#app-content .mock-app-root') // 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 -- cgit v1.2.3