fix: jest test failures coz of getIsAnvilLayout (#32664)

[![workerB](https://img.shields.io/endpoint?url=https%3A%2F%2Fworkerb.linearb.io%2Fv2%2Fbadge%2Fprivate%2FU2FsdGVkX1JO6UjhWrZEl6JP180WytEbimcxoUzA0%2Fcollaboration.svg%3FcacheSeconds%3D60)](https://workerb.linearb.io/v2/badge/collaboration-page?magicLinkId=8xbfQu9)
## Description
> [!TIP]  
> _Add a TL;DR when the description is longer than 500 words or
extremely technical (helps the content team)._
>
> _Please also include relevant motivation and context. List any
dependencies that are required for this change. Add links to Notion,
Figma or any other documents that might be relevant to the PR._

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.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/8679486679>
> Commit: fe97e718498f1974e3604ae20160e99918f9c35c
> Cypress dashboard url: <a
href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=8679486679&attempt=1"
target="_blank">Click here!</a>

<!-- end of auto-generated comment: Cypress test results  -->








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

## Summary by CodeRabbit

- **Refactor**
- Simplified the logic for determining the layout system type in the
app.
- **Tests**
- Updated test files to remove unnecessary mock implementations related
to layout system checks.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
Ashok Kumar M 2024-04-15 09:17:23 +05:30 committed by GitHub
parent efac5bfe8e
commit 353c91b8fa
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 4 additions and 21 deletions

View File

@ -1,6 +1,5 @@
import type { AppState } from "@appsmith/reducers";
import { LayoutComponentTypes, type LayoutProps } from "../utils/anvilTypes";
import { createSelector } from "reselect";
import { selectFeatureFlagCheck } from "@appsmith/selectors/featureFlagsSelectors";
import { FEATURE_FLAG } from "@appsmith/entities/FeatureFlag";
import { LayoutSystemTypes } from "layoutSystems/types";
@ -10,12 +9,10 @@ export const getIsAnvilLayoutEnabled = (state: AppState) => {
return selectFeatureFlagCheck(state, FEATURE_FLAG.release_anvil_enabled);
};
export const getIsAnvilLayout = createSelector(
getLayoutSystemType,
(layoutSystemType) => {
return layoutSystemType === LayoutSystemTypes.ANVIL;
},
);
export const getIsAnvilLayout = (state: AppState) => {
const layoutSystemType = getLayoutSystemType(state);
return layoutSystemType === LayoutSystemTypes.ANVIL;
};
// ToDo: This is a placeholder implementation this is bound to change
export function getDropTargetLayoutId(state: AppState, canvasId: string) {

View File

@ -13,7 +13,6 @@ import { sagasToRunForTests } from "test/sagas";
import {
MockApplication,
mockCreateCanvasWidget,
mockGetIsAnvilLayout,
mockGetWidgetEvalValues,
MockPageDSL,
syntheticTestMouseEvent,
@ -24,16 +23,12 @@ import { generateReactKey } from "utils/generators";
import * as widgetRenderUtils from "utils/widgetRenderUtils";
import * as widgetSelectionsActions from "actions/widgetSelectionActions";
import { SelectionRequestType } from "sagas/WidgetSelectUtils";
import * as anvilSelectors from "layoutSystems/anvil/integrations/selectors";
import Canvas from "pages/Editor/Canvas";
describe("Canvas selection test cases", () => {
jest
.spyOn(dataTreeSelectors, "getWidgetEvalValues")
.mockImplementation(mockGetWidgetEvalValues);
jest
.spyOn(anvilSelectors, "getIsAnvilLayout")
.mockImplementation(mockGetIsAnvilLayout);
jest
.spyOn(utilities, "computeMainContainerWidget")
.mockImplementation((widget) => widget as any);

View File

@ -1,14 +1,9 @@
import * as anvilSelectors from "layoutSystems/anvil/integrations/selectors";
import { mockGetIsAnvilLayout } from "test/testCommon";
import WidgetFactory from "WidgetProvider/factory";
import { BlueprintOperationTypes } from "WidgetProvider/constants";
import type { BlueprintOperation } from "./WidgetBlueprintSagas";
import { executeWidgetBlueprintChildOperations } from "./WidgetBlueprintSagas";
jest
.spyOn(anvilSelectors, "getIsAnvilLayout")
.mockImplementation(mockGetIsAnvilLayout);
describe("WidgetBlueprintSagas", () => {
it("should returns widgets after executing the child operation", async () => {
const mockBlueprintChildOperation: BlueprintOperation = {

View File

@ -137,10 +137,6 @@ export const mockGetWidgetEvalValues = (
) as WidgetEntity;
};
export const mockGetIsAnvilLayout = (state: AppState) => {
return false;
};
export const syntheticTestMouseEvent = (
event: MouseEvent,
optionsToAdd = {},