diff --git a/app/client/cypress/integration/Smoke_TestSuite/Datasources/MongoDatasource_spec.js b/app/client/cypress/integration/Smoke_TestSuite/Datasources/MongoDatasource_spec.js new file mode 100644 index 0000000000..d9f585dd08 --- /dev/null +++ b/app/client/cypress/integration/Smoke_TestSuite/Datasources/MongoDatasource_spec.js @@ -0,0 +1,49 @@ +describe("Create, test, save then delete a mongo datasource", function() { + it("Create, test, save then delete a mongo datasource", function() { + cy.NavigateToDatasourceEditor(); + cy.get("@getPlugins").then(httpResponse => { + // console.log(response, "response"); + const pluginName = httpResponse.response.body.data.find( + plugin => plugin.packageName === "mongo-plugin", + ).name; + + cy.get(".t--plugin-name") + .contains(pluginName) + .click(); + }); + + cy.getPluginFormsAndCreateDatasource(); + + cy.get(`input[name="datasourceConfiguration.endpoints[0].host"]`).type( + "ds119422.mlab.com", + ); + cy.get(`input[name="datasourceConfiguration.endpoints[0].port"]`).type( + 19422, + ); + cy.get(`input[name="datasourceConfiguration.authentication.databaseName"]`) + .clear() + .type("heroku_bcmprc4k"); + cy.get( + `input[name="datasourceConfiguration.authentication.username"]`, + ).type("akash"); + cy.get( + `input[name="datasourceConfiguration.authentication.password"]`, + ).type("123wheel"); + + cy.get( + "[data-cy=datasourceConfiguration\\.authentication\\.authType]", + ).click(); + cy.contains("SCRAM-SHA-256").click({ + force: true, + }); + + cy.get( + "[data-cy=datasourceConfiguration\\.connection\\.ssl\\.authType]", + ).click(); + cy.contains("No SSL").click({ + force: true, + }); + + cy.testSaveDeleteDatasource(); + }); +}); diff --git a/app/client/cypress/integration/Smoke_TestSuite/Datasources/PostgresDatasource_spec.js b/app/client/cypress/integration/Smoke_TestSuite/Datasources/PostgresDatasource_spec.js new file mode 100644 index 0000000000..26e896607e --- /dev/null +++ b/app/client/cypress/integration/Smoke_TestSuite/Datasources/PostgresDatasource_spec.js @@ -0,0 +1,35 @@ +describe("Create, test, save then delete a postgres datasource", function() { + it("Create, test, save then delete a postgres datasource", function() { + cy.NavigateToDatasourceEditor(); + cy.get("@getPlugins").then(httpResponse => { + // console.log(response, "response"); + const pluginName = httpResponse.response.body.data.find( + plugin => plugin.packageName === "postgres-plugin", + ).name; + + cy.get(".t--plugin-name") + .contains(pluginName) + .click(); + }); + + cy.getPluginFormsAndCreateDatasource(); + + cy.get(`input[name="datasourceConfiguration.endpoints[0].host"]`).type( + "appsmith-test-db.cgg2px8dsrli.ap-south-1.rds.amazonaws.com", + ); + cy.get(`input[name="datasourceConfiguration.endpoints[0].port"]`).type( + 5432, + ); + cy.get(`input[name="datasourceConfiguration.authentication.databaseName"]`) + .clear() + .type("postgres"); + cy.get( + `input[name="datasourceConfiguration.authentication.username"]`, + ).type("postgres"); + cy.get( + `input[name="datasourceConfiguration.authentication.password"]`, + ).type("qwerty1234"); + + cy.testSaveDeleteDatasource(); + }); +}); diff --git a/app/client/cypress/integration/Smoke_TestSuite/Datasources/RestApiDatasource_spec.js b/app/client/cypress/integration/Smoke_TestSuite/Datasources/RestApiDatasource_spec.js new file mode 100644 index 0000000000..7824c77d28 --- /dev/null +++ b/app/client/cypress/integration/Smoke_TestSuite/Datasources/RestApiDatasource_spec.js @@ -0,0 +1,23 @@ +describe("Create, test, save then delete a restapi datasource", function() { + it("Create, test, save then delete a restapi datasource", function() { + cy.NavigateToDatasourceEditor(); + cy.get("@getPlugins").then(httpResponse => { + // console.log(response, "response"); + const pluginName = httpResponse.response.body.data.find( + plugin => plugin.packageName === "restapi-plugin", + ).name; + + cy.get(".t--plugin-name") + .contains(pluginName) + .click(); + }); + + cy.getPluginFormsAndCreateDatasource(); + + cy.get(`input[name="datasourceConfiguration.url"]`).type( + "https://my-json-server.typicode.com/typicode/demo/posts", + ); + + cy.testSaveDeleteDatasource(); + }); +}); diff --git a/app/client/cypress/locators/DatasourcesEditor.json b/app/client/cypress/locators/DatasourcesEditor.json new file mode 100644 index 0000000000..591e8bfef1 --- /dev/null +++ b/app/client/cypress/locators/DatasourcesEditor.json @@ -0,0 +1,3 @@ +{ + "datasourceEditorIcon": ".t--nav-link-datasource-editor" +} \ No newline at end of file diff --git a/app/client/cypress/support/commands.js b/app/client/cypress/support/commands.js index 246d291fba..e86fdea4d8 100644 --- a/app/client/cypress/support/commands.js +++ b/app/client/cypress/support/commands.js @@ -1,6 +1,7 @@ const loginPage = require("../locators/LoginPage.json"); const homePage = require("../locators/HomePage.json"); const pages = require("../locators/Pages.json"); +const datasourceEditor = require("../locators/DatasourcesEditor.json"); const commonlocators = require("../locators/commonlocators.json"); const modalWidgetPage = require("../locators/ModalWidget.json"); const widgetsPage = require("../locators/Widgets.json"); @@ -228,6 +229,24 @@ Cypress.Commands.add("addDsl", dsl => { }); }); }); + +Cypress.Commands.add("NavigateToDatasourceEditor", () => { + cy.get(datasourceEditor.datasourceEditorIcon).click({ force: true }); +}); + +Cypress.Commands.add("getPluginFormsAndCreateDatasource", () => { + cy.wait("@getPluginForm").should( + "have.nested.property", + "response.body.responseMeta.status", + 200, + ); + cy.wait("@createDatasource").should( + "have.nested.property", + "response.body.responseMeta.status", + 201, + ); +}); + Cypress.Commands.add("NavigateToApiEditor", () => { cy.get(pages.apiEditorIcon).click({ force: true }); }); @@ -241,6 +260,29 @@ Cypress.Commands.add("testCreateApiButton", () => { ); }); +Cypress.Commands.add("testSaveDeleteDatasource", () => { + cy.get(".t--test-datasource").click(); + cy.wait("@testDatasource").should( + "have.nested.property", + "response.body.data.success", + true, + ); + + cy.get(".t--save-datasource").click(); + cy.wait("@saveDatasource").should( + "have.nested.property", + "response.body.responseMeta.status", + 200, + ); + + cy.get(".t--delete-datasource").click(); + cy.wait("@deleteDatasource").should( + "have.nested.property", + "response.body.responseMeta.status", + 200, + ); +}); + Cypress.Commands.add("testDeleteApi", () => { cy.get(ApiEditor.createBlankApiCard).click({ force: true }); cy.wait("@deleteApi").should( diff --git a/app/client/cypress/support/index.js b/app/client/cypress/support/index.js index db9da827c6..07c51c2440 100644 --- a/app/client/cypress/support/index.js +++ b/app/client/cypress/support/index.js @@ -32,6 +32,12 @@ before(function() { cy.route("GET", "/api/v1/pages/*").as("getPage"); cy.route("GET", "/api/v1/actions*").as("getActions"); + cy.route("GET", "/api/v1/plugins/*/form").as("getPluginForm"); + cy.route("POST", "/api/v1/datasources").as("createDatasource"); + cy.route("POST", "/api/v1/datasources/test").as("testDatasource"); + cy.route("PUT", "/api/v1/datasources/*").as("saveDatasource"); + cy.route("DELETE", "/api/v1/datasources/*").as("deleteDatasource"); + cy.route("GET", "/api/v1/organizations").as("organizations"); cy.route("POST", "/api/v1/actions/execute").as("executeAction"); cy.route("POST", "/api/v1/applications/publish/*").as("publishApp"); diff --git a/app/client/src/components/formControls/DropDownControl.tsx b/app/client/src/components/formControls/DropDownControl.tsx index 8e5441b528..fde31f183b 100644 --- a/app/client/src/components/formControls/DropDownControl.tsx +++ b/app/client/src/components/formControls/DropDownControl.tsx @@ -42,7 +42,7 @@ class DropDownControl extends BaseControl { const { configProperty, options } = this.props; return ( - + { className="dataSourceImage" alt="Datasource" > -

{plugin.name}

+

{plugin.name}

); })}