fix: Updated Template to create datasourceConfigurationStructureList (#22873)

This PR is a follow up to #22847 to make CRUD templates work again.

TODO:
- [x] Wait for #22847 to get merged and then uncomment generate CRUD
tests
- [ ] Test all generate CRUD flows

---------

Co-authored-by: Nikhil Nandagopal <nikhil.nandagopal@gmail.com>
This commit is contained in:
Nidhi 2023-05-04 00:19:40 +05:30 committed by GitHub
parent d9024156d5
commit cd96013b68
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 741 additions and 724 deletions

View File

@ -31,13 +31,7 @@ describe("Git sync apps", function () {
});
it("1. Generate postgreSQL crud page , connect to git, clone the page, rename page with special character in it", () => {
cy.NavigateToHome();
cy.get(homePage.createNew).first().click({ force: true });
cy.wait("@createNewApplication").should(
"have.nested.property",
"response.body.responseMeta.status",
201,
);
_.homePage.CreateNewApplication();
// create New App and generate Postgres CRUD page
cy.get(generatePage.generateCRUDPageActionCard).click();

View File

@ -10,10 +10,11 @@ describe("Leave workspace test spec", function () {
cy.get("@guid").then((uid) => {
newWorkspaceName = "LeaveWorkspace" + uid;
_.homePage.CreateNewWorkspace(newWorkspaceName);
cy.get(_.homePage._homeIcon).click();
cy.openWorkspaceOptionsPopup(newWorkspaceName);
// verify leave workspace is visible
cy.contains("Leave Workspace").scrollIntoView().click({ force: true });
cy.contains("Are you sure").scrollIntoView().click({ force: true });
cy.contains("Leave Workspace").click();
cy.contains("Are you sure").click();
cy.wait("@leaveWorkspaceApiCall").then((httpResponse) => {
expect(httpResponse.status).to.equal(400);
});

View File

@ -124,13 +124,13 @@ describe("Validate MySQL Generate CRUD with JSON Form", () => {
updateNVerify(6, 4, newStoreSecret as string);
});
table.SelectTableRow(18);
dataSources.AssertJSONFormHeader(18, 0, "store_id");
generateStoresSecretInfo(18);
table.SelectTableRow(17);
dataSources.AssertJSONFormHeader(17, 0, "store_id");
generateStoresSecretInfo(17);
cy.get("@secretInfo").then(($secretInfo) => {
newStoreSecret = $secretInfo;
cy.log("newStoreSecret is : " + newStoreSecret);
updateNVerify(18, 4, newStoreSecret as string);
updateNVerify(17, 4, newStoreSecret as string);
});
//Hidden field bug - to add here aft secret codes are updated for some fields!
@ -197,11 +197,22 @@ describe("Validate MySQL Generate CRUD with JSON Form", () => {
table.NavigateToNextPage(); //page 2
agHelper.Sleep(3000); //wait for table navigation to take effect!
table.WaitForTableEmpty(); //page 2
table.WaitUntilTableLoad(); //page 2
agHelper.AssertElementVisible(locator._jsonFormWidget); // JSON form should be present
table.NavigateToNextPage(); //page 3
agHelper.Sleep(3000); //wait for table navigation to take effect!
table.WaitForTableEmpty(); //page 3
agHelper.AssertElementAbsence(locator._jsonFormWidget); //JSON form also should not be present
//Try to add via to Insert Modal - JSON fields not showing correct fields, Open bug 14122
// Go back to page 2
table.NavigateToPreviousPage();
agHelper.Sleep(3000); //wait for table navigation to take effect!
table.WaitUntilTableLoad();
// Go back to page 1
table.NavigateToPreviousPage();
agHelper.Sleep(3000); //wait for table navigation to take effect!
table.WaitUntilTableLoad();

View File

@ -30,10 +30,11 @@ public class CreateDBTablePageSolutionImpl extends CreateDBTablePageSolutionCEIm
PluginExecutorHelper pluginExecutorHelper,
DatasourcePermission datasourcePermission,
ApplicationPermission applicationPermission,
PagePermission pagePermission) {
PagePermission pagePermission,
DatasourceStructureSolution datasourceStructureSolution) {
super(datasourceService, newPageService, layoutActionService, applicationPageService, applicationService,
pluginService, analyticsService, sessionUserService, responseUtils, pluginExecutorHelper,
datasourcePermission, applicationPermission, pagePermission);
datasourcePermission, applicationPermission, pagePermission, datasourceStructureSolution);
}
}

View File

@ -40,6 +40,7 @@ import com.appsmith.server.services.PluginService;
import com.appsmith.server.services.SessionUserService;
import com.appsmith.server.solutions.ApplicationPermission;
import com.appsmith.server.solutions.DatasourcePermission;
import com.appsmith.server.solutions.DatasourceStructureSolution;
import com.appsmith.server.solutions.PagePermission;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
@ -87,6 +88,7 @@ public class CreateDBTablePageSolutionCEImpl implements CreateDBTablePageSolutio
private final DatasourcePermission datasourcePermission;
private final ApplicationPermission applicationPermission;
private final PagePermission pagePermission;
private final DatasourceStructureSolution datasourceStructureSolution;
private static final String FILE_PATH = "CRUD-DB-Table-Template-Application.json";
@ -204,13 +206,16 @@ public class CreateDBTablePageSolutionCEImpl implements CreateDBTablePageSolutio
return datasourceMono
.zipWhen(datasource -> Mono.zip(
pageMono,
pluginService.findById(datasource.getPluginId())
pluginService.findById(datasource.getPluginId()),
datasourceStructureSolution.getStructure(datasource, false, null)
)
)
.flatMap(tuple -> {
Datasource datasource = tuple.getT1();
NewPage page = tuple.getT2().getT1();
Plugin plugin = tuple.getT2().getT2();
DatasourceStructure datasourceStructure = tuple.getT2().getT3();
final String layoutId = page.getUnpublishedPage().getLayouts().get(0).getId();
final String savedPageId = page.getId();
@ -296,7 +301,7 @@ public class CreateDBTablePageSolutionCEImpl implements CreateDBTablePageSolutio
.findAny()
.orElse(null);
Table table = getTable(templateDatasourceConfigurationStructure, tableName);
Table table = getTable(datasourceStructure, tableName);
if (table == null) {
return Mono.error(
new AppsmithException(AppsmithError.NO_RESOURCE_FOUND, FieldName.DATASOURCE_STRUCTURE, datasource.getName())
@ -473,16 +478,15 @@ public class CreateDBTablePageSolutionCEImpl implements CreateDBTablePageSolutio
}
/**
* @param datasourceConfigurationStructure resource from which table has to be filtered
* @param datasourceStructure resource from which table has to be filtered
* @param tableName to filter the available tables in the datasource
* @return Table from the provided datasource if structure is present
*/
private Table getTable(DatasourceConfigurationStructure datasourceConfigurationStructure, String tableName) {
private Table getTable(DatasourceStructure datasourceStructure, String tableName) {
/*
1. Get structure from datasource
2. Filter by tableName
*/
DatasourceStructure datasourceStructure = datasourceConfigurationStructure.getStructure();
if (datasourceStructure != null) {
return datasourceStructure.getTables()
.stream()

File diff suppressed because one or more lines are too long