From 5b9827117db2c59b8a9aa664536990aa18b23754 Mon Sep 17 00:00:00 2001 From: Dubno Petro <34708483+petro97@users.noreply.github.com> Date: Thu, 21 May 2020 21:19:55 +0300 Subject: [PATCH] Updated Profile page (#726) * Updated Profile page * Updates in Profile page * - test updates, bug fixes for empty elements Co-authored-by: Shaun Maharaj --- src/containers/ProfilePage.tsx | 4 ++-- src/containers/b2b/AddressBookPage.tsx | 8 ++++---- src/tests/e2e/profile.test.js | 3 +++ 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/containers/ProfilePage.tsx b/src/containers/ProfilePage.tsx index 5902f1b79..5d61d1ddf 100644 --- a/src/containers/ProfilePage.tsx +++ b/src/containers/ProfilePage.tsx @@ -159,7 +159,7 @@ class ProfilePage extends React.Component renderShippingAddress() { const { profileData } = this.state; - if (profileData && profileData._addresses[0]._shippingaddresses && profileData._addresses[0]._shippingaddresses[0]._selector[0]._chosen) { + if (profileData && profileData._addresses && profileData._addresses[0]._shippingaddresses && profileData._addresses[0]._shippingaddresses[0]._selector && profileData._addresses[0]._shippingaddresses[0]._selector[0]._chosen) { const selectedAddress = profileData._addresses[0]._shippingaddresses[0]._selector[0]._chosen[0]._description[0].address; const selectedAddressName = profileData._addresses[0]._shippingaddresses[0]._selector[0]._chosen[0]._description[0].name; return ( @@ -189,7 +189,7 @@ class ProfilePage extends React.Component renderBillingAddress() { const { profileData } = this.state; - if (profileData && profileData._addresses[0]._billingaddresses && profileData._addresses[0]._billingaddresses[0]._selector[0]._chosen) { + if (profileData && profileData._addresses && profileData._addresses[0]._billingaddresses && profileData._addresses[0]._billingaddresses[0]._selector && profileData._addresses[0]._billingaddresses[0]._selector[0]._chosen) { const selectedAddress = profileData._addresses[0]._billingaddresses[0]._selector[0]._chosen[0]._description[0].address; const selectedAddressName = profileData._addresses[0]._billingaddresses[0]._selector[0]._chosen[0]._description[0].name; return ( diff --git a/src/containers/b2b/AddressBookPage.tsx b/src/containers/b2b/AddressBookPage.tsx index 68d0b7867..96cca8347 100644 --- a/src/containers/b2b/AddressBookPage.tsx +++ b/src/containers/b2b/AddressBookPage.tsx @@ -101,8 +101,8 @@ class AddressBookPage extends React.Component addressData.addressUri === el._description[0].self.uri); - let selectactionBillingUri = addressData && profileData._billingaddresses[0]._selector[0]._choice + let selectactionBillingUri = addressData && profileData._billingaddresses[0]._selector && profileData._billingaddresses[0]._selector[0]._choice && profileData._billingaddresses[0]._selector[0]._choice.find(el => addressData.addressUri === el._description[0].self.uri); selectactionShippingUri = selectactionShippingUri && selectactionShippingUri._selectaction[0].self.uri; selectactionBillingUri = selectactionBillingUri && selectactionBillingUri._selectaction[0].self.uri; diff --git a/src/tests/e2e/profile.test.js b/src/tests/e2e/profile.test.js index 393de2c99..96dac775d 100644 --- a/src/tests/e2e/profile.test.js +++ b/src/tests/e2e/profile.test.js @@ -269,6 +269,9 @@ describe('Profile', () => { await page.click(MY_PROFILE); // Then I can see my addresses + await page.waitFor(3000); + await page.waitForSelector(EDIT_ADDRESS_BUTTON); + await page.click(EDIT_ADDRESS_BUTTON); await page.waitForSelector(ADDRESS_STREET_NAME); const element = await page.$(ADDRESS_STREET_NAME); const text = await page.evaluate(el => el.textContent, element);