From e44f3bb444cb498cb33c651f762a06fd8e9c5582 Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Tue, 29 Oct 2024 13:24:35 +0100 Subject: [PATCH 01/13] check userMenuLicenseBtn --- tests/e2e-frontend/tests/userMenu/userMenuButtons.spec.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/e2e-frontend/tests/userMenu/userMenuButtons.spec.js b/tests/e2e-frontend/tests/userMenu/userMenuButtons.spec.js index d590d4429a5..b36e0dd2753 100644 --- a/tests/e2e-frontend/tests/userMenu/userMenuButtons.spec.js +++ b/tests/e2e-frontend/tests/userMenu/userMenuButtons.spec.js @@ -16,6 +16,7 @@ const userMenuButtons = { "userMenuThemeSwitcherBtn": true, "userMenuAboutBtn": true, "userMenuAboutProductBtn": true, + "userMenuLicenseBtn": true, "userMenuAccessTIPBtn": false, "userMenuLogoutBtn": true, }, @@ -27,6 +28,7 @@ const userMenuButtons = { "userMenuThemeSwitcherBtn": true, "userMenuAboutBtn": true, "userMenuAboutProductBtn": true, + "userMenuLicenseBtn": true, "userMenuAccessTIPBtn": false, "userMenuLogoutBtn": true, }, @@ -38,6 +40,7 @@ const userMenuButtons = { "userMenuThemeSwitcherBtn": true, "userMenuAboutBtn": true, "userMenuAboutProductBtn": true, + "userMenuLicenseBtn": true, "userMenuAccessTIPBtn": false, "userMenuLogoutBtn": true, }, @@ -49,6 +52,7 @@ const userMenuButtons = { "userMenuThemeSwitcherBtn": true, "userMenuAboutBtn": true, "userMenuAboutProductBtn": true, + "userMenuLicenseBtn": true, "userMenuAccessTIPBtn": false, "userMenuLogoutBtn": true, }, @@ -60,6 +64,7 @@ const userMenuButtons = { "userMenuThemeSwitcherBtn": true, "userMenuAboutBtn": true, "userMenuAboutProductBtn": true, + "userMenuLicenseBtn": true, "userMenuAccessTIPBtn": false, "userMenuLogoutBtn": true, }, @@ -71,6 +76,7 @@ const userMenuButtons = { "userMenuThemeSwitcherBtn": true, "userMenuAboutBtn": true, "userMenuAboutProductBtn": true, + "userMenuLicenseBtn": true, "userMenuAccessTIPBtn": true, "userMenuLogoutBtn": true, }, From d7eacd76aa1f0b6560321ca7db053e2a75c61379 Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Tue, 29 Oct 2024 13:31:47 +0100 Subject: [PATCH 02/13] refactor --- tests/e2e-frontend/tests/fixtures/loginPage.js | 6 ++++++ .../tests/navigationBar/navigationBar.spec.js | 10 ++-------- .../tests/userMenu/userMenuButtons.spec.js | 10 ++-------- .../tests/userMenu/userMenuWindows.spec.js | 10 ++-------- 4 files changed, 12 insertions(+), 24 deletions(-) diff --git a/tests/e2e-frontend/tests/fixtures/loginPage.js b/tests/e2e-frontend/tests/fixtures/loginPage.js index ffee8c3fc58..12d12d3d242 100644 --- a/tests/e2e-frontend/tests/fixtures/loginPage.js +++ b/tests/e2e-frontend/tests/fixtures/loginPage.js @@ -17,6 +17,8 @@ export class LoginPage { * @param {string} password */ async login(email, password) { + await this.goto(this.productUrl); + const usernameField = this.page.getByTestId("loginUserEmailFld"); const passwordField = this.page.getByTestId("loginPasswordFld"); const submitButton = this.page.getByTestId("loginSubmitBtn"); @@ -24,6 +26,10 @@ export class LoginPage { await usernameField.fill(email); await passwordField.fill(password); await submitButton.click(); + + const response = await this.page.waitForResponse('**/me'); + const meData = await response.json(); + return meData["data"]["role"]; } async logout() { diff --git a/tests/e2e-frontend/tests/navigationBar/navigationBar.spec.js b/tests/e2e-frontend/tests/navigationBar/navigationBar.spec.js index 27bb724cef8..0c981ef8777 100644 --- a/tests/e2e-frontend/tests/navigationBar/navigationBar.spec.js +++ b/tests/e2e-frontend/tests/navigationBar/navigationBar.spec.js @@ -153,15 +153,9 @@ for (const product in products) { test.beforeAll(async ({ browser }) => { page = await browser.newPage(); - loginPageFixture = new LoginPage(page, productUrl); - await loginPageFixture.goto(); - - await loginPageFixture.login(user.email, user.password); - - const response = await page.waitForResponse('**/me'); - const meData = await response.json(); - expect(meData["data"]["role"]).toBe(role); + const role = await loginPageFixture.login(user.email, user.password); + expect(role).toBe(user.role); }); test.afterAll(async ({ browser }) => { diff --git a/tests/e2e-frontend/tests/userMenu/userMenuButtons.spec.js b/tests/e2e-frontend/tests/userMenu/userMenuButtons.spec.js index b36e0dd2753..053bc38f6e3 100644 --- a/tests/e2e-frontend/tests/userMenu/userMenuButtons.spec.js +++ b/tests/e2e-frontend/tests/userMenu/userMenuButtons.spec.js @@ -114,15 +114,9 @@ for (const product in products) { test.beforeAll(async ({ browser }) => { page = await browser.newPage(); - loginPageFixture = new LoginPage(page, productUrl); - await loginPageFixture.goto(); - - await loginPageFixture.login(user.email, user.password); - - const response = await page.waitForResponse('**/me'); - const meData = await response.json(); - expect(meData["data"]["role"]).toBe(role); + const role = await loginPageFixture.login(user.email, user.password); + expect(role).toBe(user.role); }); test.afterAll(async ({ browser }) => { diff --git a/tests/e2e-frontend/tests/userMenu/userMenuWindows.spec.js b/tests/e2e-frontend/tests/userMenu/userMenuWindows.spec.js index 4a50cd45153..1a44d7156b5 100644 --- a/tests/e2e-frontend/tests/userMenu/userMenuWindows.spec.js +++ b/tests/e2e-frontend/tests/userMenu/userMenuWindows.spec.js @@ -17,15 +17,9 @@ test.describe.serial(`User Menu Windows: ${product}`, () => { test.beforeAll(async ({ browser }) => { page = await browser.newPage(); - loginPageFixture = new LoginPage(page, productUrl); - await loginPageFixture.goto(); - - await loginPageFixture.login(user.email, user.password); - - const response = await page.waitForResponse('**/me'); - const meData = await response.json(); - expect(meData["data"]["role"]).toBe(user.role); + const role = await loginPageFixture.login(user.email, user.password); + expect(role).toBe(user.role); }); test.afterAll(async ({ browser }) => { From 789fe6a444fc281162f072c7544bcc79218ef95b Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Tue, 29 Oct 2024 13:48:56 +0100 Subject: [PATCH 03/13] id to widget --- .../client/source/class/osparc/navigation/UserMenu.js | 1 + tests/e2e-frontend/tests/fixtures/loginPage.js | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/services/static-webserver/client/source/class/osparc/navigation/UserMenu.js b/services/static-webserver/client/source/class/osparc/navigation/UserMenu.js index 025c7e5024c..b18f0a4d7b3 100644 --- a/services/static-webserver/client/source/class/osparc/navigation/UserMenu.js +++ b/services/static-webserver/client/source/class/osparc/navigation/UserMenu.js @@ -116,6 +116,7 @@ qx.Class.define("osparc.navigation.UserMenu", { } case "license": control = new qx.ui.menu.Button(this.tr("License")); + osparc.utils.Utils.setIdToWidget(control, "userMenuLicenseBtn"); osparc.store.Support.getLicenseURL() .then(licenseURL => control.addListener("execute", () => window.open(licenseURL))); this.add(control); diff --git a/tests/e2e-frontend/tests/fixtures/loginPage.js b/tests/e2e-frontend/tests/fixtures/loginPage.js index 12d12d3d242..04e29e66b90 100644 --- a/tests/e2e-frontend/tests/fixtures/loginPage.js +++ b/tests/e2e-frontend/tests/fixtures/loginPage.js @@ -17,7 +17,7 @@ export class LoginPage { * @param {string} password */ async login(email, password) { - await this.goto(this.productUrl); + await this.page.goto(this.productUrl); const usernameField = this.page.getByTestId("loginUserEmailFld"); const passwordField = this.page.getByTestId("loginPasswordFld"); From 1d118482220e58acc7b344a2f0e3fc1aed468172 Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Tue, 29 Oct 2024 13:49:09 +0100 Subject: [PATCH 04/13] [skip ci] License pop up --- .../tests/userMenu/userMenuWindows.spec.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/tests/e2e-frontend/tests/userMenu/userMenuWindows.spec.js b/tests/e2e-frontend/tests/userMenu/userMenuWindows.spec.js index 1a44d7156b5..4b9baa083ba 100644 --- a/tests/e2e-frontend/tests/userMenu/userMenuWindows.spec.js +++ b/tests/e2e-frontend/tests/userMenu/userMenuWindows.spec.js @@ -9,7 +9,7 @@ import users from '../users.json'; const product = "osparc"; const productUrl = products[product]; -const user = users[product]; +const user = users[product][0]; test.describe.serial(`User Menu Windows: ${product}`, () => { let page = null; @@ -45,4 +45,19 @@ test.describe.serial(`User Menu Windows: ${product}`, () => { // close window await page.getByTestId("organizationsWindowCloseBtn").click(); }); + + test(`License pop up`, async () => { + // open user menu + await page.getByTestId("userMenuBtn").click(); + + // open license in new tab + const newTabPromise = page.waitForEvent("popup"); + const newTab = await newTabPromise; + await newTab.waitForLoadState(); + await page.getByTestId("userMenuLicenseBtn").click(); + + // make sure the window opens + expect(newTab).toBeTruthy(); + // close tab + }); }); From a27da28992dc05b3cb2532ba6c2ba9fe410d032f Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Tue, 29 Oct 2024 14:05:07 +0100 Subject: [PATCH 05/13] working test --- tests/e2e-frontend/tests/userMenu/userMenuWindows.spec.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tests/e2e-frontend/tests/userMenu/userMenuWindows.spec.js b/tests/e2e-frontend/tests/userMenu/userMenuWindows.spec.js index 4b9baa083ba..6303528c8c0 100644 --- a/tests/e2e-frontend/tests/userMenu/userMenuWindows.spec.js +++ b/tests/e2e-frontend/tests/userMenu/userMenuWindows.spec.js @@ -51,13 +51,12 @@ test.describe.serial(`User Menu Windows: ${product}`, () => { await page.getByTestId("userMenuBtn").click(); // open license in new tab + await page.getByTestId("userMenuLicenseBtn").click(); const newTabPromise = page.waitForEvent("popup"); const newTab = await newTabPromise; await newTab.waitForLoadState(); - await page.getByTestId("userMenuLicenseBtn").click(); - // make sure the window opens - expect(newTab).toBeTruthy(); // close tab + await newTab.close(); }); }); From 8a1927342b492b77b9e3108cf1556ff905510ca3 Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Tue, 29 Oct 2024 14:15:25 +0100 Subject: [PATCH 06/13] renaming --- .../client/source/class/osparc/utils/Utils.js | 4 ++-- .../client/source/class/osparc/widget/NodeTreeItem.js | 4 ++-- tests/e2e/utils/auto.js | 2 +- tests/e2e/utils/utils.js | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/utils/Utils.js b/services/static-webserver/client/source/class/osparc/utils/Utils.js index ab86392270c..ead285bccab 100644 --- a/services/static-webserver/client/source/class/osparc/utils/Utils.js +++ b/services/static-webserver/client/source/class/osparc/utils/Utils.js @@ -1033,9 +1033,9 @@ qx.Class.define("osparc.utils.Utils", { return null; }, - setMoreToWidget: (qWidget, id) => { + setKeyToWidget: (qWidget, id) => { if (qWidget.getContentElement) { - qWidget.getContentElement().setAttribute("osparc-test-more", id); + qWidget.getContentElement().setAttribute("osparc-test-key", id); } }, diff --git a/services/static-webserver/client/source/class/osparc/widget/NodeTreeItem.js b/services/static-webserver/client/source/class/osparc/widget/NodeTreeItem.js index 7ce4509cc56..d424973944f 100644 --- a/services/static-webserver/client/source/class/osparc/widget/NodeTreeItem.js +++ b/services/static-webserver/client/source/class/osparc/widget/NodeTreeItem.js @@ -107,7 +107,7 @@ qx.Class.define("osparc.widget.NodeTreeItem", { __applyStudy: function(study) { const label = this.getChildControl("label"); - osparc.utils.Utils.setMoreToWidget(label, "root"); + osparc.utils.Utils.setKeyToWidget(label, "root"); study.bind("name", this, "toolTipText"); @@ -116,7 +116,7 @@ qx.Class.define("osparc.widget.NodeTreeItem", { __applyNode: function(node) { const label = this.getChildControl("label"); - osparc.utils.Utils.setMoreToWidget(label, node.getNodeId()); + osparc.utils.Utils.setKeyToWidget(label, node.getNodeId()); node.bind("label", this, "toolTipText"); diff --git a/tests/e2e/utils/auto.js b/tests/e2e/utils/auto.js index 8c7a45e3d44..3a745adaccd 100644 --- a/tests/e2e/utils/auto.js +++ b/tests/e2e/utils/auto.js @@ -334,7 +334,7 @@ async function openNode(page, pos) { } const nodeId = children[pos]; - const childId = '[osparc-test-more="' + nodeId + '"]'; + const childId = '[osparc-test-key="' + nodeId + '"]'; await utils.waitAndClick(page, childId); return nodeId; diff --git a/tests/e2e/utils/utils.js b/tests/e2e/utils/utils.js index c2d976dad97..43226419615 100644 --- a/tests/e2e/utils/utils.js +++ b/tests/e2e/utils/utils.js @@ -231,7 +231,7 @@ async function getNodeTreeItemIDs(page) { const children = []; const nodeTreeItems = document.querySelectorAll(selector); nodeTreeItems.forEach(nodeTreeItem => { - const nodeId = nodeTreeItem.getAttribute("osparc-test-more") + const nodeId = nodeTreeItem.getAttribute("osparc-test-key") if (nodeId !== "root") { children.push(nodeId); } From 3138a3ef3e6d57b5df35c7d2609e5d083c7bb821 Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Tue, 29 Oct 2024 14:24:29 +0100 Subject: [PATCH 07/13] Study browser check items on the left --- .../class/osparc/dashboard/ResourceFilter.js | 2 + tests/e2e-frontend/tests/products.json | 2 +- .../tests/studyBrowser/leftElements.spec.js | 40 +++++++++++++++++++ 3 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 tests/e2e-frontend/tests/studyBrowser/leftElements.spec.js diff --git a/services/static-webserver/client/source/class/osparc/dashboard/ResourceFilter.js b/services/static-webserver/client/source/class/osparc/dashboard/ResourceFilter.js index 92d0b1dc1b3..08e021a8023 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/ResourceFilter.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/ResourceFilter.js @@ -65,6 +65,7 @@ qx.Class.define("osparc.dashboard.ResourceFilter", { /* WORKSPACES AND FOLDERS */ __createWorkspacesAndFoldersTree: function() { const workspacesAndFoldersTree = this.__workspacesAndFoldersTree = new osparc.dashboard.WorkspacesAndFoldersTree(); + osparc.utils.Utils.setIdToWidget(workspacesAndFoldersTree, "contextTree"); // Height needs to be calculated manually to make it flexible workspacesAndFoldersTree.set({ minHeight: 60, @@ -137,6 +138,7 @@ qx.Class.define("osparc.dashboard.ResourceFilter", { /* TAGS */ __createTagsFilterLayout: function() { const layout = new qx.ui.container.Composite(new qx.ui.layout.VBox(5)); + osparc.utils.Utils.setIdToWidget(layout, "tagsFilter"); this.__populateTags(layout, []); osparc.store.Store.getInstance().addListener("changeTags", () => { diff --git a/tests/e2e-frontend/tests/products.json b/tests/e2e-frontend/tests/products.json index 3d465cfa3e2..2e4d04ed2d4 100644 --- a/tests/e2e-frontend/tests/products.json +++ b/tests/e2e-frontend/tests/products.json @@ -1,5 +1,5 @@ { - "osparc": "https://osparc-master.speag.com/", + "osparc": "http://172.29.100.6.nip.io:9081/", "s4l": "https://s4l-master.speag.com/", "s4lacad": "https://s4l-acad-master.speag.com/", "s4llite": "https://s4l-lite-master.speag.com/", diff --git a/tests/e2e-frontend/tests/studyBrowser/leftElements.spec.js b/tests/e2e-frontend/tests/studyBrowser/leftElements.spec.js new file mode 100644 index 00000000000..8d9b0a1781a --- /dev/null +++ b/tests/e2e-frontend/tests/studyBrowser/leftElements.spec.js @@ -0,0 +1,40 @@ +/* eslint-disable no-undef */ + +const { test, expect } = require('@playwright/test'); + +import { LoginPage } from '../fixtures/loginPage'; + +import products from '../products.json'; +import users from '../users.json'; + +const product = "osparc"; +const productUrl = products[product]; +const user = users[product][0]; + +test.describe.serial(`User Menu Windows: ${product}`, () => { + let page = null; + let loginPageFixture = null; + + test.beforeAll(async ({ browser }) => { + page = await browser.newPage(); + loginPageFixture = new LoginPage(page, productUrl); + const role = await loginPageFixture.login(user.email, user.password); + expect(role).toBe(user.role); + }); + + test.afterAll(async ({ browser }) => { + await loginPageFixture.logout(); + await page.close(); + await browser.close(); + }); + + test(`Context items`, async () => { + const contextTree = page.getByTestId("contextTree"); + await expect(contextTree).toBeVisible(); + }); + + test(`Tags`, async () => { + const contextTree = page.getByTestId("tagsFilter"); + await expect(contextTree).toBeVisible(); + }); +}); From 21bdeb288c041ccb8e8496bcff6f1a4c14cab079 Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Tue, 29 Oct 2024 15:08:09 +0100 Subject: [PATCH 08/13] check filters --- .../class/osparc/dashboard/ResourceFilter.js | 1 + .../dashboard/WorkspacesAndFoldersTreeItem.js | 2 ++ .../tests/studyBrowser/leftElements.spec.js | 14 ++++++++++++-- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/dashboard/ResourceFilter.js b/services/static-webserver/client/source/class/osparc/dashboard/ResourceFilter.js index 08e021a8023..0cbb3357737 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/ResourceFilter.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/ResourceFilter.js @@ -159,6 +159,7 @@ qx.Class.define("osparc.dashboard.ResourceFilter", { layout.removeAll(); osparc.store.Store.getInstance().getTags().forEach((tag, idx) => { const button = new qx.ui.form.ToggleButton(tag.name, "@FontAwesome5Solid/tag/18"); + osparc.utils.Utils.setIdToWidget(button, "tagFilterItem"); button.id = tag.id; button.set({ appearance: "filter-toggle-button", diff --git a/services/static-webserver/client/source/class/osparc/dashboard/WorkspacesAndFoldersTreeItem.js b/services/static-webserver/client/source/class/osparc/dashboard/WorkspacesAndFoldersTreeItem.js index f643218243b..071ba7e3d6d 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/WorkspacesAndFoldersTreeItem.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/WorkspacesAndFoldersTreeItem.js @@ -32,6 +32,8 @@ qx.Class.define("osparc.dashboard.WorkspacesAndFoldersTreeItem", { this.setNotHoveredStyle(); this.__attachEventHandlers(); + + osparc.utils.Utils.setIdToWidget(this, "workspacesAndFoldersTreeItem"); }, members: { diff --git a/tests/e2e-frontend/tests/studyBrowser/leftElements.spec.js b/tests/e2e-frontend/tests/studyBrowser/leftElements.spec.js index 8d9b0a1781a..59f2492ee74 100644 --- a/tests/e2e-frontend/tests/studyBrowser/leftElements.spec.js +++ b/tests/e2e-frontend/tests/studyBrowser/leftElements.spec.js @@ -31,10 +31,20 @@ test.describe.serial(`User Menu Windows: ${product}`, () => { test(`Context items`, async () => { const contextTree = page.getByTestId("contextTree"); await expect(contextTree).toBeVisible(); + + const workspacesAndFoldersTreeItems = page.getByTestId("workspacesAndFoldersTreeItem"); + const count = await workspacesAndFoldersTreeItems.count(); + // at least two: My Workspace and Shared Workspaces + expect(count > 1).toBeTruthy(); }); test(`Tags`, async () => { - const contextTree = page.getByTestId("tagsFilter"); - await expect(contextTree).toBeVisible(); + const tagsFilter = page.getByTestId("tagsFilter"); + await expect(tagsFilter).toBeVisible(); + + const tagFilterItems = page.getByTestId("tagFilterItem"); + const count = await tagFilterItems.count(); + // at least two and less than 6 (max five are shown) + expect(count > 1 && count < 6).toBeTruthy(); }); }); From 5d10cdba88d845493501a7b766eae5f6fb24ee90 Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Tue, 29 Oct 2024 15:09:13 +0100 Subject: [PATCH 09/13] undo --- tests/e2e-frontend/tests/products.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/e2e-frontend/tests/products.json b/tests/e2e-frontend/tests/products.json index 2e4d04ed2d4..3d465cfa3e2 100644 --- a/tests/e2e-frontend/tests/products.json +++ b/tests/e2e-frontend/tests/products.json @@ -1,5 +1,5 @@ { - "osparc": "http://172.29.100.6.nip.io:9081/", + "osparc": "https://osparc-master.speag.com/", "s4l": "https://s4l-master.speag.com/", "s4lacad": "https://s4l-acad-master.speag.com/", "s4llite": "https://s4l-lite-master.speag.com/", From 8bde7a9d8d813f3e7bf0941db4c6f1749d5bf511 Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Tue, 29 Oct 2024 15:35:31 +0100 Subject: [PATCH 10/13] plusButtons --- ...ftElements.spec.js => leftFilters.spec.js} | 4 +- .../tests/studyBrowser/mainView.spec.js | 79 +++++++++++++++++++ 2 files changed, 81 insertions(+), 2 deletions(-) rename tests/e2e-frontend/tests/studyBrowser/{leftElements.spec.js => leftFilters.spec.js} (93%) create mode 100644 tests/e2e-frontend/tests/studyBrowser/mainView.spec.js diff --git a/tests/e2e-frontend/tests/studyBrowser/leftElements.spec.js b/tests/e2e-frontend/tests/studyBrowser/leftFilters.spec.js similarity index 93% rename from tests/e2e-frontend/tests/studyBrowser/leftElements.spec.js rename to tests/e2e-frontend/tests/studyBrowser/leftFilters.spec.js index 59f2492ee74..35b98ba9582 100644 --- a/tests/e2e-frontend/tests/studyBrowser/leftElements.spec.js +++ b/tests/e2e-frontend/tests/studyBrowser/leftFilters.spec.js @@ -11,7 +11,7 @@ const product = "osparc"; const productUrl = products[product]; const user = users[product][0]; -test.describe.serial(`User Menu Windows: ${product}`, () => { +test.describe.serial(`Left Filters:`, () => { let page = null; let loginPageFixture = null; @@ -28,7 +28,7 @@ test.describe.serial(`User Menu Windows: ${product}`, () => { await browser.close(); }); - test(`Context items`, async () => { + test(`Context`, async () => { const contextTree = page.getByTestId("contextTree"); await expect(contextTree).toBeVisible(); diff --git a/tests/e2e-frontend/tests/studyBrowser/mainView.spec.js b/tests/e2e-frontend/tests/studyBrowser/mainView.spec.js new file mode 100644 index 00000000000..5d0f5074482 --- /dev/null +++ b/tests/e2e-frontend/tests/studyBrowser/mainView.spec.js @@ -0,0 +1,79 @@ +/* eslint-disable no-undef */ + +const { test, expect } = require('@playwright/test'); + +import { LoginPage } from '../fixtures/loginPage'; + +import products from '../products.json'; +import users from '../users.json'; + +const expectedElements = { + "osparc": { + "plusButton": { + "id": "newStudyBtn", + }, + }, + "s4l": { + "plusButton": { + "id": "startS4LButton", + }, + }, + "s4lacad": { + "plusButton": { + "id": "startS4LButton", + }, + }, + "s4llite": { + "plusButton": { + "id": "startS4LButton", + }, + }, + "tis": { + "plusButton": { + "id": "newStudyBtn", + }, + }, + "tiplite": { + "plusButton": { + "id": "newStudyBtn", + }, + }, +}; + +for (const product in products) { + if (product in users) { + const productUrl = products[product]; + const productUsers = users[product]; + for (const user of productUsers) { + // expected roles for users: "USER" + const role = "USER"; + expect(user.role).toBe(role); + + test.describe.serial(`Main View: ${product}`, () => { + let page = null; + let loginPageFixture = null; + + test.beforeAll(async ({ browser }) => { + page = await browser.newPage(); + loginPageFixture = new LoginPage(page, productUrl); + const role = await loginPageFixture.login(user.email, user.password); + expect(role).toBe(user.role); + }); + + test.afterAll(async ({ browser }) => { + await loginPageFixture.logout(); + await page.close(); + await browser.close(); + }); + + test(`Plus button`, async () => { + expect(expectedElements[product]["plusButton"]).toBeDefined(); + + const plusButtonId = expectedElements[product]["plusButton"]["id"]; + const contextTree = page.getByTestId(plusButtonId); + await expect(contextTree).toBeVisible(); + }); + }); + } + } +} From 5a9cf076e07941f1ca2e655f59369dde4bb27e8e Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Tue, 29 Oct 2024 15:47:35 +0100 Subject: [PATCH 11/13] add timeout --- tests/e2e-frontend/tests/studyBrowser/mainView.spec.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/e2e-frontend/tests/studyBrowser/mainView.spec.js b/tests/e2e-frontend/tests/studyBrowser/mainView.spec.js index 5d0f5074482..0fa55f31f7e 100644 --- a/tests/e2e-frontend/tests/studyBrowser/mainView.spec.js +++ b/tests/e2e-frontend/tests/studyBrowser/mainView.spec.js @@ -71,7 +71,9 @@ for (const product in products) { const plusButtonId = expectedElements[product]["plusButton"]["id"]; const contextTree = page.getByTestId(plusButtonId); - await expect(contextTree).toBeVisible(); + await expect(contextTree).toBeVisible({ + timeout: 20000 // it will take some time to make the plus button visible + }); }); }); } From de69d8816efb8a7b8548f784020fb86686551f48 Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Tue, 29 Oct 2024 15:59:42 +0100 Subject: [PATCH 12/13] minor --- tests/e2e-frontend/tests/studyBrowser/leftFilters.spec.js | 8 ++++++-- tests/e2e-frontend/tests/studyBrowser/mainView.spec.js | 6 +++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/tests/e2e-frontend/tests/studyBrowser/leftFilters.spec.js b/tests/e2e-frontend/tests/studyBrowser/leftFilters.spec.js index 35b98ba9582..d9d726ff694 100644 --- a/tests/e2e-frontend/tests/studyBrowser/leftFilters.spec.js +++ b/tests/e2e-frontend/tests/studyBrowser/leftFilters.spec.js @@ -30,7 +30,9 @@ test.describe.serial(`Left Filters:`, () => { test(`Context`, async () => { const contextTree = page.getByTestId("contextTree"); - await expect(contextTree).toBeVisible(); + await expect(contextTree).toBeVisible({ + timeout: 30000 // it will take some time to make the plus button visible + }); const workspacesAndFoldersTreeItems = page.getByTestId("workspacesAndFoldersTreeItem"); const count = await workspacesAndFoldersTreeItems.count(); @@ -40,7 +42,9 @@ test.describe.serial(`Left Filters:`, () => { test(`Tags`, async () => { const tagsFilter = page.getByTestId("tagsFilter"); - await expect(tagsFilter).toBeVisible(); + await expect(tagsFilter).toBeVisible({ + timeout: 30000 // it will take some time to make the plus button visible + }); const tagFilterItems = page.getByTestId("tagFilterItem"); const count = await tagFilterItems.count(); diff --git a/tests/e2e-frontend/tests/studyBrowser/mainView.spec.js b/tests/e2e-frontend/tests/studyBrowser/mainView.spec.js index 0fa55f31f7e..836f297696a 100644 --- a/tests/e2e-frontend/tests/studyBrowser/mainView.spec.js +++ b/tests/e2e-frontend/tests/studyBrowser/mainView.spec.js @@ -70,9 +70,9 @@ for (const product in products) { expect(expectedElements[product]["plusButton"]).toBeDefined(); const plusButtonId = expectedElements[product]["plusButton"]["id"]; - const contextTree = page.getByTestId(plusButtonId); - await expect(contextTree).toBeVisible({ - timeout: 20000 // it will take some time to make the plus button visible + const plusButton = page.getByTestId(plusButtonId); + await expect(plusButton).toBeVisible({ + timeout: 30000 // it will take some time to make the plus button visible }); }); }); From d2bfa7be8be3858725dee0b5f6af19e96f2b4255 Mon Sep 17 00:00:00 2001 From: Odei Maiz Date: Tue, 29 Oct 2024 16:07:28 +0100 Subject: [PATCH 13/13] comment --- tests/e2e-frontend/tests/studyBrowser/leftFilters.spec.js | 4 ++-- tests/e2e-frontend/tests/studyBrowser/mainView.spec.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/e2e-frontend/tests/studyBrowser/leftFilters.spec.js b/tests/e2e-frontend/tests/studyBrowser/leftFilters.spec.js index d9d726ff694..2a8dfa724d7 100644 --- a/tests/e2e-frontend/tests/studyBrowser/leftFilters.spec.js +++ b/tests/e2e-frontend/tests/studyBrowser/leftFilters.spec.js @@ -31,7 +31,7 @@ test.describe.serial(`Left Filters:`, () => { test(`Context`, async () => { const contextTree = page.getByTestId("contextTree"); await expect(contextTree).toBeVisible({ - timeout: 30000 // it will take some time to make the plus button visible + timeout: 30000 // it will take some time to load the Study Browser }); const workspacesAndFoldersTreeItems = page.getByTestId("workspacesAndFoldersTreeItem"); @@ -43,7 +43,7 @@ test.describe.serial(`Left Filters:`, () => { test(`Tags`, async () => { const tagsFilter = page.getByTestId("tagsFilter"); await expect(tagsFilter).toBeVisible({ - timeout: 30000 // it will take some time to make the plus button visible + timeout: 30000 // it will take some time to load the Study Browser }); const tagFilterItems = page.getByTestId("tagFilterItem"); diff --git a/tests/e2e-frontend/tests/studyBrowser/mainView.spec.js b/tests/e2e-frontend/tests/studyBrowser/mainView.spec.js index 836f297696a..ff8890af572 100644 --- a/tests/e2e-frontend/tests/studyBrowser/mainView.spec.js +++ b/tests/e2e-frontend/tests/studyBrowser/mainView.spec.js @@ -72,7 +72,7 @@ for (const product in products) { const plusButtonId = expectedElements[product]["plusButton"]["id"]; const plusButton = page.getByTestId(plusButtonId); await expect(plusButton).toBeVisible({ - timeout: 30000 // it will take some time to make the plus button visible + timeout: 30000 // it will take some time to load the Study Browser }); }); });