PromucFlow_constructor/app/client/cypress/support/queryCommands.js
Ankita Kinger e1d09b47d3
chore: Removing the feature flag for using Entity Item component from ADS templates (#39093)
## Description

Removing the feature flag for using Entity Item component from ADS
templates in the Entity Explorer in App Editor.

Fixes [#39067](https://github.com/appsmithorg/appsmith/issues/39067)

## Automation

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

### 🔍 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/13804174182>
> Commit: 8a4a2007c8e1411a9baa388cf841e5e489cb6778
> <a
href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=13804174182&attempt=1"
target="_blank">Cypress dashboard</a>.
> Tags: `@tag.All`
> Spec:
> <hr>Wed, 12 Mar 2025 06:32:35 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**
- Improved entity renaming: input fields now automatically clear
previous text for smoother editing.
- Enhanced page navigation: active selections are now verified more
consistently, ensuring clearer context.
  - New feature flag added for enhanced entity item visibility.
- Added new methods for improved entity selection and verification in
tests.
- Introduced `parentId` properties in widget definitions to enhance
hierarchical structure.
- Updated selectors for widget names and collapsible elements in tests
for improved targeting.

- **Bug Fixes**
- Resolved issues with inconsistent element detection and state feedback
for a more stable interface.

- **Refactor**
- Updated widget hierarchy and locator logic for improved layout
rendering and overall UI consistency.
- Modified locator strategies to enhance element targeting across
various components.
  - Simplified method signatures for better clarity and maintainability.
  - Enhanced test selectors to improve reliability and maintainability.
- Removed obsolete commands and streamlined interaction methods in
tests.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Hetu Nandu <hetunandu@gmail.com>
Co-authored-by: Hetu Nandu <hetu@appsmith.com>
2025-03-14 17:40:02 +05:30

147 lines
4.5 KiB
JavaScript

/* eslint-disable cypress/no-unnecessary-waiting */
/* eslint-disable cypress/no-assigning-return-values */
import { ObjectsRegistry } from "../support/Objects/Registry";
import EditorNavigation, { EntityType } from "./Pages/EditorNavigation";
require("cy-verify-downloads").addCustomCommand();
require("cypress-file-upload");
const jsEditorLocators = require("../locators/JSEditor.json");
const datasourceEditor = require("../locators/DatasourcesEditor.json");
const datasourceFormData = require("../fixtures/datasources.json");
const queryEditor = require("../locators/QueryEditor.json");
const apiwidget = require("../locators/apiWidgetslocator.json");
const datasource = require("../locators/DatasourcesEditor.json");
const formControls = require("../locators/FormControl.json");
const { AggregateHelper, PropertyPane } = ObjectsRegistry;
export const initLocalstorage = () => {
cy.window().then((window) => {
window.localStorage.setItem("ShowCommentsButtonToolTip", "");
window.localStorage.setItem("updateDismissed", "true");
});
};
Cypress.Commands.add("NavigateToDSGeneratePage", (datasourceName) => {
EditorNavigation.SelectEntityByName(datasourceName, EntityType.Datasource);
cy.get(datasource.datasourceCardGeneratePageBtn).click();
cy.wait(2000); //for the specified page to load
});
Cypress.Commands.add("ClickGotIt", () => {
cy.get("span:contains('Got it')").click();
});
Cypress.Commands.add("fillAuthenticatedAPIForm", () => {
const URL = datasourceFormData["authenticatedApiUrl"];
cy.get(datasourceEditor.url).type(URL);
});
Cypress.Commands.add("runQuery", (expectedRes = true) => {
cy.onlyQueryRun();
AggregateHelper.FailIfErrorToast("Failed to initialize pool");
cy.wait(2000); //for postexecute to go thru
cy.wait("@postExecute").should(
"have.nested.property",
"response.body.data.isExecutionSuccess",
expectedRes,
);
// cy.wait("@postExecute").should(
// "have.nested.property",
// "response.body.responseMeta.status",
// 200,
// );
});
Cypress.Commands.add("onlyQueryRun", () => {
cy.xpath(queryEditor.runQuery).last().click({ force: true }).wait(1000);
cy.get(".ads-v2-spinner").should("not.exist");
});
Cypress.Commands.add("deleteQueryUsingContext", () => {
cy.get(queryEditor.queryMoreAction).first().click();
cy.get(queryEditor.deleteUsingContext).click();
cy.get(queryEditor.deleteUsingContext).contains("Are you sure?").click();
cy.wait("@deleteAction").should(
"have.nested.property",
"response.body.responseMeta.status",
200,
);
});
Cypress.Commands.add("runAndDeleteQuery", () => {
cy.runQuery();
cy.deleteQueryUsingContext();
});
Cypress.Commands.add("executeDbQuery", (queryName, eventName) => {
PropertyPane.SelectPlatformFunction(eventName, "Execute a query");
cy.get(`.single-select:contains(${queryName})`).click({ force: true });
// cy.get(widgetsPage.buttonOnClick)
// .get(commonlocators.dropdownSelectButton)
// .eq(0)
// .click({ force: true })
// .get("ul.bp3-menu")
// .children()
// .contains("Execute a query")
// .click({ force: true })
// .get("ul.bp3-menu")
// .children()
// .contains(queryName)
// .click({ force: true });
});
Cypress.Commands.add("ValidateQueryParams", (param) => {
cy.xpath(apiwidget.paramsTab).should("be.visible").click({ force: true });
cy.validateCodeEditorContent(apiwidget.paramKey, param.key);
cy.validateCodeEditorContent(apiwidget.paramValue, param.value);
});
// from hereeee
// targeting normal dropdowns, we can simply use the label names
Cypress.Commands.add(
"TargetDropdownAndSelectOption",
(dropdownIdentifier, option, isDynamic = false) => {
if (isDynamic) {
cy.wait(5000);
}
cy.get(dropdownIdentifier)
.scrollIntoView()
.should("be.visible")
.click({ multiple: true });
cy.get(formControls.dropdownWrapper)
.should("be.visible")
.contains(option)
.first()
.click({ force: true });
cy.wait(2000);
},
);
Cypress.Commands.add(
"VerifyCurrentDropdownOption",
(dropdownIdentifier, option) => {
cy.get(dropdownIdentifier)
.scrollIntoView()
.should("be.visible")
.contains(option)
.should("be.visible");
},
);
Cypress.Commands.add(
"ValidateAndSelectDropdownOption",
(dropdownIdentifier, currentOption, newOption, isDynamic = false) => {
cy.VerifyCurrentDropdownOption(dropdownIdentifier, currentOption);
if (newOption) {
cy.TargetDropdownAndSelectOption(
dropdownIdentifier,
newOption,
isDynamic,
);
cy.wait(2000);
}
},
);