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";
|
2022-06-20 11:29:12 +00:00
|
|
|
import { commonSelectors } 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";
|
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();
|
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();
|
|
|
|
|
};
|
|
|
|
|
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-05-09 14:03:37 +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 = () => {
|
|
|
|
|
const downloadsFolder = Cypress.config("downloadsFolder");
|
|
|
|
|
cy.task("deleteFolder", downloadsFolder);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
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 });
|
2022-12-27 14:40:33 +00:00
|
|
|
//cy.wait("@appEditor");
|
2022-08-04 15:10:46 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export const viewAppCardOptions = (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-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
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
cy.get(appCardOption).should("be.visible").click();
|
|
|
|
|
};
|
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;
|
|
|
|
|
};
|