2022-08-04 15:10:46 +00:00
|
|
|
import { commonText, path } from "Texts/common";
|
2022-06-09 06:59:53 +00:00
|
|
|
import { usersSelector } from "Selectors/manageUsers";
|
2022-06-01 08:12:53 +00:00
|
|
|
import { profileSelector } from "Selectors/profile";
|
2023-07-11 11:20:52 +00:00
|
|
|
import { commonSelectors, commonWidgetSelector } from "Selectors/common";
|
2022-07-20 07:11:50 +00:00
|
|
|
import moment from "moment";
|
2022-12-09 13:12:31 +00:00
|
|
|
import { dashboardSelector } from "Selectors/dashboard";
|
2023-07-05 08:38:18 +00:00
|
|
|
import { groupsSelector } from "Selectors/manageGroups";
|
2023-08-07 11:56:43 +00:00
|
|
|
import { groupsText } from "Texts/manageGroups";
|
2022-06-01 08:12:53 +00:00
|
|
|
|
2022-07-20 07:11:50 +00:00
|
|
|
export const navigateToProfile = () => {
|
2023-02-09 10:56:10 +00:00
|
|
|
cy.get(commonSelectors.profileSettings).click();
|
|
|
|
|
cy.get(profileSelector.profileLink).click();
|
|
|
|
|
cy.url().should("include", "settings");
|
2022-06-01 08:12:53 +00:00
|
|
|
};
|
|
|
|
|
|
2022-07-20 07:11:50 +00:00
|
|
|
export const logout = () => {
|
2023-02-09 10:56:10 +00:00
|
|
|
cy.get(commonSelectors.profileSettings).click();
|
|
|
|
|
cy.get(commonSelectors.logoutLink).click();
|
2023-08-07 11:56:43 +00:00
|
|
|
cy.intercept("GET", "/api/metadata").as("publicConfig");
|
|
|
|
|
cy.wait("@publicConfig");
|
2023-07-31 17:13:52 +00:00
|
|
|
cy.wait(500);
|
2022-06-09 06:59:53 +00:00
|
|
|
};
|
|
|
|
|
|
2022-07-20 07:11:50 +00:00
|
|
|
export const navigateToManageUsers = () => {
|
2023-02-09 10:56:10 +00:00
|
|
|
cy.get(commonSelectors.workspaceSettingsIcon).click();
|
|
|
|
|
cy.get(commonSelectors.manageUsersOption).click();
|
2022-06-20 11:29:12 +00:00
|
|
|
};
|
|
|
|
|
|
2022-07-20 07:11:50 +00:00
|
|
|
export const navigateToManageGroups = () => {
|
2023-02-09 10:56:10 +00:00
|
|
|
cy.get(commonSelectors.workspaceSettingsIcon).click();
|
|
|
|
|
cy.get(commonSelectors.manageGroupsOption).click();
|
2023-07-24 15:30:14 +00:00
|
|
|
navigateToAllUserGroup();
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export const navigateToAllUserGroup = () => {
|
2023-07-05 08:38:18 +00:00
|
|
|
cy.get(groupsSelector.groupLink("Admin")).click();
|
|
|
|
|
cy.get(groupsSelector.groupLink("All users")).click();
|
|
|
|
|
cy.get(groupsSelector.groupLink("Admin")).click();
|
|
|
|
|
cy.get(groupsSelector.groupLink("All users")).click();
|
2023-07-24 15:30:14 +00:00
|
|
|
cy.wait(1000);
|
2023-07-05 12:47:00 +00:00
|
|
|
cy.get("body").then(($title) => {
|
2023-07-12 07:59:13 +00:00
|
|
|
if (
|
|
|
|
|
$title
|
|
|
|
|
.text()
|
|
|
|
|
.includes("Admin has edit access to all apps. These are not editable")
|
|
|
|
|
) {
|
2023-07-05 12:47:00 +00:00
|
|
|
cy.get(groupsSelector.groupLink("Admin")).click();
|
|
|
|
|
cy.get(groupsSelector.groupLink("All users")).click();
|
|
|
|
|
cy.get(groupsSelector.groupLink("Admin")).click();
|
|
|
|
|
cy.get(groupsSelector.groupLink("All users")).click();
|
|
|
|
|
cy.wait(2000);
|
|
|
|
|
}
|
|
|
|
|
});
|
2023-08-07 11:56:43 +00:00
|
|
|
};
|
2023-07-05 08:38:18 +00:00
|
|
|
|
2023-02-09 10:56:10 +00:00
|
|
|
export const navigateToWorkspaceVariable = () => {
|
|
|
|
|
cy.get(commonSelectors.workspaceSettingsIcon).click();
|
|
|
|
|
cy.get(commonSelectors.workspaceVariableOption).click();
|
2022-07-20 07:11:50 +00:00
|
|
|
};
|
2022-06-21 12:38:49 +00:00
|
|
|
|
2022-07-20 07:11:50 +00:00
|
|
|
export const navigateToManageSSO = () => {
|
2023-02-09 10:56:10 +00:00
|
|
|
cy.get(commonSelectors.workspaceSettingsIcon).click();
|
|
|
|
|
cy.get(commonSelectors.manageSSOOption).click();
|
2022-07-20 07:11:50 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export const randomDateOrTime = (format = "DD/MM/YYYY") => {
|
|
|
|
|
let endDate = new Date();
|
|
|
|
|
let startDate = new Date(2018, 0, 1);
|
|
|
|
|
startDate = new Date(
|
|
|
|
|
startDate.getTime() +
|
2023-07-17 05:20:42 +00:00
|
|
|
Math.random() * (endDate.getTime() - startDate.getTime())
|
2022-07-20 07:11:50 +00:00
|
|
|
);
|
|
|
|
|
return moment(startDate).format(format);
|
|
|
|
|
};
|
2022-08-04 15:10:46 +00:00
|
|
|
|
|
|
|
|
export const createFolder = (folderName) => {
|
2022-10-31 13:38:43 +00:00
|
|
|
cy.intercept("POST", "/api/folders").as("folderCreated");
|
2022-08-04 15:10:46 +00:00
|
|
|
cy.get(commonSelectors.createNewFolderButton).click();
|
|
|
|
|
cy.clearAndType(commonSelectors.folderNameInput, folderName);
|
|
|
|
|
cy.get(commonSelectors.buttonSelector(commonText.createFolderButton)).click();
|
2022-10-31 13:38:43 +00:00
|
|
|
cy.wait("@folderCreated");
|
2022-08-04 15:10:46 +00:00
|
|
|
cy.verifyToastMessage(
|
|
|
|
|
commonSelectors.toastMessage,
|
|
|
|
|
commonText.folderCreatedToast
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export const deleteFolder = (folderName) => {
|
|
|
|
|
viewFolderCardOptions(folderName);
|
2023-05-03 14:23:08 +00:00
|
|
|
cy.get(commonSelectors.deleteFolderOption(folderName)).click();
|
2022-08-04 15:10:46 +00:00
|
|
|
cy.get(commonSelectors.buttonSelector(commonText.modalYesButton)).click();
|
|
|
|
|
cy.wait("@folderDeleted");
|
|
|
|
|
cy.verifyToastMessage(
|
|
|
|
|
commonSelectors.toastMessage,
|
|
|
|
|
commonText.folderDeletedToast
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export const deleteDownloadsFolder = () => {
|
2023-07-05 07:28:09 +00:00
|
|
|
cy.exec("cd ./cypress/downloads/ && rm -rf *", {
|
|
|
|
|
failOnNonZeroExit: false,
|
|
|
|
|
});
|
2022-08-04 15:10:46 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export const navigateToAppEditor = (appName) => {
|
|
|
|
|
cy.get(commonSelectors.appCard(appName))
|
|
|
|
|
.trigger("mousehover")
|
|
|
|
|
.trigger("mouseenter")
|
|
|
|
|
.find(commonSelectors.editButton)
|
2023-05-09 14:03:37 +00:00
|
|
|
.click({ force: true });
|
2023-07-17 05:20:42 +00:00
|
|
|
if (Cypress.env("environment") === "Community") {
|
|
|
|
|
cy.intercept("GET", "/api/v2/data_sources").as("appDs");
|
|
|
|
|
cy.wait("@appDs", { timeout: 15000 });
|
|
|
|
|
cy.skipEditorPopover();
|
2023-08-07 11:56:43 +00:00
|
|
|
} else {
|
2023-07-17 05:20:42 +00:00
|
|
|
cy.intercept("GET", "/api/app-environments/**").as("appDs");
|
|
|
|
|
cy.wait("@appDs", { timeout: 15000 });
|
|
|
|
|
cy.skipEditorPopover();
|
|
|
|
|
}
|
2022-08-04 15:10:46 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export const viewAppCardOptions = (appName) => {
|
2023-07-05 08:38:18 +00:00
|
|
|
cy.reloadAppForTheElement(appName);
|
2023-05-09 14:03:37 +00:00
|
|
|
cy.contains("div", appName)
|
2023-05-02 08:44:48 +00:00
|
|
|
.parent()
|
|
|
|
|
.within(() => {
|
|
|
|
|
cy.get(commonSelectors.appCardOptionsButton).invoke("click");
|
|
|
|
|
});
|
2022-08-04 15:10:46 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export const viewFolderCardOptions = (folderName) => {
|
2023-07-05 08:38:18 +00:00
|
|
|
cy.reloadAppForTheElement(folderName);
|
2023-05-02 08:44:48 +00:00
|
|
|
cy.get(commonSelectors.folderListcard(folderName))
|
2023-02-09 10:56:10 +00:00
|
|
|
.parent()
|
|
|
|
|
.within(() => {
|
2023-05-09 14:03:37 +00:00
|
|
|
cy.get(commonSelectors.folderCardOptions(folderName)).invoke("click");
|
2023-02-09 10:56:10 +00:00
|
|
|
});
|
2022-08-04 15:10:46 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export const verifyModal = (title, buttonText, inputFiledSelector) => {
|
|
|
|
|
cy.get(commonSelectors.modalComponent).should("be.visible");
|
|
|
|
|
cy.get(commonSelectors.modalTitle(title))
|
|
|
|
|
.should("be.visible")
|
|
|
|
|
.and("have.text", title);
|
|
|
|
|
cy.get(commonSelectors.buttonSelector(commonText.closeButton)).should(
|
|
|
|
|
"be.visible"
|
|
|
|
|
);
|
|
|
|
|
cy.get(commonSelectors.buttonSelector(commonText.cancelButton))
|
|
|
|
|
.should("be.visible")
|
|
|
|
|
.and("have.text", commonText.cancelButton);
|
|
|
|
|
cy.get(commonSelectors.buttonSelector(buttonText))
|
|
|
|
|
.should("be.visible")
|
|
|
|
|
.and("have.text", buttonText);
|
|
|
|
|
|
|
|
|
|
if (inputFiledSelector) {
|
|
|
|
|
cy.get(inputFiledSelector).should("be.visible");
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export const verifyConfirmationModal = (messagse) => {
|
|
|
|
|
cy.get(commonSelectors.modalComponent).should("be.visible");
|
|
|
|
|
cy.get(commonSelectors.modalMessage)
|
|
|
|
|
.should("be.visible")
|
|
|
|
|
.and("have.text", messagse);
|
|
|
|
|
cy.get(commonSelectors.buttonSelector(commonText.cancelButton))
|
|
|
|
|
.should("be.visible")
|
|
|
|
|
.and("have.text", commonText.cancelButton);
|
|
|
|
|
cy.get(commonSelectors.buttonSelector(commonText.modalYesButton))
|
|
|
|
|
.should("be.visible")
|
|
|
|
|
.and("have.text", commonText.modalYesButton);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export const closeModal = (buttonText) => {
|
|
|
|
|
cy.get(commonSelectors.buttonSelector(buttonText)).click();
|
|
|
|
|
cy.get(commonSelectors.modalComponent).should("not.exist");
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export const cancelModal = (buttonText) => {
|
|
|
|
|
cy.get(commonSelectors.buttonSelector(buttonText)).click();
|
|
|
|
|
cy.get(commonSelectors.modalComponent).should("not.exist");
|
|
|
|
|
};
|
2022-10-31 13:38:43 +00:00
|
|
|
|
2023-07-24 15:30:14 +00:00
|
|
|
export const navigateToAuditLogsPage = () => {
|
|
|
|
|
cy.get(profileSelector.profileDropdown).invoke("show");
|
|
|
|
|
cy.contains("Audit Logs").click();
|
|
|
|
|
cy.url().should("include", path.auditLogsPath, { timeout: 1000 });
|
|
|
|
|
};
|
|
|
|
|
|
2022-10-31 13:38:43 +00:00
|
|
|
export const manageUsersPagination = (email) => {
|
|
|
|
|
cy.wait(200);
|
|
|
|
|
cy.get("body").then(($email) => {
|
|
|
|
|
if ($email.text().includes(email)) {
|
|
|
|
|
cy.log("First page");
|
|
|
|
|
} else {
|
2022-11-08 05:48:25 +00:00
|
|
|
cy.get(commonSelectors.nextPageArrow).click();
|
|
|
|
|
manageUsersPagination(email);
|
2022-10-31 13:38:43 +00:00
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
};
|
2022-11-08 05:48:25 +00:00
|
|
|
|
|
|
|
|
export const searchUser = (email) => {
|
2023-04-25 04:40:30 +00:00
|
|
|
cy.clearAndType(commonSelectors.inputUserSearch, email);
|
2022-12-09 13:12:31 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export const createWorkspace = (workspaceName) => {
|
2023-05-09 14:03:37 +00:00
|
|
|
cy.get(commonSelectors.workspaceName).click();
|
2022-12-09 13:12:31 +00:00
|
|
|
cy.get(commonSelectors.addWorkspaceButton).click();
|
|
|
|
|
cy.clearAndType(commonSelectors.workspaceNameInput, workspaceName);
|
|
|
|
|
cy.intercept("GET", "/api/apps?page=1&folder=&searchKey=").as("homePage");
|
|
|
|
|
cy.get(commonSelectors.createWorkspaceButton).click();
|
|
|
|
|
cy.wait("@homePage");
|
|
|
|
|
};
|
2022-12-27 14:40:33 +00:00
|
|
|
|
|
|
|
|
export const selectAppCardOption = (appName, appCardOption) => {
|
|
|
|
|
viewAppCardOptions(appName);
|
2023-07-12 07:59:13 +00:00
|
|
|
cy.get(appCardOption).should("be.visible").click({ force: true });
|
2022-12-27 14:40:33 +00:00
|
|
|
};
|
2023-02-09 10:56:10 +00:00
|
|
|
|
2023-03-20 13:18:10 +00:00
|
|
|
export const navigateToDatabase = () => {
|
|
|
|
|
cy.get(commonSelectors.databaseIcon).click();
|
|
|
|
|
cy.url().should("include", path.database);
|
|
|
|
|
};
|
2023-02-09 10:56:10 +00:00
|
|
|
export const randomValue = () => {
|
|
|
|
|
return Math.floor(Math.random() * (1000 - 100) + 100) / 100;
|
|
|
|
|
};
|
2023-06-14 09:30:21 +00:00
|
|
|
|
|
|
|
|
export const verifyTooltip = (selector, message) => {
|
|
|
|
|
cy.get(selector)
|
|
|
|
|
.trigger("mouseover", { timeout: 2000 })
|
|
|
|
|
.trigger("mouseover")
|
|
|
|
|
.then(() => {
|
|
|
|
|
cy.get(".tooltip-inner").last().should("have.text", message);
|
|
|
|
|
});
|
|
|
|
|
};
|
2023-07-11 11:20:52 +00:00
|
|
|
|
|
|
|
|
export const pinInspector = () => {
|
|
|
|
|
cy.get(commonWidgetSelector.sidebarinspector).click();
|
|
|
|
|
cy.get(commonSelectors.inspectorPinIcon).click();
|
2023-08-07 11:56:43 +00:00
|
|
|
cy.wait(500);
|
|
|
|
|
|
2023-07-11 11:20:52 +00:00
|
|
|
cy.get("body").then(($body) => {
|
|
|
|
|
if (!$body.find(commonSelectors.inspectorPinIcon).length > 0) {
|
|
|
|
|
cy.get(commonWidgetSelector.sidebarinspector).click();
|
|
|
|
|
cy.get(commonSelectors.inspectorPinIcon).click();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
};
|
2023-08-07 11:56:43 +00:00
|
|
|
|
|
|
|
|
export const createGroup = (groupName) => {
|
|
|
|
|
cy.get(groupsSelector.createNewGroupButton).click();
|
|
|
|
|
cy.clearAndType(groupsSelector.groupNameInput, groupName);
|
|
|
|
|
cy.get(groupsSelector.createGroupButton).click();
|
|
|
|
|
cy.verifyToastMessage(
|
|
|
|
|
commonSelectors.toastMessage,
|
|
|
|
|
groupsText.groupCreatedToast
|
|
|
|
|
);
|
2023-08-18 09:23:53 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export const navigateToworkspaceConstants = () => {
|
|
|
|
|
cy.get(commonSelectors.workspaceSettingsIcon).click();
|
|
|
|
|
cy.get(commonSelectors.workspaceConstantsOption).click();
|
2023-08-07 11:56:43 +00:00
|
|
|
};
|