fix: enable form login spec improvement (#40693)
## Description - Convert entire test case to typescript - Abstract repetitive code to functions - Remove all waits and use UI assertions - Better comments ## Automation /ok-to-test tags="@tag.Sanity" ### 🔍 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/15601034361> > Commit: 90c06c0accff37d8aaf61279df48ec8291010c4f > <a href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=15601034361&attempt=1" target="_blank">Cypress dashboard</a>. > Tags: `@tag.Sanity` > Spec: > <hr>Thu, 12 Jun 2025 04:26:52 UTC <!-- end of auto-generated comment: Cypress test results --> ## Communication Should the DevRel and Marketing teams inform users about this change? - [ ] Yes - [ ] No <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **Tests** - Replaced existing Cypress tests with a new suite verifying toggling of form login, signup, and GitHub authentication, including UI validations and server restart handling. - **New Features** - Enhanced admin settings automation with navigation and controls for authentication options, including GitHub OAuth configuration and form login/signup toggles. - **Chores** - Added a new locator for the login form to support UI testing. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
parent
f8acc2a839
commit
eca0daa1bb
|
|
@ -1,141 +0,0 @@
|
|||
import adminSettings from "../../../../locators/AdminsSettings";
|
||||
import homePage from "../../../../locators/HomePage";
|
||||
|
||||
describe("Form Login test functionality", function () {
|
||||
it(
|
||||
"1. Go to admin settings and disable Form Signup",
|
||||
{ tags: ["@tag.Authentication", "@tag.Settings"] },
|
||||
function () {
|
||||
cy.LogOut();
|
||||
cy.LoginFromAPI(Cypress.env("USERNAME"), Cypress.env("PASSWORD"));
|
||||
cy.openAuthentication();
|
||||
cy.get(adminSettings.formloginButton)
|
||||
.should("be.visible")
|
||||
.should("contain", "Edit");
|
||||
cy.get(adminSettings.formloginButton).click();
|
||||
cy.wait(2000);
|
||||
// disable form signup
|
||||
cy.get(adminSettings.formSignupDisabled).should("have.value", "on");
|
||||
cy.get(adminSettings.formSignupDisabled).click({ force: true });
|
||||
cy.wait(2000);
|
||||
// assert server is restarting
|
||||
cy.get(adminSettings.saveButton).should("be.visible");
|
||||
cy.get(adminSettings.saveButton).should("not.be.disabled");
|
||||
cy.get(adminSettings.saveButton).click();
|
||||
cy.waitUntil(() => cy.get(homePage.profileMenu).should("be.visible"));
|
||||
cy.get(homePage.profileMenu).click();
|
||||
cy.get(homePage.signOutIcon).click();
|
||||
cy.wait(500);
|
||||
// validating form signup is disabled
|
||||
cy.get(".t--sign-up").click({ force: true });
|
||||
cy.generateUUID().then((uid) => {
|
||||
cy.get("[type='email']").type(uid + "@appsmith.com");
|
||||
cy.get("[type='password']").type(uid);
|
||||
cy.get("[type='submit']").click({ force: true });
|
||||
cy.get(".ads-v2-callout__children").should(
|
||||
"contain",
|
||||
"Signup is restricted on this instance of Appsmith",
|
||||
);
|
||||
// restore setting
|
||||
cy.LoginFromAPI(Cypress.env("USERNAME"), Cypress.env("PASSWORD"));
|
||||
cy.get(".admin-settings-menu-option").click();
|
||||
cy.get(adminSettings.authenticationTab).click();
|
||||
cy.get(adminSettings.formloginButton).click();
|
||||
cy.wait(2000);
|
||||
cy.get(adminSettings.formSignupDisabled).click({ force: true });
|
||||
cy.wait(2000);
|
||||
cy.get(adminSettings.saveButton).click();
|
||||
cy.waitUntil(() => cy.get(homePage.profileMenu).should("be.visible"));
|
||||
cy.get(homePage.profileMenu).click();
|
||||
cy.get(homePage.signOutIcon).click();
|
||||
});
|
||||
cy.wait(500);
|
||||
// validating form signup is disabled
|
||||
cy.get(".t--sign-up").click({ force: true });
|
||||
cy.generateUUID().then((uid) => {
|
||||
cy.get("[type='email']").type(uid + "@appsmith.com");
|
||||
cy.get("[type='password']").type(uid);
|
||||
cy.get("[type='submit']").click({ force: true });
|
||||
cy.get(".ads-v2-callout__children").should("not.exist");
|
||||
});
|
||||
},
|
||||
);
|
||||
|
||||
it(
|
||||
"2. Go to admin settings and disable Form Login",
|
||||
{ tags: ["@tag.excludeForAirgap"] },
|
||||
function () {
|
||||
cy.LogOut(false);
|
||||
cy.LoginFromAPI(Cypress.env("USERNAME"), Cypress.env("PASSWORD"));
|
||||
cy.openAuthentication();
|
||||
cy.get(adminSettings.formloginButton)
|
||||
.should("be.visible")
|
||||
.should("contain", "Edit");
|
||||
|
||||
// enable github login
|
||||
cy.get(adminSettings.githubButton).click();
|
||||
cy.wait(2000);
|
||||
// fill github form
|
||||
cy.fillGithubForm();
|
||||
cy.wait(120000);
|
||||
cy.waitUntil(() => cy.get(homePage.profileMenu).should("be.visible"));
|
||||
cy.wait(5000);
|
||||
cy.reload();
|
||||
cy.get(adminSettings.authenticationTab).click();
|
||||
cy.get(adminSettings.formloginButton).click();
|
||||
cy.wait(2000);
|
||||
// disable form signup
|
||||
cy.get(adminSettings.formLoginEnabled).should("have.value", "on");
|
||||
cy.get(adminSettings.formLoginEnabled).click({ force: true });
|
||||
cy.wait(2000);
|
||||
// assert server is restarting
|
||||
cy.get(adminSettings.saveButton).should("be.visible");
|
||||
cy.get(adminSettings.saveButton).should("not.be.disabled");
|
||||
cy.get(adminSettings.saveButton).click();
|
||||
cy.waitUntil(() => cy.get(homePage.profileMenu).should("be.visible"));
|
||||
cy.get(homePage.profileMenu).click();
|
||||
cy.get(homePage.signOutIcon).click();
|
||||
cy.wait(500);
|
||||
cy.reload();
|
||||
cy.wait(5000);
|
||||
// validating form signup is disabled
|
||||
cy.get("form").should("not.exist");
|
||||
cy.get(".t--sign-up").should("not.exist");
|
||||
// cy.wait(30000); // restart nginx docker
|
||||
cy.LoginFromAPI(Cypress.env("USERNAME"), Cypress.env("PASSWORD"));
|
||||
cy.openAuthentication();
|
||||
|
||||
// enable form login
|
||||
cy.get(adminSettings.formloginButton)
|
||||
.should("be.visible")
|
||||
.should("contain", "Enable");
|
||||
cy.get(adminSettings.formloginButton).click();
|
||||
cy.get(adminSettings.formLoginEnabled).click({ force: true });
|
||||
cy.wait(2000);
|
||||
// assert server is restarting
|
||||
cy.get(adminSettings.saveButton).should("be.visible");
|
||||
cy.get(adminSettings.saveButton).should("not.be.disabled");
|
||||
cy.get(adminSettings.saveButton).click();
|
||||
cy.waitUntil(() => cy.get(homePage.profileMenu).should("be.visible"));
|
||||
cy.reload();
|
||||
|
||||
// disable github
|
||||
cy.get(adminSettings.authenticationTab).click();
|
||||
cy.get(adminSettings.githubButton).click();
|
||||
cy.wait(2000);
|
||||
cy.get(adminSettings.disconnectBtn)
|
||||
.click()
|
||||
.should("contain", "Are you sure?");
|
||||
cy.get(adminSettings.disconnectBtn).click();
|
||||
cy.wait(120000);
|
||||
cy.waitUntil(() => cy.get(homePage.profileMenu).should("be.visible"));
|
||||
cy.reload();
|
||||
cy.get(homePage.profileMenu).click();
|
||||
cy.get(homePage.signOutIcon).click();
|
||||
cy.wait(500);
|
||||
cy.get(adminSettings.loginWithGithub).should("not.exist");
|
||||
cy.get("form").should("exist");
|
||||
cy.get(".t--sign-up").should("exist");
|
||||
},
|
||||
);
|
||||
});
|
||||
|
|
@ -0,0 +1,104 @@
|
|||
import adminSettings from "../../../../locators/AdminsSettings";
|
||||
import loginPage from "../../../../locators/LoginPage.json";
|
||||
import {
|
||||
agHelper,
|
||||
adminSettings as objectsCoreAdminSettings,
|
||||
} from "../../../../support/Objects/ObjectsCore";
|
||||
|
||||
describe("Form Login test functionality", function () {
|
||||
it(
|
||||
"1. Go to admin settings and disable Form Signup",
|
||||
{ tags: ["@tag.Authentication", "@tag.Settings"] },
|
||||
function () {
|
||||
objectsCoreAdminSettings.NavigateToAuthenticationSettings();
|
||||
objectsCoreAdminSettings.verifyFormLogin();
|
||||
|
||||
// disable form signup
|
||||
objectsCoreAdminSettings.toggleFormSignupLoginAndSave(false, "signup");
|
||||
objectsCoreAdminSettings.logoutFromApp();
|
||||
|
||||
agHelper.GetNClick(loginPage.signupLink);
|
||||
agHelper.GenerateUUID();
|
||||
agHelper.GetElement("@guid").then((uid) => {
|
||||
const email = uid.toString() + "@appsmith.com";
|
||||
const password = uid.toString();
|
||||
|
||||
agHelper.TypeText("[type='email']", email);
|
||||
agHelper.TypeText("[type='password']", password);
|
||||
agHelper.GetNClick("[type='submit']");
|
||||
|
||||
agHelper.AssertContains(
|
||||
"Signup is restricted on this instance of Appsmith",
|
||||
"exist",
|
||||
".ads-v2-callout__children",
|
||||
);
|
||||
|
||||
// Cleanup: Restore form signup to enabled state
|
||||
cy.LoginFromAPI(Cypress.env("USERNAME"), Cypress.env("PASSWORD"));
|
||||
objectsCoreAdminSettings.NavigateToAuthenticationSettings();
|
||||
objectsCoreAdminSettings.toggleFormSignupLoginAndSave(true, "signup");
|
||||
objectsCoreAdminSettings.logoutFromApp();
|
||||
|
||||
agHelper.GetNClick(loginPage.signupLink);
|
||||
agHelper.GenerateUUID();
|
||||
agHelper.GetElement("@guid").then((uid) => {
|
||||
const email = uid.toString() + "@appsmith.com";
|
||||
const password = uid.toString();
|
||||
|
||||
agHelper.TypeText("[type='email']", email);
|
||||
agHelper.TypeText("[type='password']", password);
|
||||
agHelper.GetNClick("[type='submit']");
|
||||
|
||||
agHelper.AssertElementAbsence(".ads-v2-callout__children");
|
||||
});
|
||||
});
|
||||
},
|
||||
);
|
||||
|
||||
it(
|
||||
"2. Go to admin settings and disable Form Login",
|
||||
{ tags: ["@tag.excludeForAirgap"] },
|
||||
function () {
|
||||
cy.LoginFromAPI(Cypress.env("USERNAME"), Cypress.env("PASSWORD"));
|
||||
// agHelper.Sleep(10000);
|
||||
objectsCoreAdminSettings.NavigateToAuthenticationSettings(false);
|
||||
objectsCoreAdminSettings.verifyFormLogin();
|
||||
|
||||
// enable github login
|
||||
agHelper.GetNClick(adminSettings.githubButton);
|
||||
agHelper.WaitForCondition(() =>
|
||||
agHelper.AssertContains("GitHub authentication", "exist"),
|
||||
);
|
||||
objectsCoreAdminSettings.fillSaveAndAssertGithubForm();
|
||||
|
||||
// Disable form login
|
||||
objectsCoreAdminSettings.NavigateToAuthenticationSettings();
|
||||
objectsCoreAdminSettings.verifyFormLogin();
|
||||
objectsCoreAdminSettings.toggleFormSignupLoginAndSave(false, "login");
|
||||
objectsCoreAdminSettings.logoutFromApp();
|
||||
|
||||
// validate login is disabled
|
||||
agHelper.AssertElementAbsence(loginPage.loginForm);
|
||||
agHelper.AssertElementAbsence(loginPage.signupLink);
|
||||
|
||||
// restore settings
|
||||
cy.LoginFromAPI(Cypress.env("USERNAME"), Cypress.env("PASSWORD"));
|
||||
|
||||
objectsCoreAdminSettings.NavigateToAuthenticationSettings(false);
|
||||
objectsCoreAdminSettings.toggleFormSignupLoginAndSave(true, "login");
|
||||
objectsCoreAdminSettings.NavigateToAuthenticationSettings(true);
|
||||
agHelper.GetNClick(adminSettings.githubButton);
|
||||
agHelper.GetNClick(adminSettings.disconnectBtn);
|
||||
agHelper
|
||||
.GetElement(adminSettings.disconnectBtn)
|
||||
.should("contain.text", "Are you sure?");
|
||||
agHelper.GetNClick(adminSettings.disconnectBtn);
|
||||
agHelper.WaitUntilEleAppear(adminSettings.restartNotice);
|
||||
agHelper.AssertElementAbsence(adminSettings.restartNotice, 200000);
|
||||
objectsCoreAdminSettings.logoutFromApp();
|
||||
agHelper.AssertElementAbsence(adminSettings.loginWithGithub);
|
||||
agHelper.AssertElementExist(loginPage.loginForm);
|
||||
agHelper.AssertElementExist(loginPage.signupLink);
|
||||
},
|
||||
);
|
||||
});
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
{
|
||||
"username": "input[name='username'], input[name='email']",
|
||||
"password": "input[name='password']",
|
||||
"submitBtn": "button[type='submit']",
|
||||
"signupLink": ".t--sign-up"
|
||||
"username": "input[name='username'], input[name='email']",
|
||||
"password": "input[name='password']",
|
||||
"submitBtn": "button[type='submit']",
|
||||
"signupLink": ".t--sign-up",
|
||||
"loginForm": "form"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
import { ObjectsRegistry } from "../Objects/Registry";
|
||||
import AdminsSettings from "../../locators/AdminsSettings";
|
||||
import githubForm from "../../locators/GithubForm.json";
|
||||
import HomePage from "../../locators/HomePage";
|
||||
import { featureFlagIntercept } from "../Objects/FeatureFlags";
|
||||
import { ObjectsRegistry } from "../Objects/Registry";
|
||||
|
||||
export class AdminSettings {
|
||||
public agHelper = ObjectsRegistry.AggregateHelper;
|
||||
|
|
@ -8,6 +11,7 @@ export class AdminSettings {
|
|||
public assertHelper = ObjectsRegistry.AssertHelper;
|
||||
|
||||
public _adminSettingsBtn = ".admin-settings-menu-option";
|
||||
public _authenticationTab = ".t--settings-category-authentication";
|
||||
public _saveButton = ".t--admin-settings-save-button";
|
||||
private _settingsList = ".t--settings-category-list";
|
||||
public _usersTab = ".t--settings-category-users";
|
||||
|
|
@ -47,6 +51,60 @@ export class AdminSettings {
|
|||
this.agHelper.AssertElementVisibility(this._settingsList);
|
||||
}
|
||||
|
||||
public NavigateToAuthenticationSettings(toNavigateToHome = true) {
|
||||
this.NavigateToAdminSettings(toNavigateToHome);
|
||||
this.agHelper.GetNClick(this._authenticationTab);
|
||||
}
|
||||
|
||||
public FillAndSaveGithubForm() {
|
||||
this.agHelper.GetNClick(githubForm.githubClientId);
|
||||
this.agHelper.TypeText(
|
||||
githubForm.githubClientId,
|
||||
Cypress.env("APPSMITH_OAUTH2_GITHUB_CLIENT_ID"),
|
||||
);
|
||||
|
||||
this.agHelper.GetNClick(githubForm.githubClientSecret);
|
||||
this.agHelper.TypeText(
|
||||
githubForm.githubClientSecret,
|
||||
Cypress.env("APPSMITH_OAUTH2_GITHUB_CLIENT_SECRET"),
|
||||
);
|
||||
|
||||
this.agHelper.GetNClick(githubForm.saveBtn);
|
||||
}
|
||||
|
||||
public fillSaveAndAssertGithubForm() {
|
||||
this.FillAndSaveGithubForm();
|
||||
this.agHelper.WaitUntilEleAppear(AdminsSettings.restartNotice);
|
||||
this.agHelper.AssertElementAbsence(AdminsSettings.restartNotice, 200000);
|
||||
}
|
||||
|
||||
public toggleFormSignupLoginAndSave(enable = true, type = "signup") {
|
||||
const selector =
|
||||
type === "signup"
|
||||
? AdminsSettings.formSignupDisabled
|
||||
: AdminsSettings.formLoginEnabled;
|
||||
this.agHelper.GetNClick(AdminsSettings.formloginButton);
|
||||
this.agHelper.WaitUntilEleAppear(selector);
|
||||
|
||||
if (enable) {
|
||||
this.agHelper.GetElement(selector).then(($el) => {
|
||||
if (!$el.prop("checked")) {
|
||||
this.agHelper.GetNClick(selector);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
this.agHelper.GetElement(selector).then(($el) => {
|
||||
if ($el.prop("checked")) {
|
||||
this.agHelper.GetNClick(selector);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
this.agHelper.AssertElementVisibility(AdminsSettings.saveButton);
|
||||
this.agHelper.GetNClick(AdminsSettings.saveButton);
|
||||
this.agHelper.WaitUntilToastDisappear("Successfully saved");
|
||||
}
|
||||
|
||||
public EnableGAC(
|
||||
toNavigateToHome = true,
|
||||
toNavigateBackToHome = true,
|
||||
|
|
@ -74,6 +132,20 @@ export class AdminSettings {
|
|||
}
|
||||
}
|
||||
|
||||
public logoutFromApp() {
|
||||
this.agHelper.GetNClick(HomePage.profileMenu);
|
||||
this.agHelper.GetNClick(HomePage.signOutIcon);
|
||||
}
|
||||
|
||||
public verifyFormLogin() {
|
||||
this.agHelper.AssertElementVisibility(AdminsSettings.formloginButton);
|
||||
this.agHelper.AssertContains(
|
||||
"Edit",
|
||||
"exist",
|
||||
AdminsSettings.formloginButton,
|
||||
);
|
||||
}
|
||||
|
||||
private enableGACFeatureFlag() {
|
||||
featureFlagIntercept({ license_gac_enabled: true });
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user