def test_login_flow(
    login_sample: AppHarness, driver: WebDriver, local_storage: utils.LocalStorage
):
    """Test login flow.

    Args:
        login_sample: harness for LoginSample app.
        driver: WebDriver instance.
        local_storage: Local storage helper.
    """
    assert login_sample.frontend_url is not None
    local_storage.clear()

    with pytest.raises(NoSuchElementException):
        driver.find_element(By.ID, "auth-token")

    login_button = driver.find_element(By.ID, "login")
    login_sample.poll_for_content(login_button)
    with utils.poll_for_navigation(driver):
        login_button.click()
    assert driver.current_url.endswith("/login/")

    do_it_button = driver.find_element(By.ID, "doit")
    with utils.poll_for_navigation(driver):
        do_it_button.click()
    assert driver.current_url == login_sample.frontend_url + "/"

    def check_auth_token_header():
        try:
            auth_token_header = driver.find_element(By.ID, "auth-token")
        except NoSuchElementException:
            return False
        return auth_token_header.text

    assert login_sample._poll_for(check_auth_token_header) == "12345"

    logout_button = driver.find_element(By.ID, "logout")
    logout_button.click()

    state_name = login_sample.get_full_state_name(["_state"])
    assert login_sample._poll_for(
        lambda: local_storage[f"{state_name}.auth_token"] == ""
    )
    with pytest.raises(NoSuchElementException):
        driver.find_element(By.ID, "auth-token")
Test login flow.

    Args:
        login_sample: harness for LoginSample app.
        driver: WebDriver instance.
        local_storage: Local storage helper.
    
tests/integration/test_login_flow.py