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:
parent
d9024156d5
commit
cd96013b68
|
|
@ -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", () => {
|
it("1. Generate postgreSQL crud page , connect to git, clone the page, rename page with special character in it", () => {
|
||||||
cy.NavigateToHome();
|
cy.NavigateToHome();
|
||||||
cy.get(homePage.createNew).first().click({ force: true });
|
_.homePage.CreateNewApplication();
|
||||||
|
|
||||||
cy.wait("@createNewApplication").should(
|
|
||||||
"have.nested.property",
|
|
||||||
"response.body.responseMeta.status",
|
|
||||||
201,
|
|
||||||
);
|
|
||||||
|
|
||||||
// create New App and generate Postgres CRUD page
|
// create New App and generate Postgres CRUD page
|
||||||
cy.get(generatePage.generateCRUDPageActionCard).click();
|
cy.get(generatePage.generateCRUDPageActionCard).click();
|
||||||
|
|
|
||||||
|
|
@ -10,10 +10,11 @@ describe("Leave workspace test spec", function () {
|
||||||
cy.get("@guid").then((uid) => {
|
cy.get("@guid").then((uid) => {
|
||||||
newWorkspaceName = "LeaveWorkspace" + uid;
|
newWorkspaceName = "LeaveWorkspace" + uid;
|
||||||
_.homePage.CreateNewWorkspace(newWorkspaceName);
|
_.homePage.CreateNewWorkspace(newWorkspaceName);
|
||||||
|
cy.get(_.homePage._homeIcon).click();
|
||||||
cy.openWorkspaceOptionsPopup(newWorkspaceName);
|
cy.openWorkspaceOptionsPopup(newWorkspaceName);
|
||||||
// verify leave workspace is visible
|
// verify leave workspace is visible
|
||||||
cy.contains("Leave Workspace").scrollIntoView().click({ force: true });
|
cy.contains("Leave Workspace").click();
|
||||||
cy.contains("Are you sure").scrollIntoView().click({ force: true });
|
cy.contains("Are you sure").click();
|
||||||
cy.wait("@leaveWorkspaceApiCall").then((httpResponse) => {
|
cy.wait("@leaveWorkspaceApiCall").then((httpResponse) => {
|
||||||
expect(httpResponse.status).to.equal(400);
|
expect(httpResponse.status).to.equal(400);
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -124,13 +124,13 @@ describe("Validate MySQL Generate CRUD with JSON Form", () => {
|
||||||
updateNVerify(6, 4, newStoreSecret as string);
|
updateNVerify(6, 4, newStoreSecret as string);
|
||||||
});
|
});
|
||||||
|
|
||||||
table.SelectTableRow(18);
|
table.SelectTableRow(17);
|
||||||
dataSources.AssertJSONFormHeader(18, 0, "store_id");
|
dataSources.AssertJSONFormHeader(17, 0, "store_id");
|
||||||
generateStoresSecretInfo(18);
|
generateStoresSecretInfo(17);
|
||||||
cy.get("@secretInfo").then(($secretInfo) => {
|
cy.get("@secretInfo").then(($secretInfo) => {
|
||||||
newStoreSecret = $secretInfo;
|
newStoreSecret = $secretInfo;
|
||||||
cy.log("newStoreSecret is : " + newStoreSecret);
|
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!
|
//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
|
table.NavigateToNextPage(); //page 2
|
||||||
agHelper.Sleep(3000); //wait for table navigation to take effect!
|
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
|
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
|
//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();
|
table.NavigateToPreviousPage();
|
||||||
agHelper.Sleep(3000); //wait for table navigation to take effect!
|
agHelper.Sleep(3000); //wait for table navigation to take effect!
|
||||||
table.WaitUntilTableLoad();
|
table.WaitUntilTableLoad();
|
||||||
|
|
|
||||||
|
|
@ -30,10 +30,11 @@ public class CreateDBTablePageSolutionImpl extends CreateDBTablePageSolutionCEIm
|
||||||
PluginExecutorHelper pluginExecutorHelper,
|
PluginExecutorHelper pluginExecutorHelper,
|
||||||
DatasourcePermission datasourcePermission,
|
DatasourcePermission datasourcePermission,
|
||||||
ApplicationPermission applicationPermission,
|
ApplicationPermission applicationPermission,
|
||||||
PagePermission pagePermission) {
|
PagePermission pagePermission,
|
||||||
|
DatasourceStructureSolution datasourceStructureSolution) {
|
||||||
|
|
||||||
super(datasourceService, newPageService, layoutActionService, applicationPageService, applicationService,
|
super(datasourceService, newPageService, layoutActionService, applicationPageService, applicationService,
|
||||||
pluginService, analyticsService, sessionUserService, responseUtils, pluginExecutorHelper,
|
pluginService, analyticsService, sessionUserService, responseUtils, pluginExecutorHelper,
|
||||||
datasourcePermission, applicationPermission, pagePermission);
|
datasourcePermission, applicationPermission, pagePermission, datasourceStructureSolution);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -40,6 +40,7 @@ import com.appsmith.server.services.PluginService;
|
||||||
import com.appsmith.server.services.SessionUserService;
|
import com.appsmith.server.services.SessionUserService;
|
||||||
import com.appsmith.server.solutions.ApplicationPermission;
|
import com.appsmith.server.solutions.ApplicationPermission;
|
||||||
import com.appsmith.server.solutions.DatasourcePermission;
|
import com.appsmith.server.solutions.DatasourcePermission;
|
||||||
|
import com.appsmith.server.solutions.DatasourceStructureSolution;
|
||||||
import com.appsmith.server.solutions.PagePermission;
|
import com.appsmith.server.solutions.PagePermission;
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.google.gson.GsonBuilder;
|
import com.google.gson.GsonBuilder;
|
||||||
|
|
@ -87,6 +88,7 @@ public class CreateDBTablePageSolutionCEImpl implements CreateDBTablePageSolutio
|
||||||
private final DatasourcePermission datasourcePermission;
|
private final DatasourcePermission datasourcePermission;
|
||||||
private final ApplicationPermission applicationPermission;
|
private final ApplicationPermission applicationPermission;
|
||||||
private final PagePermission pagePermission;
|
private final PagePermission pagePermission;
|
||||||
|
private final DatasourceStructureSolution datasourceStructureSolution;
|
||||||
|
|
||||||
private static final String FILE_PATH = "CRUD-DB-Table-Template-Application.json";
|
private static final String FILE_PATH = "CRUD-DB-Table-Template-Application.json";
|
||||||
|
|
||||||
|
|
@ -204,13 +206,16 @@ public class CreateDBTablePageSolutionCEImpl implements CreateDBTablePageSolutio
|
||||||
return datasourceMono
|
return datasourceMono
|
||||||
.zipWhen(datasource -> Mono.zip(
|
.zipWhen(datasource -> Mono.zip(
|
||||||
pageMono,
|
pageMono,
|
||||||
pluginService.findById(datasource.getPluginId())
|
pluginService.findById(datasource.getPluginId()),
|
||||||
|
datasourceStructureSolution.getStructure(datasource, false, null)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
.flatMap(tuple -> {
|
.flatMap(tuple -> {
|
||||||
Datasource datasource = tuple.getT1();
|
Datasource datasource = tuple.getT1();
|
||||||
NewPage page = tuple.getT2().getT1();
|
NewPage page = tuple.getT2().getT1();
|
||||||
Plugin plugin = tuple.getT2().getT2();
|
Plugin plugin = tuple.getT2().getT2();
|
||||||
|
DatasourceStructure datasourceStructure = tuple.getT2().getT3();
|
||||||
|
|
||||||
final String layoutId = page.getUnpublishedPage().getLayouts().get(0).getId();
|
final String layoutId = page.getUnpublishedPage().getLayouts().get(0).getId();
|
||||||
final String savedPageId = page.getId();
|
final String savedPageId = page.getId();
|
||||||
|
|
||||||
|
|
@ -296,7 +301,7 @@ public class CreateDBTablePageSolutionCEImpl implements CreateDBTablePageSolutio
|
||||||
.findAny()
|
.findAny()
|
||||||
.orElse(null);
|
.orElse(null);
|
||||||
|
|
||||||
Table table = getTable(templateDatasourceConfigurationStructure, tableName);
|
Table table = getTable(datasourceStructure, tableName);
|
||||||
if (table == null) {
|
if (table == null) {
|
||||||
return Mono.error(
|
return Mono.error(
|
||||||
new AppsmithException(AppsmithError.NO_RESOURCE_FOUND, FieldName.DATASOURCE_STRUCTURE, datasource.getName())
|
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
|
* @param tableName to filter the available tables in the datasource
|
||||||
* @return Table from the provided datasource if structure is present
|
* @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
|
1. Get structure from datasource
|
||||||
2. Filter by tableName
|
2. Filter by tableName
|
||||||
*/
|
*/
|
||||||
DatasourceStructure datasourceStructure = datasourceConfigurationStructure.getStructure();
|
|
||||||
if (datasourceStructure != null) {
|
if (datasourceStructure != null) {
|
||||||
return datasourceStructure.getTables()
|
return datasourceStructure.getTables()
|
||||||
.stream()
|
.stream()
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user