From f6d0deb80bff81eb24e34b5a9d9ea16e9aea0c55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patryk=20=C5=81ucka?= Date: Tue, 29 Sep 2020 18:47:55 +0200 Subject: [PATCH] Fix 3Box sync and e2e tests (#9422) Co-authored-by: Whymarrh Whitby --- app/scripts/controllers/threebox.js | 14 +++++++------- test/e2e/threebox.spec.js | 19 +++++++++---------- 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/app/scripts/controllers/threebox.js b/app/scripts/controllers/threebox.js index 080fac6cc..be6c2fa0a 100644 --- a/app/scripts/controllers/threebox.js +++ b/app/scripts/controllers/threebox.js @@ -178,16 +178,16 @@ export default class ThreeBoxController { async migrateBackedUpState (backedUpState) { const migrator = new Migrator({ migrations }) - + const { preferences, addressBook } = JSON.parse(backedUpState) const formattedStateBackup = { - PreferencesController: backedUpState.preferences, - AddressBookController: backedUpState.addressBook, + PreferencesController: preferences, + AddressBookController: addressBook, } const initialMigrationState = migrator.generateInitialState(formattedStateBackup) const migratedState = await migrator.migrateData(initialMigrationState) return { - preferences: migratedState.PreferencesController, - addressBook: migratedState.AddressBookController, + preferences: migratedState.data.PreferencesController, + addressBook: migratedState.data.AddressBookController, } } @@ -198,8 +198,8 @@ export default class ThreeBoxController { addressBook, } = await this.migrateBackedUpState(backedUpState) this.store.updateState({ threeBoxLastUpdated: backedUpState.lastUpdated }) - preferences && this.preferencesController.store.updateState(JSON.parse(preferences)) - addressBook && this.addressBookController.update(JSON.parse(addressBook), true) + preferences && this.preferencesController.store.updateState(preferences) + addressBook && this.addressBookController.update(addressBook, true) this.setShowRestorePromptToFalse() } diff --git a/test/e2e/threebox.spec.js b/test/e2e/threebox.spec.js index 3ba7c060e..3254d8cb9 100644 --- a/test/e2e/threebox.spec.js +++ b/test/e2e/threebox.spec.js @@ -213,27 +213,26 @@ describe('MetaMask', function () { await driver2.clickElement(By.css('.home-notification__accept-button')) }) - // TODO: Fix tests from here forward; they're using the wrong driver it('goes to the settings screen', async function () { - await driver.clickElement(By.css('.account-menu__icon')) - await driver.delay(regularDelayMs) + await driver2.clickElement(By.css('.account-menu__icon')) + await driver2.delay(regularDelayMs) - await driver.clickElement(By.xpath(`//div[contains(text(), 'Settings')]`)) + await driver2.clickElement(By.xpath(`//div[contains(text(), 'Settings')]`)) }) it('finds the blockies toggle turned on', async function () { - await driver.delay(regularDelayMs) - const toggleLabel = await driver.findElement(By.css('.toggle-button__status')) + await driver2.delay(regularDelayMs) + const toggleLabel = await driver2.findElement(By.css('.toggle-button__status')) const toggleLabelText = await toggleLabel.getText() assert.equal(toggleLabelText, 'ON') }) it('finds the restored address in the contact list', async function () { - await driver.clickElement(By.xpath(`//div[contains(text(), 'Contacts')]`)) - await driver.delay(regularDelayMs) + await driver2.clickElement(By.xpath(`//div[contains(text(), 'Contacts')]`)) + await driver2.delay(regularDelayMs) - await driver.findElement(By.xpath(`//div[contains(text(), 'Test User Name 11')]`)) - await driver.delay(regularDelayMs) + await driver2.findElement(By.xpath(`//div[contains(text(), 'Test User Name 11')]`)) + await driver2.delay(regularDelayMs) }) }) })