"use strict";
var specHelper = require("../../utils/intSpecHelper");
var oracleHelper = require("../../utils/oracleHelper");
var config = global.envConfig;
describe("Profile", function () { // NOSONAR (relax "Functions should not have too many lines")
var testProfileLinks = function (expectedLinks) {
var verifyItem = function (index, link) {
specHelper.waitForElementToBeVisible(".profile-wrapper .sub-menu");
specHelper.performMouseMove($(".profile-wrapper"));
var element = $$(".profile-wrapper a").get(index);
if (link.href) {
specHelper.verifyExternalLink(element, link.label, link.href);
} else {
specHelper.expectText(element, link.label);
}
};
// Verify the text of the hover
var fullNameElem = $(".profile-wrapper .profile-full-name");
expect(fullNameElem.getText()).toEqual(expectedLinks[0].label);
// Verify the contents of the hover menu are initially hidden
expect($(".profile-wrapper .sub-menu").isDisplayed()).toEqual(false);
expect($$(".profile-wrapper a").count()).toEqual(expectedLinks.length);
// Skip the first link because it's the menu button
for (var i = 1; i < expectedLinks.length; i++) {
verifyItem(i, expectedLinks[i]);
}
};
describe("Non-admin user", function () {
beforeAll(function (done) {
var that = this;
oracleHelper.addUser("murano_profile_non_admin").then(function () {
return specHelper.login("murano_profile_non_admin", that);
}).done(done);
});
afterAll(function (done) {
oracleHelper.removeUser("murano_profile_non_admin").done(done);
});
it("should display the correct profile dropdown", function (done) {
testProfileLinks([
{
label: "Murano User"
},
{
label: "My Profile"
},
{
label: "My Security",
href: config.eConnectUrl + "/auth/security/credentialChange.do?cmdCredentialChange=20"
},
{
label: "My Alerts",
href: config.eConnectUrl + "/alerts/learn_more.jsp?QUICKLINK_MODE=1"
}
]);
done();
});
});
fdescribe("Admin user", function () {
beforeAll(function (done) {
specHelper.login("ericmah", this);
done();
});
it("should display the correct profile dropdown", function (done) {
testProfileLinks([
{
label: "Eric Mah"
},
{
label: "My Profile"
},
{
label: "My Security",
href: config.eConnectUrl + "/auth/security/credentialChange.do?cmdCredentialChange=20"
},
{
label: "My Alerts",
href: config.eConnectUrl + "/alerts/learn_more.jsp?QUICKLINK_MODE=1"
},
{
label: "Administration"
},
{
label: "Users",
href: config.eConnectUrl + "/useradmin/userSearchAction.do?actionLabel=getClientUserList&" +
"QUICKLINK_MODE=1"
},
{
label: "Alerts",
href: config.eConnectUrl + "/alerts/AutoAlerts.do?cmdAlertGroup=1&QUICKLINK_MODE=1"
},
{
label: "Audits",
href: config.eConnectUrl + "/audit/activityReportAction.do?cmd=103&QUICKLINK_MODE=1"
}
]);
done();
});
});
});