Test client side state. Args: client_side: harness for ClientSide app. driver: WebDriver instance. local_storage: Local storage helper. session_storage: Session storage helper.
(
client_side: AppHarness,
driver: WebDriver,
local_storage: utils.LocalStorage,
session_storage: utils.SessionStorage,
)
| 240 | |
| 241 | @pytest.mark.asyncio |
| 242 | async def test_client_side_state( |
| 243 | client_side: AppHarness, |
| 244 | driver: WebDriver, |
| 245 | local_storage: utils.LocalStorage, |
| 246 | session_storage: utils.SessionStorage, |
| 247 | ): |
| 248 | """Test client side state. |
| 249 | |
| 250 | Args: |
| 251 | client_side: harness for ClientSide app. |
| 252 | driver: WebDriver instance. |
| 253 | local_storage: Local storage helper. |
| 254 | session_storage: Session storage helper. |
| 255 | """ |
| 256 | app = client_side.app_instance |
| 257 | assert app is not None |
| 258 | assert client_side.frontend_url is not None |
| 259 | |
| 260 | def poll_for_token(): |
| 261 | token_input = AppHarness.poll_for_or_raise_timeout( |
| 262 | lambda: driver.find_element(By.ID, "token") |
| 263 | ) |
| 264 | |
| 265 | # wait for the backend connection to send the token |
| 266 | token = client_side.poll_for_value(token_input) |
| 267 | assert token is not None |
| 268 | return token |
| 269 | |
| 270 | def set_sub(var: str, value: str): |
| 271 | # Get a reference to the cookie manipulation form. |
| 272 | state_var_input = driver.find_element(By.ID, "state_var") |
| 273 | input_value_input = driver.find_element(By.ID, "input_value") |
| 274 | set_sub_state_button = driver.find_element(By.ID, "set_sub_state") |
| 275 | AppHarness.expect(lambda: state_var_input.get_attribute("value") == "") |
| 276 | AppHarness.expect(lambda: input_value_input.get_attribute("value") == "") |
| 277 | |
| 278 | # Set the values. |
| 279 | state_var_input.send_keys(var) |
| 280 | input_value_input.send_keys(value) |
| 281 | set_sub_state_button.click() |
| 282 | |
| 283 | def set_sub_sub(var: str, value: str): |
| 284 | # Get a reference to the cookie manipulation form. |
| 285 | state_var_input = driver.find_element(By.ID, "state_var") |
| 286 | input_value_input = driver.find_element(By.ID, "input_value") |
| 287 | set_sub_sub_state_button = driver.find_element(By.ID, "set_sub_sub_state") |
| 288 | AppHarness.expect(lambda: state_var_input.get_attribute("value") == "") |
| 289 | AppHarness.expect(lambda: input_value_input.get_attribute("value") == "") |
| 290 | |
| 291 | # Set the values. |
| 292 | state_var_input.send_keys(var) |
| 293 | input_value_input.send_keys(value) |
| 294 | set_sub_sub_state_button.click() |
| 295 | |
| 296 | token = poll_for_token() |
| 297 | |
| 298 | # get a reference to all cookie and local storage elements |
| 299 | c1 = driver.find_element(By.ID, "c1") |
nothing calls this directly
no test coverage detected