From a9f4a377306cf5e875b40066865251b871ac18a7 Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Thu, 25 Apr 2024 08:58:24 +0200 Subject: [PATCH 1/5] Avoid flick --- tests/e2e-playwright/tests/ti_plan.py | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/tests/e2e-playwright/tests/ti_plan.py b/tests/e2e-playwright/tests/ti_plan.py index 461b1cbf3cd..1d6a6a01a09 100644 --- a/tests/e2e-playwright/tests/ti_plan.py +++ b/tests/e2e-playwright/tests/ti_plan.py @@ -8,7 +8,7 @@ import re from http import HTTPStatus -from playwright.sync_api import APIRequestContext, Page, WebSocket +from playwright.sync_api import APIRequestContext, Page, WebSocket, expect from pydantic import AnyUrl from pytest_simcore.playwright_utils import SocketIOOsparcMessagePrinter from tenacity import Retrying @@ -58,7 +58,12 @@ def test_tip( # 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) + expect(es_page.get_by_test_id("TargetStructure_Selector")).to_be_visible( + timeout=300000 + ) + # Sometimes this iframe flicks and shows a white page. This wait will avoid it + page.wait_for_timeout(5000) + es_page.get_by_test_id("TargetStructure_Selector").click() es_page.get_by_test_id( "TargetStructure_Target_(Targets_combined) Hypothalamus" ).click() @@ -94,7 +99,10 @@ def test_tip( # 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) + expect(ti_page.get_by_role("button", name="Run Optimization")).to_be_visible( + timeout=300000 + ) + ti_page.get_by_role("button", name="Run Optimization").click() page.wait_for_timeout(20000) ti_page.get_by_role("button", name="Load Analysis").click() page.wait_for_timeout(20000) @@ -125,8 +133,11 @@ def test_tip( # Sim4Life PostPro s4l_postpro_page = page.frame_locator(f'[osparc-test-id="iframe_{node_ids[2]}"]') - # click on the mode button - s4l_postpro_page.get_by_test_id("mode-button-postro").click(timeout=300000) + expect(s4l_postpro_page.get_by_test_id("mode-button-postro")).to_be_visible( + timeout=300000 + ) + # click on the postpro mode button + s4l_postpro_page.get_by_test_id("mode-button-postro").click() # click on the surface viewer s4l_postpro_page.get_by_test_id("tree-item-ti_field.cache").click() s4l_postpro_page.get_by_test_id("tree-item-SurfaceViewer").click() From 95e5bb21ac7ba046371008798f5d8e2dc825c625 Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Thu, 25 Apr 2024 09:42:12 +0200 Subject: [PATCH 2/5] Create key with expiration date --- .../preferences/window/CreateAPIKey.js | 43 ++++++++++++------- 1 file changed, 28 insertions(+), 15 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/desktop/preferences/window/CreateAPIKey.js b/services/static-webserver/client/source/class/osparc/desktop/preferences/window/CreateAPIKey.js index 334d0f65709..dda1e630b8e 100644 --- a/services/static-webserver/client/source/class/osparc/desktop/preferences/window/CreateAPIKey.js +++ b/services/static-webserver/client/source/class/osparc/desktop/preferences/window/CreateAPIKey.js @@ -29,30 +29,43 @@ qx.Class.define("osparc.desktop.preferences.window.CreateAPIKey", { }, members: { + __form: null, + __populateWindow: function() { - const hBox1 = new qx.ui.container.Composite(new qx.ui.layout.HBox(10)); - const sTitle = new qx.ui.basic.Label(this.tr("API Key")).set({ - width: 50, - alignY: "middle" - }); - hBox1.add(sTitle); - const labelEditor = new qx.ui.form.TextField(); - this.add(labelEditor, { - flex: 1 + const form = this.__form = new qx.ui.form.Form(); + + const keyName = new qx.ui.form.TextField().set({ + required: true }); - hBox1.add(labelEditor, { - flex: 1 + form.add(keyName, this.tr("Key Name"), null, "name"); + this.addListener("appear", () => keyName.focus()); + + const dateFormat = new qx.util.format.DateFormat("dd/MM/yyyy-HH:mm:ss"); + const expirationDate = new qx.ui.form.DateField(); + form.add(expirationDate, this.tr("Expiration Date"), null, "expiration"); + expirationDate.addListener("changeValue", e => { + const date = e.getData(); + if (new Date(date).getTime() < new Date().getTime()) { + const msg = this.tr("Choose a future date"); + osparc.FlashMessenger.getInstance().logAs(msg, "WARNING"); + expirationDate.resetValue(); + } + expirationDate.setDateFormat(dateFormat); }); - this.add(hBox1); + + const formRenderer = new qx.ui.form.renderer.Single(form); + this.add(formRenderer); const hBox2 = new qx.ui.container.Composite(new qx.ui.layout.HBox(10)); hBox2.add(new qx.ui.core.Spacer(), { flex: 1 }); const confirmBtn = new qx.ui.form.Button(this.tr("Confirm")); - confirmBtn.addListener("execute", e => { - const keyLabel = labelEditor.getValue(); - this.fireDataEvent("finished", keyLabel); + confirmBtn.addListener("execute", () => { + this.fireDataEvent("finished", { + name: form.getItem("name").getValue(), + expiration: form.getItem("expiration").getValue() + }); }, this); hBox2.add(confirmBtn); From 9292e162c6f6ebc2818140709912baecf2eb45c8 Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Thu, 25 Apr 2024 09:42:56 +0200 Subject: [PATCH 3/5] send expiration to backend --- .../class/osparc/desktop/preferences/pages/TokensPage.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/desktop/preferences/pages/TokensPage.js b/services/static-webserver/client/source/class/osparc/desktop/preferences/pages/TokensPage.js index 428df069ba4..2067f393ea8 100644 --- a/services/static-webserver/client/source/class/osparc/desktop/preferences/pages/TokensPage.js +++ b/services/static-webserver/client/source/class/osparc/desktop/preferences/pages/TokensPage.js @@ -73,12 +73,17 @@ qx.Class.define("osparc.desktop.preferences.pages.TokensPage", { } const createAPIKeyWindow = new osparc.desktop.preferences.window.CreateAPIKey(); - createAPIKeyWindow.addListener("finished", keyLabel => { + createAPIKeyWindow.addListener("finished", e => { + const formData = e.getData(); const params = { data: { - "display_name": keyLabel.getData() + "display_name": formData["name"] } }; + if (formData["expiration"]) { + const seconds = parseInt((new Date(formData["expiration"]).getTime() - new Date().getTime()) / 1000); + params.data["expiration"] = seconds + } createAPIKeyWindow.close(); this.__requestAPIKeyBtn.setFetching(true); osparc.data.Resources.fetch("apiKeys", "post", params) From f3b590e770006a87e25ba1282d85b93ab819bdf5 Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Thu, 25 Apr 2024 09:48:57 +0200 Subject: [PATCH 4/5] "Choose a future date" --- .../desktop/preferences/window/CreateAPIKey.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/desktop/preferences/window/CreateAPIKey.js b/services/static-webserver/client/source/class/osparc/desktop/preferences/window/CreateAPIKey.js index dda1e630b8e..a1fff213357 100644 --- a/services/static-webserver/client/source/class/osparc/desktop/preferences/window/CreateAPIKey.js +++ b/services/static-webserver/client/source/class/osparc/desktop/preferences/window/CreateAPIKey.js @@ -45,12 +45,16 @@ qx.Class.define("osparc.desktop.preferences.window.CreateAPIKey", { form.add(expirationDate, this.tr("Expiration Date"), null, "expiration"); expirationDate.addListener("changeValue", e => { const date = e.getData(); - if (new Date(date).getTime() < new Date().getTime()) { - const msg = this.tr("Choose a future date"); - osparc.FlashMessenger.getInstance().logAs(msg, "WARNING"); - expirationDate.resetValue(); + if (date) { + // allow only today and future dates + if (new Date(date).getDate() < new Date().getDate()) { + const msg = this.tr("Choose a future date"); + osparc.FlashMessenger.getInstance().logAs(msg, "WARNING"); + expirationDate.resetValue(); + } else { + expirationDate.setDateFormat(dateFormat); + } } - expirationDate.setDateFormat(dateFormat); }); const formRenderer = new qx.ui.form.renderer.Single(form); From 82dff9ded6bbd76edfa0c67dc36fe65c6b55c465 Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Thu, 25 Apr 2024 09:57:37 +0200 Subject: [PATCH 5/5] partially hide the key and secret --- .../class/osparc/desktop/preferences/window/ShowAPIKey.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/desktop/preferences/window/ShowAPIKey.js b/services/static-webserver/client/source/class/osparc/desktop/preferences/window/ShowAPIKey.js index b70cf8b982b..4c63579a70f 100644 --- a/services/static-webserver/client/source/class/osparc/desktop/preferences/window/ShowAPIKey.js +++ b/services/static-webserver/client/source/class/osparc/desktop/preferences/window/ShowAPIKey.js @@ -69,9 +69,11 @@ qx.Class.define("osparc.desktop.preferences.window.ShowAPIKey", { width: 40 }); hBox.add(sTitle); - const sLabel = new qx.ui.basic.Label(label).set({ - selectable: true - }); + const sLabel = new qx.ui.basic.Label(); + if (label) { + // partially hide the key and secret + sLabel.setValue(label.substring(1, 8) + "****") + } hBox.add(sLabel); return hBox; }