|
@@ -1,5 +1,4 @@
|
|
"""Integration tests for text input and related components."""
|
|
"""Integration tests for text input and related components."""
|
|
-import time
|
|
|
|
from typing import Generator
|
|
from typing import Generator
|
|
|
|
|
|
import pytest
|
|
import pytest
|
|
@@ -97,10 +96,11 @@ async def test_fully_controlled_input(fully_controlled_input: AppHarness):
|
|
# move cursor to home, then to the right and type characters
|
|
# move cursor to home, then to the right and type characters
|
|
debounce_input.send_keys(Keys.HOME, Keys.ARROW_RIGHT)
|
|
debounce_input.send_keys(Keys.HOME, Keys.ARROW_RIGHT)
|
|
debounce_input.send_keys("foo")
|
|
debounce_input.send_keys("foo")
|
|
- time.sleep(0.5)
|
|
|
|
|
|
+ assert AppHarness._poll_for(
|
|
|
|
+ lambda: fully_controlled_input.poll_for_value(value_input) == "ifoonitial"
|
|
|
|
+ )
|
|
assert debounce_input.get_attribute("value") == "ifoonitial"
|
|
assert debounce_input.get_attribute("value") == "ifoonitial"
|
|
assert await get_state_text() == "ifoonitial"
|
|
assert await get_state_text() == "ifoonitial"
|
|
- assert fully_controlled_input.poll_for_value(value_input) == "ifoonitial"
|
|
|
|
assert fully_controlled_input.poll_for_value(plain_value_input) == "ifoonitial"
|
|
assert fully_controlled_input.poll_for_value(plain_value_input) == "ifoonitial"
|
|
|
|
|
|
# clear the input on the backend
|
|
# clear the input on the backend
|
|
@@ -116,10 +116,12 @@ async def test_fully_controlled_input(fully_controlled_input: AppHarness):
|
|
|
|
|
|
# type more characters
|
|
# type more characters
|
|
debounce_input.send_keys("getting testing done")
|
|
debounce_input.send_keys("getting testing done")
|
|
- time.sleep(0.5)
|
|
|
|
|
|
+ assert AppHarness._poll_for(
|
|
|
|
+ lambda: fully_controlled_input.poll_for_value(value_input)
|
|
|
|
+ == "getting testing done"
|
|
|
|
+ )
|
|
assert debounce_input.get_attribute("value") == "getting testing done"
|
|
assert debounce_input.get_attribute("value") == "getting testing done"
|
|
assert await get_state_text() == "getting testing done"
|
|
assert await get_state_text() == "getting testing done"
|
|
- assert fully_controlled_input.poll_for_value(value_input) == "getting testing done"
|
|
|
|
assert (
|
|
assert (
|
|
fully_controlled_input.poll_for_value(plain_value_input)
|
|
fully_controlled_input.poll_for_value(plain_value_input)
|
|
== "getting testing done"
|
|
== "getting testing done"
|
|
@@ -127,19 +129,20 @@ async def test_fully_controlled_input(fully_controlled_input: AppHarness):
|
|
|
|
|
|
# type into the on_change input
|
|
# type into the on_change input
|
|
on_change_input.send_keys("overwrite the state")
|
|
on_change_input.send_keys("overwrite the state")
|
|
- time.sleep(0.5)
|
|
|
|
|
|
+ assert AppHarness._poll_for(
|
|
|
|
+ lambda: fully_controlled_input.poll_for_value(value_input)
|
|
|
|
+ == "overwrite the state"
|
|
|
|
+ )
|
|
assert debounce_input.get_attribute("value") == "overwrite the state"
|
|
assert debounce_input.get_attribute("value") == "overwrite the state"
|
|
assert on_change_input.get_attribute("value") == "overwrite the state"
|
|
assert on_change_input.get_attribute("value") == "overwrite the state"
|
|
assert await get_state_text() == "overwrite the state"
|
|
assert await get_state_text() == "overwrite the state"
|
|
- assert fully_controlled_input.poll_for_value(value_input) == "overwrite the state"
|
|
|
|
assert (
|
|
assert (
|
|
fully_controlled_input.poll_for_value(plain_value_input)
|
|
fully_controlled_input.poll_for_value(plain_value_input)
|
|
== "overwrite the state"
|
|
== "overwrite the state"
|
|
)
|
|
)
|
|
|
|
|
|
clear_button.click()
|
|
clear_button.click()
|
|
- time.sleep(0.5)
|
|
|
|
- assert on_change_input.get_attribute("value") == ""
|
|
|
|
|
|
+ assert AppHarness._poll_for(lambda: on_change_input.get_attribute("value") == "")
|
|
# potential bug: clearing the on_change field doesn't itself trigger on_change
|
|
# potential bug: clearing the on_change field doesn't itself trigger on_change
|
|
# assert backend_state.text == ""
|
|
# assert backend_state.text == ""
|
|
# assert debounce_input.get_attribute("value") == ""
|
|
# assert debounce_input.get_attribute("value") == ""
|