mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-12-18 04:18:10 +00:00
chore(tests): adapt click tests for the new recovery flow
[no changelog]
This commit is contained in:
parent
d48bae4598
commit
e8ee3f7ee1
@ -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)
|
||||
|
@ -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()
|
||||
|
@ -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"
|
||||
|
Loading…
Reference in New Issue
Block a user