Skip to content

Commit fe95d75

Browse files
authored
🎨 [e2e frontend] Navigation Bar and User Menu (#6603)
1 parent f870beb commit fe95d75

File tree

15 files changed

+516
-55
lines changed

15 files changed

+516
-55
lines changed

.eslintrc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"block-scoped-var": "warn",
2424
"brace-style": [
2525
"warn",
26-
"stroustrup"
26+
"1tbs"
2727
],
2828
"indent": [
2929
"warn",

services/static-webserver/client/source/class/osparc/desktop/StudyEditor.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ qx.Class.define("osparc.desktop.StudyEditor", {
288288
this.__listenToNoMoreCreditsEvents();
289289
this.__listenToEvent();
290290
this.__listenToServiceStatus();
291-
this.__listenToStateInputPorts();
291+
this.__listenToStatePorts();
292292
},
293293

294294
__listenToLogger: function() {
@@ -436,7 +436,7 @@ qx.Class.define("osparc.desktop.StudyEditor", {
436436
}
437437
},
438438

439-
__listenToStateInputPorts: function() {
439+
__listenToStatePorts: function() {
440440
const socket = osparc.wrapper.WebSocket.getInstance();
441441
if (!socket.slotExists("stateInputPorts")) {
442442
socket.on("stateInputPorts", data => {

services/static-webserver/client/source/class/osparc/desktop/organizations/OrganizationsList.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ qx.Class.define("osparc.desktop.organizations.OrganizationsList", {
126126
height: 150,
127127
width: 150
128128
});
129+
osparc.utils.Utils.setIdToWidget(orgsUIList, "organizationsList");
129130
orgsUIList.addListener("changeSelection", e => this.__organizationSelected(e.getData()), this);
130131

131132
const orgsModel = this.__orgsModel = new qx.data.Array();
@@ -143,6 +144,7 @@ qx.Class.define("osparc.desktop.organizations.OrganizationsList", {
143144
},
144145
configureItem: item => {
145146
item.subscribeToFilterGroup("organizationsList");
147+
osparc.utils.Utils.setIdToWidget(item, "organizationListItem");
146148
const thumbnail = item.getChildControl("thumbnail");
147149
thumbnail.getContentElement()
148150
.setStyles({

services/static-webserver/client/source/class/osparc/desktop/organizations/OrganizationsWindow.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ qx.Class.define("osparc.desktop.organizations.OrganizationsWindow", {
3131
appearance: "service-window"
3232
});
3333

34+
osparc.utils.Utils.setIdToWidget(this, "organizationsWindow");
35+
const closeBtn = this.getChildControl("close-button");
36+
osparc.utils.Utils.setIdToWidget(closeBtn, "organizationsWindowCloseBtn");
37+
3438
this.__buildLayout();
3539
},
3640

services/static-webserver/client/source/class/osparc/navigation/UserMenu.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ qx.Class.define("osparc.navigation.UserMenu", {
3737
break;
3838
case "theme-switcher":
3939
control = new osparc.ui.switch.ThemeSwitcherMenuBtn();
40+
osparc.utils.Utils.setIdToWidget(control, "userMenuThemeSwitcherBtn");
4041
this.add(control);
4142
break;
4243
case "log-in":
@@ -46,6 +47,7 @@ qx.Class.define("osparc.navigation.UserMenu", {
4647
break;
4748
case "user-center":
4849
control = new qx.ui.menu.Button(this.tr("My Account"));
50+
osparc.utils.Utils.setIdToWidget(control, "userMenuMyAccountBtn");
4951
control.addListener("execute", () => osparc.desktop.account.MyAccountWindow.openWindow(), this);
5052
this.add(control);
5153
break;
@@ -80,6 +82,7 @@ qx.Class.define("osparc.navigation.UserMenu", {
8082
control = new qx.ui.menu.Button(this.tr("Organizations")).set({
8183
visibility: osparc.data.Permissions.getInstance().canDo("user.organizations.create") ? "visible" :"excluded"
8284
});
85+
osparc.utils.Utils.setIdToWidget(control, "userMenuOrganizationsBtn");
8386
control.addListener("execute", () => osparc.desktop.organizations.OrganizationsWindow.openWindow(), this);
8487
this.add(control);
8588
break;
@@ -97,12 +100,13 @@ qx.Class.define("osparc.navigation.UserMenu", {
97100
break;
98101
case "about":
99102
control = new qx.ui.menu.Button(this.tr("About oSPARC"));
100-
control.addListener("execute", () => osparc.About.getInstance().open());
101103
osparc.utils.Utils.setIdToWidget(control, "userMenuAboutBtn");
104+
control.addListener("execute", () => osparc.About.getInstance().open());
102105
this.add(control);
103106
break;
104107
case "about-product": {
105108
control = new qx.ui.menu.Button(this.tr("About Product"));
109+
osparc.utils.Utils.setIdToWidget(control, "userMenuAboutProductBtn");
106110
const displayName = osparc.store.StaticInfo.getInstance().getDisplayName();
107111
control.getChildControl("label").setRich(true);
108112
control.setLabel(this.tr("About ") + displayName);

services/static-webserver/client/source/class/osparc/ui/list/ListItem.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,9 @@ qx.Class.define("osparc.ui.list.ListItem", {
207207
}
208208
const parts = value.split("/");
209209
const id = parts.pop();
210-
osparc.utils.Utils.setIdToWidget(this, "serviceBrowserListItem_"+id);
210+
if (osparc.utils.Utils.getIdFromWidget(this) === null) {
211+
osparc.utils.Utils.setIdToWidget(this, "listItem_"+id);
212+
}
211213
},
212214

213215
_applyThumbnail: function(value) {

services/static-webserver/client/source/class/osparc/utils/Utils.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1026,6 +1026,13 @@ qx.Class.define("osparc.utils.Utils", {
10261026
}
10271027
},
10281028

1029+
getIdFromWidget: qWidget => {
1030+
if (qWidget.getContentElement) {
1031+
return qWidget.getContentElement().getAttribute("osparc-test-id");
1032+
}
1033+
return null;
1034+
},
1035+
10291036
setMoreToWidget: (qWidget, id) => {
10301037
if (qWidget.getContentElement) {
10311038
qWidget.getContentElement().setAttribute("osparc-test-more", id);

tests/e2e-frontend/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@ run-tests-headed: install-dev ## run tests headed (you can see what's going on)
1010
npx playwright test --headed
1111

1212
.PHONY: run-tests-ui
13-
run-tests-ui: install-dev ## run tests headed with an assistance GUI
13+
run-tests-ui: install-dev ## starts a GUI where tests can be launched
1414
npx playwright test --ui

tests/e2e-frontend/tests/init/statics.spec.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,17 @@ const expectedStatics = {
1818
"isPaymentEnabled": true
1919
},
2020
"s4llite": {
21-
"displayName": "<i>S4L<sup>lite</sup></i>",
21+
"displayName": "Sim4Life.lite",
2222
"isPaymentEnabled": false
2323
},
2424
"tis": {
2525
"displayName": "TI Planning Tool",
2626
"isPaymentEnabled": true
2727
},
28+
"tiplite": {
29+
"displayName": "TI Planning Tool lite",
30+
"isPaymentEnabled": true
31+
},
2832
};
2933

3034
for (const product in products) {

tests/e2e-frontend/tests/login/invitationRequired.spec.js

Lines changed: 29 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,38 @@ const { test, expect } = require('@playwright/test');
44

55
import products from '../products.json';
66

7-
const expectedCreateAccountLabel = {
8-
"osparc": "Create Account",
9-
"s4l": "Request Account",
10-
"s4lacad": "Request Account",
11-
"s4llite": "Request Account",
12-
"tis": "Request Account"
13-
};
14-
15-
const expectedActionOnCreateAccount = {
16-
"osparc": "registrationSubmitBtn",
17-
"s4l": "registrationSubmitBtn",
18-
"s4lacad": "registrationSubmitBtn",
19-
"s4llite": "createAccountWindow",
20-
"tis": "createAccountWindow"
7+
const expectedLogin = {
8+
"osparc": {
9+
"label": "Request Account",
10+
"afterClicking": "registrationSubmitBtn",
11+
},
12+
"s4l": {
13+
"label": "Request Account",
14+
"afterClicking": "registrationSubmitBtn",
15+
},
16+
"s4lacad": {
17+
"label": "Request Account",
18+
"afterClicking": "registrationSubmitBtn",
19+
},
20+
"s4llite": {
21+
"label": "Request Account",
22+
"afterClicking": "createAccountWindow",
23+
},
24+
"tis": {
25+
"label": "Request Account",
26+
"afterClicking": "registrationSubmitBtn",
27+
},
28+
"tiplite": {
29+
"label": "Request Account",
30+
"afterClicking": "registrationSubmitBtn",
31+
},
2132
};
2233

2334
for (const product in products) {
2435
test(`Invitation required text in ${product}`, async ({ page }) => {
25-
expect(expectedCreateAccountLabel[product]).toBeDefined();
36+
expect(expectedLogin[product]["label"]).toBeDefined();
2637

27-
const expectedLabel = expectedCreateAccountLabel[product];
38+
const expectedLabel = expectedLogin[product]["label"];
2839
await page.goto(products[product]);
2940

3041
const button = page.getByTestId("loginCreateAccountBtn");
@@ -33,14 +44,14 @@ for (const product in products) {
3344
});
3445

3546
test(`Callback action on Create Account ${product}`, async ({ page }) => {
36-
expect(expectedActionOnCreateAccount[product]).toBeDefined();
47+
expect(expectedLogin[product]["afterClicking"]).toBeDefined();
3748

3849
await page.goto(products[product]);
3950

4051
const button = page.getByTestId("loginCreateAccountBtn");
4152
button.click();
4253

43-
const expectedWidget = page.getByTestId(expectedActionOnCreateAccount[product]);
54+
const expectedWidget = page.getByTestId(expectedLogin[product]["afterClicking"]);
4455
await expect(expectedWidget).toBeVisible();
4556
});
4657
}

0 commit comments

Comments
 (0)