chore: AI Chat e2e tests (#39490)

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

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **New Features**
- Introduced an AI Agents integration tag, broadening the available
options for future enhancements.
- Added new public methods for retrieving widget, datasource, and action
states, improving testability and state management.

- **Tests**
- The text input component now supports a new testing identifier
attribute, greatly improving targeting in automated tests.
- Enhanced testing commands provide more reliable state tracking and
feature flag management, contributing to a more stable application
experience.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

<!-- This is an auto-generated comment: Cypress test results  -->
> [!TIP]
> 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
> Workflow run:
<https://github.com/appsmithorg/appsmith/actions/runs/13719108635>
> Commit: d7fc099930a658b3d68cc5ef063661df02765801
> <a
href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=13719108635&attempt=1"
target="_blank">Cypress dashboard</a>.
> Tags: `@tag.Anvil`
> Spec:
> <hr>Fri, 07 Mar 2025 11:14:32 UTC
<!-- end of auto-generated comment: Cypress test results  -->
This commit is contained in:
Pawan Kumar 2025-03-07 17:33:16 +05:30 committed by GitHub
parent ab9abd6efa
commit c027e9395c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 66 additions and 2 deletions

View File

@ -119,6 +119,7 @@ export const TABLE_DATA_STATIC = `
export const WALKTHROUGH_TEST_PAGE = "WALKTHROUGH_TEST_PAGE";
export const ANVIL_EDITOR_TEST = "ANVIL_EDITOR_TEST";
export const AI_AGENTS_TEST = "AI_AGENTS_TEST";
export const DEFAULT_COLUMN_NAME = "Table Column";
export const FEATURE_WALKTHROUGH_INDEX_KEY = "FEATURE_WALKTHROUGH";
export const USER_SIGN_UP_INDEX_KEY = "USER_SIGN_UP";

View File

@ -2094,4 +2094,60 @@ export class AggregateHelper {
return fetchEmail();
}
public getCanvasWidgetStateByWidgetName(widgetName: string): any {
return cy
.window()
.its("store")
.invoke("getState")
.then((state) => {
const widgets = state.entities.canvasWidgets;
const widgetId = Object.keys(widgets).find((widgetId) => {
if (widgets[widgetId].widgetName === widgetName) {
return widgets[widgetId];
}
});
if (!widgetId) return null;
return widgets[widgetId];
});
}
public getDatasourceStateByName(datasourceName: string): any {
return cy
.window()
.its("store")
.invoke("getState")
.then((state) => {
const datasources = state.entities.datasources.list;
const datasource = datasources.find(
(datasource: any) => datasource.name === datasourceName,
);
if (!datasource) return null;
return datasource;
});
}
public getActionStateByName(actionName: string): any {
return cy
.window()
.its("store")
.invoke("getState")
.then((state) => {
const actions = state.entities.actions;
const action = actions.find(
(action: any) => action.config.name === actionName,
);
if (!action) return null;
return action;
});
}
}

View File

@ -1,7 +1,7 @@
/* eslint-disable cypress/no-unnecessary-waiting */
/* eslint-disable cypress/no-assigning-return-values */
/* This file is used to maintain comman methods across tests , refer other *.js files for adding common methods */
import { ANVIL_EDITOR_TEST } from "./Constants.js";
import { ANVIL_EDITOR_TEST, AI_AGENTS_TEST } from "./Constants.js";
import advancedFormat from "dayjs/plugin/advancedFormat";
import EditorNavigation, {
@ -741,7 +741,10 @@ Cypress.Commands.add("startServerAndRoutes", () => {
cy.intercept("PUT", "/api/v1/git/discard/app/*").as("discardChanges");
cy.intercept("GET", "/api/v1/libraries/*").as("getLibraries");
if (Cypress.currentTest.titlePath[0].includes(ANVIL_EDITOR_TEST)) {
if (
Cypress.currentTest.titlePath[0].includes(ANVIL_EDITOR_TEST) ||
Cypress.currentTest.titlePath[0].includes(AI_AGENTS_TEST)
) {
// intercept features call for creating pages that support Anvil + WDS tests
featureFlagIntercept({ release_anvil_enabled: true }, false);
} else {

View File

@ -73,5 +73,6 @@ module.exports = {
"@tag.Workspace",
"@tag.airgap",
"@tag.excludeForAirgap",
"@tag.AIAgents",
],
};

View File

@ -21,6 +21,7 @@ interface Size {
export function TextArea(props: TextAreaProps) {
const {
contextualHelp,
"data-testid": dataTestId,
errorMessage,
fieldClassName,
inputClassName,
@ -141,6 +142,7 @@ export function TextArea(props: TextAreaProps) {
</FieldLabel>
<TextAreaInput
className={inputClassName}
data-testid={dataTestId}
isLoading={isLoading}
isReadOnly={isReadOnly}
ref={inputRef}

View File

@ -12,4 +12,5 @@ export interface TextAreaProps extends AriaTextFieldProps, FieldProps {
inputClassName?: string;
size?: Exclude<keyof typeof SIZES, "xSmall">;
maxRows?: number;
"data-testid"?: string;
}