Skip to content

Commit

Permalink
test: replace LogintoApp with LoginFromAPI (#34040)
Browse files Browse the repository at this point in the history
This replaces LogintoApp with LoginFromAPI

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

EE PR: appsmithorg/appsmith-ee#4440
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **Bug Fixes**
- Enhanced login functionality in multiple test scripts by shifting from
user-based login to API-based login.

- **Chores**
- Updated the spec names in the limited Cypress tests to align with new
test locations and names.
- Added new logout API call in the `LoginFromAPI` custom command to
improve test reliability.
<!-- end of auto-generated comment: release notes by coderabbit.ai
--><!-- This is an auto-generated comment: Cypress test results -->
> [!TIP]
> 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
> Workflow run:
<https://github.com/appsmithorg/appsmith/actions/runs/9517666274>
> Commit: a42a585
> Cypress dashboard url: <a
href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=9517666274&attempt=1"
target="_blank">Click here!</a>

<!-- end of auto-generated comment: Cypress test results  -->
  • Loading branch information
NandanAnantharamu committed Jun 14, 2024
1 parent 84f67fe commit 1007c23
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ describe(
cy.url().then((url) => {
const forkableAppUrl = url;
cy.LogOut();
cy.LogintoApp(
cy.LoginFromAPI(
Cypress.env("TESTUSERNAME1"),
Cypress.env("TESTPASSWORD1"),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ describe(
{ tags: ["@tag.Fork"] },
function () {
it("1. Mark application as forkable", () => {
homePage.LogintoApp(Cypress.env("USERNAME"), Cypress.env("PASSWORD"));
cy.LoginFromAPI(Cypress.env("USERNAME"), Cypress.env("PASSWORD"));
if (CURRENT_REPO === REPO.EE) adminSettings.EnableGAC(false, true);

homePage.CreateNewApplication();
Expand All @@ -50,7 +50,7 @@ describe(
cy.url().then((url) => {
forkableAppUrl = url;
cy.LogOut();
homePage.LogintoApp(
cy.LoginFromAPI(
Cypress.env("TESTUSERNAME1"),
Cypress.env("TESTPASSWORD1"),
);
Expand All @@ -60,7 +60,7 @@ describe(
});

it("2. Check if the forked application has the same dsl as the original", function () {
homePage.LogintoApp(Cypress.env("USERNAME"), Cypress.env("PASSWORD"));
cy.LoginFromAPI(Cypress.env("USERNAME"), Cypress.env("PASSWORD"));
const workspaceName = fakerHelper.GetRandomNumber() + "workspace";

homePage.CreateNewWorkspace(workspaceName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ describe(
);
cy.LogOut();

cy.LogintoApp(
cy.LoginFromAPI(
Cypress.env("TESTUSERNAME1"),
Cypress.env("TESTPASSWORD1"),
);
Expand All @@ -52,7 +52,7 @@ describe(
});

it("2. User with developer access,should not be able to export the app", function () {
cy.LogintoApp(Cypress.env("USERNAME"), Cypress.env("PASSWORD"));
cy.LoginFromAPI(Cypress.env("USERNAME"), Cypress.env("PASSWORD"));
if (CURRENT_REPO === REPO.EE) adminSettings.EnableGAC(false, true);
agHelper.GenerateUUID();
cy.get("@guid").then((uid) => {
Expand All @@ -68,7 +68,7 @@ describe(

cy.LogOut();

cy.LogintoApp(
cy.LoginFromAPI(
Cypress.env("TESTUSERNAME1"),
Cypress.env("TESTPASSWORD1"),
);
Expand All @@ -90,7 +90,7 @@ describe(
});

it("3. User with viewer access,should not be able to export the app", function () {
homePage.LogintoApp(Cypress.env("USERNAME"), Cypress.env("PASSWORD"));
cy.LoginFromAPI(Cypress.env("USERNAME"), Cypress.env("PASSWORD"));
if (CURRENT_REPO === REPO.EE) adminSettings.EnableGAC(false, true);
agHelper.GenerateUUID();
cy.get("@guid").then((uid) => {
Expand All @@ -106,7 +106,7 @@ describe(
);
cy.LogOut();

cy.LogintoApp(
cy.LoginFromAPI(
Cypress.env("TESTUSERNAME1"),
Cypress.env("TESTPASSWORD1"),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ describe("Private embed in-app ramp", { tags: ["@tag.Settings"] }, () => {
);
_.inviteModal.CloseModal();
_.homePage.Signout(false);
_.homePage.LogintoApp(
cy.LoginFromAPI(
Cypress.env("TESTUSERNAME1"),
Cypress.env("TESTPASSWORD1"),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,9 @@ describe(
false,
);
homePage.LogOutviaAPI();
homePage.LogintoApp(
cy.LoginFromAPI(
Cypress.env("TESTUSERNAME1"),
Cypress.env("TESTPASSWORD1"),
"App Viewer",
);
homePage.OpenWorkspaceOptions(newWorkspaceName);
agHelper.AssertContains(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,9 @@ describe(
);
homePage.LogOutviaAPI();

homePage.LogintoApp(
cy.LoginFromAPI(
Cypress.env("TESTUSERNAME1"),
Cypress.env("TESTPASSWORD1"),
"App Viewer",
);
agHelper.AssertContains(newWorkspaceName);
homePage.SelectWorkspace(newWorkspaceName, false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ describe(
});

it("2. Login as Administrator and search for users using search bar", () => {
_.homePage.LogintoApp(Cypress.env("USERNAME"), Cypress.env("PASSWORD"));
cy.LoginFromAPI(Cypress.env("USERNAME"), Cypress.env("PASSWORD"));
if (CURRENT_REPO === REPO.EE) _.adminSettings.EnableGAC(false, true);
_.homePage.SelectWorkspace(workspaceId);
_.agHelper.GetNClick(_.homePage._shareWorkspace(workspaceId));
Expand All @@ -46,10 +46,9 @@ describe(
});

it("3. Login as Invited user and validate Viewer role", function () {
_.homePage.LogintoApp(
cy.LoginFromAPI(
Cypress.env("TESTUSERNAME1"),
Cypress.env("TESTPASSWORD1"),
"App Viewer",
);
if (CURRENT_REPO === REPO.EE)
_.adminSettings.EnableGAC(false, true, "home");
Expand All @@ -69,7 +68,7 @@ describe(
});

it("4. Login as Workspace owner and Update the Invited user role to Developer", function () {
_.homePage.LogintoApp(Cypress.env("USERNAME"), Cypress.env("PASSWORD"));
cy.LoginFromAPI(Cypress.env("USERNAME"), Cypress.env("PASSWORD"));
if (CURRENT_REPO === REPO.EE) _.adminSettings.EnableGAC(false, true);
_.homePage.SelectWorkspace(workspaceId);
_.homePage.UpdateUserRoleInWorkspace(
Expand All @@ -81,10 +80,9 @@ describe(
});

it("5. Login as Invited user and validate Developer role", function () {
_.homePage.LogintoApp(
cy.LoginFromAPI(
Cypress.env("TESTUSERNAME1"),
Cypress.env("TESTPASSWORD1"),
"Developer",
);
if (CURRENT_REPO === REPO.EE)
_.adminSettings.EnableGAC(false, true, "home");
Expand Down Expand Up @@ -113,7 +111,7 @@ describe(
});

it("6. Login as Workspace owner and Update the Invited user role to Administrator", function () {
_.homePage.LogintoApp(Cypress.env("USERNAME"), Cypress.env("PASSWORD"));
cy.LoginFromAPI(Cypress.env("USERNAME"), Cypress.env("PASSWORD"));
if (CURRENT_REPO === REPO.EE) _.adminSettings.EnableGAC(false, true);
_.homePage.SelectWorkspace(workspaceId);
_.homePage.UpdateUserRoleInWorkspace(
Expand All @@ -125,10 +123,9 @@ describe(
});

it("7. Login as Invited user and validate Administrator role", function () {
_.homePage.LogintoApp(
cy.LoginFromAPI(
Cypress.env("TESTUSERNAME1"),
Cypress.env("TESTPASSWORD1"),
"Administrator",
);
if (CURRENT_REPO === REPO.EE)
_.adminSettings.EnableGAC(false, true, "home");
Expand Down Expand Up @@ -167,7 +164,7 @@ describe(
});

it("8. Login as Workspace owner and verify all 3 users are present", function () {
_.homePage.LogintoApp(Cypress.env("USERNAME"), Cypress.env("PASSWORD"));
cy.LoginFromAPI(Cypress.env("USERNAME"), Cypress.env("PASSWORD"));
if (CURRENT_REPO === REPO.EE) _.adminSettings.EnableGAC(false, true);
_.homePage.SelectWorkspace(workspaceId);
_.homePage.UpdateUserRoleInWorkspace(
Expand All @@ -189,7 +186,7 @@ describe(
});

it("9. Login as Developer, Verify leave workspace flow", () => {
_.homePage.LogintoApp(
cy.LoginFromAPI(
Cypress.env("TESTUSERNAME1"),
Cypress.env("TESTPASSWORD1"),
);
Expand All @@ -199,10 +196,9 @@ describe(
});

it("10. Login as App Viewer, Verify leave workspace flow", () => {
_.homePage.LogintoApp(
cy.LoginFromAPI(
Cypress.env("TESTUSERNAME2"),
Cypress.env("TESTPASSWORD2"),
"App Viewer",
);
if (CURRENT_REPO === REPO.EE)
_.adminSettings.EnableGAC(false, true, "home");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,9 @@ describe(
});

it("2. login as Invited user and then validate viewer privilage", function () {
homePage.LogintoApp(
cy.LoginFromAPI(
Cypress.env("TESTUSERNAME1"),
Cypress.env("TESTPASSWORD1"),
"App Viewer",
);
if (CURRENT_REPO == REPO.EE) adminSettings.EnableGAC(false, true, "home");

Expand All @@ -61,7 +60,7 @@ describe(
});

it("3. Enable public access to Application", function () {
homePage.LogintoApp(Cypress.env("USERNAME"), Cypress.env("PASSWORD"));
cy.LoginFromAPI(Cypress.env("USERNAME"), Cypress.env("PASSWORD"));
homePage.FilterApplication(appid);
homePage.EditAppFromAppHover();
agHelper.AssertElementAbsence(locators._loading);
Expand Down Expand Up @@ -90,7 +89,7 @@ describe(
});

it("5. login as uninvited user and then validate public access of Application", function () {
homePage.LogintoApp(
cy.LoginFromAPI(
Cypress.env("TESTUSERNAME2"),
Cypress.env("TESTPASSWORD2"),
);
Expand All @@ -105,7 +104,7 @@ describe(
});

it("6. login as Owner and disable public access", function () {
homePage.LogintoApp(Cypress.env("USERNAME"), Cypress.env("PASSWORD"));
cy.LoginFromAPI(Cypress.env("USERNAME"), Cypress.env("PASSWORD"));
homePage.FilterApplication(appid);
agHelper
.GetElement(homePage._applicationCard)
Expand All @@ -120,7 +119,7 @@ describe(
});

it("7. login as uninvited user, validate public access disable feature ", function () {
homePage.LogintoApp(
cy.LoginFromAPI(
Cypress.env("TESTUSERNAME2"),
Cypress.env("TESTPASSWORD2"),
);
Expand Down
1 change: 1 addition & 0 deletions app/client/cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ Cypress.Commands.add("LogintoApp", (uname, pword) => {
});

Cypress.Commands.add("LoginFromAPI", (uname, pword) => {
homePageTS.LogOutviaAPI();
let baseURL = Cypress.config().baseUrl;
baseURL = baseURL.endsWith("/") ? baseURL.slice(0, -1) : baseURL;

Expand Down

0 comments on commit 1007c23

Please sign in to comment.