Skip to content

Commit 41817c8

Browse files
authored
🎨 [e2e-frontend] Service browser (#6664)
1 parent cddaab9 commit 41817c8

File tree

4 files changed

+159
-5
lines changed

4 files changed

+159
-5
lines changed

services/static-webserver/client/source/class/osparc/dashboard/ResourceFilter.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ qx.Class.define("osparc.dashboard.ResourceFilter", {
2222
construct: function(resourceType) {
2323
this.base(arguments);
2424

25-
osparc.utils.Utils.setIdToWidget(this, "resourceFilter");
25+
osparc.utils.Utils.setIdToWidget(this, resourceType + "-resourceFilter");
2626

2727
this.__resourceType = resourceType;
2828
this.__sharedWithButtons = [];
@@ -102,6 +102,7 @@ qx.Class.define("osparc.dashboard.ResourceFilter", {
102102
label: option.label,
103103
icon: option.icon,
104104
});
105+
osparc.utils.Utils.setIdToWidget(button, this.__resourceType + "-sharedWithFilterItem");
105106
if (this.__resourceType === "study") {
106107
if (option.id === "show-all") {
107108
button.set({
@@ -138,7 +139,7 @@ qx.Class.define("osparc.dashboard.ResourceFilter", {
138139
/* TAGS */
139140
__createTagsFilterLayout: function() {
140141
const layout = new qx.ui.container.Composite(new qx.ui.layout.VBox(5));
141-
osparc.utils.Utils.setIdToWidget(layout, "tagsFilter");
142+
osparc.utils.Utils.setIdToWidget(layout, this.__resourceType + "-tagsFilter");
142143

143144
this.__populateTags(layout, []);
144145
osparc.store.Store.getInstance().addListener("changeTags", () => {
@@ -159,7 +160,7 @@ qx.Class.define("osparc.dashboard.ResourceFilter", {
159160
layout.removeAll();
160161
osparc.store.Store.getInstance().getTags().forEach((tag, idx) => {
161162
const button = new qx.ui.form.ToggleButton(tag.name, "@FontAwesome5Solid/tag/18");
162-
osparc.utils.Utils.setIdToWidget(button, "tagFilterItem");
163+
osparc.utils.Utils.setIdToWidget(button, this.__resourceType + "-tagFilterItem");
163164
button.id = tag.id;
164165
button.set({
165166
appearance: "filter-toggle-button",
@@ -220,6 +221,7 @@ qx.Class.define("osparc.dashboard.ResourceFilter", {
220221
const iconSize = 20;
221222
const button = new qx.ui.toolbar.RadioButton(serviceType.label, serviceType.icon+iconSize);
222223
button.id = serviceId;
224+
osparc.utils.Utils.setIdToWidget(button, this.__resourceType + "-serviceTypeFilterItem");
223225
button.set({
224226
appearance: "filter-toggle-button",
225227
value: false
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/* eslint-disable no-undef */
2+
3+
const { test, expect } = require('@playwright/test');
4+
5+
import { LoginPage } from '../fixtures/loginPage';
6+
7+
import products from '../products.json';
8+
import users from '../users.json';
9+
10+
const product = "osparc";
11+
const productUrl = products[product];
12+
const user = users[product][0];
13+
14+
test.describe.serial(`Left Filters:`, () => {
15+
let page = null;
16+
let loginPageFixture = null;
17+
18+
test.beforeAll(async ({ browser }) => {
19+
page = await browser.newPage();
20+
21+
const responsePromise = page.waitForResponse('**/services/-/latest**', {
22+
timeout: 30000
23+
});
24+
25+
loginPageFixture = new LoginPage(page, productUrl);
26+
const role = await loginPageFixture.login(user.email, user.password);
27+
expect(role).toBe(user.role);
28+
29+
await responsePromise;
30+
31+
await page.getByTestId("servicesTabBtn").click();
32+
});
33+
34+
test.afterAll(async ({ browser }) => {
35+
await loginPageFixture.logout();
36+
await page.close();
37+
await browser.close();
38+
});
39+
40+
test(`Filters`, async () => {
41+
const sharedWithButtons = page.getByTestId("service-sharedWithFilterItem");
42+
await expect(sharedWithButtons.first()).toBeVisible({
43+
timeout: 30000 // it will take some time to load the Study Browser
44+
});
45+
46+
const countSharedWithButtons = await sharedWithButtons.count();
47+
// All Services
48+
// My Services
49+
// Shared with Me
50+
// Shared with Everyone
51+
expect(countSharedWithButtons === 4).toBeTruthy();
52+
53+
54+
const serviceTypeButtons = page.getByTestId("service-serviceTypeFilterItem");
55+
await expect(serviceTypeButtons.first()).toBeVisible({
56+
timeout: 30000 // it will take some time to load the Study Browser
57+
});
58+
59+
const countServiceTypeButtons = await serviceTypeButtons.count();
60+
// Computational
61+
// Interactive
62+
expect(countServiceTypeButtons === 2).toBeTruthy();
63+
});
64+
});
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
/* eslint-disable no-undef */
2+
3+
const { test, expect } = require('@playwright/test');
4+
5+
import { LoginPage } from '../fixtures/loginPage';
6+
7+
import products from '../products.json';
8+
import users from '../users.json';
9+
10+
const servicesTabExposed = {
11+
"osparc": {
12+
"areServicesExposed": true,
13+
},
14+
"s4l": {
15+
"areServicesExposed": true,
16+
},
17+
"s4lacad": {
18+
"areServicesExposed": true,
19+
},
20+
"s4llite": {
21+
"areServicesExposed": false,
22+
},
23+
"tis": {
24+
"areServicesExposed": false,
25+
},
26+
"tiplite": {
27+
"areServicesExposed": false,
28+
},
29+
}
30+
31+
for (const product in products) {
32+
expect(servicesTabExposed[product]).toBeDefined();
33+
if (!servicesTabExposed[product]["areServicesExposed"]) {
34+
continue;
35+
}
36+
37+
if (product in users) {
38+
const productUrl = products[product];
39+
const productUsers = users[product];
40+
for (const user of productUsers) {
41+
// expected roles for users: "USER"
42+
const role = "USER";
43+
expect(user.role).toBe(role);
44+
45+
test.describe.serial(`Main View: ${product}`, () => {
46+
let page = null;
47+
let loginPageFixture = null;
48+
49+
test.beforeAll(async ({ browser }) => {
50+
page = await browser.newPage();
51+
52+
const responsePromise = page.waitForResponse('**/services/-/latest**', {
53+
timeout: 30000
54+
});
55+
56+
loginPageFixture = new LoginPage(page, productUrl);
57+
const role = await loginPageFixture.login(user.email, user.password);
58+
expect(role).toBe(user.role);
59+
60+
const response = await responsePromise;
61+
const resp = await response.json();
62+
expect("data" in resp && "_meta" in resp["data"] && "total" in resp["data"]["_meta"]);
63+
console.log("N Services in Response:", resp["data"]["_meta"]["total"]);
64+
65+
await page.getByTestId("servicesTabBtn").click();
66+
});
67+
68+
test.afterAll(async ({ browser }) => {
69+
await loginPageFixture.logout();
70+
await page.close();
71+
await browser.close();
72+
});
73+
74+
test(`Services list`, async () => {
75+
const servicesList = page.getByTestId("servicesList");
76+
await expect(servicesList).toBeVisible({
77+
timeout: 30000
78+
});
79+
80+
const serviceCards = servicesList.locator(':scope > *');
81+
const count = await serviceCards.count();
82+
console.log("N Services listed", count);
83+
expect(count > 0);
84+
});
85+
});
86+
}
87+
}
88+
}

tests/e2e-frontend/tests/studyBrowser/leftFilters.spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,12 @@ test.describe.serial(`Left Filters:`, () => {
4141
});
4242

4343
test(`Tags`, async () => {
44-
const tagsFilter = page.getByTestId("tagsFilter");
44+
const tagsFilter = page.getByTestId("study-tagsFilter");
4545
await expect(tagsFilter).toBeVisible({
4646
timeout: 30000 // it will take some time to load the Study Browser
4747
});
4848

49-
const tagFilterItems = page.getByTestId("tagFilterItem");
49+
const tagFilterItems = page.getByTestId("study-tagFilterItem");
5050
const count = await tagFilterItems.count();
5151
// at least two and less than 6 (max five are shown)
5252
expect(count > 1 && count < 6).toBeTruthy();

0 commit comments

Comments
 (0)