Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🎨 [e2e][Frontend] Folders and Workspaces related test-ids #6766

Merged
merged 10 commits into from
Nov 19, 2024
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ qx.Class.define("osparc.dashboard.FolderButtonItem", {
control.getContentElement().setStyles({
"border-radius": `${osparc.dashboard.ListButtonItem.MENU_BTN_DIMENSIONS / 2}px`
});
osparc.utils.Utils.setIdToWidget(control, "folderItemMenuButton");
this._add(control, osparc.dashboard.FolderButtonBase.POS.MENU);
break;
}
Expand All @@ -146,6 +147,8 @@ qx.Class.define("osparc.dashboard.FolderButtonItem", {
folder.bind("name", this, "title");
folder.bind("lastModified", this, "lastModified");

osparc.utils.Utils.setIdToWidget(this, "folderItem_" + folder.getFolderId());

this.__addMenuButton();
},

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

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

menu.addSeparator();

const deleteButton = new qx.ui.menu.Button(this.tr("Delete"), "@FontAwesome5Solid/trash/12");
osparc.utils.Utils.setIdToWidget(deleteButton, "deleteFolderMenuItem");
deleteButton.addListener("execute", () => this.__deleteFolderRequested(), this);
menu.add(deleteButton);
}
Expand Down Expand Up @@ -264,6 +269,7 @@ qx.Class.define("osparc.dashboard.FolderButtonItem", {
confirmText: this.tr("Delete"),
confirmAction: "delete"
});
osparc.utils.Utils.setIdToWidget(confirmationWin.getConfirmButton(), "confirmDeleteFolderButton");
confirmationWin.center();
confirmationWin.open();
confirmationWin.addListener("close", () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ qx.Class.define("osparc.dashboard.FolderButtonNew", {
this.setPriority(osparc.dashboard.CardBase.CARD_PRIORITY.NEW);

this.__buildLayout();

osparc.utils.Utils.setIdToWidget(this, "newFolderButton");
},

events: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,30 +140,89 @@ qx.Class.define("osparc.dashboard.TemplateBrowser", {
const studyAlias = osparc.product.Utils.getStudyAlias({firstUpperCase: true});
this._showLoadingPage(this.tr("Creating ") + (templateData.name || studyAlias));

const studyOptions = new osparc.study.StudyOptions();
// they will be patched once the study is created
studyOptions.setPatchStudy(false);
studyOptions.setStudyData(templateData);
const win = osparc.study.StudyOptions.popUpInWindow(studyOptions);
win.moveItUp();
const cancelStudyOptions = () => {
this._hideLoadingPage();
win.close();
}
win.addListener("cancel", () => cancelStudyOptions());
studyOptions.addListener("cancel", () => cancelStudyOptions());
studyOptions.addListener("startStudy", () => {
const newName = studyOptions.getChildControl("title-field").getValue();
const walletSelection = studyOptions.getChildControl("wallet-selector").getSelection();
const nodesPricingUnits = studyOptions.getChildControl("study-pricing-units").getNodePricingUnits();
win.close();
this._showLoadingPage(this.tr("Creating ") + (newName || studyAlias));
if (osparc.desktop.credits.Utils.areWalletsEnabled()) {
const studyOptions = new osparc.study.StudyOptions();
// they will be patched once the study is created
studyOptions.setPatchStudy(false);
studyOptions.setStudyData(templateData);
const win = osparc.study.StudyOptions.popUpInWindow(studyOptions);
win.moveItUp();
const cancelStudyOptions = () => {
this._hideLoadingPage();
win.close();
}
win.addListener("cancel", () => cancelStudyOptions());
studyOptions.addListener("cancel", () => cancelStudyOptions());
studyOptions.addListener("startStudy", () => {
const newName = studyOptions.getChildControl("title-field").getValue();
const walletSelection = studyOptions.getChildControl("wallet-selector").getSelection();
const nodesPricingUnits = studyOptions.getChildControl("study-pricing-units").getNodePricingUnits();
win.close();

this._showLoadingPage(this.tr("Creating ") + (newName || studyAlias));
osparc.study.Utils.createStudyFromTemplate(templateData, this._loadingPage)
.then(newStudyData => {
const studyId = newStudyData["uuid"];
const openCB = () => {
this._hideLoadingPage();
};
const cancelCB = () => {
this._hideLoadingPage();
const params = {
url: {
studyId
}
};
osparc.data.Resources.fetch("studies", "delete", params);
};

const promises = [];
// patch the name
if (newStudyData["name"] !== newName) {
promises.push(osparc.study.StudyOptions.updateName(newStudyData, newName));
}
// patch the wallet
if (walletSelection.length && walletSelection[0]["walletId"]) {
const walletId = walletSelection[0]["walletId"];
promises.push(osparc.study.StudyOptions.updateWallet(newStudyData["uuid"], walletId));
}
// patch the pricing units
// the nodeIds are coming from the original template, they need to be mapped to the newStudy
const workbench = newStudyData["workbench"];
const nodesIdsListed = [];
Object.keys(workbench).forEach(nodeId => {
const node = workbench[nodeId];
if (osparc.study.StudyPricingUnits.includeInList(node)) {
nodesIdsListed.push(nodeId);
}
});
nodesPricingUnits.forEach((nodePricingUnits, idx) => {
const selectedPricingUnitId = nodePricingUnits.getPricingUnits().getSelectedUnitId();
if (selectedPricingUnitId) {
const nodeId = nodesIdsListed[idx];
const pricingPlanId = nodePricingUnits.getPricingPlanId();
promises.push(osparc.study.NodePricingUnits.patchPricingUnitSelection(studyId, nodeId, pricingPlanId, selectedPricingUnitId));
}
});

Promise.all(promises)
.then(() => {
win.close();
const showStudyOptions = false;
this._startStudyById(studyId, openCB, cancelCB, showStudyOptions);
});
})
.catch(err => {
this._hideLoadingPage();
osparc.FlashMessenger.getInstance().logAs(err.message, "ERROR");
console.error(err);
});
});
} else {
osparc.study.Utils.createStudyFromTemplate(templateData, this._loadingPage)
.then(newStudyData => {
const studyId = newStudyData["uuid"];
const openCB = () => {
this._hideLoadingPage();
};
const openCB = () => this._hideLoadingPage();
const cancelCB = () => {
this._hideLoadingPage();
const params = {
Expand All @@ -173,49 +232,15 @@ qx.Class.define("osparc.dashboard.TemplateBrowser", {
};
osparc.data.Resources.fetch("studies", "delete", params);
};

const promises = [];
// patch the name
if (newStudyData["name"] !== newName) {
promises.push(osparc.study.StudyOptions.updateName(newStudyData, newName));
}
// patch the wallet
if (walletSelection.length && walletSelection[0]["walletId"]) {
const walletId = walletSelection[0]["walletId"];
promises.push(osparc.study.StudyOptions.updateWallet(newStudyData["uuid"], walletId));
}
// patch the pricing units
// the nodeIds are coming from the original template, they need to be mapped to the newStudy
const workbench = newStudyData["workbench"];
const nodesIdsListed = [];
Object.keys(workbench).forEach(nodeId => {
const node = workbench[nodeId];
if (osparc.study.StudyPricingUnits.includeInList(node)) {
nodesIdsListed.push(nodeId);
}
});
nodesPricingUnits.forEach((nodePricingUnits, idx) => {
const selectedPricingUnitId = nodePricingUnits.getPricingUnits().getSelectedUnitId();
if (selectedPricingUnitId) {
const nodeId = nodesIdsListed[idx];
const pricingPlanId = nodePricingUnits.getPricingPlanId();
promises.push(osparc.study.NodePricingUnits.patchPricingUnitSelection(studyId, nodeId, pricingPlanId, selectedPricingUnitId));
}
});

Promise.all(promises)
.then(() => {
win.close();
const showStudyOptions = false;
this._startStudyById(studyId, openCB, cancelCB, showStudyOptions);
});
const isStudyCreation = true;
this._startStudyById(studyId, openCB, cancelCB, isStudyCreation);
})
.catch(err => {
this._hideLoadingPage();
osparc.FlashMessenger.getInstance().logAs(err.message, "ERROR");
console.error(err);
});
});
}
},

// LAYOUT //
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ qx.Class.define("osparc.dashboard.WorkspaceButtonItem", {
control.getContentElement().setStyles({
"border-radius": `${this.self().MENU_BTN_DIMENSIONS / 2}px`
});
osparc.utils.Utils.setIdToWidget(control, "workspaceItemMenuButton");
layout = this.getChildControl("header");
layout.addAt(control, osparc.dashboard.WorkspaceButtonBase.HPOS.MENU);
break;
Expand Down Expand Up @@ -159,6 +160,8 @@ qx.Class.define("osparc.dashboard.WorkspaceButtonItem", {
workspace.bind("accessRights", this, "accessRights");
workspace.bind("modifiedAt", this, "modifiedAt");
workspace.bind("myAccessRights", this, "myAccessRights");

osparc.utils.Utils.setIdToWidget(this, "workspaceItem_" + workspace.getWorkspaceId());
},

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

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

Expand Down Expand Up @@ -254,6 +258,7 @@ qx.Class.define("osparc.dashboard.WorkspaceButtonItem", {
confirmText: this.tr("Delete"),
confirmAction: "delete"
});
osparc.utils.Utils.setIdToWidget(confirmationWin.getConfirmButton(), "confirmDeleteWorkspaceButton");
confirmationWin.center();
confirmationWin.open();
confirmationWin.addListener("close", () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ qx.Class.define("osparc.dashboard.WorkspaceButtonNew", {
opacity: 1
});
this.getChildControl("footer").exclude();

osparc.utils.Utils.setIdToWidget(this, "newWorkspaceButton");
},

events: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,12 @@ qx.Class.define("osparc.dashboard.WorkspacesAndFoldersTree", {
return isOpen;
},
}, item, id);
},
configureItem: item => {
item.addListener("changeModel", e => {
const model = e.getData();
osparc.utils.Utils.setIdToWidget(item, `workspacesAndFoldersTreeItem_${model.getWorkspaceId()}_${model.getFolderId()}`);
})
}
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ qx.Class.define("osparc.dashboard.WorkspacesAndFoldersTreeItem", {

this.setNotHoveredStyle();
this.__attachEventHandlers();

osparc.utils.Utils.setIdToWidget(this, "workspacesAndFoldersTreeItem");
},

members: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ qx.Class.define("osparc.editor.FolderEditor", {
placeholder: this.tr("Title"),
height: 27
});
osparc.utils.Utils.setIdToWidget(control, "folderEditorTitle");
this.bind("label", control, "value");
control.bind("value", this, "label");
this._add(control);
Expand All @@ -78,6 +79,7 @@ qx.Class.define("osparc.editor.FolderEditor", {
this.fireEvent("createFolder");
}
}, this);
osparc.utils.Utils.setIdToWidget(control, "folderEditorCreate");
buttons.addAt(control, 1);
break;
}
Expand All @@ -94,6 +96,7 @@ qx.Class.define("osparc.editor.FolderEditor", {
this.fireEvent("updateFolder");
}
}, this);
osparc.utils.Utils.setIdToWidget(control, "folderEditorSave");
buttons.addAt(control, 1);
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ qx.Class.define("osparc.editor.WorkspaceEditor", {
placeholder: this.tr("Title"),
height: 30,
});
osparc.utils.Utils.setIdToWidget(control, "workspaceEditorTitle");
this.bind("label", control, "value");
control.bind("value", this, "label");
this._addAt(control, this.self().POS.TITLE);
Expand Down Expand Up @@ -170,6 +171,7 @@ qx.Class.define("osparc.editor.WorkspaceEditor", {
control = new osparc.ui.form.FetchButton(this.tr("Save")).set({
appearance: "form-button"
});
osparc.utils.Utils.setIdToWidget(control, "workspaceEditorSave");
control.addListener("execute", () => this.__saveWorkspace(control), this);
buttons.addAt(control, 1);
break;
Expand Down
Loading