ToolJet/cypress-tests/cypress/support/utils/dashboard.js
Ajith KV 142d54bc50
Fixed failing profile cypress spec (#6245)
* Fix failed profile spec

* Modify data-cy of the dashboard section header

* Fix manage users spec

* Fix user permission spec

* Remove single workspace cypress test cases

* Add indentation changes

* Update self host signup spec

* Update cypress config file

* adding changes to capture downloads

* fix cypress tests for actions

* fecth invitation url from the database

* database test commit

* test commit

* test commit

* test commit

* test commit for pg host

* test commit

* commit for screenshot

* revert test commits

* Update sql task name

* Add changes for actions

* Fix manage groups spec

* Update folder structure

* Fix user permission spec

---------

Co-authored-by: Adish M <[email protected]>
2023-05-09 19:33:37 +05:30

70 lines
2.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 login = () => {
cy.visit("/");
cy.clearAndType(commonSelectors.workEmailInputField, "[email protected]");
cy.clearAndType(commonSelectors.passwordInputField, "password");
cy.get(commonSelectors.loginButton).click();
};
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();
}
});
};