chore: update a cypress test (#13036)
This commit is contained in:
parent
3a22cda148
commit
9ed26a92b0
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -5,6 +5,7 @@
|
|||
.vscode/*
|
||||
|
||||
app/client/cypress.env.json
|
||||
stacks
|
||||
|
||||
# to ignore the node_modeules folder
|
||||
node_modules
|
||||
|
|
|
|||
4
app/client/cypress/fixtures/githubSource.json
Normal file
4
app/client/cypress/fixtures/githubSource.json
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
"githubClientId": "",
|
||||
"githubClientSecret": ""
|
||||
}
|
||||
5
app/client/cypress/fixtures/googleSource.json
Normal file
5
app/client/cypress/fixtures/googleSource.json
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"googleClientId": "",
|
||||
"googleClientSecret": "",
|
||||
"googleAllowedDomains": "appsmith.com"
|
||||
}
|
||||
|
|
@ -23,9 +23,11 @@ describe("Admin settings page", function() {
|
|||
cy.visit("/settings/general");
|
||||
cy.get(adminsSettings.authenticationTab).click();
|
||||
cy.url().should("contain", "/settings/authentication");
|
||||
cy.get(EnterpriseAdminSettingsLocators.upgradeButton).each(($el) => {
|
||||
cy.wrap($el).should("be.visible");
|
||||
cy.wrap($el).should("contain", "UPGRADE");
|
||||
});
|
||||
cy.get(EnterpriseAdminSettingsLocators.upgradeOidcButton)
|
||||
.should("be.visible")
|
||||
.should("contain", "UPGRADE");
|
||||
cy.get(EnterpriseAdminSettingsLocators.upgradeSamlButton)
|
||||
.should("be.visible")
|
||||
.should("contain", "UPGRADE");
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -0,0 +1,103 @@
|
|||
const adminSettings = require("../../../../locators/AdminsSettings");
|
||||
const commonlocators = require("../../../../locators/commonlocators.json");
|
||||
import homePage from "../../../../locators/HomePage";
|
||||
|
||||
describe("SSO with Github test functionality", function() {
|
||||
it("1. Go to admin settings and enable Github with not all mandatory fields filled", function() {
|
||||
cy.LogOut();
|
||||
cy.LoginFromAPI(Cypress.env("USERNAME"), Cypress.env("PASSWORD"));
|
||||
cy.visit("/applications");
|
||||
cy.get(".t--profile-menu-icon").should("be.visible");
|
||||
cy.get(".t--profile-menu-icon").click();
|
||||
cy.get(".t--admin-settings-menu").should("be.visible");
|
||||
cy.get(".t--admin-settings-menu").click();
|
||||
cy.url().should("contain", "/settings/general");
|
||||
// click authentication tab
|
||||
cy.get(adminSettings.authenticationTab).click();
|
||||
cy.url().should("contain", "/settings/authentication");
|
||||
cy.get(adminSettings.githubButton)
|
||||
.should("be.visible")
|
||||
.should("contain", "ENABLE");
|
||||
cy.get(adminSettings.githubButton).click();
|
||||
cy.wait(2000);
|
||||
// fill github form
|
||||
cy.fillGithubFormPartly();
|
||||
cy.get(commonlocators.toastBody).should("be.visible");
|
||||
cy.get(commonlocators.toastBody).should(
|
||||
"contain",
|
||||
"Mandatory fields cannot be empty",
|
||||
);
|
||||
});
|
||||
|
||||
it("2. Go to admin settings and enable Github", function() {
|
||||
cy.LogOut();
|
||||
cy.LoginFromAPI(Cypress.env("USERNAME"), Cypress.env("PASSWORD"));
|
||||
cy.visit("/applications");
|
||||
cy.get(".t--profile-menu-icon").should("be.visible");
|
||||
cy.get(".t--profile-menu-icon").click();
|
||||
cy.get(".t--admin-settings-menu").should("be.visible");
|
||||
cy.get(".t--admin-settings-menu").click();
|
||||
cy.url().should("contain", "/settings/general");
|
||||
// click authentication tab
|
||||
cy.get(adminSettings.authenticationTab).click();
|
||||
cy.url().should("contain", "/settings/authentication");
|
||||
cy.get(adminSettings.githubButton)
|
||||
.should("be.visible")
|
||||
.should("contain", "ENABLE");
|
||||
cy.get(adminSettings.githubButton).click();
|
||||
cy.wait(2000);
|
||||
// fill github form
|
||||
cy.fillGithubForm();
|
||||
cy.wait(2000);
|
||||
// assert server is restarting
|
||||
cy.get(adminSettings.restartNotice).should("be.visible");
|
||||
// adding wait for server to restart
|
||||
cy.wait(120000);
|
||||
cy.waitUntil(() => cy.get(homePage.profileMenu).should("be.visible"));
|
||||
cy.get(homePage.profileMenu).click();
|
||||
cy.get(homePage.signOutIcon).click();
|
||||
cy.wait(500);
|
||||
// validating sso with github is enabled
|
||||
cy.get(adminSettings.loginWithGithub).should(
|
||||
"have.text",
|
||||
"continue with Github",
|
||||
);
|
||||
});
|
||||
|
||||
it("3. Go to admin settings and disable Github", function() {
|
||||
cy.LogOut();
|
||||
cy.LoginFromAPI(Cypress.env("USERNAME"), Cypress.env("PASSWORD"));
|
||||
cy.visit("/applications");
|
||||
cy.get(".t--profile-menu-icon").should("be.visible");
|
||||
cy.get(".t--profile-menu-icon").click();
|
||||
cy.get(".t--admin-settings-menu").should("be.visible");
|
||||
cy.get(".t--admin-settings-menu").click();
|
||||
cy.url().should("contain", "/settings/general");
|
||||
// click authentication tab
|
||||
cy.get(adminSettings.authenticationTab).click();
|
||||
cy.url().should("contain", "/settings/authentication");
|
||||
cy.get(adminSettings.githubButton)
|
||||
.should("be.visible")
|
||||
.should("contain", "EDIT");
|
||||
cy.get(adminSettings.githubButton).click();
|
||||
cy.wait(2000);
|
||||
cy.get(adminSettings.disconnectBtn)
|
||||
.should("be.visible")
|
||||
.should("contain", "Disconnect");
|
||||
cy.get(adminSettings.disconnectBtn)
|
||||
.click()
|
||||
.should("contain", "Are you sure?");
|
||||
cy.get(adminSettings.disconnectBtn).click();
|
||||
|
||||
// assert server is restarting
|
||||
cy.get(adminSettings.restartNotice).should("be.visible");
|
||||
// adding wait for server to restart
|
||||
cy.wait(120000);
|
||||
cy.waitUntil(() => cy.get(homePage.profileMenu).should("be.visible"));
|
||||
cy.get(homePage.profileMenu).click();
|
||||
cy.get(homePage.signOutIcon).click();
|
||||
cy.wait(500);
|
||||
// validating sso with github is disabled
|
||||
cy.get(adminSettings.loginWithGithub).should("not.exist");
|
||||
});
|
||||
});
|
||||
|
|
@ -0,0 +1,103 @@
|
|||
const adminSettings = require("../../../../locators/AdminsSettings");
|
||||
const commonlocators = require("../../../../locators/commonlocators.json");
|
||||
import homePage from "../../../../locators/HomePage";
|
||||
|
||||
describe("SSO with Google test functionality", function() {
|
||||
it("1. Go to admin settings and enable Google with not all mandatory fields filled", function() {
|
||||
cy.LogOut();
|
||||
cy.LoginFromAPI(Cypress.env("USERNAME"), Cypress.env("PASSWORD"));
|
||||
cy.visit("/applications");
|
||||
cy.get(".t--profile-menu-icon").should("be.visible");
|
||||
cy.get(".t--profile-menu-icon").click();
|
||||
cy.get(".t--admin-settings-menu").should("be.visible");
|
||||
cy.get(".t--admin-settings-menu").click();
|
||||
cy.url().should("contain", "/settings/general");
|
||||
// click authentication tab
|
||||
cy.get(adminSettings.authenticationTab).click();
|
||||
cy.url().should("contain", "/settings/authentication");
|
||||
cy.get(adminSettings.googleButton)
|
||||
.should("be.visible")
|
||||
.should("contain", "ENABLE");
|
||||
cy.get(adminSettings.googleButton).click();
|
||||
cy.wait(2000);
|
||||
// fill google form
|
||||
cy.fillGoogleFormPartly();
|
||||
cy.get(commonlocators.toastBody).should("be.visible");
|
||||
cy.get(commonlocators.toastBody).should(
|
||||
"contain",
|
||||
"Mandatory fields cannot be empty",
|
||||
);
|
||||
});
|
||||
|
||||
it("2. Go to admin settings and enable Google", function() {
|
||||
cy.LogOut();
|
||||
cy.LoginFromAPI(Cypress.env("USERNAME"), Cypress.env("PASSWORD"));
|
||||
cy.visit("/applications");
|
||||
cy.get(".t--profile-menu-icon").should("be.visible");
|
||||
cy.get(".t--profile-menu-icon").click();
|
||||
cy.get(".t--admin-settings-menu").should("be.visible");
|
||||
cy.get(".t--admin-settings-menu").click();
|
||||
cy.url().should("contain", "/settings/general");
|
||||
// click authentication tab
|
||||
cy.get(adminSettings.authenticationTab).click();
|
||||
cy.url().should("contain", "/settings/authentication");
|
||||
cy.get(adminSettings.googleButton)
|
||||
.should("be.visible")
|
||||
.should("contain", "ENABLE");
|
||||
cy.get(adminSettings.googleButton).click();
|
||||
cy.wait(2000);
|
||||
// fill google form
|
||||
cy.fillGoogleForm();
|
||||
cy.wait(2000);
|
||||
// assert server is restarting
|
||||
cy.get(adminSettings.restartNotice).should("be.visible");
|
||||
// adding wait for server to restart
|
||||
cy.wait(120000);
|
||||
cy.waitUntil(() => cy.get(homePage.profileMenu).should("be.visible"));
|
||||
cy.get(homePage.profileMenu).click();
|
||||
cy.get(homePage.signOutIcon).click();
|
||||
cy.wait(500);
|
||||
// validating sso with google is enabled
|
||||
cy.get(adminSettings.loginWithGoogle).should(
|
||||
"have.text",
|
||||
"continue with Google",
|
||||
);
|
||||
});
|
||||
|
||||
it("3. Go to admin settings and disable Google", function() {
|
||||
cy.LogOut();
|
||||
cy.LoginFromAPI(Cypress.env("USERNAME"), Cypress.env("PASSWORD"));
|
||||
cy.visit("/applications");
|
||||
cy.get(".t--profile-menu-icon").should("be.visible");
|
||||
cy.get(".t--profile-menu-icon").click();
|
||||
cy.get(".t--admin-settings-menu").should("be.visible");
|
||||
cy.get(".t--admin-settings-menu").click();
|
||||
cy.url().should("contain", "/settings/general");
|
||||
// click authentication tab
|
||||
cy.get(adminSettings.authenticationTab).click();
|
||||
cy.url().should("contain", "/settings/authentication");
|
||||
cy.get(adminSettings.googleButton)
|
||||
.should("be.visible")
|
||||
.should("contain", "EDIT");
|
||||
cy.get(adminSettings.googleButton).click();
|
||||
cy.wait(2000);
|
||||
cy.get(adminSettings.disconnectBtn)
|
||||
.should("be.visible")
|
||||
.should("contain", "Disconnect");
|
||||
cy.get(adminSettings.disconnectBtn)
|
||||
.click()
|
||||
.should("contain", "Are you sure?");
|
||||
cy.get(adminSettings.disconnectBtn).click();
|
||||
|
||||
// assert server is restarting
|
||||
cy.get(adminSettings.restartNotice).should("be.visible");
|
||||
// adding wait for server to restart
|
||||
cy.wait(120000);
|
||||
cy.waitUntil(() => cy.get(homePage.profileMenu).should("be.visible"));
|
||||
cy.get(homePage.profileMenu).click();
|
||||
cy.get(homePage.signOutIcon).click();
|
||||
cy.wait(500);
|
||||
// validating sso with google is disabled
|
||||
cy.get(adminSettings.loginWithGoogle).should("not.exist");
|
||||
});
|
||||
});
|
||||
|
|
@ -20,4 +20,7 @@ export default {
|
|||
restartNotice: ".t--admin-settings-restart-notice",
|
||||
appsmithLogo: ".t--appsmith-logo",
|
||||
appsmithHeader: "[data-testid='t--appsmith-page-header']",
|
||||
loginWithGoogle: "[data-testid='login-with-Google']",
|
||||
loginWithGithub: "[data-testid='login-with-Github']",
|
||||
disconnectBtn: "[data-testid='disconnect-service-button']",
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
{
|
||||
"upgradeButton": ".t--settings-sub-category-upgrade"
|
||||
"upgradeSamlButton": ".t--settings-sub-category-upgrade-saml",
|
||||
"upgradeOidcButton": ".t--settings-sub-category-upgrade-oidc"
|
||||
}
|
||||
5
app/client/cypress/locators/GithubForm.json
Normal file
5
app/client/cypress/locators/GithubForm.json
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"githubClientId": "[name='APPSMITH_OAUTH2_GITHUB_CLIENT_ID']",
|
||||
"githubClientSecret": "[name='APPSMITH_OAUTH2_GITHUB_CLIENT_SECRET']",
|
||||
"saveBtn": ".t--admin-settings-save-button"
|
||||
}
|
||||
6
app/client/cypress/locators/GoogleForm.json
Normal file
6
app/client/cypress/locators/GoogleForm.json
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"googleClientId": "[name='APPSMITH_OAUTH2_GOOGLE_CLIENT_ID']",
|
||||
"googleClientSecret": "[name='APPSMITH_OAUTH2_GOOGLE_CLIENT_SECRET']",
|
||||
"googleAllowedDomains": "[name='APPSMITH_SIGNUP_ALLOWED_DOMAINS']",
|
||||
"saveBtn": ".t--admin-settings-save-button"
|
||||
}
|
||||
46
app/client/cypress/support/AdminSettingsCommands.js
Normal file
46
app/client/cypress/support/AdminSettingsCommands.js
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
/* eslint-disable cypress/no-unnecessary-waiting */
|
||||
/* eslint-disable cypress/no-assigning-return-values */
|
||||
|
||||
require("cy-verify-downloads").addCustomCommand();
|
||||
require("cypress-file-upload");
|
||||
|
||||
const googleForm = require("../locators/GoogleForm.json");
|
||||
const googleData = require("../fixtures/googleSource.json");
|
||||
const githubForm = require("../locators/GithubForm.json");
|
||||
const githubData = require("../fixtures/githubSource.json");
|
||||
|
||||
Cypress.Commands.add("fillGoogleFormPartly", () => {
|
||||
cy.get(googleForm.googleClientId).type(
|
||||
Cypress.env("APPSMITH_OAUTH2_GOOGLE_CLIENT_ID"),
|
||||
);
|
||||
cy.get(googleForm.googleAllowedDomains).type(googleData.googleAllowedDomains);
|
||||
cy.get(googleForm.saveBtn).click({ force: true });
|
||||
});
|
||||
|
||||
Cypress.Commands.add("fillGoogleForm", () => {
|
||||
cy.get(googleForm.googleClientId).type(
|
||||
Cypress.env("APPSMITH_OAUTH2_GOOGLE_CLIENT_ID"),
|
||||
);
|
||||
cy.get(googleForm.googleClientSecret).type(
|
||||
Cypress.env("APPSMITH_OAUTH2_GOOGLE_CLIENT_SECRET"),
|
||||
);
|
||||
cy.get(googleForm.googleAllowedDomains).type(googleData.googleAllowedDomains);
|
||||
cy.get(googleForm.saveBtn).click({ force: true });
|
||||
});
|
||||
|
||||
Cypress.Commands.add("fillGithubFormPartly", () => {
|
||||
cy.get(githubForm.githubClientId).type(
|
||||
Cypress.env("APPSMITH_OAUTH2_GITHUB_CLIENT_ID"),
|
||||
);
|
||||
cy.get(githubForm.saveBtn).click({ force: true });
|
||||
});
|
||||
|
||||
Cypress.Commands.add("fillGithubForm", () => {
|
||||
cy.get(githubForm.githubClientId).type(
|
||||
Cypress.env("APPSMITH_OAUTH2_GITHUB_CLIENT_ID"),
|
||||
);
|
||||
cy.get(githubForm.githubClientSecret).type(
|
||||
Cypress.env("APPSMITH_OAUTH2_GITHUB_CLIENT_SECRET"),
|
||||
);
|
||||
cy.get(githubForm.saveBtn).click({ force: true });
|
||||
});
|
||||
|
|
@ -28,6 +28,7 @@ import { initLocalstorageRegistry } from "./Objects/Registry";
|
|||
import "./OrgCommands";
|
||||
import "./queryCommands";
|
||||
import "./widgetCommands";
|
||||
import "./AdminSettingsCommands";
|
||||
/// <reference types="cypress-xpath" />
|
||||
|
||||
Cypress.on("uncaught:exception", () => {
|
||||
|
|
|
|||
|
|
@ -184,7 +184,11 @@ export function AuthPage({ authMethods }: { authMethods: AuthMethodType[] }) {
|
|||
openOnTargetFocus={false}
|
||||
position={Position.RIGHT}
|
||||
>
|
||||
<Icon fillColor={Colors.GREEN} name="oval-check" />
|
||||
<Icon
|
||||
className={`${method.category}-green-check`}
|
||||
fillColor={Colors.GREEN}
|
||||
name="oval-check"
|
||||
/>
|
||||
</TooltipComponent>
|
||||
)}
|
||||
</MethodTitle>
|
||||
|
|
@ -202,7 +206,9 @@ export function AuthPage({ authMethods }: { authMethods: AuthMethodType[] }) {
|
|||
method.isConnected ? Category.primary : Category.tertiary
|
||||
}
|
||||
className={`t--settings-sub-category-${
|
||||
method.needsUpgrade ? "upgrade" : method.category
|
||||
method.needsUpgrade
|
||||
? `upgrade-${method.category}`
|
||||
: method.category
|
||||
}`}
|
||||
data-cy="btn-auth-account"
|
||||
onClick={() =>
|
||||
|
|
|
|||
|
|
@ -181,6 +181,7 @@ export const Github_Auth_Callout: AuthMethodType = {
|
|||
|
||||
export const Saml_Auth_Callout: AuthMethodType = {
|
||||
id: "APPSMITH_SAML_AUTH",
|
||||
category: "saml",
|
||||
label: "SAML 2.0",
|
||||
subText: `Enable your organization to sign in with your preferred SAML2 compliant provider.`,
|
||||
image: SamlSso,
|
||||
|
|
@ -190,6 +191,7 @@ export const Saml_Auth_Callout: AuthMethodType = {
|
|||
|
||||
export const Oidc_Auth_Callout: AuthMethodType = {
|
||||
id: "APPSMITH_OIDC_AUTH",
|
||||
category: "oidc",
|
||||
label: "OIDC",
|
||||
subText: `Enable your organization to sign in with Open ID Connect.`,
|
||||
image: OIDC,
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ function SocialLoginButton(props: {
|
|||
}}
|
||||
>
|
||||
<ButtonLogo alt={` ${props.name} login`} src={props.logo} />
|
||||
<div className="login-method">
|
||||
<div className="login-method" data-testid={`login-with-${props.name}`}>
|
||||
{props.label ?? `continue with ${props.name}`}
|
||||
</div>
|
||||
</StyledSocialLoginButton>
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user