[#9902] Make Sign out go to Multiaccount overview 'Your keys' screen
Fix e2e tests Signed-off-by: Gheorghe Pinzaru <feross95@gmail.com>
This commit is contained in:
parent
b2a70c8331
commit
0a7dc8fdd2
|
@ -32,18 +32,24 @@
|
||||||
:view-id view-id)})
|
:view-id view-id)})
|
||||||
|
|
||||||
(fx/defn initialize-views
|
(fx/defn initialize-views
|
||||||
[cofx]
|
[cofx {:keys [logout?]}]
|
||||||
(let [{{:multiaccounts/keys [multiaccounts] :as db} :db} cofx]
|
(let [{{:multiaccounts/keys [multiaccounts] :as db} :db} cofx]
|
||||||
(if (empty? multiaccounts)
|
(cond
|
||||||
|
(empty? multiaccounts)
|
||||||
(navigation/navigate-to-cofx cofx :intro nil)
|
(navigation/navigate-to-cofx cofx :intro nil)
|
||||||
|
|
||||||
|
logout?
|
||||||
|
(navigation/navigate-to-cofx cofx :multiaccounts nil)
|
||||||
|
|
||||||
|
:else
|
||||||
(let [{:keys [key-uid public-key photo-path name]} (first (#(sort-by :last-sign-in > %) (vals multiaccounts)))]
|
(let [{:keys [key-uid public-key photo-path name]} (first (#(sort-by :last-sign-in > %) (vals multiaccounts)))]
|
||||||
(multiaccounts.login/open-login cofx key-uid photo-path name public-key)))))
|
(multiaccounts.login/open-login cofx key-uid photo-path name public-key)))))
|
||||||
|
|
||||||
(fx/defn initialize-multiaccounts
|
(fx/defn initialize-multiaccounts
|
||||||
{:events [::initialize-multiaccounts]}
|
{:events [::initialize-multiaccounts]}
|
||||||
[{:keys [db] :as cofx} all-multiaccounts]
|
[{:keys [db] :as cofx} all-multiaccounts {:keys [logout?]}]
|
||||||
(let [multiaccounts (reduce (fn [acc {:keys [key-uid keycard-pairing]
|
(let [multiaccounts (reduce (fn [acc {:keys [key-uid keycard-pairing]
|
||||||
:as multiaccount}]
|
:as multiaccount}]
|
||||||
(-> (assoc acc key-uid multiaccount)
|
(-> (assoc acc key-uid multiaccount)
|
||||||
(assoc-in [key-uid :keycard-pairing]
|
(assoc-in [key-uid :keycard-pairing]
|
||||||
(when-not (string/blank? keycard-pairing)
|
(when-not (string/blank? keycard-pairing)
|
||||||
|
@ -52,14 +58,14 @@
|
||||||
all-multiaccounts)]
|
all-multiaccounts)]
|
||||||
(fx/merge cofx
|
(fx/merge cofx
|
||||||
{:db (assoc db :multiaccounts/multiaccounts multiaccounts)}
|
{:db (assoc db :multiaccounts/multiaccounts multiaccounts)}
|
||||||
(initialize-views))))
|
(initialize-views {:logout? logout?}))))
|
||||||
|
|
||||||
(fx/defn start-app [cofx]
|
(fx/defn start-app [cofx]
|
||||||
(fx/merge cofx
|
(fx/merge cofx
|
||||||
{:get-supported-biometric-auth nil
|
{:get-supported-biometric-auth nil
|
||||||
::init-keystore nil
|
::init-keystore nil
|
||||||
::restore-native-settings nil
|
::restore-native-settings nil
|
||||||
::open-multiaccounts #(re-frame/dispatch [::initialize-multiaccounts %])
|
::open-multiaccounts #(re-frame/dispatch [::initialize-multiaccounts % {:logout? false}])
|
||||||
:ui/listen-to-window-dimensions-change nil
|
:ui/listen-to-window-dimensions-change nil
|
||||||
::network/listen-to-network-info nil
|
::network/listen-to-network-info nil
|
||||||
:hardwallet/register-card-events nil
|
:hardwallet/register-card-events nil
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
[status-im.native-module.core :as status]
|
[status-im.native-module.core :as status]
|
||||||
[status-im.transport.core :as transport]
|
[status-im.transport.core :as transport]
|
||||||
[status-im.utils.fx :as fx]
|
[status-im.utils.fx :as fx]
|
||||||
|
[status-im.ui.screens.navigation :as navigation]
|
||||||
[status-im.utils.keychain.core :as keychain]))
|
[status-im.utils.keychain.core :as keychain]))
|
||||||
|
|
||||||
(fx/defn logout-method [{:keys [db] :as cofx} auth-method]
|
(fx/defn logout-method [{:keys [db] :as cofx} auth-method]
|
||||||
|
@ -13,7 +14,7 @@
|
||||||
(fx/merge cofx
|
(fx/merge cofx
|
||||||
{::logout nil
|
{::logout nil
|
||||||
:keychain/clear-user-password key-uid
|
:keychain/clear-user-password key-uid
|
||||||
::init/open-multiaccounts #(re-frame/dispatch [::init/initialize-multiaccounts %])}
|
::init/open-multiaccounts #(re-frame/dispatch [::init/initialize-multiaccounts % {:logout? true}])}
|
||||||
(keychain/save-auth-method key-uid auth-method)
|
(keychain/save-auth-method key-uid auth-method)
|
||||||
(transport/stop-whisper)
|
(transport/stop-whisper)
|
||||||
(chaos-mode/stop-checking)
|
(chaos-mode/stop-checking)
|
||||||
|
|
|
@ -21,7 +21,6 @@ class TestCreateAccount(SingleDeviceTestCase):
|
||||||
profile.logout()
|
profile.logout()
|
||||||
if sign_in.ok_button.is_element_displayed():
|
if sign_in.ok_button.is_element_displayed():
|
||||||
sign_in.ok_button.click()
|
sign_in.ok_button.click()
|
||||||
sign_in.back_button.click()
|
|
||||||
sign_in.your_keys_more_icon.click()
|
sign_in.your_keys_more_icon.click()
|
||||||
sign_in.generate_new_key_button.click()
|
sign_in.generate_new_key_button.click()
|
||||||
sign_in.generate_key_button.click()
|
sign_in.generate_key_button.click()
|
||||||
|
|
|
@ -10,14 +10,20 @@ class MultiAccountButton(BaseButton):
|
||||||
class Username(BaseText):
|
class Username(BaseText):
|
||||||
def __init__(self, driver, locator_value):
|
def __init__(self, driver, locator_value):
|
||||||
super(MultiAccountButton.Username, self).__init__(driver)
|
super(MultiAccountButton.Username, self).__init__(driver)
|
||||||
self.locator = self.Locator.xpath_selector(locator_value + '/preceding-sibling::*[1]')
|
self.locator = self.Locator.xpath_selector(locator_value + '/android.view.ViewGroup/android.widget.TextView[1]')
|
||||||
|
|
||||||
def __init__(self, driver, position):
|
def __init__(self, driver, position=1):
|
||||||
super(MultiAccountButton, self).__init__(driver)
|
super(MultiAccountButton, self).__init__(driver)
|
||||||
self.locator = self.Locator.xpath_selector("(//*[contains(@text,'0x')])[%s]" % position)
|
self.locator = self.Locator.xpath_selector("//*[@content-desc='select-account-button-%s']" % position)
|
||||||
self.username = self.Username(driver, self.locator.value)
|
self.username = self.Username(driver, self.locator.value)
|
||||||
|
|
||||||
|
|
||||||
|
class MultiAccountOnLoginButton(BaseButton):
|
||||||
|
def __init__(self, driver, position=1):
|
||||||
|
super(MultiAccountOnLoginButton, self).__init__(driver)
|
||||||
|
self.locator = self.Locator.xpath_selector("(//*[@content-desc='chat-icon'])[%s]/.." % position)
|
||||||
|
|
||||||
|
|
||||||
class PasswordInput(BaseEditBox):
|
class PasswordInput(BaseEditBox):
|
||||||
def __init__(self, driver):
|
def __init__(self, driver):
|
||||||
super(PasswordInput, self).__init__(driver)
|
super(PasswordInput, self).__init__(driver)
|
||||||
|
@ -189,6 +195,8 @@ class SignInView(BaseView):
|
||||||
self.maybe_later_button = MaybeLaterButton(self.driver)
|
self.maybe_later_button = MaybeLaterButton(self.driver)
|
||||||
self.name_input = NameInput(self.driver)
|
self.name_input = NameInput(self.driver)
|
||||||
self.other_multiaccounts_button = OtherMultiAccountsButton(self.driver)
|
self.other_multiaccounts_button = OtherMultiAccountsButton(self.driver)
|
||||||
|
self.multiaccount_button = MultiAccountButton(self.driver)
|
||||||
|
self.multi_account_on_login_button = MultiAccountOnLoginButton(self.driver)
|
||||||
self.privacy_policy_link = PrivacyPolicyLink(self.driver)
|
self.privacy_policy_link = PrivacyPolicyLink(self.driver)
|
||||||
self.lets_go_button = LetsGoButton(self.driver)
|
self.lets_go_button = LetsGoButton(self.driver)
|
||||||
|
|
||||||
|
@ -223,14 +231,12 @@ class SignInView(BaseView):
|
||||||
return self.get_home_view()
|
return self.get_home_view()
|
||||||
|
|
||||||
def sign_in(self, password=common_password):
|
def sign_in(self, password=common_password):
|
||||||
self.accept_agreements()
|
self.multi_account_on_login_button.click()
|
||||||
self.password_input.set_value(password)
|
self.password_input.set_value(password)
|
||||||
self.confirm()
|
self.sign_in_button.click()
|
||||||
return self.get_home_view()
|
return self.get_home_view()
|
||||||
|
|
||||||
def get_account_by_position(self, position: int):
|
def get_account_by_position(self, position: int):
|
||||||
if self.ok_button.is_element_displayed():
|
|
||||||
self.ok_button.click()
|
|
||||||
account_button = MultiAccountButton(self.driver, position)
|
account_button = MultiAccountButton(self.driver, position)
|
||||||
if account_button.is_element_displayed():
|
if account_button.is_element_displayed():
|
||||||
return account_button
|
return account_button
|
||||||
|
|
Loading…
Reference in New Issue