Skip to content

Commit b1e60f0

Browse files
committed
add logs for broken websockets
1 parent 11463f3 commit b1e60f0

File tree

1 file changed

+21
-8
lines changed

1 file changed

+21
-8
lines changed

tests/e2e-playwright/tests/conftest.py

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,16 @@
2525
from pytest import Item
2626
from pytest_simcore.helpers.logging_tools import log_context
2727
from pytest_simcore.helpers.playwright import (
28-
SECOND,
2928
MINUTE,
29+
SECOND,
3030
AutoRegisteredUser,
3131
RunningState,
3232
ServiceType,
3333
SocketIOEvent,
3434
SocketIOProjectClosedWaiter,
3535
SocketIOProjectStateUpdatedWaiter,
3636
decode_socketio_42_message,
37+
web_socket_default_log_handler,
3738
)
3839

3940
_PROJECT_CLOSING_TIMEOUT: Final[int] = 10 * MINUTE
@@ -369,7 +370,8 @@ def log_in_and_out(
369370
if quickStartWindowCloseBtnLocator.is_visible():
370371
quickStartWindowCloseBtnLocator.click()
371372

372-
yield ws
373+
with web_socket_default_log_handler(ws):
374+
yield ws
373375

374376
with log_context(
375377
logging.INFO,
@@ -410,12 +412,17 @@ def _(
410412
f"Open project in {product_url=} as {product_billable=}",
411413
) as ctx:
412414
waiter = SocketIOProjectStateUpdatedWaiter(expected_states=expected_states)
413-
timeout = _OPENING_TUTORIAL_MAX_WAIT_TIME if template_id is not None else _OPENING_NEW_EMPTY_PROJECT_MAX_WAIT_TIME
415+
timeout = (
416+
_OPENING_TUTORIAL_MAX_WAIT_TIME
417+
if template_id is not None
418+
else _OPENING_NEW_EMPTY_PROJECT_MAX_WAIT_TIME
419+
)
414420
with (
415-
log_in_and_out.expect_event("framereceived", waiter, timeout=timeout + 10 * SECOND),
421+
log_in_and_out.expect_event(
422+
"framereceived", waiter, timeout=timeout + 10 * SECOND
423+
),
416424
page.expect_response(
417-
re.compile(r"/projects/[^:]+:open"),
418-
timeout=timeout + 5 * SECOND
425+
re.compile(r"/projects/[^:]+:open"), timeout=timeout + 5 * SECOND
419426
) as response_info,
420427
):
421428
# Project detail view pop-ups shows
@@ -436,8 +443,11 @@ def _(
436443
# From the long running tasks response's urls, only their path is relevant
437444
def url_to_path(url):
438445
return urllib.parse.urlparse(url).path
446+
439447
def wait_for_done(response):
440-
if url_to_path(response.url) == url_to_path(lrt_data["status_href"]):
448+
if url_to_path(response.url) == url_to_path(
449+
lrt_data["status_href"]
450+
):
441451
resp_data = response.json()
442452
resp_data = resp_data["data"]
443453
assert "task_progress" in resp_data
@@ -448,10 +458,13 @@ def wait_for_done(response):
448458
task_progress["message"],
449459
)
450460
return False
451-
if url_to_path(response.url) == url_to_path(lrt_data["result_href"]):
461+
if url_to_path(response.url) == url_to_path(
462+
lrt_data["result_href"]
463+
):
452464
copying_logger.logger.info("project created")
453465
return response.status == 201
454466
return False
467+
455468
with page.expect_response(wait_for_done, timeout=timeout):
456469
# if the above calls go to fast, this test could fail
457470
# not expected in the sim4life context though

0 commit comments

Comments
 (0)