test: Admin setting test cases (#38172)

## Description
Admin setting cases for CE.


Fixes #
https://app.zenhub.com/workspaces/stability-pod-6690c4814e31602e25cab7fd/issues/gh/appsmithorg/appsmith/38320

## Automation

/ok-to-test tags="@tag.Settings"

### 🔍 Cypress test results
<!-- This is an auto-generated comment: Cypress test results  -->
> [!TIP]
> 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
> Workflow run:
<https://github.com/appsmithorg/appsmith/actions/runs/12466577616>
> Commit: fabd248b9631e80676036798cd12587ff031600e
> <a
href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=12466577616&attempt=1"
target="_blank">Cypress dashboard</a>.
> Tags: `@tag.Settings`
> Spec:
> <hr>Mon, 23 Dec 2024 12:36:13 UTC
<!-- end of auto-generated comment: Cypress test results  -->


## Communication
Should the DevRel and Marketing teams inform users about this change?
- [ ] Yes
- [x] No


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **New Features**
- Introduced comprehensive end-to-end tests for the Admin Settings page,
covering various user scenarios and settings functionality.
- Added a new property `adminEmailsData` for improved element selection
in tests.

- **Chores**
- Enhanced the readability and maintainability of end-to-end tests for
the Admin Settings page by replacing direct commands with helper
functions.
	- Streamlined element interactions and assertions for improved clarity.
- Expanded test coverage with additional cases for default instance name
and admin setting sections.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
Sagar Khalasi 2024-12-23 18:37:43 +05:30 committed by GitHub
parent 8a16903f31
commit 4a63176b0c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 90 additions and 54 deletions

View File

@ -24,26 +24,25 @@ describe("Admin settings page", { tags: ["@tag.Settings"] }, function () {
it("1. Should test that settings page is accessible to super user", () => {
cy.LogOut();
cy.LoginFromAPI(Cypress.env("USERNAME"), Cypress.env("PASSWORD"));
cy.get(".admin-settings-menu-option").should("be.visible");
cy.get(".admin-settings-menu-option").click();
cy.url().should("contain", adminSettingsHelper.routes.GENERAL);
agHelper.GetNClick(adminSettingsHelper._adminSettingsBtn);
agHelper.AssertURL(adminSettingsHelper.routes.GENERAL);
cy.wait("@getEnvVariables");
cy.LogOut();
});
it("2. Should test that settings page is not accessible to normal users", () => {
cy.LoginFromAPI(Cypress.env("TESTUSERNAME3"), Cypress.env("TESTPASSWORD3"));
cy.get(".admin-settings-menu-option").should("not.exist");
agHelper.AssertElementAbsence(adminSettingsHelper._adminSettingsBtn);
agHelper.VisitNAssert(adminSettingsHelper.routes.GENERAL);
// non super users are redirected to home page
cy.url().should("contain", "/applications");
agHelper.AssertURL("/applications");
cy.LogOut(false);
});
it("3. Should test that settings page is redirected to default tab", () => {
cy.LoginFromAPI(Cypress.env("USERNAME"), Cypress.env("PASSWORD"));
cy.visit("/settings", { timeout: 60000 });
cy.url().should("contain", adminSettingsHelper.routes.GENERAL);
agHelper.AssertURL(adminSettingsHelper.routes.GENERAL);
cy.wait("@getEnvVariables");
});
@ -55,19 +54,19 @@ describe("Admin settings page", { tags: ["@tag.Settings"] }, function () {
cy.visit("/applications", { timeout: 60000 });
if (!Cypress.env("AIRGAPPED")) cy.wait("@getAllWorkspaces");
cy.get(".admin-settings-menu-option").click();
agHelper.GetNClick(adminSettingsHelper._adminSettingsBtn);
cy.wait("@getEnvVariables");
cy.get(adminsSettings.generalTab).click();
cy.url().should("contain", adminSettingsHelper.routes.GENERAL);
cy.get(adminsSettings.advancedTab).click();
cy.url().should("contain", adminSettingsHelper.routes.ADVANCED);
cy.get(adminsSettings.authenticationTab).click();
cy.url().should("contain", adminSettingsHelper.routes.AUTHENTICATION);
cy.get(adminsSettings.emailTab).click();
cy.url().should("contain", adminSettingsHelper.routes.EMAIL);
cy.get(adminsSettings.developerSettingsTab).should("not.exist");
cy.get(adminsSettings.versionTab).click();
cy.url().should("contain", adminSettingsHelper.routes.VERSION);
agHelper.GetNClick(adminsSettings.generalTab);
agHelper.AssertURL(adminSettingsHelper.routes.GENERAL);
agHelper.GetNClick(adminsSettings.advancedTab);
agHelper.AssertURL(adminSettingsHelper.routes.ADVANCED);
agHelper.GetNClick(adminsSettings.authenticationTab);
agHelper.AssertURL(adminSettingsHelper.routes.AUTHENTICATION);
agHelper.GetNClick(adminsSettings.emailTab);
agHelper.AssertURL(adminSettingsHelper.routes.EMAIL);
agHelper.AssertElementAbsence(adminsSettings.developerSettingsTab);
agHelper.GetNClick(adminsSettings.versionTab);
agHelper.AssertURL(adminSettingsHelper.routes.VERSION);
},
);
@ -80,12 +79,12 @@ describe("Admin settings page", { tags: ["@tag.Settings"] }, function () {
adminSettingsHelper.routes.GENERAL,
"getEnvVariables",
);
cy.get(adminsSettings.authenticationTab).click();
cy.url().should("contain", adminSettingsHelper.routes.AUTHENTICATION);
cy.get(adminsSettings.googleButton).should("not.exist");
cy.get(adminsSettings.githubButton).should("not.exist");
cy.get(adminsSettings.formloginButton).click();
cy.url().should("contain", adminSettingsHelper.routes.FORMLOGIN);
agHelper.GetNClick(adminsSettings.authenticationTab);
agHelper.AssertURL(adminSettingsHelper.routes.AUTHENTICATION);
agHelper.AssertElementAbsence(adminsSettings.googleButton);
agHelper.AssertElementAbsence(adminsSettings.githubButton);
agHelper.GetNClick(adminsSettings.formloginButton);
agHelper.AssertURL(adminSettingsHelper.routes.FORMLOGIN);
},
);
@ -97,16 +96,16 @@ describe("Admin settings page", { tags: ["@tag.Settings"] }, function () {
adminSettingsHelper.routes.GENERAL,
"getEnvVariables",
);
cy.get(adminsSettings.authenticationTab).click();
cy.url().should("contain", adminSettingsHelper.routes.AUTHENTICATION);
cy.get(adminsSettings.googleButton).click();
cy.url().should("contain", adminSettingsHelper.routes.GOOGLEAUTH);
agHelper.GetNClick(adminsSettings.authenticationTab);
agHelper.AssertURL(adminSettingsHelper.routes.AUTHENTICATION);
agHelper.GetNClick(adminsSettings.googleButton);
agHelper.AssertURL(adminSettingsHelper.routes.GOOGLEAUTH);
cy.get(adminsSettings.readMoreLink).within(() => {
cy.get("a")
.should("have.attr", "target", "_blank")
.invoke("removeAttr", "target")
.click();
cy.url().should("contain", GOOGLE_SIGNUP_SETUP_DOC);
agHelper.AssertURL(GOOGLE_SIGNUP_SETUP_DOC);
});
},
);
@ -117,19 +116,19 @@ describe("Admin settings page", { tags: ["@tag.Settings"] }, function () {
"getEnvVariables",
);
const assertVisibilityAndDisabledState = () => {
cy.get(adminsSettings.saveButton).should("be.visible");
agHelper.AssertElementVisibility(adminsSettings.saveButton);
cy.get(adminsSettings.saveButton).should("be.disabled");
cy.get(adminsSettings.resetButton).should("be.visible");
agHelper.AssertElementVisibility(adminsSettings.resetButton);
cy.get(adminsSettings.resetButton).should("be.disabled");
};
assertVisibilityAndDisabledState();
cy.get(adminsSettings.instanceName).should("be.visible");
agHelper.AssertElementVisibility(adminsSettings.instanceName);
cy.get(adminsSettings.instanceName).clear().type("AppsmithInstance");
cy.get(adminsSettings.saveButton).should("be.visible");
agHelper.AssertElementVisibility(adminsSettings.saveButton);
cy.get(adminsSettings.saveButton).should("not.be.disabled");
cy.get(adminsSettings.resetButton).should("be.visible");
agHelper.AssertElementVisibility(adminsSettings.resetButton);
cy.get(adminsSettings.resetButton).should("not.be.disabled");
cy.get(adminsSettings.resetButton).click();
agHelper.GetNClick(adminsSettings.resetButton);
assertVisibilityAndDisabledState();
});
@ -139,16 +138,16 @@ describe("Admin settings page", { tags: ["@tag.Settings"] }, function () {
"getEnvVariables",
);
cy.get(adminsSettings.restartNotice).should("not.exist");
cy.get(adminsSettings.instanceName).should("be.visible");
let instanceName;
cy.generateUUID().then((uuid) => {
agHelper.AssertElementAbsence(adminsSettings.restartNotice);
agHelper.AssertElementVisibility(adminsSettings.instanceName);
let instanceName: string;
cy.generateUUID().then((uuid: string) => {
instanceName = uuid;
cy.get(adminsSettings.instanceName).clear().type(uuid);
});
cy.get(adminsSettings.saveButton).should("be.visible");
agHelper.AssertElementVisibility(adminsSettings.saveButton);
cy.get(adminsSettings.saveButton).should("not.be.disabled");
cy.get(adminsSettings.saveButton).click();
agHelper.GetNClick(adminsSettings.saveButton);
cy.wait("@postTenantConfig").then((interception) => {
expect(interception.request.body.instanceName).to.equal(instanceName);
});
@ -163,28 +162,28 @@ describe("Admin settings page", { tags: ["@tag.Settings"] }, function () {
adminSettingsHelper.routes.GENERAL,
"getEnvVariables",
);
cy.get(adminsSettings.restartNotice).should("not.exist");
cy.get(adminsSettings.instanceName).should("be.visible");
let instanceName;
cy.generateUUID().then((uuid) => {
agHelper.AssertElementAbsence(adminsSettings.restartNotice);
agHelper.AssertElementVisibility(adminsSettings.instanceName);
let instanceName: string;
cy.generateUUID().then((uuid: string) => {
instanceName = uuid;
cy.get(adminsSettings.instanceName).clear().type(uuid);
});
cy.get(adminsSettings.saveButton).should("be.visible");
agHelper.AssertElementVisibility(adminsSettings.saveButton);
cy.get(adminsSettings.saveButton).should("not.be.disabled");
cy.get(adminsSettings.emailTab).click();
cy.get(adminsSettings.saveButton).should("be.visible");
agHelper.GetNClick(adminsSettings.emailTab);
agHelper.AssertElementVisibility(adminsSettings.saveButton);
cy.get(adminsSettings.saveButton).should("not.be.disabled");
cy.get(adminsSettings.fromAddress).should("be.visible");
let fromAddress;
cy.generateUUID().then((uuid) => {
agHelper.AssertElementVisibility(adminsSettings.fromAddress);
let fromAddress: string;
cy.generateUUID().then((uuid: string) => {
fromAddress = uuid;
cy.get(adminsSettings.fromAddress).clear().type(`${uuid}@appsmith.com`);
});
cy.intercept("POST", "/api/v1/admin/restart", {
body: { responseMeta: { status: 200, success: true }, data: true },
});
cy.get(adminsSettings.saveButton).click();
agHelper.GetNClick(adminsSettings.saveButton);
cy.wait("@postTenantConfig").then((interception) => {
expect(interception.request.body.instanceName).to.equal(instanceName);
});
@ -193,7 +192,43 @@ describe("Admin settings page", { tags: ["@tag.Settings"] }, function () {
`${fromAddress}@appsmith.com`,
);
});
cy.get(adminsSettings.restartNotice).should("be.visible");
cy.get(adminsSettings.restartNotice).should("not.exist");
agHelper.AssertElementVisibility(adminsSettings.restartNotice);
});
it("10. Verify default instance name", () => {
cy.LogOut();
cy.LoginFromAPI(Cypress.env("USERNAME"), Cypress.env("PASSWORD"));
agHelper.GetNClick(adminSettingsHelper._adminSettingsBtn);
agHelper.AssertURL(adminSettingsHelper.routes.GENERAL);
cy.wait("@getEnvVariables");
agHelper
.GetText(adminSettingsHelper._instanceName, "val")
.then(($text) => expect($text).to.eq("Appsmith"));
});
it("11. Verify all admin setting sections are accessible", () => {
cy.visit("/applications", { timeout: 60000 });
agHelper.GetNClick(adminSettingsHelper._adminSettingsBtn);
cy.wait("@getEnvVariables");
agHelper.GetNClick(adminsSettings.generalTab);
agHelper.AssertURL(adminSettingsHelper.routes.GENERAL);
agHelper.GetNClick(adminsSettings.advancedTab);
agHelper.AssertURL(adminSettingsHelper.routes.ADVANCED);
agHelper.GetNClick(adminsSettings.authenticationTab);
agHelper.AssertURL(adminSettingsHelper.routes.AUTHENTICATION);
agHelper.GetNClick(adminsSettings.emailTab);
agHelper.AssertURL(adminSettingsHelper.routes.EMAIL);
agHelper.GetNClick(adminsSettings.developerSettingsTab);
agHelper.AssertURL(adminSettingsHelper.routes.DEVELOPER_SETTINGS);
agHelper.GetNClick(adminsSettings.versionTab);
agHelper.AssertURL(adminSettingsHelper.routes.VERSION);
agHelper.GetNClick(adminsSettings.branding);
agHelper.AssertURL(adminSettingsHelper.routes.BRANDING);
agHelper.GetNClick(adminsSettings.provisioning);
agHelper.AssertURL(adminSettingsHelper.routes.PROVISIONING);
agHelper.GetNClick(adminsSettings.accessControl);
agHelper.AssertURL(adminSettingsHelper.routes.ACCESS_CONTROL);
agHelper.GetNClick(adminsSettings.auditLogs);
agHelper.AssertURL(adminSettingsHelper.routes.AUDIT_LOGS);
});
});

View File

@ -46,4 +46,5 @@ export default {
singleSessionPerUserInput: "[data-testid='singleSessionPerUserEnabled']",
sessionTimeoutWrapper: ".t--admin-settings-userSessionTimeoutInMinutes",
sessionTimeoutInput: "[name='userSessionTimeoutInMinutes']",
adminEmailsData: ".t--admin-settings-APPSMITH_ADMIN_EMAILS span > span",
};