Skip to content

Commit e873406

Browse files
authored
E2E: Fix classic TIP test (#8259)
1 parent 2755211 commit e873406

File tree

2 files changed

+40
-17
lines changed

2 files changed

+40
-17
lines changed

packages/pytest-simcore/src/pytest_simcore/helpers/playwright.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,29 @@ def __call__(self, message: str) -> bool:
302302
return False
303303

304304

305+
@dataclass
306+
class SocketIOWaitNodeForOutputs:
307+
logger: logging.Logger
308+
expected_number_of_outputs: int
309+
node_id: str
310+
311+
def __call__(self, message: str) -> bool:
312+
if message.startswith(SOCKETIO_MESSAGE_PREFIX):
313+
decoded_message = decode_socketio_42_message(message)
314+
if decoded_message.name == _OSparcMessages.NODE_UPDATED:
315+
assert "data" in decoded_message.obj
316+
assert "node_id" in decoded_message.obj
317+
if decoded_message.obj["node_id"] == self.node_id:
318+
assert "outputs" in decoded_message.obj["data"]
319+
320+
return (
321+
len(decoded_message.obj["data"]["outputs"])
322+
== self.expected_number_of_outputs
323+
)
324+
325+
return False
326+
327+
305328
@dataclass
306329
class SocketIOOsparcMessagePrinter:
307330
include_logger_messages: bool = False

tests/e2e-playwright/tests/tip/test_ti_plan.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@
2121
MINUTE,
2222
SECOND,
2323
RobustWebSocket,
24+
SocketIOWaitNodeForOutputs,
2425
app_mode_trigger_next_app,
26+
decode_socketio_42_message,
2527
expected_service_running,
2628
wait_for_service_running,
2729
)
@@ -165,7 +167,7 @@ def test_classic_ti_plan( # noqa: PLR0915
165167
# NOTE: Sometimes this iframe flicks and shows a white page. This wait will avoid it
166168
page.wait_for_timeout(_ELECTRODE_SELECTOR_FLICKERING_WAIT_TIME)
167169

168-
with log_context(logging.INFO, "Configure selector"):
170+
with log_context(logging.INFO, "Configure selector", logger=ctx.logger):
169171
assert (
170172
page.get_by_test_id("settingsForm_" + node_ids[0]).count() == 0
171173
), "service settings should not be visible"
@@ -185,22 +187,20 @@ def test_classic_ti_plan( # noqa: PLR0915
185187
electrode_id = "Electrode_" + selection[1]
186188
electrode_selector_iframe.get_by_test_id(group_id).click()
187189
electrode_selector_iframe.get_by_test_id(electrode_id).click()
188-
# configuration done, push and wait for output
189-
with (
190-
log_context(logging.INFO, "Check outputs"),
191-
page.expect_request(
192-
lambda r: bool(
193-
re.search(_GET_NODE_OUTPUTS_REQUEST_PATTERN, r.url)
194-
and r.method.upper() == "GET"
195-
)
196-
) as request_info,
197-
):
198-
electrode_selector_iframe.get_by_test_id("FinishSetUp").click()
199-
response = request_info.value.response()
200-
assert response
201-
assert response.ok, f"{response.json()}"
202-
response_body = response.json()
203-
ctx.logger.info("the following output was generated: %s", response_body)
190+
# configuration done, push and wait for the 1 output
191+
with log_context(logging.INFO, "Check outputs", logger=ctx.logger):
192+
waiter = SocketIOWaitNodeForOutputs(
193+
ctx.logger, expected_number_of_outputs=1, node_id=node_ids[0]
194+
)
195+
with log_in_and_out.expect_event(
196+
"framereceived", waiter
197+
) as frame_received_event:
198+
electrode_selector_iframe.get_by_test_id("FinishSetUp").click()
199+
socket_io_message = decode_socketio_42_message(frame_received_event.value)
200+
ctx.logger.info(
201+
"the following output was generated: %s",
202+
socket_io_message.obj["data"]["outputs"]["output_1"]["path"],
203+
)
204204

205205
with log_context(
206206
logging.INFO, "Classic TI step (2/%s)", expected_number_of_steps

0 commit comments

Comments
 (0)