diff --git a/packages/pytest-simcore/src/pytest_simcore/helpers/playwright.py b/packages/pytest-simcore/src/pytest_simcore/helpers/playwright.py index 98745718289..5ae58db0d87 100644 --- a/packages/pytest-simcore/src/pytest_simcore/helpers/playwright.py +++ b/packages/pytest-simcore/src/pytest_simcore/helpers/playwright.py @@ -11,7 +11,7 @@ from typing import Any, Final from playwright._impl._sync_base import EventContextManager -from playwright.sync_api import APIRequestContext, FrameLocator, Page, Request +from playwright.sync_api import APIRequestContext, FrameLocator, Locator, Page, Request from playwright.sync_api import TimeoutError as PlaywrightTimeoutError from playwright.sync_api import WebSocket from pydantic import AnyUrl @@ -508,3 +508,22 @@ def app_mode_trigger_next_app(page: Page) -> None: ): # Move to next step (this auto starts the next service) page.get_by_test_id("AppMode_NextBtn").click() + + +def wait_for_label_text( + page: Page, + locator: str, + substring: str, + timeout: int = 10000 +) -> Locator: + page.locator(locator).wait_for( + state="visible", + timeout=timeout + ) + + page.wait_for_function( + f"() => document.querySelector('{locator}').innerText.includes('{substring}')", + timeout=timeout + ) + + return page.locator(locator) diff --git a/services/static-webserver/client/source/class/osparc/data/PollTask.js b/services/static-webserver/client/source/class/osparc/data/PollTask.js index ce9ee8dc707..951ad3a0435 100644 --- a/services/static-webserver/client/source/class/osparc/data/PollTask.js +++ b/services/static-webserver/client/source/class/osparc/data/PollTask.js @@ -22,10 +22,10 @@ qx.Class.define("osparc.data.PollTask", { extend: qx.core.Object, - construct: function(taskData, interval) { + construct: function(taskData, interval = 1000) { this.base(arguments); - interval ? this.setPollInterval(interval) : this.initPollInterval(); + this.setPollInterval(interval); if (taskData && "task_id" in taskData) { this.set({ diff --git a/services/static-webserver/client/source/class/osparc/data/Resources.js b/services/static-webserver/client/source/class/osparc/data/Resources.js index c738cd8c3b6..926d47b667d 100644 --- a/services/static-webserver/client/source/class/osparc/data/Resources.js +++ b/services/static-webserver/client/source/class/osparc/data/Resources.js @@ -1241,26 +1241,6 @@ qx.Class.define("osparc.data.Resources", { } } }, - /* - * STORAGE ASYNC - */ - "storageAsyncJobs": { - useCache: false, - endpoints: { - jobStatus: { - method: "GET", - url: statics.API + "/storage/async-jobs/{jobId}/status" - }, - jobResult: { - method: "GET", - url: statics.API + "/storage/async-jobs/{jobId}/result" - }, - abortJob: { - method: "POST", - url: statics.API + "/storage/async-jobs/{jobId}/abort" - }, - } - }, /* * ACTIVITY */ diff --git a/services/static-webserver/client/source/class/osparc/file/StorageAsyncJob.js b/services/static-webserver/client/source/class/osparc/file/StorageAsyncJob.js deleted file mode 100644 index ac45eab9c24..00000000000 --- a/services/static-webserver/client/source/class/osparc/file/StorageAsyncJob.js +++ /dev/null @@ -1,98 +0,0 @@ -/* ************************************************************************ - - osparc - the simcore frontend - - https://osparc.io - - Copyright: - 2025 IT'IS Foundation, https://itis.swiss - - License: - MIT: https://opensource.org/licenses/MIT - - Authors: - * Odei Maiz (odeimaiz) - -************************************************************************ */ - -qx.Class.define("osparc.file.StorageAsyncJob", { - extend: qx.core.Object, - - construct: function(jobId, interval = 1000) { - this.base(arguments); - - this.setPollInterval(interval); - - this.setJobId(jobId); - }, - - events: { - "resultReceived": "qx.event.type.Data", - "taskAborted": "qx.event.type.Event", - "pollingError": "qx.event.type.Data", - }, - - properties: { - pollInterval: { - check: "Number", - nullable: false, - init: 1000 - }, - - jobId: { - check: "String", - nullable: false, - apply: "fetchStatus", - }, - }, - - members: { - __retries: null, - __aborting: null, - - fetchStatus: function() { - const jobId = this.getJobId(); - osparc.data.Resources.fetch("storageAsyncJobs", "jobStatus", { url: { jobId } }) - .then(status => { - if (this.__aborting) { - return; - } - if (status["done"]) { - this.__fetchResults(); - } else { - setTimeout(() => this.fetchStatus(), this.getPollInterval()); - } - }) - .catch(err => { - if (this.__retries > 0) { - this.__retries--; - this.fetchStatus(); - return; - } - this.fireDataEvent("pollingError", err); - }); - }, - - __fetchResults: function() { - const jobId = this.getJobId(); - osparc.data.Resources.fetch("storageAsyncJobs", "jobResult", { url: { jobId } }) - .then(resp => { - this.fireDataEvent("resultReceived", resp["result"]); - }) - .catch(err => { - console.error(err); - this.fireDataEvent("pollingError", err); - }); - }, - - abortRequested: function() { - this.__aborting = true; - const jobId = this.getJobId(); - osparc.data.Resources.fetch("storageAsyncJobs", "result", { url: { jobId } }) - .then(() => this.fireEvent("taskAborted")) - .catch(err => { - throw err; - }); - } - } -}); diff --git a/services/static-webserver/client/source/class/osparc/file/TreeFolderView.js b/services/static-webserver/client/source/class/osparc/file/TreeFolderView.js index a0fb8bc88ee..e05b112ffd7 100644 --- a/services/static-webserver/client/source/class/osparc/file/TreeFolderView.js +++ b/services/static-webserver/client/source/class/osparc/file/TreeFolderView.js @@ -62,6 +62,7 @@ qx.Class.define("osparc.file.TreeFolderView", { icon: "@FontAwesome5Solid/spinner/14", allowGrowX: false }); + osparc.utils.Utils.setIdToWidget(control.getChildControl("label"), "totalSizeLabel"); this.getChildControl("header-layout").add(control); break; case "tree-folder-layout": @@ -160,22 +161,18 @@ qx.Class.define("osparc.file.TreeFolderView", { const totalSize = this.getChildControl("total-size-label"); totalSize.getChildControl("icon").getContentElement().addClass("rotate"); - osparc.data.Resources.fetch("storagePaths", "requestSize", { url: { pathId } }) - .then(resp => { - const jobId = resp["job_id"]; - if (jobId) { - const asyncJob = new osparc.file.StorageAsyncJob(jobId); - asyncJob.addListener("resultReceived", e => { - const size = e.getData(); - totalSize.set({ - icon: null, - label: this.tr("Total size: ") + osparc.utils.Utils.bytesToSize(size), - }); + const pollTasks = osparc.store.PollTasks.getInstance(); + const fetchPromise = osparc.data.Resources.fetch("storagePaths", "requestSize", { url: { pathId } }) + pollTasks.createPollingTask(fetchPromise) + .then(task => { + task.addListener("resultReceived", e => { + const size = e.getData(); + totalSize.set({ + icon: null, + label: this.tr("Total size: ") + osparc.utils.Utils.bytesToSize(size), }); - asyncJob.addListener("pollingError", e => { - totalSize.hide(); - }); - } + }); + task.addListener("pollingError", e => totalSize.hide()); }) .catch(err => { console.error(err); diff --git a/services/static-webserver/client/source/class/osparc/store/Services.js b/services/static-webserver/client/source/class/osparc/store/Services.js index a01d4cf91a0..676e98e6169 100644 --- a/services/static-webserver/client/source/class/osparc/store/Services.js +++ b/services/static-webserver/client/source/class/osparc/store/Services.js @@ -51,7 +51,7 @@ qx.Class.define("osparc.store.Services", { const services = this.__servicesCached; if (key in services) { const latestMetadata = Object.values(services[key])[0]; - if (!osparc.service.Utils.isRetired(latestMetadata)) { + if (!osparc.service.Utils.isDeprecated(latestMetadata)) { return latestMetadata; } } @@ -168,8 +168,8 @@ qx.Class.define("osparc.store.Services", { continue; } if (excludeDeprecated) { - if (osparc.service.Utils.isRetired(serviceLatest)) { - // first check if a previous version of this service isn't retired + if (osparc.service.Utils.isDeprecated(serviceLatest)) { + // first check if a previous version of this service isn't deprecated // getService to get its history await this.getService(serviceLatest["key"], serviceLatest["version"]); const serviceMetadata = this.__servicesCached[key][serviceLatest["version"]]; @@ -185,7 +185,7 @@ qx.Class.define("osparc.store.Services", { } } } - if (osparc.service.Utils.isRetired(serviceLatest)) { + if (osparc.service.Utils.isDeprecated(serviceLatest)) { // do not add retired services continue; }