ToolJet/cypress-tests/cypress/support/utils/dashboard.js
Ajith KV db918e7132
Optimize platform cypress test cases (#11689)
* Optimize platform Cypress test cases

* Add custom command for creating and rename custom commands
2024-12-23 14:51:27 +05:30

63 lines
2 KiB
JavaScript

import { commonSelectors } from "Selectors/common";
import { dashboardSelector } from "Selectors/dashboard";
import { dashboardText } from "Texts/dashboard";
import { commonText } from "Texts/common";
import {
viewAppCardOptions,
verifyModal,
closeModal,
cancelModal,
} from "Support/utils/common";
export const modifyAndVerifyAppCardIcon = (appName) => {
var random = function (obj) {
var keys = Object.keys(obj);
return obj[keys[(keys.length * Math.random()) << 0]];
};
const randomIcon = random(dashboardText.iconText);
cy.get(commonSelectors.appCardOptions(commonText.changeIconOption)).click();
verifyModal(dashboardText.changeIconTitle, dashboardText.changeButton);
for (const icons in dashboardText.iconText) {
cy.get(dashboardSelector.appIcon(dashboardText.iconText[icons])).should(
"be.visible"
);
}
closeModal(commonText.closeButton);
viewAppCardOptions(appName);
cy.get(commonSelectors.appCardOptions(commonText.changeIconOption)).click();
cy.get(".modal-body")
.parent()
.within(() => {
cy.get(dashboardSelector.appIcon(randomIcon)).first().click();
});
cancelModal(commonText.cancelButton);
viewAppCardOptions(appName);
cy.get(commonSelectors.appCardOptions(commonText.changeIconOption)).click();
cy.get(".modal-body")
.parent()
.within(() => {
cy.get(dashboardSelector.appIcon(randomIcon)).first().click();
});
cy.get(dashboardSelector.changeButton).click();
cy.verifyToastMessage(
commonSelectors.toastMessage,
dashboardText.iconUpdatedToast
);
cy.get(commonSelectors.appCard(appName)).should("exist");
cy.get(dashboardText.modalComponent).should("not.exist");
};
export const verifyAppDelete = (appName) => {
cy.get("body").then(($title) => {
if (!$title.text().includes(commonText.introductionMessage)) {
cy.clearAndType(commonSelectors.homePageSearchBar, appName);
cy.get(commonSelectors.appCard(appName)).should("not.exist");
cy.get(commonSelectors.homePageSearchBar).clear();
}
});
};