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
This commit is contained in:
Nilansh Bansal 2023-05-28 00:43:26 +05:30 committed by GitHub
parent ee219bef43
commit c028cf083c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 17 additions and 1 deletions

View File

@ -260,6 +260,7 @@ public class Application extends BaseDomain {
this.setPublishedCustomJSLibs(new HashSet<>());
this.setExportWithConfiguration(null);
this.setForkWithConfiguration(null);
this.setForkingEnabled(null);
super.sanitiseToExportDBObject();
}

View File

@ -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()

View File

@ -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

View File

@ -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<Application> 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();
}
}

View File

@ -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();

View File

@ -366,6 +366,7 @@ public class ImportExportApplicationServiceTests {
assertThat(exportedApplication.getPublishedModeThemeId()).isNull();
assertThat(exportedApplication.getExportWithConfiguration()).isNull();
assertThat(exportedApplication.getForkWithConfiguration()).isNull();
assertThat(exportedApplication.getForkingEnabled()).isNull();
})
.verifyComplete();
}