From e8ee3f7ee134bb6b5fb75079381be87cb2062008 Mon Sep 17 00:00:00 2001 From: grdddj Date: Thu, 27 Jul 2023 15:55:01 +0200 Subject: [PATCH] chore(tests): adapt click tests for the new recovery flow [no changelog] --- tests/click_tests/recovery.py | 50 ++++++------------- tests/click_tests/test_autolock.py | 12 ++--- .../test_shamir_persistence.py | 5 ++ 3 files changed, 22 insertions(+), 45 deletions(-) diff --git a/tests/click_tests/recovery.py b/tests/click_tests/recovery.py index 8d7ac5644e..30fbf17f34 100644 --- a/tests/click_tests/recovery.py +++ b/tests/click_tests/recovery.py @@ -39,19 +39,13 @@ def enter_word( def confirm_recovery(debug: "DebugLink") -> None: + layout = debug.wait_layout() if debug.model == "T": - if not debug.legacy_ui and not debug.legacy_debug: - layout = debug.wait_layout() - assert layout.title().startswith( - ("WALLET RECOVERY", "RECOVER WALLET", "BACKUP CHECK") - ) + assert layout.title().startswith(("RECOVER WALLET", "BACKUP CHECK")) debug.click(buttons.OK, wait=True) elif debug.model == "R": - layout = debug.wait_layout() assert layout.title() == "RECOVER WALLET" debug.press_right(wait=True) - layout = debug.press_right(wait=True) - assert "safe to eject" in layout.text_content() debug.press_right() @@ -61,20 +55,11 @@ def select_number_of_words( if wait: debug.wait_layout() if debug.model == "T": - # select number of words - if not debug.legacy_ui and not debug.legacy_debug: - assert "number of words" in debug.read_layout().text_content() - layout = debug.click(buttons.OK, wait=True) - if debug.legacy_ui: - assert layout.json_str == "WordSelector" - elif debug.legacy_debug: - assert "SelectWordCount" in layout.json_str - else: - assert layout.title() in ( - "WALLET RECOVERY", - "BACKUP CHECK", - "RECOVER WALLET", - ) + assert "number of words" in debug.read_layout().text_content() + assert debug.read_layout().title() in ( + "BACKUP CHECK", + "RECOVER WALLET", + ) # click the number word_option_offset = 6 @@ -99,11 +84,10 @@ def select_number_of_words( else: raise ValueError("Unknown model") - if not debug.legacy_ui and not debug.legacy_debug: - if num_of_words in (20, 33): - assert "Enter any share" in layout.text_content() - else: - assert "Enter your backup" in layout.text_content() + if num_of_words in (20, 33): + assert "Enter any share" in layout.text_content() + else: + assert "Enter your backup" in layout.text_content() def enter_share( @@ -112,13 +96,7 @@ def enter_share( if debug.model == "T": layout = debug.click(buttons.OK, wait=True) - if debug.legacy_ui: - assert layout.json_str == "Slip39Keyboard" - elif debug.legacy_debug: - assert "MnemonicKeyboard" in layout.json_str - else: - assert layout.main_component() == "MnemonicKeyboard" - + assert layout.main_component() == "MnemonicKeyboard" for word in share.split(" "): layout = enter_word(debug, word, is_slip39=True) @@ -130,7 +108,7 @@ def enter_share( # Word entering info debug.press_right() layout = debug.press_right(wait=True) - assert "Slip39Entry" in layout.all_components() + assert "MnemonicKeyboard" in layout.all_components() for word in share.split(" "): layout = enter_word(debug, word, is_slip39=True) @@ -162,7 +140,7 @@ def enter_seed(debug: "DebugLink", seed_words: list[str]) -> None: debug.press_right() layout = debug.press_right(wait=True) - assert "Bip39Entry" in layout.all_components() + assert "MnemonicKeyboard" in layout.all_components() for word in seed_words: layout = enter_word(debug, word, is_slip39=False) diff --git a/tests/click_tests/test_autolock.py b/tests/click_tests/test_autolock.py index 342a3164e9..dbf40c624f 100644 --- a/tests/click_tests/test_autolock.py +++ b/tests/click_tests/test_autolock.py @@ -301,10 +301,7 @@ def test_dryrun_locks_at_word_entry(device_handler: "BackgroundDeviceHandler"): assert layout.main_component() == "MnemonicKeyboard" elif debug.model == "R": layout = debug.press_right(wait=True) - assert layout.title() in ("RECOVER WALLET", "BACKUP CHECK") - debug.press_right() - layout = debug.press_right(wait=True) - assert "Slip39Entry" in layout.all_components() + assert "MnemonicKeyboard" in layout.all_components() # make sure keyboard locks time.sleep(10.1) @@ -338,10 +335,7 @@ def test_dryrun_enter_word_slowly(device_handler: "BackgroundDeviceHandler"): assert layout.main_component() == "MnemonicKeyboard" elif debug.model == "R": layout = debug.press_right(wait=True) - assert layout.title() in ("RECOVER WALLET", "BACKUP CHECK") - debug.press_right() - layout = debug.press_right(wait=True) - assert "Slip39Entry" in layout.all_components() + assert "MnemonicKeyboard" in layout.all_components() # pressing middle button three times for _ in range(3): @@ -349,7 +343,7 @@ def test_dryrun_enter_word_slowly(device_handler: "BackgroundDeviceHandler"): debug.press_middle() layout = debug.wait_layout() # should not have locked, even though we took 9 seconds to type each letter - assert "Slip39Entry" in layout.all_components() + assert "MnemonicKeyboard" in layout.all_components() with pytest.raises(exceptions.Cancelled): device_handler.result() diff --git a/tests/persistence_tests/test_shamir_persistence.py b/tests/persistence_tests/test_shamir_persistence.py index 98486559d8..d5981ac940 100644 --- a/tests/persistence_tests/test_shamir_persistence.py +++ b/tests/persistence_tests/test_shamir_persistence.py @@ -54,6 +54,11 @@ def test_abort(core_emulator: Emulator): # no waiting for layout because layout doesn't change assert "number of words" in debug.read_layout().text_content() + # clicking at 24 in word choice (the same coords as CANCEL) + layout = debug.click(buttons.CANCEL, wait=True) + + # Cancelling the backup + assert "Enter your backup" in debug.read_layout().text_content() layout = debug.click(buttons.CANCEL, wait=True) assert layout.title() == "ABORT RECOVERY"