PromucFlow_constructor/app/client/src/selectors/debuggerSelectors.test.ts
Ayush Pahwa 7d621de978
feat: console log implementation in appsmith (#16286)
* feat: capture console from across the app (#15676)

* create: console override file

- Adds methods to override the given console functionality to capture the console statements written by the user

* update: evaluate function to extract console op

- Added logs extraction for both sync and async functions
- Adding them to the return object of the evaluations

* update: timestamp field to log addition method

- Added optional argument to function definition for inputting the timestamp of the log
- This is done to maintain timings of the execution of the log

* update: interface for log objects

* update: post function execution logic

- Added logic to push the logs generated by the evaluation to the logs store

* update: added handling for sending nested fns

- While console logging functions or objects that had functions was causing an error
- Added a check for removing functions and replacing them with name of the functions instead

* chore: added types and comments

* fix: updated evaluation tests

* fix: added check for log in returned obj

* update: added the source data in the trigger logs

- Removed on js execute logs from showing up here since they are already handled. If they are not removed, they will show up on the first page load twice

* add: ellipsis function for log title string

- This is to keep big object contained in the first line only

* update: made logs reset function public

* update: resetting logs before new eval

- Logs object has to be cleared before next eval can happen to make sure there are no roll overs from last evals

* chore: added comments

* add: extracting logs after eval of functions

* add: storing logs to redux after eval

* refactor: updated types

* add: func to store logs w/ severity as arg

* refactor: updating func call for user logs

* chore: fixed elipsis logic

* chore: removed unused type

* chore: updated preview text logic

* add: type for transfer object post eval

* update: aded new userLogs obj to dataTreeEvaluator

* update: passing logs from object to saga

* update: parsing received userlogs

* refactor: used predefined fns

* refactor: moved resetlogs to common func

* chore: updated comments

* feat: update redux store and UI for system + user logs (#15936)

* update: updated types for the redux store

- Added category and data fields in the log object

* update: types of log redux store

* update: calls for the console log store function

* update: icon fetch func for log item UI

* update: syncing UI with the new designs (WIP)

* chore: fixed lint error

* update: filters for logs

* update: icon for clearing log filters

* update: filtering function

- Added checks against category and severity

* update: logitem UI

- updated type of the UI object
- added css based ellipsis
- added toggle for console logs
- added array of json views for objects/arrays
- css tweaks

* update: debugger cta

- Removed copy option
- Updated UI

* update: logic for expanding user logs

- Removed debugger CTA
- Fixed position for the expand/collapse icon
- Added joining char for when the log is expanded

* update: assets for new UI

- updated colors
- Added new icon

* hotfix: ternserver code

* add: search across the text of log

* update: icons for the app

* update: click to expand/collapse of logs

* fix: search keyword update on change within JSObjects

* fix: alignment of log items in both states

* update: jest tests for debugger errors and filter

* fix: drop down options color issue

- the icon used was not the standard one
- We have a lot of duplicates of the same icon

* fix: synced with ADS changes on release

* fix: remove dependency from old icon

* add: cypress selectors for automation testing

* fix: replaced static messages with variables

* fix: updated the dependency map for filter

* fix: height of the filter drop down

* fix: chaining logic for search filter

* fix: syncing the padding values to ADS

* fix: help icon visibility issue

* fix: width of filter dropdown

Co-authored-by: Rishabh-Rathod <rishabh.rathod@appsmith.com>

* add: e2e tests for console statements using IIFE

* test: added test for console logs in jsobjects

* fix: functionality of expanding context menu on msg click

* fix: added try catch and handling for numbers

* hotfix: handling unwanted toasts

* fix: alignment and clickable cursor

* fix: alignment of expanded span in console logs

* add: analytics event on new console log created

* fix: added handling for boolean and undefined

* fix: removed log reset from common func

- Whenever we are creating global DTO, the logs were being reset. This caused logs to reset whenever a promise was encountered in the logs.

* fix: combined JS log saving to widget process

* add: new analytics event on filter changed

* update: added handling for empty value

* update: removed comma between multiple logs

* update: synced test changes with release

* update: removed unused wait timings

* Logs spec script update

* update: ts methods in log spec e2e test

* logs spec update

* update: removed body clicks from test script

* Logs spec update

* update: removed ask from google option

* refactor: ui fixes

* fix: text selection of logs

* fix: updated dropdown width management

* update: made the flushlogs function async

* update: added handling for promises

* update: added test with promises fail and pass

* fix: added sync variant to work for sync objects

* refactor: commented out unused tests

* update: exceptions in the name of log entity

* fix: pagination of logs to handle dynamic data stream

* fix: removed unused async function

* fix: moved logs handling to separate saga

* fix: color for context menu text

Co-authored-by: Rishabh-Rathod <rishabh.rathod@appsmith.com>
Co-authored-by: Aishwarya UR <aishwarya@appsmith.com>
2022-09-04 17:28:05 +05:30

876 lines
25 KiB
TypeScript

import { Severity, ENTITY_TYPE, LOG_CATEGORY } from "entities/AppsmithConsole";
import { DataTree } from "entities/DataTree/dataTreeFactory";
import { CanvasWidgetsReduxState } from "reducers/entityReducers/canvasWidgetsReducer";
import { PropertyEvaluationErrorType } from "utils/DynamicBindingUtils";
import { getFilteredErrors } from "./debuggerSelectors";
describe("getFilteredErrors", () => {
it("hides error from hidden widget in main canvas", () => {
const TestData = {
debuggerErrors: {
"main_input_id-defaultText": {
id: "main_input_id-defaultText",
logType: 5,
text: "The value at defaultText is invalid",
messages: [
{
message:
"TypeError: Cannot read properties of undefined (reading 'users')",
type: PropertyEvaluationErrorType.PARSE,
},
],
source: {
id: "main_input_id",
name: "main_input",
type: ENTITY_TYPE.WIDGET,
propertyPath: "defaultText",
},
state: {
defaultText: "",
},
analytics: {
widgetType: "INPUT_WIDGET_V2",
},
severity: Severity.ERROR,
timestamp: "02:40:10",
category: LOG_CATEGORY.PLATFORM_GENERATED,
},
},
canvasWidgets: {
main_input_id: {
widgetName: "main_input",
type: "INPUT_WIDGET_V2",
widgetId: "main_input_id",
parentId: "0",
},
},
dataTree: {
main_input: {
isVisible: false,
parentId: "0",
widgetId: "main_input_id",
type: "INPUT_WIDGET_V2",
ENTITY_TYPE: ENTITY_TYPE.WIDGET,
},
},
expectedResult: {},
};
const result = getFilteredErrors.resultFunc(
TestData.debuggerErrors,
false,
(TestData.canvasWidgets as unknown) as CanvasWidgetsReduxState,
(TestData.dataTree as unknown) as DataTree,
);
expect(result).toStrictEqual(TestData.expectedResult);
});
it("hides error from widget in closed modal", () => {
const TestData = {
debuggerErrors: {
"modal_input-defaultText": {
id: "modal_input-defaultText",
logType: 5,
text: "The value at defaultText is invalid",
messages: [
{
message:
"TypeError: Cannot read properties of undefined (reading 'users')",
type: PropertyEvaluationErrorType.PARSE,
},
],
source: {
id: "modal_input",
name: "ModalInput",
type: ENTITY_TYPE.WIDGET,
propertyPath: "defaultText",
},
state: {
defaultText: "",
},
analytics: {
widgetType: "INPUT_WIDGET_V2",
},
severity: Severity.ERROR,
category: LOG_CATEGORY.PLATFORM_GENERATED,
timestamp: "02:40:10",
},
},
canvasWidgets: {
modal_input: {
widgetName: "ModalInput",
type: "INPUT_WIDGET_V2",
widgetId: "modal_input",
parentId: "modal_canvas_id",
},
modal_canvas_id: {
widgetName: "ModalCanvas",
type: "CANVAS_WIDGET",
widgetId: "modal_canvas_id",
parentId: "modal1_id",
},
modal1_id: {
widgetName: "Modal1",
type: "MODAL_WIDGET",
widgetId: "modal1_id",
parentId: "0",
},
},
dataTree: {
ModalInput: {
isVisible: true,
parentId: "modal_canvas_id",
widgetId: "modal_input",
type: "INPUT_WIDGET_V2",
ENTITY_TYPE: ENTITY_TYPE.WIDGET,
},
ModalCanvas: {
isVisible: true,
type: "CANVAS_WIDGET",
widgetId: "modal_canvas_id",
parentId: "modal1_id",
ENTITY_TYPE: ENTITY_TYPE.WIDGET,
},
Modal1: {
isVisible: false,
type: "MODAL_WIDGET",
widgetId: "modal1_id",
parentId: "0",
ENTITY_TYPE: ENTITY_TYPE.WIDGET,
},
},
expectedResult: {},
};
const result = getFilteredErrors.resultFunc(
TestData.debuggerErrors,
false,
(TestData.canvasWidgets as unknown) as CanvasWidgetsReduxState,
(TestData.dataTree as unknown) as DataTree,
);
expect(result).toStrictEqual(TestData.expectedResult);
});
it("hides error from widget in non-active tab", () => {
const TestData = {
debuggerErrors: {
"tab2_input-defaultText": {
id: "tab2_input-defaultText",
logType: 5,
text: "The value at defaultText is invalid",
messages: [
{
message:
"TypeError: Cannot read properties of undefined (reading 'users')",
type: PropertyEvaluationErrorType.PARSE,
},
],
source: {
id: "tab2_input",
name: "Tab2Input",
type: ENTITY_TYPE.WIDGET,
propertyPath: "defaultText",
},
state: {
defaultText: "",
},
analytics: {
widgetType: "INPUT_WIDGET_V2",
},
severity: Severity.ERROR,
category: LOG_CATEGORY.PLATFORM_GENERATED,
timestamp: "02:40:10",
},
},
canvasWidgets: {
tab1_id: {
tabId: "tab1",
widgetName: "Tab1Canvas",
type: "CANVAS_WIDGET",
tabName: "Tab 1",
widgetId: "tab1_id",
parentId: "tabs_widget_id",
},
tab2_input: {
widgetName: "Tab2Input",
type: "INPUT_WIDGET_V2",
widgetId: "tab2_input",
parentId: "tab2_id",
},
tab2_id: {
tabId: "tab2",
widgetName: "Tab2Canvas",
type: "CANVAS_WIDGET",
tabName: "Tab 2",
widgetId: "tab2_id",
parentId: "tabs_widget_id",
},
tabs_widget_id: {
widgetName: "Tabs1",
type: "TABS_WIDGET",
widgetId: "tabs_widget_id",
defaultTab: "Tab 1",
parentId: "0",
},
},
dataTree: {
Tab1Canvas: {
tabId: "tab1",
type: "CANVAS_WIDGET",
tabName: "Tab 1",
widgetId: "tab1_id",
isVisible: true,
parentId: "tabs_widget_id",
ENTITY_TYPE: "WIDGET",
},
Tab2Input: {
type: "INPUT_WIDGET_V2",
widgetId: "tab2_input",
isVisible: true,
parentId: "tab2_id",
ENTITY_TYPE: "WIDGET",
},
Tab2Canvas: {
tabId: "tab2",
tabName: "Tab 2",
widgetId: "tab2_id",
isVisible: true,
parentId: "tabs_widget_id",
ENTITY_TYPE: "WIDGET",
},
Tabs1: {
isVisible: true,
widgetName: "Tabs1",
type: "TABS_WIDGET",
widgetId: "tabs_widget_id",
defaultTab: "Tab 1",
parentId: "0",
selectedTab: "Tab 1",
ENTITY_TYPE: "WIDGET",
},
},
expectedResult: {},
};
const result = getFilteredErrors.resultFunc(
TestData.debuggerErrors,
false,
(TestData.canvasWidgets as unknown) as CanvasWidgetsReduxState,
(TestData.dataTree as unknown) as DataTree,
);
expect(result).toStrictEqual(TestData.expectedResult);
});
it("hides error from widget in active tab (hidden tab widget)", () => {
const TestData = {
debuggerErrors: {
"tab2_input-defaultText": {
id: "tab2_input-defaultText",
logType: 5,
text: "The value at defaultText is invalid",
messages: [
{
message:
"TypeError: Cannot read properties of undefined (reading 'users')",
type: PropertyEvaluationErrorType.PARSE,
},
],
source: {
id: "tab2_input",
name: "Tab2Input",
type: ENTITY_TYPE.WIDGET,
propertyPath: "defaultText",
},
state: {
defaultText: "",
},
analytics: {
widgetType: "INPUT_WIDGET_V2",
},
severity: Severity.ERROR,
category: LOG_CATEGORY.PLATFORM_GENERATED,
timestamp: "02:40:10",
},
},
canvasWidgets: {
tab1_id: {
tabId: "tab1",
widgetName: "Tab1Canvas",
type: "CANVAS_WIDGET",
tabName: "Tab 1",
widgetId: "tab1_id",
parentId: "tabs_widget_id",
},
tab2_input: {
widgetName: "Tab2Input",
type: "INPUT_WIDGET_V2",
widgetId: "tab2_input",
parentId: "tab2_id",
},
tab2_id: {
tabId: "tab2",
widgetName: "Tab2Canvas",
type: "CANVAS_WIDGET",
tabName: "Tab 2",
widgetId: "tab2_id",
parentId: "tabs_widget_id",
},
tabs_widget_id: {
widgetName: "Tabs1",
type: "TABS_WIDGET",
widgetId: "tabs_widget_id",
defaultTab: "Tab 1",
parentId: "0",
},
},
dataTree: {
Tab1Canvas: {
tabId: "tab1",
type: "CANVAS_WIDGET",
tabName: "Tab 1",
widgetId: "tab1_id",
isVisible: true,
parentId: "tabs_widget_id",
ENTITY_TYPE: "WIDGET",
},
Tab2Input: {
type: "INPUT_WIDGET_V2",
widgetId: "tab2_input",
isVisible: true,
parentId: "tab2_id",
ENTITY_TYPE: "WIDGET",
},
Tab2Canvas: {
tabId: "tab2",
tabName: "Tab 2",
widgetId: "tab2_id",
isVisible: true,
parentId: "tabs_widget_id",
ENTITY_TYPE: "WIDGET",
},
Tabs1: {
isVisible: false,
widgetName: "Tabs1",
type: "TABS_WIDGET",
widgetId: "tabs_widget_id",
defaultTab: "Tab 1",
parentId: "0",
selectedTab: "Tab 2",
ENTITY_TYPE: "WIDGET",
},
},
expectedResult: {},
};
const result = getFilteredErrors.resultFunc(
TestData.debuggerErrors,
false,
(TestData.canvasWidgets as unknown) as CanvasWidgetsReduxState,
(TestData.dataTree as unknown) as DataTree,
);
expect(result).toStrictEqual(TestData.expectedResult);
});
it("hides error from widget in active tab (tab widget inside hidden container)", () => {
const TestData = {
debuggerErrors: {
"tab2_input-defaultText": {
id: "tab2_input-defaultText",
logType: 5,
text: "The value at defaultText is invalid",
messages: [
{
message:
"TypeError: Cannot read properties of undefined (reading 'users')",
type: PropertyEvaluationErrorType.PARSE,
},
],
source: {
id: "tab2_input",
name: "Tab2Input",
type: ENTITY_TYPE.WIDGET,
propertyPath: "defaultText",
},
state: {
defaultText: "",
},
analytics: {
widgetType: "INPUT_WIDGET_V2",
},
severity: Severity.ERROR,
category: LOG_CATEGORY.PLATFORM_GENERATED,
timestamp: "02:40:10",
},
},
canvasWidgets: {
tab1_id: {
tabId: "tab1",
widgetName: "Tab1Canvas",
type: "CANVAS_WIDGET",
tabName: "Tab 1",
widgetId: "tab1_id",
parentId: "tabs_widget_id",
},
tab2_input: {
widgetName: "Tab2Input",
type: "INPUT_WIDGET_V2",
widgetId: "tab2_input",
parentId: "tab2_id",
},
tab2_id: {
tabId: "tab2",
widgetName: "Tab2Canvas",
type: "CANVAS_WIDGET",
tabName: "Tab 2",
widgetId: "tab2_id",
parentId: "tabs_widget_id",
},
tabs_widget_id: {
widgetName: "Tabs1",
type: "TABS_WIDGET",
widgetId: "tabs_widget_id",
defaultTab: "Tab 1",
parentId: "canvas_widget_id",
},
canvas_widget_id: {
widgetName: "ContainerCanvas",
type: "CANVAS_WIDGET",
widgetId: "canvas_widget_id",
parentId: "container1_id",
},
container1_id: {
widgetName: "Container1",
type: "CONTAINER_WIDGET",
widgetId: "container1_id",
parentId: "0",
},
},
dataTree: {
Tab1Canvas: {
tabId: "tab1",
type: "CANVAS_WIDGET",
tabName: "Tab 1",
widgetId: "tab1_id",
isVisible: true,
parentId: "tabs_widget_id",
ENTITY_TYPE: "WIDGET",
},
Tab2Input: {
type: "INPUT_WIDGET_V2",
widgetId: "tab2_input",
isVisible: true,
parentId: "tab2_id",
ENTITY_TYPE: "WIDGET",
},
Tab2Canvas: {
tabId: "tab2",
tabName: "Tab 2",
widgetId: "tab2_id",
isVisible: true,
parentId: "tabs_widget_id",
ENTITY_TYPE: "WIDGET",
},
Tabs1: {
isVisible: true,
widgetName: "Tabs1",
type: "TABS_WIDGET",
widgetId: "tabs_widget_id",
defaultTab: "Tab 1",
parentId: "canvas_widget_id",
selectedTab: "Tab 2",
ENTITY_TYPE: "WIDGET",
},
ContainerCanvas: {
type: "CANVAS_WIDGET",
widgetId: "canvas_widget_id",
isVisible: true,
parentId: "container1_id",
ENTITY_TYPE: "WIDGET",
},
Container1: {
type: "CONTAINER_WIDGET",
widgetId: "container1_id",
isVisible: false,
parentId: "0",
ENTITY_TYPE: "WIDGET",
},
},
expectedResult: {},
};
const result = getFilteredErrors.resultFunc(
TestData.debuggerErrors,
false,
(TestData.canvasWidgets as unknown) as CanvasWidgetsReduxState,
(TestData.dataTree as unknown) as DataTree,
);
expect(result).toStrictEqual(TestData.expectedResult);
});
it("hides error from widget in hidden container", () => {
const TestData = {
debuggerErrors: {
"container1_input_id-defaultText": {
id: "container1_input_id-defaultText",
logType: 5,
text: "The value at defaultText is invalid",
messages: [
{
message:
"TypeError: Cannot read properties of undefined (reading 'users')",
type: PropertyEvaluationErrorType.PARSE,
},
],
source: {
id: "container1_input_id",
name: "container1_input",
type: ENTITY_TYPE.WIDGET,
propertyPath: "defaultText",
},
state: {
defaultText: "",
},
analytics: {
widgetType: "INPUT_WIDGET_V2",
},
severity: Severity.ERROR,
category: LOG_CATEGORY.PLATFORM_GENERATED,
timestamp: "02:40:10",
},
},
canvasWidgets: {
container1_input_id: {
widgetName: "container1_input",
type: "INPUT_WIDGET_V2",
widgetId: "container1_input_id",
parentId: "canvas_widget_id",
},
canvas_widget_id: {
widgetName: "ContainerCanvas",
type: "CANVAS_WIDGET",
widgetId: "canvas_widget_id",
parentId: "container1_id",
},
container1_id: {
widgetName: "Container1",
type: "CONTAINER_WIDGET",
widgetId: "container1_id",
parentId: "0",
},
},
dataTree: {
container1_input: {
type: "INPUT_WIDGET_V2",
widgetId: "container1_input_id",
isVisible: true,
parentId: "canvas_widget_id",
ENTITY_TYPE: "WIDGET",
},
ContainerCanvas: {
type: "CANVAS_WIDGET",
widgetId: "canvas_widget_id",
isVisible: true,
parentId: "container1_id",
ENTITY_TYPE: "WIDGET",
},
Container1: {
type: "CONTAINER_WIDGET",
widgetId: "container1_id",
isVisible: false,
parentId: "0",
ENTITY_TYPE: "WIDGET",
},
},
expectedResult: {},
};
const result = getFilteredErrors.resultFunc(
TestData.debuggerErrors,
false,
(TestData.canvasWidgets as unknown) as CanvasWidgetsReduxState,
(TestData.dataTree as unknown) as DataTree,
);
expect(result).toStrictEqual(TestData.expectedResult);
});
it("shows error for widget with faulty binding for isVisible prop", () => {
const TestData = {
debuggerErrors: {
"main_input_id-isVisible": {
id: "main_input_id-isVisible",
logType: 5,
text: "The value at isVisible is invalid",
messages: [
{
message:
"TypeError: Cannot read properties of undefined (reading 'users')",
type: PropertyEvaluationErrorType.PARSE,
},
],
source: {
id: "main_input_id",
name: "main_input",
type: ENTITY_TYPE.WIDGET,
propertyPath: "isVisible",
},
state: {
isVisible: "{{users}}",
},
analytics: {
widgetType: "INPUT_WIDGET_V2",
},
severity: Severity.ERROR,
category: LOG_CATEGORY.PLATFORM_GENERATED,
timestamp: "02:40:10",
},
},
canvasWidgets: {
main_input_id: {
widgetName: "main_input",
type: "INPUT_WIDGET_V2",
widgetId: "main_input_id",
parentId: "0",
},
},
dataTree: {
main_input: {
isVisible: false,
parentId: "0",
widgetId: "main_input_id",
type: "INPUT_WIDGET_V2",
ENTITY_TYPE: ENTITY_TYPE.WIDGET,
},
},
expectedResult: {
"main_input_id-isVisible": {
id: "main_input_id-isVisible",
logType: 5,
category: LOG_CATEGORY.PLATFORM_GENERATED,
text: "The value at isVisible is invalid",
messages: [
{
message:
"TypeError: Cannot read properties of undefined (reading 'users')",
type: PropertyEvaluationErrorType.PARSE,
},
],
source: {
id: "main_input_id",
name: "main_input",
type: ENTITY_TYPE.WIDGET,
propertyPath: "isVisible",
},
state: {
isVisible: "{{users}}",
},
analytics: {
widgetType: "INPUT_WIDGET_V2",
},
severity: Severity.ERROR,
timestamp: "02:40:10",
},
},
};
const result = getFilteredErrors.resultFunc(
TestData.debuggerErrors,
false,
(TestData.canvasWidgets as unknown) as CanvasWidgetsReduxState,
(TestData.dataTree as unknown) as DataTree,
);
expect(result).toStrictEqual(TestData.expectedResult);
});
it("shows error for widget with faulty binding for isVisible prop (visible parent container)", () => {
const TestData = {
debuggerErrors: {
"container1_input_id-isVisible": {
id: "container1_input_id-isVisible",
logType: 5,
text: "The value at isVisible is invalid",
messages: [
{
message:
"TypeError: Cannot read properties of undefined (reading 'users')",
type: PropertyEvaluationErrorType.PARSE,
},
],
source: {
id: "container1_input_id",
name: "container1_input",
type: ENTITY_TYPE.WIDGET,
propertyPath: "isVisible",
},
state: {
isVisible: "{{users}}",
},
analytics: {
widgetType: "INPUT_WIDGET_V2",
},
severity: Severity.ERROR,
category: LOG_CATEGORY.PLATFORM_GENERATED,
timestamp: "02:40:10",
},
},
canvasWidgets: {
container1_input_id: {
widgetName: "container1_input",
type: "INPUT_WIDGET_V2",
widgetId: "container1_input_id",
parentId: "canvas_widget_id",
},
canvas_widget_id: {
widgetName: "ContainerCanvas",
type: "CANVAS_WIDGET",
widgetId: "canvas_widget_id",
parentId: "container1_id",
},
container1_id: {
widgetName: "Container1",
type: "CONTAINER_WIDGET",
widgetId: "container1_id",
parentId: "0",
},
},
dataTree: {
container1_input: {
type: "INPUT_WIDGET_V2",
widgetId: "container1_input_id",
isVisible: false,
parentId: "canvas_widget_id",
ENTITY_TYPE: "WIDGET",
},
ContainerCanvas: {
type: "CANVAS_WIDGET",
widgetId: "canvas_widget_id",
isVisible: true,
parentId: "container1_id",
ENTITY_TYPE: "WIDGET",
},
Container1: {
type: "CONTAINER_WIDGET",
widgetId: "container1_id",
isVisible: true,
parentId: "0",
ENTITY_TYPE: "WIDGET",
},
},
expectedResult: {
"container1_input_id-isVisible": {
id: "container1_input_id-isVisible",
logType: 5,
text: "The value at isVisible is invalid",
messages: [
{
message:
"TypeError: Cannot read properties of undefined (reading 'users')",
type: PropertyEvaluationErrorType.PARSE,
},
],
source: {
id: "container1_input_id",
name: "container1_input",
type: ENTITY_TYPE.WIDGET,
propertyPath: "isVisible",
},
state: {
isVisible: "{{users}}",
},
analytics: {
widgetType: "INPUT_WIDGET_V2",
},
severity: Severity.ERROR,
category: LOG_CATEGORY.PLATFORM_GENERATED,
timestamp: "02:40:10",
},
},
};
const result = getFilteredErrors.resultFunc(
TestData.debuggerErrors,
false,
(TestData.canvasWidgets as unknown) as CanvasWidgetsReduxState,
(TestData.dataTree as unknown) as DataTree,
);
expect(result).toStrictEqual(TestData.expectedResult);
});
it("hides error for widget with faulty binding for isVisible prop (hidden parent container)", () => {
const TestData = {
debuggerErrors: {
"container1_input_id-isVisible": {
id: "container1_input_id-isVisible",
logType: 5,
text: "The value at isVisible is invalid",
messages: [
{
message:
"TypeError: Cannot read properties of undefined (reading 'users')",
type: PropertyEvaluationErrorType.PARSE,
},
],
source: {
id: "container1_input_id",
name: "container1_input",
type: ENTITY_TYPE.WIDGET,
propertyPath: "isVisible",
},
state: {
isVisible: "{{users}}",
},
analytics: {
widgetType: "INPUT_WIDGET_V2",
},
severity: Severity.ERROR,
category: LOG_CATEGORY.PLATFORM_GENERATED,
timestamp: "02:40:10",
},
},
canvasWidgets: {
container1_input_id: {
widgetName: "container1_input",
type: "INPUT_WIDGET_V2",
widgetId: "container1_input_id",
parentId: "canvas_widget_id",
},
canvas_widget_id: {
widgetName: "ContainerCanvas",
type: "CANVAS_WIDGET",
widgetId: "canvas_widget_id",
parentId: "container1_id",
},
container1_id: {
widgetName: "Container1",
type: "CONTAINER_WIDGET",
widgetId: "container1_id",
parentId: "0",
},
},
dataTree: {
container1_input: {
type: "INPUT_WIDGET_V2",
widgetId: "container1_input_id",
isVisible: false,
parentId: "canvas_widget_id",
ENTITY_TYPE: "WIDGET",
},
ContainerCanvas: {
type: "CANVAS_WIDGET",
widgetId: "canvas_widget_id",
isVisible: true,
parentId: "container1_id",
ENTITY_TYPE: "WIDGET",
},
Container1: {
type: "CONTAINER_WIDGET",
widgetId: "container1_id",
isVisible: false,
parentId: "0",
ENTITY_TYPE: "WIDGET",
},
},
expectedResult: {},
};
const result = getFilteredErrors.resultFunc(
TestData.debuggerErrors,
false,
(TestData.canvasWidgets as unknown) as CanvasWidgetsReduxState,
(TestData.dataTree as unknown) as DataTree,
);
expect(result).toStrictEqual(TestData.expectedResult);
});
});