Added TestableInput

This commit is contained in:
2025-10-31 21:11:56 +01:00
parent b5c1c15198
commit 3721bb7ad7
15 changed files with 730 additions and 246 deletions

View File

@@ -1,9 +1,9 @@
import pytest
from fasthtml.fastapp import fast_app
from myfasthtml.controls.button import mk_button
from myfasthtml.controls.helpers import mk
from myfasthtml.core.commands import Command, CommandsManager
from myfasthtml.core.testclient import MyTestClient, TestableElement
from myfasthtml.test.testclient import MyTestClient, TestableElement
def new_value(value):
@@ -24,7 +24,7 @@ def rt(user):
def test_i_can_trigger_a_command(user):
command = Command('test', 'TestingCommand', new_value, "this is my new value")
testable = TestableElement(user, mk_button('button', command))
testable = TestableElement(user, mk.button('button', command))
testable.click()
assert user.get_content() == "this is my new value"
@@ -32,7 +32,7 @@ def test_i_can_trigger_a_command(user):
def test_error_is_raised_when_command_is_not_found(user):
command = Command('test', 'TestingCommand', new_value, "this is my new value")
CommandsManager.reset()
testable = TestableElement(user, mk_button('button', command))
testable = TestableElement(user, mk.button('button', command))
with pytest.raises(ValueError) as exc_info:
testable.click()
@@ -44,7 +44,7 @@ def test_i_can_play_a_complex_scenario(user, rt):
command = Command('test', 'TestingCommand', new_value, "this is my new value")
@rt('/')
def get(): return mk_button('button', command)
def get(): return mk.button('button', command)
user.open("/")
user.should_see("button")