PromucFlow_constructor/app/client/src/components/formControls/DynamicTextFieldControl.test.tsx
Arsalan Yaldram f58451aa5f
feat: upgrade to create react app 5 (#14000)
* Updated Typescript types.

* Typefixes after merge with release.

* chore: GenericApiResponse Removed alltogether.

* chore: resolved ApiResponse unknown errors removed PageListPayload.

* Added shouldBeDefined.

* fix: Resolved type errors.

* fix: Typescript upgrade to 4.5 and type fixes.

* feat: upgrade to cra 5

* feat: uncomment service worker registeration

* force secure websocket protocol

* jest test fixes

* fix: react function lint rule removed

* fix: klona test case.

* fix: typescirpt issues resolved

* fix: timeout for colorpicker test and change env.

* feat: update client-build.yml file

* fix: remove brotliplugin use compression plugin

* fix: build config fixed

* fix: upgrade webpack plugin

* fix: add branchbutton test to todo.

* fix: remove branch button test.

* fix: Add tailwind theme values, fix cypress tests

* fix: Typescript type fixes.

* feat: run jest tests in silent mode

* fix: cypress rgb values add branchbutton jest test

* fix: review comments, fixes for error.message

* fix: increase cache size for the workbox

* fix: remove OrgApi.ts file

* fix: cypress.json file remove credentials

* fix: downgrade react and react-dom packages

Co-authored-by: rahulramesha <rahul@appsmith.com>
2022-06-21 19:27:34 +05:30

78 lines
2.6 KiB
TypeScript

import React from "react";
import { render, screen } from "test/testUtils";
import DynamicTextFieldControl from "./DynamicTextFieldControl";
import { reduxForm } from "redux-form";
import { mockCodemirrorRender } from "test/__mocks__/CodeMirrorEditorMock";
import { PluginType } from "entities/Action";
import { waitFor } from "@testing-library/dom";
import userEvent from "@testing-library/user-event";
import { EvaluationSubstitutionType } from "entities/DataTree/dataTreeFactory";
import { DatasourceComponentTypes, UIComponentTypes } from "api/PluginApi";
function TestForm(props: any) {
return <div>{props.children}</div>;
}
const ReduxFormDecorator = reduxForm({
form: "TestForm",
initialValues: { name: "TestAction", datasource: { pluginId: "123" } },
})(TestForm);
describe("DynamicTextFieldControl", () => {
beforeEach(() => {
mockCodemirrorRender();
});
it("renders template menu correctly", () => {
render(
<ReduxFormDecorator>
<DynamicTextFieldControl
actionName="TestAction"
configProperty="actionConfiguration.body"
controlType="DYNAMIC_TEXT_FIELD_CONTROL"
createTemplate={jest.fn()}
evaluationSubstitutionType={EvaluationSubstitutionType.TEMPLATE}
formName="TestForm"
id={"test"}
isValid
label={"TestAction body"}
onPropertyChange={jest.fn()}
pluginId="123"
responseType={"TABLE"}
/>
</ReduxFormDecorator>,
{
url: "/?showTemplate=true",
initialState: {
entities: {
// @ts-expect-error: Types are not available
plugins: {
list: [
{
id: "123",
name: "testPlugin",
type: PluginType.DB,
packageName: "DB",
templates: {
CREATE: "test plugin template",
},
uiComponent: UIComponentTypes.DbEditorForm,
datasourceComponent: DatasourceComponentTypes.AutoForm,
},
],
},
},
},
},
);
const createTemplateButton = screen.getByText("Create");
userEvent.click(createTemplateButton);
// Test each word separately because they are in different spans
expect(screen.getByText("test")).toBeDefined();
expect(screen.getByText("plugin")).toBeDefined();
expect(screen.getByText("template")).toBeDefined();
waitFor(async () => {
await expect(screen.findByText("Create")).toBeNull();
});
});
});