Type text after moving cursor. Update text on backend. Args: fully_controlled_input: harness for FullyControlledInput app
(fully_controlled_input: AppHarness)
| 63 | |
| 64 | @pytest.mark.asyncio |
| 65 | async def test_fully_controlled_input(fully_controlled_input: AppHarness): |
| 66 | """Type text after moving cursor. Update text on backend. |
| 67 | |
| 68 | Args: |
| 69 | fully_controlled_input: harness for FullyControlledInput app |
| 70 | """ |
| 71 | assert fully_controlled_input.app_instance is not None, "app is not running" |
| 72 | driver = fully_controlled_input.frontend() |
| 73 | |
| 74 | # get a reference to the connected client |
| 75 | token_input = driver.find_element(By.ID, "token") |
| 76 | assert token_input |
| 77 | |
| 78 | # wait for the backend connection to send the token |
| 79 | token = fully_controlled_input.poll_for_value(token_input) |
| 80 | assert token |
| 81 | |
| 82 | # find the input and wait for it to have the initial state value |
| 83 | debounce_input = driver.find_element(By.ID, "debounce_input_input") |
| 84 | value_input = driver.find_element(By.ID, "value_input") |
| 85 | on_change_input = driver.find_element(By.ID, "on_change_input") |
| 86 | plain_value_input = driver.find_element(By.ID, "plain_value_input") |
| 87 | clear_button = driver.find_element(By.TAG_NAME, "button") |
| 88 | assert fully_controlled_input.poll_for_value(debounce_input) == "initial" |
| 89 | assert fully_controlled_input.poll_for_value(value_input) == "initial" |
| 90 | assert fully_controlled_input.poll_for_value(plain_value_input) == "initial" |
| 91 | assert ( |
| 92 | plain_value_input.value_of_css_property("background-color") |
| 93 | == "rgba(238, 238, 238, 1)" |
| 94 | ) |
| 95 | |
| 96 | # move cursor to home, then to the right and type characters |
| 97 | debounce_input.send_keys(Keys.HOME, Keys.ARROW_RIGHT) |
| 98 | debounce_input.send_keys("foo") |
| 99 | time.sleep(0.5) |
| 100 | assert debounce_input.get_attribute("value") == "ifoonitial" |
| 101 | assert (await fully_controlled_input.get_state(token)).substates[ |
| 102 | "state" |
| 103 | ].text == "ifoonitial" |
| 104 | assert fully_controlled_input.poll_for_value(value_input) == "ifoonitial" |
| 105 | assert fully_controlled_input.poll_for_value(plain_value_input) == "ifoonitial" |
| 106 | |
| 107 | # clear the input on the backend |
| 108 | async with fully_controlled_input.modify_state(token) as state: |
| 109 | state.substates["state"].text = "" |
| 110 | assert (await fully_controlled_input.get_state(token)).substates["state"].text == "" |
| 111 | assert ( |
| 112 | fully_controlled_input.poll_for_value( |
| 113 | debounce_input, exp_not_equal="ifoonitial" |
| 114 | ) |
| 115 | == "" |
| 116 | ) |
| 117 | |
| 118 | # type more characters |
| 119 | debounce_input.send_keys("getting testing done") |
| 120 | time.sleep(0.5) |
| 121 | assert debounce_input.get_attribute("value") == "getting testing done" |
| 122 | assert (await fully_controlled_input.get_state(token)).substates[ |
nothing calls this directly
no test coverage detected