ToolJet/cypress-tests/cypress/support/utils/profile.js
YuktiGoyal02 33d6813f74
Automation fixes (#15577)
* fixed all user page functionality falky case

* Fixed profile flaky case

* fixed minor issue
2026-03-16 22:04:23 +05:30

61 lines
1.7 KiB
JavaScript

import { profileSelector } from "Selectors/profile";
import { profileText } from "Texts/profile";
export const profilePageElements = () => {
for (const elements in profileSelector.profileElements) {
cy.get(profileSelector.profileElements[elements]).verifyVisibleElement(
"have.text",
profileText.profileElements[elements]
);
}
cy.get(profileSelector.updateButton).verifyVisibleElement(
"have.text",
profileText.updateButton
);
cy.get(profileSelector.changePasswordButton).verifyVisibleElement(
"have.text",
profileText.changePasswordButton
);
cy.get(profileSelector.userNameInput).verifyVisibleElement(
"have.value",
profileText.userName
);
cy.get(profileSelector.emailInput).verifyVisibleElement(
"have.value",
profileText.email
);
cy.get(profileSelector.currentPasswordField)
.should("be.visible")
.should("be.visible");
cy.get(profileSelector.newPasswordField)
.should("be.visible")
.should("be.visible");
};
export const extApiUpdateUser = (userEmail = '', userIdCached = Cypress.env('userIdDev')) => {
cy.request({
method: 'PATCH',
url: `${Cypress.env("server_host")}/api/ext/user/:${userIdCached}`,
headers: {
'Authorization': `Basic ${Cypress.env('AUTH_TOKEN')}`,
'Content-Type': 'application/json'
},
body: {
name: 'The Developer',
email: '[email protected]',
password: 'password',
status: 'active'
}
});
}
export const removeAvatar = (userEmail = "[email protected]") => {
cy.getUserIdByEmail(userEmail, "user").then((userId) => {
return cy.task("dbConnection", {
dbconfig: Cypress.env("app_db"),
sql: `UPDATE users SET avatar_id = NULL WHERE id = '${userId}';`,
});
});
};