From c028cf083c24beec2c4e4e6a6f8d5756535f60f6 Mon Sep 17 00:00:00 2001 From: Nilansh Bansal Date: Sun, 28 May 2023 00:43:26 +0530 Subject: [PATCH] fix: Resetting forking enabled field (#23604) ## Description > This PR resets the `forkingEnabled` field when the application is forked/cloned or imported in the newly created app. Fixes #23584 #### Type of change - Bug fix (non-breaking change which fixes an issue) ## Testing > #### How Has This Been Tested? - [x] JUnit #### Test Plan > Add Testsmith test cases links that relate to this PR > > #### Issues raised during DP testing > Link issues raised during DP testing for better visiblity and tracking (copy link from comments dropped on this PR) > > > ## Checklist: #### Dev activity - [x] My code follows the style guidelines of this project - [x] I have performed a self-review of my own code - [x] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [x] I have added tests that prove my fix is effective or that my feature works - [x] New and existing unit tests pass locally with my changes - [ ] PR is being merged under a feature flag #### QA activity: - [ ] [Speedbreak features](https://github.com/appsmithorg/TestSmith/wiki/Test-plan-implementation#speedbreaker-features-to-consider-for-every-change) have been covered - [ ] Test plan covers all impacted features and [areas of interest](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans/_edit#areas-of-interest) - [ ] Test plan has been peer reviewed by project stakeholders and other QA members - [ ] Manually tested functionality on DP - [ ] We had an implementation alignment call with stakeholders post QA Round 2 - [ ] Cypress test cases have been added and approved by SDET/manual QA - [ ] Added `Test Plan Approved` label after Cypress tests were reviewed - [ ] Added `Test Plan Approved` label after JUnit tests were reviewed --- .../main/java/com/appsmith/server/domains/Application.java | 1 + .../solutions/ce/ForkExamplesWorkspaceServiceCEImpl.java | 4 +++- .../solutions/ce/ImportExportApplicationServiceCEImpl.java | 5 +++++ .../server/services/ce/ApplicationServiceCETest.java | 2 ++ .../server/solutions/ApplicationForkingServiceTests.java | 5 +++++ .../solutions/ImportExportApplicationServiceTests.java | 1 + 6 files changed, 17 insertions(+), 1 deletion(-) diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/domains/Application.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/domains/Application.java index 22f6ba381b..6da35b029a 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/domains/Application.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/domains/Application.java @@ -260,6 +260,7 @@ public class Application extends BaseDomain { this.setPublishedCustomJSLibs(new HashSet<>()); this.setExportWithConfiguration(null); this.setForkWithConfiguration(null); + this.setForkingEnabled(null); super.sanitiseToExportDBObject(); } diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/ce/ForkExamplesWorkspaceServiceCEImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/ce/ForkExamplesWorkspaceServiceCEImpl.java index 1f1faf2ac4..b2ac08a812 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/ce/ForkExamplesWorkspaceServiceCEImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/ce/ForkExamplesWorkspaceServiceCEImpl.java @@ -222,9 +222,11 @@ public class ForkExamplesWorkspaceServiceCEImpl implements ForkExamplesWorkspace } else { forkWithConfig = Boolean.FALSE; } - // Setting the forkWithConfiguration and exportWithConfiguration to null for newly forked app + // Setting the forkWithConfiguration, exportWithConfiguration and forkingEnabled fields to null for + // newly forked app application.setForkWithConfiguration(null); application.setExportWithConfiguration(null); + application.setForkingEnabled(null); final String defaultPageId = application.getPages() .stream() diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/ce/ImportExportApplicationServiceCEImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/ce/ImportExportApplicationServiceCEImpl.java index 829cd382da..e9bae4dcca 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/ce/ImportExportApplicationServiceCEImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/ce/ImportExportApplicationServiceCEImpl.java @@ -833,6 +833,9 @@ public class ImportExportApplicationServiceCEImpl implements ImportExportApplica importedApplication.setPages(null); importedApplication.setPublishedPages(null); + //re-setting the properties + importedApplication.setForkWithConfiguration(null); + importedApplication.setExportWithConfiguration(null); // Start the stopwatch to log the execution time Stopwatch stopwatch = new Stopwatch(AnalyticsEvents.IMPORT.getEventName()); @@ -2235,7 +2238,9 @@ public class ImportExportApplicationServiceCEImpl implements ImportExportApplica applicationJson.getExportedApplication().setName(null); applicationJson.getExportedApplication().setSlug(null); applicationJson.getExportedApplication().setForkingEnabled(null); + applicationJson.getExportedApplication().setForkWithConfiguration(null); applicationJson.getExportedApplication().setClonedFromApplicationId(null); + applicationJson.getExportedApplication().setExportWithConfiguration(null); } // need to remove git sync id. Also filter pages if pageToImport is not empty diff --git a/app/server/appsmith-server/src/test/java/com/appsmith/server/services/ce/ApplicationServiceCETest.java b/app/server/appsmith-server/src/test/java/com/appsmith/server/services/ce/ApplicationServiceCETest.java index df320f0add..73cc7c2aa7 100644 --- a/app/server/appsmith-server/src/test/java/com/appsmith/server/services/ce/ApplicationServiceCETest.java +++ b/app/server/appsmith-server/src/test/java/com/appsmith/server/services/ce/ApplicationServiceCETest.java @@ -3619,6 +3619,7 @@ public class ApplicationServiceCETest { testApplication.setName(applicationName); testApplication.setExportWithConfiguration(TRUE); testApplication.setForkWithConfiguration(TRUE); + testApplication.setForkingEnabled(TRUE); Application application = applicationPageService.createApplication(testApplication, workspaceId).block(); Mono clonedApplicationMono = applicationPageService.cloneApplication(application.getId(), null); @@ -3627,6 +3628,7 @@ public class ApplicationServiceCETest { StepVerifier.create(clonedApplicationMono).assertNext(clonedApplication -> { assertThat(clonedApplication.getExportWithConfiguration()).isNull(); assertThat(clonedApplication.getForkWithConfiguration()).isNull(); + assertThat(clonedApplication.getForkingEnabled()).isNull(); }).verifyComplete(); } } diff --git a/app/server/appsmith-server/src/test/java/com/appsmith/server/solutions/ApplicationForkingServiceTests.java b/app/server/appsmith-server/src/test/java/com/appsmith/server/solutions/ApplicationForkingServiceTests.java index e1609302c3..e1da7ebabe 100644 --- a/app/server/appsmith-server/src/test/java/com/appsmith/server/solutions/ApplicationForkingServiceTests.java +++ b/app/server/appsmith-server/src/test/java/com/appsmith/server/solutions/ApplicationForkingServiceTests.java @@ -911,6 +911,7 @@ public class ApplicationForkingServiceTests { Application srcApp = applicationPageService.createApplication(application, srcWorkspace.getId()).block(); srcApp.setForkWithConfiguration(true); srcApp.setExportWithConfiguration(true); + srcApp.setForkingEnabled(true); Application resultApplication = applicationForkingService .forkApplicationToWorkspaceWithEnvironment(srcApp.getId(), targetWorkspaceId, createdSrcDefaultEnvironmentId) .block(); @@ -922,6 +923,7 @@ public class ApplicationForkingServiceTests { assertThat(forkedApplication).isNotNull(); assertThat(forkedApplication.getForkWithConfiguration()).isNull(); assertThat(forkedApplication.getExportWithConfiguration()).isNull(); + assertThat(forkedApplication.getForkingEnabled()).isNull(); }) .verifyComplete(); } @@ -1018,6 +1020,7 @@ public class ApplicationForkingServiceTests { assertThat(forkedApplicationImportDTO.getIsPartialImport()).isTrue(); assertThat(forkedApplication.getForkWithConfiguration()).isNull(); assertThat(forkedApplication.getExportWithConfiguration()).isNull(); + assertThat(forkedApplication.getForkingEnabled()).isNull(); }) .verifyComplete(); @@ -1050,6 +1053,7 @@ public class ApplicationForkingServiceTests { assertThat(forkedApplicationImportDTO.getIsPartialImport()).isFalse(); assertThat(forkedApplication.getForkWithConfiguration()).isNull(); assertThat(forkedApplication.getExportWithConfiguration()).isNull(); + assertThat(forkedApplication.getForkingEnabled()).isNull(); }) .verifyComplete(); @@ -1082,6 +1086,7 @@ public class ApplicationForkingServiceTests { assertThat(forkedApplicationImportDTO.getIsPartialImport()).isFalse(); assertThat(forkedApplication.getForkWithConfiguration()).isNull(); assertThat(forkedApplication.getExportWithConfiguration()).isNull(); + assertThat(forkedApplication.getForkingEnabled()).isNull(); }) .verifyComplete(); diff --git a/app/server/appsmith-server/src/test/java/com/appsmith/server/solutions/ImportExportApplicationServiceTests.java b/app/server/appsmith-server/src/test/java/com/appsmith/server/solutions/ImportExportApplicationServiceTests.java index a7fd45fe87..fb638694ab 100644 --- a/app/server/appsmith-server/src/test/java/com/appsmith/server/solutions/ImportExportApplicationServiceTests.java +++ b/app/server/appsmith-server/src/test/java/com/appsmith/server/solutions/ImportExportApplicationServiceTests.java @@ -366,6 +366,7 @@ public class ImportExportApplicationServiceTests { assertThat(exportedApplication.getPublishedModeThemeId()).isNull(); assertThat(exportedApplication.getExportWithConfiguration()).isNull(); assertThat(exportedApplication.getForkWithConfiguration()).isNull(); + assertThat(exportedApplication.getForkingEnabled()).isNull(); }) .verifyComplete(); }