Test client side state. Args: client_side: harness for ClientSide app. driver: WebDriver instance. local_storage: Local storage helper.
(
client_side: AppHarness, driver: WebDriver, local_storage: utils.LocalStorage
)
| 183 | |
| 184 | @pytest.mark.asyncio |
| 185 | async def test_client_side_state( |
| 186 | client_side: AppHarness, driver: WebDriver, local_storage: utils.LocalStorage |
| 187 | ): |
| 188 | """Test client side state. |
| 189 | |
| 190 | Args: |
| 191 | client_side: harness for ClientSide app. |
| 192 | driver: WebDriver instance. |
| 193 | local_storage: Local storage helper. |
| 194 | """ |
| 195 | assert client_side.app_instance is not None |
| 196 | assert client_side.frontend_url is not None |
| 197 | token_input = driver.find_element(By.ID, "token") |
| 198 | assert token_input |
| 199 | |
| 200 | # wait for the backend connection to send the token |
| 201 | token = client_side.poll_for_value(token_input) |
| 202 | assert token is not None |
| 203 | |
| 204 | # get a reference to the cookie manipulation form |
| 205 | state_var_input = driver.find_element(By.ID, "state_var") |
| 206 | input_value_input = driver.find_element(By.ID, "input_value") |
| 207 | set_sub_state_button = driver.find_element(By.ID, "set_sub_state") |
| 208 | set_sub_sub_state_button = driver.find_element(By.ID, "set_sub_sub_state") |
| 209 | |
| 210 | # get a reference to all cookie and local storage elements |
| 211 | c1 = driver.find_element(By.ID, "c1") |
| 212 | c2 = driver.find_element(By.ID, "c2") |
| 213 | c3 = driver.find_element(By.ID, "c3") |
| 214 | c4 = driver.find_element(By.ID, "c4") |
| 215 | c5 = driver.find_element(By.ID, "c5") |
| 216 | c6 = driver.find_element(By.ID, "c6") |
| 217 | c7 = driver.find_element(By.ID, "c7") |
| 218 | l1 = driver.find_element(By.ID, "l1") |
| 219 | l2 = driver.find_element(By.ID, "l2") |
| 220 | l3 = driver.find_element(By.ID, "l3") |
| 221 | l4 = driver.find_element(By.ID, "l4") |
| 222 | c1s = driver.find_element(By.ID, "c1s") |
| 223 | l1s = driver.find_element(By.ID, "l1s") |
| 224 | |
| 225 | # assert on defaults where present |
| 226 | assert c1.text == "" |
| 227 | assert c2.text == "c2 default" |
| 228 | assert c3.text == "" |
| 229 | assert c4.text == "" |
| 230 | assert c5.text == "" |
| 231 | assert c6.text == "" |
| 232 | assert c7.text == "c7 default" |
| 233 | assert l1.text == "" |
| 234 | assert l2.text == "l2 default" |
| 235 | assert l3.text == "" |
| 236 | assert l4.text == "l4 default" |
| 237 | assert c1s.text == "" |
| 238 | assert l1s.text == "" |
| 239 | |
| 240 | # no cookies should be set yet! |
| 241 | assert not driver.get_cookies() |
| 242 | local_storage_items = local_storage.items() |
nothing calls this directly
no test coverage detected