Repository: appsmithorg/appsmith
File: app/client/cypress/e2e/Regression/ClientSide/FormLogin/EnableFormLogin_spec.ts (TypeScript)

Code before:
      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"));

      agHelper.AssertElementVisibility(homePage.homeIcon);
      agHelper.GetNClick(homePage.homeIcon, 0, true, 2500);
      objectsCoreAdminSettings.NavigateToAuthenticationSettings(false);
      objectsCoreAdminSettings.toggleFormSignupLoginAndSave(true, "login");
      agHelper.AssertElementVisibility(homePage.homeIcon);
      agHelper.GetNClick(homePage.homeIcon, 0, true, 2500);
      objectsCoreAdminSettings.NavigateToAuthenticationSettings(false);
      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);
    },
  );
});


Review comment (security):
Steps 76 and 77 not needed. Might as well update 78 to:
`objectsCoreAdminSettings.NavigateToAuthenticationSettings(true)`

Code after:
        });
      });
    },
  );

  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);
    },
  );