|
| 1 | +# SPDX-FileCopyrightText: 2025 Mathis Logemann <[email protected]> |
| 2 | +# |
| 3 | +# SPDX-License-Identifier: MIT |
| 4 | + |
| 5 | +from __future__ import annotations |
| 6 | + |
| 7 | +from datetime import timedelta |
| 8 | + |
| 9 | +import pytest |
| 10 | +import test_paths |
| 11 | +from pytest_bdd import parsers, scenario, then, when |
| 12 | + |
| 13 | +from quite import Probe, ProbeManager, make_query |
| 14 | + |
| 15 | + |
| 16 | +@pytest.fixture |
| 17 | +def application(): |
| 18 | + """Test article.""" |
| 19 | + return ProbeManager().launch_qt_probe_application( |
| 20 | + name="todo-app", path_to_application=test_paths.APP_PATH |
| 21 | + ) |
| 22 | + |
| 23 | + |
| 24 | +@scenario("manage_todo.feature", "Adding a new todo item to the list") |
| 25 | +def test_add_todo(): |
| 26 | + pass |
| 27 | + |
| 28 | + |
| 29 | +@when(parsers.parse("I have entered '{todo_text}' into the todo input field")) |
| 30 | +def enter_todo_text(application: Probe, todo_text: str): |
| 31 | + input_field = application.find_object( |
| 32 | + object_query=make_query().with_property("objectName", "inputField") |
| 33 | + ) |
| 34 | + input_field.property("text").write(todo_text) |
| 35 | + |
| 36 | + |
| 37 | +@when("I click the 'Add' button") |
| 38 | +def click_add_button(application: Probe): |
| 39 | + button = application.find_object( |
| 40 | + object_query=make_query().with_property("objectName", "addButton") |
| 41 | + ) |
| 42 | + button.mouse_action() |
| 43 | + |
| 44 | + |
| 45 | +@then( |
| 46 | + parsers.parse("the todo list should display '{expected_todo_text}' as a new item") |
| 47 | +) |
| 48 | +def verify_new_todo_exists(application: Probe, expected_todo_text: str): |
| 49 | + list_item = application.find_object( |
| 50 | + object_query=make_query().with_property("objectName", "listView") |
| 51 | + ) |
| 52 | + new_item_index = list_item.property("count").value() - 1 |
| 53 | + todo_list_item = application.try_find_object( |
| 54 | + object_query=make_query() |
| 55 | + .with_property("index", new_item_index) |
| 56 | + .with_type("SwipeDelegate"), |
| 57 | + timeout=timedelta(seconds=1), |
| 58 | + ) |
| 59 | + assert todo_list_item.property("text").value() == expected_todo_text |
0 commit comments