Skip to content

Commit fe0b500

Browse files
committed
Refactor: Replace RUN_BEHAVIOR_VALUES with JS_OBJECT_RUN_BEHAVIOR_VALUES in utils and tests
- Introduced JS_OBJECT_RUN_BEHAVIOR_VALUES to include the new ON_PAGE_UNLOAD action run behavior. - Updated references in the JSEditor utility functions and tests to use the new constant for consistency and improved functionality. - Ensured all related tests reflect the changes to maintain expected behavior under various feature flag states.
1 parent 5bc697d commit fe0b500

File tree

3 files changed

+14
-10
lines changed

3 files changed

+14
-10
lines changed

app/client/src/constants/AppsmithActionConstants/formConfig/PluginSettings.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ export const RUN_BEHAVIOR_VALUES = [
2121
value: ActionRunBehaviour.MANUAL,
2222
children: "Manual",
2323
},
24+
];
25+
26+
export const JS_OBJECT_RUN_BEHAVIOR_VALUES = [
27+
...RUN_BEHAVIOR_VALUES,
2428
{
2529
label: "On page unload",
2630
subText: "Query runs when the page unloads or when manually triggered",

app/client/src/pages/Editor/JSEditor/JSEditorToolbar/components/utils.test.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
getDefaultRunBehaviorOptionWhenFeatureFlagIsDisabled,
77
getRunBehaviorOptionsBasedOnFeatureFlags,
88
} from "./utils";
9-
import { RUN_BEHAVIOR_VALUES } from "constants/AppsmithActionConstants/formConfig/PluginSettings";
9+
import { JS_OBJECT_RUN_BEHAVIOR_VALUES } from "constants/AppsmithActionConstants/formConfig/PluginSettings";
1010
import type { SelectOptionProps } from "@appsmith/ads";
1111

1212
describe("getRunBehaviorOptions", () => {
@@ -19,26 +19,26 @@ describe("getRunBehaviorOptions", () => {
1919
{
2020
isReactiveActionsEnabled: true,
2121
isOnPageUnloadEnabled: true,
22-
expectedOptions: RUN_BEHAVIOR_VALUES,
22+
expectedOptions: JS_OBJECT_RUN_BEHAVIOR_VALUES,
2323
},
2424
{
2525
isReactiveActionsEnabled: false,
2626
isOnPageUnloadEnabled: true,
27-
expectedOptions: RUN_BEHAVIOR_VALUES.filter(
27+
expectedOptions: JS_OBJECT_RUN_BEHAVIOR_VALUES.filter(
2828
(option) => option.value !== ActionRunBehaviour.AUTOMATIC,
2929
),
3030
},
3131
{
3232
isReactiveActionsEnabled: true,
3333
isOnPageUnloadEnabled: false,
34-
expectedOptions: RUN_BEHAVIOR_VALUES.filter(
34+
expectedOptions: JS_OBJECT_RUN_BEHAVIOR_VALUES.filter(
3535
(option) => option.value !== ActionRunBehaviour.ON_PAGE_UNLOAD,
3636
),
3737
},
3838
{
3939
isReactiveActionsEnabled: false,
4040
isOnPageUnloadEnabled: false,
41-
expectedOptions: RUN_BEHAVIOR_VALUES.filter(
41+
expectedOptions: JS_OBJECT_RUN_BEHAVIOR_VALUES.filter(
4242
(option) =>
4343
option.value !== ActionRunBehaviour.AUTOMATIC &&
4444
option.value !== ActionRunBehaviour.ON_PAGE_UNLOAD,
@@ -65,11 +65,11 @@ describe("getRunBehaviorOptions", () => {
6565

6666
describe("getDefaultRunBehaviorOptionWhenFeatureFlagIsDisabled", () => {
6767
const onPageLoadOption =
68-
RUN_BEHAVIOR_VALUES.find(
68+
JS_OBJECT_RUN_BEHAVIOR_VALUES.find(
6969
(option) => option.value === ActionRunBehaviour.ON_PAGE_LOAD,
7070
) ?? null;
7171
const manualOption =
72-
RUN_BEHAVIOR_VALUES.find(
72+
JS_OBJECT_RUN_BEHAVIOR_VALUES.find(
7373
(option) => option.value === ActionRunBehaviour.MANUAL,
7474
) ?? null;
7575

@@ -141,7 +141,7 @@ describe("getDefaultRunBehaviorOptionWhenFeatureFlagIsDisabled", () => {
141141
runBehaviour,
142142
isReactiveActionsEnabled,
143143
isOnPageUnloadEnabled,
144-
RUN_BEHAVIOR_VALUES,
144+
JS_OBJECT_RUN_BEHAVIOR_VALUES,
145145
);
146146

147147
expect(option).toEqual(expectedOption);

app/client/src/pages/Editor/JSEditor/JSEditorToolbar/components/utils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import {
22
ActionRunBehaviour,
33
type ActionRunBehaviourType,
44
} from "PluginActionEditor/types/PluginActionTypes";
5-
import { RUN_BEHAVIOR_VALUES } from "constants/AppsmithActionConstants/formConfig/PluginSettings";
5+
import { JS_OBJECT_RUN_BEHAVIOR_VALUES } from "constants/AppsmithActionConstants/formConfig/PluginSettings";
66

77
import { type SelectOptionProps } from "@appsmith/ads";
88
/**
@@ -14,7 +14,7 @@ export const getRunBehaviorOptionsBasedOnFeatureFlags = (
1414
isReactiveActionsEnabled: boolean,
1515
isOnPageUnloadEnabled: boolean,
1616
) =>
17-
RUN_BEHAVIOR_VALUES.filter(
17+
JS_OBJECT_RUN_BEHAVIOR_VALUES.filter(
1818
(option) =>
1919
(isReactiveActionsEnabled ||
2020
option.value !== ActionRunBehaviour.AUTOMATIC) &&

0 commit comments

Comments
 (0)