Skip to content

Commit c41b681

Browse files
authored
🎨 [e2e][Frontend] Folders and Workspaces related test-ids (#6766)
1 parent 0a52ba5 commit c41b681

File tree

9 files changed

+109
-60
lines changed

9 files changed

+109
-60
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ qx.Class.define("osparc.dashboard.FolderButtonItem", {
128128
control.getContentElement().setStyles({
129129
"border-radius": `${osparc.dashboard.ListButtonItem.MENU_BTN_DIMENSIONS / 2}px`
130130
});
131+
osparc.utils.Utils.setIdToWidget(control, "folderItemMenuButton");
131132
this._add(control, osparc.dashboard.FolderButtonBase.POS.MENU);
132133
break;
133134
}
@@ -146,6 +147,8 @@ qx.Class.define("osparc.dashboard.FolderButtonItem", {
146147
folder.bind("name", this, "title");
147148
folder.bind("lastModified", this, "lastModified");
148149

150+
osparc.utils.Utils.setIdToWidget(this, "folderItem_" + folder.getFolderId());
151+
149152
this.__addMenuButton();
150153
},
151154

@@ -211,11 +214,13 @@ qx.Class.define("osparc.dashboard.FolderButtonItem", {
211214

212215
const moveToButton = new qx.ui.menu.Button(this.tr("Move to..."), "@FontAwesome5Solid/folder/12");
213216
moveToButton.addListener("execute", () => this.fireDataEvent("moveFolderToRequested", this.getFolderId()), this);
217+
osparc.utils.Utils.setIdToWidget(moveToButton, "moveFolderMenuItem");
214218
menu.add(moveToButton);
215219

216220
menu.addSeparator();
217221

218222
const deleteButton = new qx.ui.menu.Button(this.tr("Delete"), "@FontAwesome5Solid/trash/12");
223+
osparc.utils.Utils.setIdToWidget(deleteButton, "deleteFolderMenuItem");
219224
deleteButton.addListener("execute", () => this.__deleteFolderRequested(), this);
220225
menu.add(deleteButton);
221226
}
@@ -264,6 +269,7 @@ qx.Class.define("osparc.dashboard.FolderButtonItem", {
264269
confirmText: this.tr("Delete"),
265270
confirmAction: "delete"
266271
});
272+
osparc.utils.Utils.setIdToWidget(confirmationWin.getConfirmButton(), "confirmDeleteFolderButton");
267273
confirmationWin.center();
268274
confirmationWin.open();
269275
confirmationWin.addListener("close", () => {

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ qx.Class.define("osparc.dashboard.FolderButtonNew", {
3535
this.setPriority(osparc.dashboard.CardBase.CARD_PRIORITY.NEW);
3636

3737
this.__buildLayout();
38+
39+
osparc.utils.Utils.setIdToWidget(this, "newFolderButton");
3840
},
3941

4042
events: {

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

Lines changed: 83 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -140,30 +140,89 @@ qx.Class.define("osparc.dashboard.TemplateBrowser", {
140140
const studyAlias = osparc.product.Utils.getStudyAlias({firstUpperCase: true});
141141
this._showLoadingPage(this.tr("Creating ") + (templateData.name || studyAlias));
142142

143-
const studyOptions = new osparc.study.StudyOptions();
144-
// they will be patched once the study is created
145-
studyOptions.setPatchStudy(false);
146-
studyOptions.setStudyData(templateData);
147-
const win = osparc.study.StudyOptions.popUpInWindow(studyOptions);
148-
win.moveItUp();
149-
const cancelStudyOptions = () => {
150-
this._hideLoadingPage();
151-
win.close();
152-
}
153-
win.addListener("cancel", () => cancelStudyOptions());
154-
studyOptions.addListener("cancel", () => cancelStudyOptions());
155-
studyOptions.addListener("startStudy", () => {
156-
const newName = studyOptions.getChildControl("title-field").getValue();
157-
const walletSelection = studyOptions.getChildControl("wallet-selector").getSelection();
158-
const nodesPricingUnits = studyOptions.getChildControl("study-pricing-units").getNodePricingUnits();
159-
win.close();
160-
this._showLoadingPage(this.tr("Creating ") + (newName || studyAlias));
143+
if (osparc.desktop.credits.Utils.areWalletsEnabled()) {
144+
const studyOptions = new osparc.study.StudyOptions();
145+
// they will be patched once the study is created
146+
studyOptions.setPatchStudy(false);
147+
studyOptions.setStudyData(templateData);
148+
const win = osparc.study.StudyOptions.popUpInWindow(studyOptions);
149+
win.moveItUp();
150+
const cancelStudyOptions = () => {
151+
this._hideLoadingPage();
152+
win.close();
153+
}
154+
win.addListener("cancel", () => cancelStudyOptions());
155+
studyOptions.addListener("cancel", () => cancelStudyOptions());
156+
studyOptions.addListener("startStudy", () => {
157+
const newName = studyOptions.getChildControl("title-field").getValue();
158+
const walletSelection = studyOptions.getChildControl("wallet-selector").getSelection();
159+
const nodesPricingUnits = studyOptions.getChildControl("study-pricing-units").getNodePricingUnits();
160+
win.close();
161+
162+
this._showLoadingPage(this.tr("Creating ") + (newName || studyAlias));
163+
osparc.study.Utils.createStudyFromTemplate(templateData, this._loadingPage)
164+
.then(newStudyData => {
165+
const studyId = newStudyData["uuid"];
166+
const openCB = () => {
167+
this._hideLoadingPage();
168+
};
169+
const cancelCB = () => {
170+
this._hideLoadingPage();
171+
const params = {
172+
url: {
173+
studyId
174+
}
175+
};
176+
osparc.data.Resources.fetch("studies", "delete", params);
177+
};
178+
179+
const promises = [];
180+
// patch the name
181+
if (newStudyData["name"] !== newName) {
182+
promises.push(osparc.study.StudyOptions.updateName(newStudyData, newName));
183+
}
184+
// patch the wallet
185+
if (walletSelection.length && walletSelection[0]["walletId"]) {
186+
const walletId = walletSelection[0]["walletId"];
187+
promises.push(osparc.study.StudyOptions.updateWallet(newStudyData["uuid"], walletId));
188+
}
189+
// patch the pricing units
190+
// the nodeIds are coming from the original template, they need to be mapped to the newStudy
191+
const workbench = newStudyData["workbench"];
192+
const nodesIdsListed = [];
193+
Object.keys(workbench).forEach(nodeId => {
194+
const node = workbench[nodeId];
195+
if (osparc.study.StudyPricingUnits.includeInList(node)) {
196+
nodesIdsListed.push(nodeId);
197+
}
198+
});
199+
nodesPricingUnits.forEach((nodePricingUnits, idx) => {
200+
const selectedPricingUnitId = nodePricingUnits.getPricingUnits().getSelectedUnitId();
201+
if (selectedPricingUnitId) {
202+
const nodeId = nodesIdsListed[idx];
203+
const pricingPlanId = nodePricingUnits.getPricingPlanId();
204+
promises.push(osparc.study.NodePricingUnits.patchPricingUnitSelection(studyId, nodeId, pricingPlanId, selectedPricingUnitId));
205+
}
206+
});
207+
208+
Promise.all(promises)
209+
.then(() => {
210+
win.close();
211+
const showStudyOptions = false;
212+
this._startStudyById(studyId, openCB, cancelCB, showStudyOptions);
213+
});
214+
})
215+
.catch(err => {
216+
this._hideLoadingPage();
217+
osparc.FlashMessenger.getInstance().logAs(err.message, "ERROR");
218+
console.error(err);
219+
});
220+
});
221+
} else {
161222
osparc.study.Utils.createStudyFromTemplate(templateData, this._loadingPage)
162223
.then(newStudyData => {
163224
const studyId = newStudyData["uuid"];
164-
const openCB = () => {
165-
this._hideLoadingPage();
166-
};
225+
const openCB = () => this._hideLoadingPage();
167226
const cancelCB = () => {
168227
this._hideLoadingPage();
169228
const params = {
@@ -173,49 +232,15 @@ qx.Class.define("osparc.dashboard.TemplateBrowser", {
173232
};
174233
osparc.data.Resources.fetch("studies", "delete", params);
175234
};
176-
177-
const promises = [];
178-
// patch the name
179-
if (newStudyData["name"] !== newName) {
180-
promises.push(osparc.study.StudyOptions.updateName(newStudyData, newName));
181-
}
182-
// patch the wallet
183-
if (walletSelection.length && walletSelection[0]["walletId"]) {
184-
const walletId = walletSelection[0]["walletId"];
185-
promises.push(osparc.study.StudyOptions.updateWallet(newStudyData["uuid"], walletId));
186-
}
187-
// patch the pricing units
188-
// the nodeIds are coming from the original template, they need to be mapped to the newStudy
189-
const workbench = newStudyData["workbench"];
190-
const nodesIdsListed = [];
191-
Object.keys(workbench).forEach(nodeId => {
192-
const node = workbench[nodeId];
193-
if (osparc.study.StudyPricingUnits.includeInList(node)) {
194-
nodesIdsListed.push(nodeId);
195-
}
196-
});
197-
nodesPricingUnits.forEach((nodePricingUnits, idx) => {
198-
const selectedPricingUnitId = nodePricingUnits.getPricingUnits().getSelectedUnitId();
199-
if (selectedPricingUnitId) {
200-
const nodeId = nodesIdsListed[idx];
201-
const pricingPlanId = nodePricingUnits.getPricingPlanId();
202-
promises.push(osparc.study.NodePricingUnits.patchPricingUnitSelection(studyId, nodeId, pricingPlanId, selectedPricingUnitId));
203-
}
204-
});
205-
206-
Promise.all(promises)
207-
.then(() => {
208-
win.close();
209-
const showStudyOptions = false;
210-
this._startStudyById(studyId, openCB, cancelCB, showStudyOptions);
211-
});
235+
const isStudyCreation = true;
236+
this._startStudyById(studyId, openCB, cancelCB, isStudyCreation);
212237
})
213238
.catch(err => {
214239
this._hideLoadingPage();
215240
osparc.FlashMessenger.getInstance().logAs(err.message, "ERROR");
216241
console.error(err);
217242
});
218-
});
243+
}
219244
},
220245

221246
// LAYOUT //

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ qx.Class.define("osparc.dashboard.WorkspaceButtonItem", {
127127
control.getContentElement().setStyles({
128128
"border-radius": `${this.self().MENU_BTN_DIMENSIONS / 2}px`
129129
});
130+
osparc.utils.Utils.setIdToWidget(control, "workspaceItemMenuButton");
130131
layout = this.getChildControl("header");
131132
layout.addAt(control, osparc.dashboard.WorkspaceButtonBase.HPOS.MENU);
132133
break;
@@ -159,6 +160,8 @@ qx.Class.define("osparc.dashboard.WorkspaceButtonItem", {
159160
workspace.bind("accessRights", this, "accessRights");
160161
workspace.bind("modifiedAt", this, "modifiedAt");
161162
workspace.bind("myAccessRights", this, "myAccessRights");
163+
164+
osparc.utils.Utils.setIdToWidget(this, "workspaceItem_" + workspace.getWorkspaceId());
162165
},
163166

164167
__applyTitle: function(value) {
@@ -201,6 +204,7 @@ qx.Class.define("osparc.dashboard.WorkspaceButtonItem", {
201204
menu.addSeparator();
202205

203206
const deleteButton = new qx.ui.menu.Button(this.tr("Delete"), "@FontAwesome5Solid/trash/12");
207+
osparc.utils.Utils.setIdToWidget(deleteButton, "deleteWorkspaceMenuItem");
204208
deleteButton.addListener("execute", () => this.__deleteWorkspaceRequested(), this);
205209
menu.add(deleteButton);
206210

@@ -254,6 +258,7 @@ qx.Class.define("osparc.dashboard.WorkspaceButtonItem", {
254258
confirmText: this.tr("Delete"),
255259
confirmAction: "delete"
256260
});
261+
osparc.utils.Utils.setIdToWidget(confirmationWin.getConfirmButton(), "confirmDeleteWorkspaceButton");
257262
confirmationWin.center();
258263
confirmationWin.open();
259264
confirmationWin.addListener("close", () => {

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ qx.Class.define("osparc.dashboard.WorkspaceButtonNew", {
4343
opacity: 1
4444
});
4545
this.getChildControl("footer").exclude();
46+
47+
osparc.utils.Utils.setIdToWidget(this, "newWorkspaceButton");
4648
},
4749

4850
events: {

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,12 @@ qx.Class.define("osparc.dashboard.WorkspacesAndFoldersTree", {
137137
return isOpen;
138138
},
139139
}, item, id);
140+
},
141+
configureItem: item => {
142+
item.addListener("changeModel", e => {
143+
const model = e.getData();
144+
osparc.utils.Utils.setIdToWidget(item, `workspacesAndFoldersTreeItem_${model.getWorkspaceId()}_${model.getFolderId()}`);
145+
})
140146
}
141147
});
142148

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@ qx.Class.define("osparc.dashboard.WorkspacesAndFoldersTreeItem", {
2929

3030
this.setNotHoveredStyle();
3131
this.__attachEventHandlers();
32-
33-
osparc.utils.Utils.setIdToWidget(this, "workspacesAndFoldersTreeItem");
3432
},
3533

3634
members: {

services/static-webserver/client/source/class/osparc/editor/FolderEditor.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ qx.Class.define("osparc.editor.FolderEditor", {
6060
placeholder: this.tr("Title"),
6161
height: 27
6262
});
63+
osparc.utils.Utils.setIdToWidget(control, "folderEditorTitle");
6364
this.bind("label", control, "value");
6465
control.bind("value", this, "label");
6566
this._add(control);
@@ -78,6 +79,7 @@ qx.Class.define("osparc.editor.FolderEditor", {
7879
this.fireEvent("createFolder");
7980
}
8081
}, this);
82+
osparc.utils.Utils.setIdToWidget(control, "folderEditorCreate");
8183
buttons.addAt(control, 1);
8284
break;
8385
}
@@ -94,6 +96,7 @@ qx.Class.define("osparc.editor.FolderEditor", {
9496
this.fireEvent("updateFolder");
9597
}
9698
}, this);
99+
osparc.utils.Utils.setIdToWidget(control, "folderEditorSave");
97100
buttons.addAt(control, 1);
98101
break;
99102
}

services/static-webserver/client/source/class/osparc/editor/WorkspaceEditor.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ qx.Class.define("osparc.editor.WorkspaceEditor", {
125125
placeholder: this.tr("Title"),
126126
height: 30,
127127
});
128+
osparc.utils.Utils.setIdToWidget(control, "workspaceEditorTitle");
128129
this.bind("label", control, "value");
129130
control.bind("value", this, "label");
130131
this._addAt(control, this.self().POS.TITLE);
@@ -170,6 +171,7 @@ qx.Class.define("osparc.editor.WorkspaceEditor", {
170171
control = new osparc.ui.form.FetchButton(this.tr("Save")).set({
171172
appearance: "form-button"
172173
});
174+
osparc.utils.Utils.setIdToWidget(control, "workspaceEditorSave");
173175
control.addListener("execute", () => this.__saveWorkspace(control), this);
174176
buttons.addAt(control, 1);
175177
break;

0 commit comments

Comments
 (0)