2022-04-21 06:14:02 +00:00
|
|
|
/* 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");
|
2023-05-11 18:45:06 +00:00
|
|
|
import adminSettings from "../locators/AdminsSettings";
|
2023-08-21 07:49:28 +00:00
|
|
|
import { ObjectsRegistry } from "./Objects/Registry";
|
2022-04-21 06:14:02 +00:00
|
|
|
|
2023-08-21 07:49:28 +00:00
|
|
|
let agHelper = ObjectsRegistry.AggregateHelper;
|
2024-03-21 10:07:13 +00:00
|
|
|
let adminSettingsHelper = ObjectsRegistry.AdminSettings;
|
2023-03-14 06:11:52 +00:00
|
|
|
const BASE_URL = Cypress.config().baseUrl;
|
|
|
|
|
|
2022-04-21 06:14:02 +00:00
|
|
|
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", () => {
|
2023-03-14 06:11:52 +00:00
|
|
|
const baseUrl = BASE_URL.endsWith("/") ? BASE_URL.slice(0, -1) : BASE_URL;
|
|
|
|
|
cy.get(googleForm.googleJSOriginUrl).should("have.value", `${baseUrl}`);
|
|
|
|
|
cy.get(googleForm.googleRedirectUrl).should(
|
|
|
|
|
"have.value",
|
|
|
|
|
`${baseUrl}/login/oauth2/code/google`,
|
|
|
|
|
);
|
2022-04-21 06:14:02 +00:00
|
|
|
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", () => {
|
2023-06-13 13:53:33 +00:00
|
|
|
const baseUrl = BASE_URL.endsWith("/") ? BASE_URL.slice(0, -1) : BASE_URL;
|
|
|
|
|
cy.get(githubForm.githubHomepageUrl).should("have.value", `${baseUrl}`);
|
|
|
|
|
cy.get(githubForm.githubCallbackUrl).should(
|
|
|
|
|
"have.value",
|
|
|
|
|
`${baseUrl}/login/oauth2/code/github`,
|
|
|
|
|
);
|
2022-04-21 06:14:02 +00:00
|
|
|
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 });
|
|
|
|
|
});
|
2022-05-06 14:51:08 +00:00
|
|
|
|
|
|
|
|
// open authentication page
|
|
|
|
|
Cypress.Commands.add("openAuthentication", () => {
|
2022-09-26 14:08:32 +00:00
|
|
|
cy.get(".admin-settings-menu-option").should("be.visible");
|
|
|
|
|
cy.get(".admin-settings-menu-option").click();
|
2024-03-21 10:07:13 +00:00
|
|
|
cy.url().should("contain", adminSettingsHelper.routes.GENERAL);
|
2022-05-06 14:51:08 +00:00
|
|
|
// click authentication tab
|
|
|
|
|
cy.get(adminSettings.authenticationTab).click();
|
2024-03-21 10:07:13 +00:00
|
|
|
cy.url().should("contain", adminSettingsHelper.routes.AUTHENTICATION);
|
2022-05-06 14:51:08 +00:00
|
|
|
});
|
2022-11-30 04:12:20 +00:00
|
|
|
|
|
|
|
|
Cypress.Commands.add("waitForServerRestart", () => {
|
|
|
|
|
cy.get(adminSettings.restartNotice).should("be.visible");
|
|
|
|
|
// Wait for restart notice to not be visible with a timeout
|
|
|
|
|
// Cannot use cy.get as mentioned in https://github.com/NoriSte/cypress-wait-until/issues/75#issuecomment-572685623
|
2023-08-18 08:18:41 +00:00
|
|
|
// cy.waitUntil(() => !Cypress.$(adminSettings.restartNotice).length, {
|
|
|
|
|
// timeout: 180000,
|
|
|
|
|
// });
|
2024-12-13 09:34:00 +00:00
|
|
|
cy.get(adminSettings.restartNotice, { timeout: 600000 }).should("not.exist");
|
|
|
|
|
cy.get(adminSettings.appsmithStarting, { timeout: 600000 }).should(
|
2023-09-13 17:03:14 +00:00
|
|
|
"not.exist",
|
|
|
|
|
);
|
|
|
|
|
|
2023-08-18 05:18:35 +00:00
|
|
|
cy.window().then((win) => {
|
|
|
|
|
win.location.reload();
|
2022-11-30 04:12:20 +00:00
|
|
|
});
|
2023-08-21 07:49:28 +00:00
|
|
|
agHelper.AssertElementVisibility(adminSettings.saveButton, true, 0, 30000);
|
2023-08-21 12:09:26 +00:00
|
|
|
agHelper.AssertElementAbsence(adminSettings.restartNotice, 30000);
|
2022-11-30 04:12:20 +00:00
|
|
|
});
|