PromucFlow_constructor/app/client/cypress/support/AdminSettingsCommands.js
Sagar Khalasi 8f88466195
fix: Fix for the embedded case (#38101)
## Description
Fix the case for embedded case

Fixes #`Issue Number`  
_or_  
Fixes `Issue URL`
> [!WARNING]  
> _If no issue exists, please create an issue first, and check with the
maintainers if the issue is valid._

## Automation

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

### 🔍 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/12311687620>
> Commit: b4e86b07be4154330ec77a7716d1ef9d29629cea
> <a
href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=12311687620&attempt=1"
target="_blank">Cypress dashboard</a>.
> Tags: `@tag.Settings`
> Spec:
> <hr>Fri, 13 Dec 2024 08:14:04 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

- **New Features**
- Introduced a new "copy application URL" button for easier URL
management.
  
- **Bug Fixes**
- Enhanced timeout durations for server restart notifications to improve
reliability.

- **Improvements**
- Modified test setup for better navigation and application creation
process.
- Updated navigation to wait for the page header before proceeding,
improving test flow.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2024-12-13 15:04:00 +05:30

93 lines
3.5 KiB
JavaScript

/* 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");
import adminSettings from "../locators/AdminsSettings";
import { ObjectsRegistry } from "./Objects/Registry";
let agHelper = ObjectsRegistry.AggregateHelper;
let adminSettingsHelper = ObjectsRegistry.AdminSettings;
const BASE_URL = Cypress.config().baseUrl;
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", () => {
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`,
);
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", () => {
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`,
);
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 });
});
// open authentication page
Cypress.Commands.add("openAuthentication", () => {
cy.get(".admin-settings-menu-option").should("be.visible");
cy.get(".admin-settings-menu-option").click();
cy.url().should("contain", adminSettingsHelper.routes.GENERAL);
// click authentication tab
cy.get(adminSettings.authenticationTab).click();
cy.url().should("contain", adminSettingsHelper.routes.AUTHENTICATION);
});
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
// cy.waitUntil(() => !Cypress.$(adminSettings.restartNotice).length, {
// timeout: 180000,
// });
cy.get(adminSettings.restartNotice, { timeout: 600000 }).should("not.exist");
cy.get(adminSettings.appsmithStarting, { timeout: 600000 }).should(
"not.exist",
);
cy.window().then((win) => {
win.location.reload();
});
agHelper.AssertElementVisibility(adminSettings.saveButton, true, 0, 30000);
agHelper.AssertElementAbsence(adminSettings.restartNotice, 30000);
});