From 086df7aef376ebc520fc4a0e7fdd3beb27c7853e Mon Sep 17 00:00:00 2001 From: Odei Maiz <33152403+odeimaiz@users.noreply.github.com> Date: Wed, 24 Apr 2024 17:11:02 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fix:=20Add=20recipient=20to=20St?= =?UTF-8?q?icky=20notes=20(#5723)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/pytest_simcore/playwright_utils.py | 18 ++++++++++ .../osparc/desktop/wallets/MembersList.js | 2 +- .../osparc/editor/AnnotationNoteCreator.js | 24 ++++++------- .../class/osparc/share/Collaborators.js | 2 +- .../osparc/share/NewCollaboratorsManager.js | 4 +-- .../class/osparc/workbench/Annotation.js | 2 +- .../class/osparc/workbench/SvgWidget.js | 6 ++-- .../class/osparc/workbench/WorkbenchUI.js | 4 +-- .../client/source/class/osparc/wrapper/Svg.js | 4 +-- tests/e2e-playwright/tests/ti_plan.py | 36 +++++++++++++------ 10 files changed, 68 insertions(+), 34 deletions(-) diff --git a/packages/pytest-simcore/src/pytest_simcore/playwright_utils.py b/packages/pytest-simcore/src/pytest_simcore/playwright_utils.py index 01cd80d7aba..3c593c0f795 100644 --- a/packages/pytest-simcore/src/pytest_simcore/playwright_utils.py +++ b/packages/pytest-simcore/src/pytest_simcore/playwright_utils.py @@ -86,6 +86,24 @@ def __call__(self, message: str) -> bool: return False +@dataclass +class SocketIOOsparcMessagePrinter: + def __call__(self, message: str) -> None: + osparc_messages = [ + "logger", + "nodeUpdated", + "nodeProgress", + "projectStateUpdated", + "serviceDiskUsage", + "walletOsparcCreditsUpdated", + ] + + if message.startswith("42"): + decoded_message: SocketIOEvent = decode_socketio_42_message(message) + if decoded_message.name in osparc_messages: + print("WS Message:", decoded_message.name, decoded_message.obj) + + def wait_for_pipeline_state( current_state: RunningState, *, diff --git a/services/static-webserver/client/source/class/osparc/desktop/wallets/MembersList.js b/services/static-webserver/client/source/class/osparc/desktop/wallets/MembersList.js index 2514d68d718..8aa4c4de229 100644 --- a/services/static-webserver/client/source/class/osparc/desktop/wallets/MembersList.js +++ b/services/static-webserver/client/source/class/osparc/desktop/wallets/MembersList.js @@ -132,7 +132,7 @@ qx.Class.define("osparc.desktop.wallets.MembersList", { serializedData["resourceType"] = "wallet"; const showOrganizations = false; const collaboratorsManager = new osparc.share.NewCollaboratorsManager(serializedData, showOrganizations); - collaboratorsManager.addListener("addEditors", e => { + collaboratorsManager.addListener("addCollaborators", e => { const cb = () => collaboratorsManager.close(); this.__addMembers(e.getData(), cb); }, this); diff --git a/services/static-webserver/client/source/class/osparc/editor/AnnotationNoteCreator.js b/services/static-webserver/client/source/class/osparc/editor/AnnotationNoteCreator.js index 55b54f2785f..cd2ed18d12e 100644 --- a/services/static-webserver/client/source/class/osparc/editor/AnnotationNoteCreator.js +++ b/services/static-webserver/client/source/class/osparc/editor/AnnotationNoteCreator.js @@ -24,17 +24,17 @@ qx.Class.define("osparc.editor.AnnotationNoteCreator", { this._setLayout(new qx.ui.layout.VBox(10)); this.getChildControl("instructions"); - this.getChildControl("select-destinatary"); + this.getChildControl("select-recipient"); this.getChildControl("note"); this.getChildControl("add"); }, properties: { - destinataryGid: { + recipientGid: { check: "Integer", init: null, nullable: true, - event: "changeDestinataryGid" + event: "changeRecipientGid" }, note: { @@ -74,13 +74,13 @@ qx.Class.define("osparc.editor.AnnotationNoteCreator", { }); this._add(control); break; - case "destinatary-layout": + case "recipient-layout": control = new qx.ui.container.Composite(new qx.ui.layout.HBox(10)).set({ alignY: "middle" }); this._add(control); break; - case "select-destinatary": + case "select-recipient": control = new qx.ui.form.Button(this.tr("Select recipient")).set({ allowGrowX: false }); @@ -92,18 +92,18 @@ qx.Class.define("osparc.editor.AnnotationNoteCreator", { const collabs = e.getData(); if (collabs) { collaboratorsManager.close(); - this.__setDestinataryGid(collabs[0]); + this.__setRecipientGid(collabs[0]); } }, this); }, this); - this.getChildControl("destinatary-layout").add(control); + this.getChildControl("recipient-layout").add(control); break; - case "selected-destinatary": + case "selected-recipient": control = new qx.ui.basic.Label().set({ font: "text-14", alignY: "middle" }); - this.getChildControl("destinatary-layout").add(control, { + this.getChildControl("recipient-layout").add(control, { flex: 1 }); break; @@ -148,11 +148,11 @@ qx.Class.define("osparc.editor.AnnotationNoteCreator", { return control || this.base(arguments, id); }, - __setDestinataryGid: function(gid) { - this.setDestinataryGid(gid); + __setRecipientGid: function(gid) { + this.setRecipientGid(gid); osparc.store.Store.getInstance().getGroup(gid) .then(user => { - this.getChildControl("selected-destinatary").setValue(user.label); + this.getChildControl("selected-recipient").setValue(user.label); }); } } diff --git a/services/static-webserver/client/source/class/osparc/share/Collaborators.js b/services/static-webserver/client/source/class/osparc/share/Collaborators.js index 0bd2d174a4e..3704a0a4b2a 100644 --- a/services/static-webserver/client/source/class/osparc/share/Collaborators.js +++ b/services/static-webserver/client/source/class/osparc/share/Collaborators.js @@ -225,7 +225,7 @@ qx.Class.define("osparc.share.Collaborators", { }); addCollaboratorBtn.addListener("execute", () => { const collaboratorsManager = new osparc.share.NewCollaboratorsManager(this._serializedData); - collaboratorsManager.addListener("addEditors", e => { + collaboratorsManager.addListener("addCollaborators", e => { const cb = () => collaboratorsManager.close(); this._addEditors(e.getData(), cb); }, this); diff --git a/services/static-webserver/client/source/class/osparc/share/NewCollaboratorsManager.js b/services/static-webserver/client/source/class/osparc/share/NewCollaboratorsManager.js index 169b0c7e5a0..3437a5e54db 100644 --- a/services/static-webserver/client/source/class/osparc/share/NewCollaboratorsManager.js +++ b/services/static-webserver/client/source/class/osparc/share/NewCollaboratorsManager.js @@ -37,7 +37,7 @@ qx.Class.define("osparc.share.NewCollaboratorsManager", { }, events: { - "addEditors": "qx.event.type.Data" + "addCollaborators": "qx.event.type.Data" }, members: { @@ -166,7 +166,7 @@ qx.Class.define("osparc.share.NewCollaboratorsManager", { addCollabs.push(collabId); } if (addCollabs.length) { - this.fireDataEvent("addEditors", addCollabs); + this.fireDataEvent("addCollaborators", addCollabs); } // The parent class will close the window } diff --git a/services/static-webserver/client/source/class/osparc/workbench/Annotation.js b/services/static-webserver/client/source/class/osparc/workbench/Annotation.js index 919d6132088..23e073b283e 100644 --- a/services/static-webserver/client/source/class/osparc/workbench/Annotation.js +++ b/services/static-webserver/client/source/class/osparc/workbench/Annotation.js @@ -92,7 +92,7 @@ qx.Class.define("osparc.workbench.Annotation", { let representation = null; switch (this.getType()) { case "note": { - const user = await osparc.store.Store.getInstance().getGroup(attrs.destinataryGid); + const user = await osparc.store.Store.getInstance().getGroup(attrs.recipientGid); representation = this.__svgLayer.drawAnnotationNote(attrs.x, attrs.y, user ? user.label : "", attrs.text); break; } diff --git a/services/static-webserver/client/source/class/osparc/workbench/SvgWidget.js b/services/static-webserver/client/source/class/osparc/workbench/SvgWidget.js index f10a226d181..238c9a2c0e9 100644 --- a/services/static-webserver/client/source/class/osparc/workbench/SvgWidget.js +++ b/services/static-webserver/client/source/class/osparc/workbench/SvgWidget.js @@ -27,7 +27,7 @@ * Here is a little example of how to use the widget. * *
- *   let svgWidget = new osparc.workbench.SvgWidget("SvgWidget_(Purporse)");
+ *   let svgWidget = new osparc.workbench.SvgWidget("SvgWidget_(Purpose)");
  *   this.getRoot().add(svgWidget);
  * 
*/ @@ -97,8 +97,8 @@ qx.Class.define("osparc.workbench.SvgWidget", { return osparc.wrapper.Svg.drawAnnotationText(this.__canvas, x, y, label, color, fontSize); }, - drawAnnotationNote: function(x, y, destinataryName = "", text = "") { - return osparc.wrapper.Svg.drawAnnotationNote(this.__canvas, x, y, destinataryName, text); + drawAnnotationNote: function(x, y, recipientName = "", text = "") { + return osparc.wrapper.Svg.drawAnnotationNote(this.__canvas, x, y, recipientName, text); }, drawAnnotationRect: function(width, height, x, y, color) { diff --git a/services/static-webserver/client/source/class/osparc/workbench/WorkbenchUI.js b/services/static-webserver/client/source/class/osparc/workbench/WorkbenchUI.js index 98f02c93bc3..9342375f4b6 100644 --- a/services/static-webserver/client/source/class/osparc/workbench/WorkbenchUI.js +++ b/services/static-webserver/client/source/class/osparc/workbench/WorkbenchUI.js @@ -1890,10 +1890,10 @@ qx.Class.define("osparc.workbench.WorkbenchUI", { const noteEditor = new osparc.editor.AnnotationNoteCreator(); const win = osparc.editor.AnnotationNoteCreator.popUpInWindow(noteEditor, true); noteEditor.addListener("addNote", () => { - const gid = noteEditor.getDestinataryGid(); + const gid = noteEditor.getRecipientGid(); osparc.store.Store.getInstance().getGroup(gid) .then(user => { - serializeData.attributes.destinataryGid = gid; + serializeData.attributes.recipientGid = gid; serializeData.attributes.text = noteEditor.getNote(); if (user) { osparc.notification.Notifications.postNewAnnotationNote(user.id, this.getStudy().getUuid()); diff --git a/services/static-webserver/client/source/class/osparc/wrapper/Svg.js b/services/static-webserver/client/source/class/osparc/wrapper/Svg.js index 09260d02d9a..17c053e3785 100644 --- a/services/static-webserver/client/source/class/osparc/wrapper/Svg.js +++ b/services/static-webserver/client/source/class/osparc/wrapper/Svg.js @@ -158,7 +158,7 @@ qx.Class.define("osparc.wrapper.Svg", { return text; }, - drawAnnotationNote: function(draw, x, y, destinataryName, note) { + drawAnnotationNote: function(draw, x, y, recipientName, note) { const lines = note.split("\n"); const width = 200; const minHeight = 120; @@ -224,7 +224,7 @@ qx.Class.define("osparc.wrapper.Svg", { gNote.add(separator); const defaultFont = osparc.utils.Utils.getDefaultFont(); - const title = gNote.text(destinataryName) + const title = gNote.text(recipientName) .font({ fill: "#000000", size: (defaultFont["size"]+1) + "px", diff --git a/tests/e2e-playwright/tests/ti_plan.py b/tests/e2e-playwright/tests/ti_plan.py index 02c968e9e5b..461b1cbf3cd 100644 --- a/tests/e2e-playwright/tests/ti_plan.py +++ b/tests/e2e-playwright/tests/ti_plan.py @@ -7,30 +7,26 @@ import re from http import HTTPStatus -from typing import Final -from playwright.sync_api import APIRequestContext, Page +from playwright.sync_api import APIRequestContext, Page, WebSocket from pydantic import AnyUrl -from pytest_simcore.playwright_utils import on_web_socket_default_handler +from pytest_simcore.playwright_utils import SocketIOOsparcMessagePrinter from tenacity import Retrying from tenacity.retry import retry_if_exception_type from tenacity.stop import stop_after_attempt from tenacity.wait import wait_fixed -projects_uuid_pattern: Final[re.Pattern] = re.compile( - r"/projects/([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})" -) - def test_tip( page: Page, - log_in_and_out: None, + log_in_and_out: WebSocket, api_request_context: APIRequestContext, product_url: AnyUrl, product_billable: bool, ): - # connect and listen to websocket - page.on("websocket", on_web_socket_default_handler) + handler = SocketIOOsparcMessagePrinter() + # log_in_and_out is the initial websocket + log_in_and_out.on("framereceived", handler) # open studies tab and filter page.get_by_test_id("studiesTabBtn").click() @@ -54,6 +50,12 @@ def test_tip( print("node_id: ", node_id) node_ids.append(node_id) + # let it start or force + page.wait_for_timeout(5000) + start_button = page.get_by_test_id("Start_" + node_ids[0]) + if start_button.is_visible() and start_button.is_enabled(): + start_button.click() + # Electrode Selector es_page = page.frame_locator(f'[osparc-test-id="iframe_{node_ids[0]}"]') es_page.get_by_test_id("TargetStructure_Selector").click(timeout=300000) @@ -71,6 +73,8 @@ def test_tip( electrode_id = "Electrode_" + selection[1] es_page.get_by_test_id(group_id).click() es_page.get_by_test_id(electrode_id).click() + # configuration done, push output + page.wait_for_timeout(1000) es_page.get_by_test_id("FinishSetUp").click() page.wait_for_timeout(10000) # check outputs @@ -82,6 +86,12 @@ def test_tip( # Move to next step page.get_by_test_id("AppMode_NextBtn").click() + # let it start or force + page.wait_for_timeout(5000) + start_button = page.get_by_test_id("Start_" + node_ids[1]) + if start_button.is_visible() and start_button.is_enabled(): + start_button.click() + # Optimal Configuration Identification ti_page = page.frame_locator(f'[osparc-test-id="iframe_{node_ids[1]}"]') ti_page.get_by_role("button", name="Run Optimization").click(timeout=300000) @@ -107,6 +117,12 @@ def test_tip( # Move to next step page.get_by_test_id("AppMode_NextBtn").click() + # let it start or force + page.wait_for_timeout(5000) + start_button = page.get_by_test_id("Start_ " + node_ids[2]) + if start_button.is_visible() and start_button.is_enabled(): + start_button.click() + # Sim4Life PostPro s4l_postpro_page = page.frame_locator(f'[osparc-test-id="iframe_{node_ids[2]}"]') # click on the mode button