mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-17 21:22:10 +00:00
fix(core): raise ActionCancelled when cancelling tutorial flow for TR
[no changelog]
This commit is contained in:
parent
de7458dd49
commit
9a4cb1887d
@ -684,10 +684,12 @@ async def tutorial(
|
||||
br_code: ButtonRequestType = BR_TYPE_OTHER,
|
||||
) -> None:
|
||||
"""Showing users how to interact with the device."""
|
||||
await interact(
|
||||
RustLayout(trezorui2.tutorial()),
|
||||
"tutorial",
|
||||
br_code,
|
||||
await raise_if_not_confirmed(
|
||||
interact(
|
||||
RustLayout(trezorui2.tutorial()),
|
||||
"tutorial",
|
||||
br_code,
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
|
@ -20,6 +20,7 @@ from typing import TYPE_CHECKING, Generator
|
||||
import pytest
|
||||
|
||||
from trezorlib import device
|
||||
from trezorlib.exceptions import Cancelled
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..device_handler import BackgroundDeviceHandler
|
||||
@ -32,14 +33,18 @@ pytestmark = [pytest.mark.skip_t1, pytest.mark.skip_t2]
|
||||
|
||||
@contextmanager
|
||||
def prepare_tutorial_and_cancel_after_it(
|
||||
device_handler: "BackgroundDeviceHandler",
|
||||
device_handler: "BackgroundDeviceHandler", cancelled: bool = False
|
||||
) -> Generator["DebugLink", None, None]:
|
||||
debug = device_handler.debuglink()
|
||||
device_handler.run(device.show_device_tutorial)
|
||||
|
||||
yield debug
|
||||
|
||||
device_handler.result()
|
||||
try:
|
||||
device_handler.result()
|
||||
except Cancelled:
|
||||
if not cancelled:
|
||||
raise
|
||||
|
||||
|
||||
def go_through_tutorial(debug: "DebugLink") -> None:
|
||||
@ -64,7 +69,7 @@ def test_tutorial_finish(device_handler: "BackgroundDeviceHandler"):
|
||||
|
||||
@pytest.mark.setup_client(uninitialized=True)
|
||||
def test_tutorial_skip(device_handler: "BackgroundDeviceHandler"):
|
||||
with prepare_tutorial_and_cancel_after_it(device_handler) as debug:
|
||||
with prepare_tutorial_and_cancel_after_it(device_handler, cancelled=True) as debug:
|
||||
# SKIP
|
||||
debug.press_left(wait=True)
|
||||
debug.press_right(wait=True)
|
||||
@ -72,7 +77,7 @@ def test_tutorial_skip(device_handler: "BackgroundDeviceHandler"):
|
||||
|
||||
@pytest.mark.setup_client(uninitialized=True)
|
||||
def test_tutorial_again_and_skip(device_handler: "BackgroundDeviceHandler"):
|
||||
with prepare_tutorial_and_cancel_after_it(device_handler) as debug:
|
||||
with prepare_tutorial_and_cancel_after_it(device_handler, cancelled=True) as debug:
|
||||
# CLICK THROUGH
|
||||
go_through_tutorial(debug)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user