async def test_spawn_pending_progress(
    app, browser, no_patience, user_special_chars, slow_spawn
):
    """verify that the server process messages are showing up to the user
    when the server is going to start up"""

    user = user_special_chars.user
    urlname = user_special_chars.urlname
    # visit the spawn-pending page
    await open_spawn_pending(app, browser, user_special_chars)
    launch_btn = browser.locator("//div[@class='text-center']").get_by_role(
        "button", name="Launch Server"
    )
    await expect(launch_btn).to_be_enabled()

    # begin starting the server
    async with browser.expect_navigation(
        url=re.compile(".*/spawn-pending/" + f"{urlname}")
    ):
        await launch_btn.click()
    # wait for progress message to appear
    progress = browser.locator("#progress-message")
    progress_message = await progress.text_content()
    async with browser.expect_navigation(url=re.compile(".*/user/" + f"{urlname}/")):
        # wait for log messages to appear
        expected_messages = [
            "Server requested",
            "Spawning server...",
            f"Server ready at {app.base_url}user/{urlname}/",
        ]
        while not user.spawner.ready:
            logs_list = [
                await log.text_content()
                for log in await browser.locator("div.progress-log-event").all()
            ]
            if progress_message:
                assert progress_message in expected_messages
            # race condition: progress_message _should_
            # be the last log message, but it _may_ be the next one
            if logs_list:
                assert progress_message
            assert logs_list == expected_messages[: len(logs_list)]
    await expect(browser).to_have_url(re.compile(".*/user/" + f"{urlname}/"))
    assert user.spawner.ready
verify that the server process messages are showing up to the user
when the server is going to start up
jupyterhub/tests/browser/test_browser.py