Skip to content

Commit

Permalink
🐛 Fix: Add recipient to Sticky notes (#5723)
Browse files Browse the repository at this point in the history
  • Loading branch information
odeimaiz authored Apr 24, 2024
1 parent bfad302 commit 086df7a
Show file tree
Hide file tree
Showing 10 changed files with 68 additions and 34 deletions.
18 changes: 18 additions & 0 deletions packages/pytest-simcore/src/pytest_simcore/playwright_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
*,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down Expand Up @@ -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
});
Expand All @@ -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;
Expand Down Expand Up @@ -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);
});
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ qx.Class.define("osparc.share.NewCollaboratorsManager", {
},

events: {
"addEditors": "qx.event.type.Data"
"addCollaborators": "qx.event.type.Data"
},

members: {
Expand Down Expand Up @@ -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
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
* Here is a little example of how to use the widget.
*
* <pre class='javascript'>
* let svgWidget = new osparc.workbench.SvgWidget("SvgWidget_(Purporse)");
* let svgWidget = new osparc.workbench.SvgWidget("SvgWidget_(Purpose)");
* this.getRoot().add(svgWidget);
* </pre>
*/
Expand Down Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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",
Expand Down
36 changes: 26 additions & 10 deletions tests/e2e-playwright/tests/ti_plan.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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)
Expand All @@ -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
Expand All @@ -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)
Expand All @@ -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
Expand Down

0 comments on commit 086df7a

Please sign in to comment.