fix: disallows page load to automatic transition in run behaviour for older actions (#40755)

## Description
This PR updates run behaviour logic so that it does not transition from
page load to automatic for older actions. This allows users to be
intentional about their choice to be automatic with older actions.

Fixes #40752   
_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.Sanity"

### 🔍 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/15271052226>
> Commit: 1aaa57506bd227d3e78eebce2919911a8ec54c43
> <a
href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=15271052226&attempt=1"
target="_blank">Cypress dashboard</a>.
> Tags: `@tag.Sanity`
> Spec:
> <hr>Tue, 27 May 2025 09:39:01 UTC
<!-- end of auto-generated comment: Cypress test results  -->


## Communication
Should the DevRel and Marketing teams inform users about this change?
- [ ] Yes
- [x] No


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

- **Tests**
- Added a new test to verify that executables with "ON_PAGE_LOAD" run
behavior are not incorrectly updated when a specific feature flag is
enabled.

- **Refactor**
- Simplified internal logic for checking run behavior, making the code
more concise without changing functionality.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: “sneha122” <“sneha@appsmith.com”>
This commit is contained in:
sneha122 2025-05-27 15:24:30 +05:30 committed by GitHub
parent 429e92727b
commit 4f6b1e627b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 40 additions and 4 deletions

View File

@ -316,13 +316,11 @@ public class OnLoadExecutablesUtilCEImpl implements OnLoadExecutablesUtilCE {
return featureFlagService
.check(FeatureFlagEnum.release_reactive_actions_enabled)
.flatMap(isReactiveActionsEnabled -> {
RunBehaviourEnum runBehaviourToCheck =
isReactiveActionsEnabled ? RunBehaviourEnum.AUTOMATIC : RunBehaviourEnum.ON_PAGE_LOAD;
// Before we update the actions, fetch all the actions which are currently set to execute on load.
Mono<List<Executable>> existingOnLoadExecutablesMono = creatorContextExecutablesFlux
.flatMap(executable -> {
if (runBehaviourToCheck.equals(executable.getRunBehaviour())) {
if (RunBehaviourEnum.AUTOMATIC.equals(executable.getRunBehaviour())
|| RunBehaviourEnum.ON_PAGE_LOAD.equals(executable.getRunBehaviour())) {
return Mono.just(executable);
}
return Mono.empty();

View File

@ -476,6 +476,44 @@ public class OnLoadExecutablesUtilCEImplTest {
assert executableUpdates.isEmpty();
}
@Test
public void testUpdateExecutablesRunBehaviour_WhenExistingIsOnPageLoadAndFlagEnabled_ShouldNotUpdateToAutomatic() {
// Setup
String creatorId = "testCreatorId";
CreatorContextType creatorType = CreatorContextType.PAGE;
List<LayoutExecutableUpdateDTO> executableUpdatesRef = new ArrayList<>();
List<String> messagesRef = new ArrayList<>();
// Existing action is ON_PAGE_LOAD
ActionDTO existingAction = createTestExecutable("Api1", RunBehaviourEnum.ON_PAGE_LOAD);
existingAction.setId("api1Id");
existingAction.setUserSetOnLoad(FALSE);
// Updated action comes in onLoadExecutables (should not trigger AUTOMATIC)
ActionDTO updatedAction = createTestExecutable("Api1", RunBehaviourEnum.ON_PAGE_LOAD);
updatedAction.setId("api1Id");
updatedAction.setUserSetOnLoad(FALSE);
List<Executable> onLoadExecutables = List.of(updatedAction);
List<Executable> allExecutables = List.of(existingAction);
// Mock behavior
when(featureFlagService.check(FeatureFlagEnum.release_reactive_actions_enabled))
.thenReturn(Mono.just(TRUE));
when(executableOnLoadService.getAllExecutablesByCreatorIdFlux(anyString()))
.thenReturn(Flux.fromIterable(allExecutables));
// Should not call updateUnpublishedExecutable at all
// Execute
Mono<Boolean> result = onLoadExecutablesUtilCE.updateExecutablesRunBehaviour(
onLoadExecutables, creatorId, executableUpdatesRef, messagesRef, creatorType);
// Verify
StepVerifier.create(result).expectNext(true).verifyComplete();
// Should not update run behaviour to AUTOMATIC
verify(executableOnLoadService, times(0)).updateUnpublishedExecutable(anyString(), any(ActionDTO.class));
}
// Helper methods to create test executables
private List<Executable> createTestExecutables(String... names) {
List<Executable> executables = new ArrayList<>();