diff --git a/app/client/cypress/fixtures/SMTPTestdsl.json b/app/client/cypress/fixtures/SMTPTestdsl.json new file mode 100644 index 0000000000..46ff5b31b4 --- /dev/null +++ b/app/client/cypress/fixtures/SMTPTestdsl.json @@ -0,0 +1,411 @@ +{ + "dsl": { + "widgetName": "MainContainer", + "backgroundColor": "none", + "rightColumn": 816, + "snapColumns": 64, + "detachFromLayout": true, + "widgetId": "0", + "topRow": 0, + "bottomRow": 620, + "containerStyle": "none", + "snapRows": 125, + "parentRowSpace": 1, + "type": "CANVAS_WIDGET", + "canExtend": true, + "version": 52, + "minHeight": 630, + "parentColumnSpace": 1, + "dynamicBindingPathList": [], + "leftColumn": 0, + "children": [ + { + "widgetName": "Form1", + "backgroundColor": "white", + "rightColumn": 50, + "isCanvas": true, + "displayName": "Form", + "iconSVG": "/static/media/icon.ea3e08d1.svg", + "widgetId": "73l6ga3t1o", + "topRow": 2, + "bottomRow": 56, + "parentRowSpace": 10, + "isVisible": true, + "type": "FORM_WIDGET", + "hideCard": false, + "parentId": "0", + "renderMode": "CANVAS", + "isLoading": false, + "animateLoading": true, + "parentColumnSpace": 12.5625, + "leftColumn": 15, + "children": [ + { + "widgetName": "Canvas1", + "rightColumn": 301.5, + "detachFromLayout": true, + "displayName": "Canvas", + "widgetId": "95zj2zlob5", + "containerStyle": "none", + "topRow": 0, + "bottomRow": 520, + "parentRowSpace": 1, + "isVisible": true, + "type": "CANVAS_WIDGET", + "canExtend": false, + "version": 1, + "hideCard": true, + "parentId": "73l6ga3t1o", + "minHeight": 400, + "renderMode": "CANVAS", + "isLoading": false, + "parentColumnSpace": 1, + "leftColumn": 0, + "children": [ + { + "widgetName": "Subject", + "displayName": "Input", + "iconSVG": "/static/media/icon.9f505595.svg", + "topRow": 13, + "bottomRow": 17, + "parentRowSpace": 10, + "autoFocus": false, + "type": "INPUT_WIDGET_V2", + "hideCard": false, + "animateLoading": true, + "parentColumnSpace": 4.3984375, + "resetOnSubmit": true, + "leftColumn": 27, + "labelStyle": "", + "inputType": "TEXT", + "isDisabled": false, + "key": "qgh3y2e6xa", + "isRequired": false, + "rightColumn": 63, + "widgetId": "6onfkhvbvf", + "isVisible": true, + "label": "", + "version": 2, + "parentId": "95zj2zlob5", + "renderMode": "CANVAS", + "isLoading": false, + "iconAlign": "left", + "defaultText": "" + }, + { + "widgetName": "Text2Copy1", + "displayName": "Text", + "iconSVG": "/static/media/icon.97c59b52.svg", + "topRow": 13, + "bottomRow": 17, + "parentRowSpace": 10, + "type": "TEXT_WIDGET", + "hideCard": false, + "animateLoading": true, + "parentColumnSpace": 4.3984375, + "dynamicTriggerPathList": [], + "leftColumn": 5, + "dynamicBindingPathList": [], + "shouldTruncate": false, + "truncateButtonColor": "#FFC13D", + "text": "Subject", + "key": "rwx19fujyl", + "rightColumn": 21, + "textAlign": "LEFT", + "widgetId": "xw1l7uqcvg", + "isVisible": true, + "fontStyle": "BOLD", + "textColor": "#231F20", + "shouldScroll": false, + "version": 1, + "parentId": "95zj2zlob5", + "renderMode": "CANVAS", + "isLoading": false, + "fontSize": "PARAGRAPH" + }, + { + "widgetName": "Text2Copy", + "displayName": "Text", + "iconSVG": "/static/media/icon.97c59b52.svg", + "topRow": 18, + "bottomRow": 22, + "parentRowSpace": 10, + "type": "TEXT_WIDGET", + "hideCard": false, + "animateLoading": true, + "parentColumnSpace": 4.3984375, + "dynamicTriggerPathList": [], + "leftColumn": 5, + "dynamicBindingPathList": [], + "shouldTruncate": false, + "truncateButtonColor": "#FFC13D", + "text": "Body", + "key": "rwx19fujyl", + "rightColumn": 21, + "textAlign": "LEFT", + "widgetId": "dwo8a0dh83", + "isVisible": true, + "fontStyle": "BOLD", + "textColor": "#231F20", + "shouldScroll": false, + "version": 1, + "parentId": "95zj2zlob5", + "renderMode": "CANVAS", + "isLoading": false, + "fontSize": "PARAGRAPH" + }, + { + "widgetName": "To", + "displayName": "Input", + "iconSVG": "/static/media/icon.9f505595.svg", + "topRow": 7, + "bottomRow": 11, + "parentRowSpace": 10, + "autoFocus": false, + "type": "INPUT_WIDGET_V2", + "hideCard": false, + "animateLoading": true, + "parentColumnSpace": 4.3984375, + "resetOnSubmit": true, + "leftColumn": 27, + "labelStyle": "", + "inputType": "TEXT", + "isDisabled": false, + "key": "qgh3y2e6xa", + "isRequired": false, + "rightColumn": 62, + "widgetId": "o49e2rbj01", + "isVisible": true, + "label": "", + "version": 2, + "parentId": "95zj2zlob5", + "renderMode": "CANVAS", + "isLoading": false, + "iconAlign": "left", + "defaultText": "" + }, + { + "widgetName": "From", + "displayName": "Input", + "iconSVG": "/static/media/icon.9f505595.svg", + "topRow": 1, + "bottomRow": 5, + "parentRowSpace": 10, + "autoFocus": false, + "type": "INPUT_WIDGET_V2", + "hideCard": false, + "animateLoading": true, + "parentColumnSpace": 4.3984375, + "resetOnSubmit": true, + "leftColumn": 27, + "labelStyle": "", + "inputType": "TEXT", + "isDisabled": false, + "key": "qgh3y2e6xa", + "isRequired": false, + "rightColumn": 63, + "widgetId": "mtore0zjqu", + "isVisible": true, + "label": "", + "version": 2, + "parentId": "95zj2zlob5", + "renderMode": "CANVAS", + "isLoading": false, + "iconAlign": "left", + "defaultText": "" + }, + { + "widgetName": "Text1", + "displayName": "Text", + "iconSVG": "/static/media/icon.97c59b52.svg", + "topRow": 1, + "bottomRow": 5, + "parentRowSpace": 10, + "type": "TEXT_WIDGET", + "hideCard": false, + "animateLoading": true, + "parentColumnSpace": 4.3984375, + "dynamicTriggerPathList": [], + "leftColumn": 5, + "dynamicBindingPathList": [], + "shouldTruncate": false, + "truncateButtonColor": "#FFC13D", + "text": "From email", + "key": "rwx19fujyl", + "rightColumn": 24, + "textAlign": "LEFT", + "widgetId": "rrjfd8tf8h", + "isVisible": true, + "fontStyle": "BOLD", + "textColor": "#231F20", + "shouldScroll": false, + "version": 1, + "parentId": "95zj2zlob5", + "renderMode": "CANVAS", + "isLoading": false, + "fontSize": "PARAGRAPH" + }, + { + "widgetName": "Text2", + "displayName": "Text", + "iconSVG": "/static/media/icon.97c59b52.svg", + "topRow": 7, + "bottomRow": 11, + "parentRowSpace": 10, + "type": "TEXT_WIDGET", + "hideCard": false, + "animateLoading": true, + "parentColumnSpace": 4.3984375, + "dynamicTriggerPathList": [], + "leftColumn": 5, + "dynamicBindingPathList": [], + "shouldTruncate": false, + "truncateButtonColor": "#FFC13D", + "text": "To email", + "key": "rwx19fujyl", + "rightColumn": 21, + "textAlign": "LEFT", + "widgetId": "aytwi0e3vc", + "isVisible": true, + "fontStyle": "BOLD", + "textColor": "#231F20", + "shouldScroll": false, + "version": 1, + "parentId": "95zj2zlob5", + "renderMode": "CANVAS", + "isLoading": false, + "fontSize": "PARAGRAPH" + }, + { + "widgetName": "RunQuery", + "onClick": "{{smtpquery.run(() => showAlert(smtpquery.data.message), () => showAlert(smtpquery.data))}}", + "buttonColor": "#2E3D49", + "dynamicPropertyPathList": [], + "displayName": "Button", + "iconSVG": "/static/media/icon.cca02633.svg", + "topRow": 46, + "bottomRow": 50, + "parentRowSpace": 10, + "type": "BUTTON_WIDGET", + "hideCard": false, + "animateLoading": true, + "parentColumnSpace": 6.9501953125, + "dynamicTriggerPathList": [ + { + "key": "onClick" + } + ], + "leftColumn": 5, + "dynamicBindingPathList": [], + "text": "Run query", + "isDisabled": false, + "key": "ldhjnzuffx", + "rightColumn": 21, + "isDefaultClickDisabled": true, + "widgetId": "vx3hvncn5r", + "isVisible": true, + "recaptchaType": "V3", + "version": 1, + "parentId": "95zj2zlob5", + "renderMode": "CANVAS", + "isLoading": false, + "buttonVariant": "PRIMARY", + "placement": "CENTER" + }, + { + "widgetName": "FilePicker", + "displayName": "FilePicker", + "iconSVG": "/static/media/icon.7c5ad9c3.svg", + "topRow": 39, + "bottomRow": 43, + "parentRowSpace": 10, + "allowedFileTypes": [], + "type": "FILE_PICKER_WIDGET_V2", + "hideCard": false, + "animateLoading": true, + "parentColumnSpace": 10.0576171875, + "leftColumn": 27, + "isDisabled": false, + "key": "h660o0jhyv", + "isRequired": false, + "rightColumn": 43, + "isDefaultClickDisabled": true, + "widgetId": "zibdcinyru", + "isVisible": true, + "label": "Select Files", + "maxFileSize": 5, + "version": 1, + "fileDataType": "Base64", + "parentId": "95zj2zlob5", + "selectedFiles": [], + "renderMode": "CANVAS", + "isLoading": false, + "files": [], + "maxNumFiles": 1 + }, + { + "widgetName": "Body", + "displayName": "Rich Text Editor", + "iconSVG": "/static/media/icon.b35e139c.svg", + "topRow": 19, + "bottomRow": 37, + "parentRowSpace": 10, + "type": "RICH_TEXT_EDITOR_WIDGET", + "hideCard": false, + "animateLoading": true, + "parentColumnSpace": 10.0576171875, + "leftColumn": 27, + "inputType": "html", + "isDisabled": false, + "key": "kb9bett42e", + "isRequired": false, + "rightColumn": 63, + "isDefaultClickDisabled": true, + "widgetId": "avhynnh5qt", + "isVisible": true, + "version": 1, + "parentId": "95zj2zlob5", + "renderMode": "CANVAS", + "isLoading": false, + "defaultText": "This is the initial content of the editor" + }, + { + "widgetName": "Text3", + "displayName": "Text", + "iconSVG": "/static/media/icon.97c59b52.svg", + "topRow": 39, + "bottomRow": 43, + "parentRowSpace": 10, + "type": "TEXT_WIDGET", + "hideCard": false, + "animateLoading": true, + "parentColumnSpace": 10.0576171875, + "dynamicTriggerPathList": [], + "leftColumn": 5, + "dynamicBindingPathList": [], + "shouldTruncate": false, + "truncateButtonColor": "#FFC13D", + "text": "Attach File", + "key": "zbnhq6b2ca", + "rightColumn": 21, + "textAlign": "LEFT", + "widgetId": "djbr6kevto", + "isVisible": true, + "fontStyle": "BOLD", + "textColor": "#231F20", + "shouldScroll": false, + "version": 1, + "parentId": "95zj2zlob5", + "renderMode": "CANVAS", + "isLoading": false, + "fontSize": "PARAGRAPH" + } + ], + "key": "xqrk7ndd5t" + } + ], + "key": "ojuvvynv5l" + } + ] + } + } \ No newline at end of file diff --git a/app/client/cypress/fixtures/datasources.json b/app/client/cypress/fixtures/datasources.json index 98449e0cd7..cd7de82f95 100644 --- a/app/client/cypress/fixtures/datasources.json +++ b/app/client/cypress/fixtures/datasources.json @@ -29,6 +29,10 @@ "redshift-databaseName": "fakeapi", "redshift-username": "root", "redshift-password": "Redshift$123", + "smtp-host":"localhost", + "smtp-port":"25", + "smtp-username":"root", + "smtp-password":"root", "restapi-url": "https://my-json-server.typicode.com/typicode/demo/posts", "connection-type": "Replica set", "database-url": "appsmith-f9fe4.firebaseio.com", diff --git a/app/client/cypress/integration/Smoke_TestSuite/ServerSideTests/Datasources/SMTPDatasource_spec.js b/app/client/cypress/integration/Smoke_TestSuite/ServerSideTests/Datasources/SMTPDatasource_spec.js new file mode 100644 index 0000000000..d46d7ce192 --- /dev/null +++ b/app/client/cypress/integration/Smoke_TestSuite/ServerSideTests/Datasources/SMTPDatasource_spec.js @@ -0,0 +1,122 @@ +const datasource = require("../../../../locators/DatasourcesEditor.json"); +const commonlocators = require("../../../../locators/commonlocators.json"); +const queryLocators = require("../../../../locators/QueryEditor.json"); +const dsl = require("../../../../fixtures/SMTPTestdsl.json"); +let datasourceName; + +describe("SMTP datasource test cases using ted", function() { + let SMTPDatasourceName; + beforeEach(() => { + cy.startRoutesForDatasource(); + }); + before(() => { + cy.addDsl(dsl); + }); + + it("1. Create and configure smtp datasource and query, binding widgets to query fields", function() { + cy.NavigateToDatasourceEditor(); + cy.get(datasource.SMTP).click(); + cy.generateUUID().then((uid) => { + SMTPDatasourceName = uid; + + cy.get(".t--edit-datasource-name").click(); + cy.get(".t--edit-datasource-name input") + .clear() + .type(SMTPDatasourceName, { force: true }) + .should("have.value", SMTPDatasourceName) + .blur(); + + cy.getPluginFormsAndCreateDatasource(); + cy.fillSMTPDatasourceForm(); + cy.testSaveDatasource(); + cy.NavigateToActiveDSQueryPane(SMTPDatasourceName); + }); + // create new query and bind fields with widgets + cy.get(queryLocators.queryNameField).type("smtpquery"); + cy.get(queryLocators.queryFromEmail) + .first() + .type("{{From.text}}", { parseSpecialCharSequences: false }); + cy.get(queryLocators.queryFromEmail) + .eq(1) + .type("{{To.text}}", { parseSpecialCharSequences: false }); + cy.get(queryLocators.queryFromEmail) + .eq(4) + .type("{{Subject.text}}", { parseSpecialCharSequences: false }); + cy.get(queryLocators.queryFromEmail) + .eq(5) + .type("{{Body.text}}", { parseSpecialCharSequences: false }); + cy.get(queryLocators.queryFromEmail) + .eq(6) + .type("{{FilePicker.text}}", { parseSpecialCharSequences: false }); + cy.get(`.t--entity-name:contains("Page1")`) + .should("be.visible") + .click({ force: true }); + cy.wait(2000); + }); + + it("2. On canvas, passing wrong email address in widgets should give error", function() { + // verify an error is thrown when recipient address is not added + cy.xpath("//input[@class='bp3-input']") + .eq(0) + .type("test@appsmith.com"); + cy.xpath( + "//span[text()='Run query' and @class='bp3-button-text']", + ).click(); + cy.wait("@postExecute", { timeout: 8000 }).then(({ response }) => { + expect(response.body.data.statusCode).to.eq("5005"); + expect(response.body.data.body).to.contain( + "Couldn't find a valid recipient address. Please check your action configuration", + ); + }); + // verify an error is thrown when sender address is not added + cy.xpath("//input[@class='bp3-input']") + .eq(0) + .clear(); + cy.xpath("//input[@class='bp3-input']") + .eq(1) + .type("qwerty@appsmith.com"); + cy.xpath( + "//span[text()='Run query' and @class='bp3-button-text']", + ).click(); + cy.wait("@postExecute", { timeout: 8000 }).then(({ response }) => { + expect(response.body.data.statusCode).to.eq("5005"); + expect(response.body.data.body).to.contain( + "Couldn't find a valid sender address. Please check your action configuration", + ); + }); + }); + /* it("3. On canvas, fill to email, from email, subject, body, attachment and run query", function() { + cy.get(`.t--entity-name:contains("smtpquery")`) + .should("be.visible") + .click({ force: true }); + cy.get(`.t--entity-name:contains("Page1")`) + .should("be.visible") + .click({ force: true }); + cy.wait(2000); + cy.xpath("//input[@class='bp3-input']") + .eq(0) + .type("test@appsmith.com"); + cy.xpath("//input[@class='bp3-input']") + .eq(2) + .type("this is a smtp test"); + // adding an attachment in file picker + /* cy.SearchEntityandOpen("FilePicker"); + const fixturePath = "testFile.mov"; + cy.get(commonlocators.filePickerButton).click(); + cy.get(commonlocators.filePickerInput) + .first() + .attachFile(fixturePath); + cy.get(commonlocators.filePickerUploadButton).click(); + cy.get(".bp3-spinner").should("have.length", 1); + //eslint-disable-next-line cypress/no-unnecessary-waiting + cy.wait(500); + cy.get("button").contains("1 files selected"); + cy.xpath( + "//span[text()='Run query' and @class='bp3-button-text']", + ).click(); + cy.wait("@postExecute", { timeout: 8000 }).then(({ response }) => { + // expect(response.body.data.statusCode).to.eq("5000"); + expect(response.body.data.body).to.contain("Sent the email successfully"); + }); + }); */ +}); diff --git a/app/client/cypress/locators/DatasourcesEditor.json b/app/client/cypress/locators/DatasourcesEditor.json index 2ef278f069..b3e36b972b 100644 --- a/app/client/cypress/locators/DatasourcesEditor.json +++ b/app/client/cypress/locators/DatasourcesEditor.json @@ -10,6 +10,7 @@ "MongoDB": ".t--plugin-name:contains('MongoDB')", "RESTAPI": ".t--plugin-name:contains('REST API')", "PostgreSQL": ".t--plugin-name:contains('PostgreSQL')", + "SMTP":".t--plugin-name:contains('SMTP')", "MySQL": ".t--plugin-name:contains('MySQL')", "sectionAuthentication": "[data-cy=section-Authentication]", "PostgresEntity": ".t--entity-name:contains(PostgreSQL)", diff --git a/app/client/cypress/locators/QueryEditor.json b/app/client/cypress/locators/QueryEditor.json index 8abcb16bc5..d019b4c0c4 100644 --- a/app/client/cypress/locators/QueryEditor.json +++ b/app/client/cypress/locators/QueryEditor.json @@ -21,6 +21,7 @@ "queryCreate": "//div[contains(@class, 't--template-menu')]//div[text()='Create']", "queryUpdate": "//div[contains(@class, 't--template-menu')]//div[text()='Update']", "queryDelete": "//div[contains(@class, 't--template-menu')]//div[text()='Delete']", + "queryFromEmail":".CodeMirror-lines", "codeTextArea": "//div[@class='CodeMirror-code']//span/span", "countText": "//span[contains(@class, 'cs-text')][text()='Result:']/span", "searchFilefield": "//input[@placeholder='Search File Prefix']", diff --git a/app/client/cypress/setup-test.sh b/app/client/cypress/setup-test.sh index 8fd7df521f..6ba97a4420 100755 --- a/app/client/cypress/setup-test.sh +++ b/app/client/cypress/setup-test.sh @@ -32,7 +32,7 @@ sudo mkdir -p git-server/keys sudo mkdir -p git-server/repos sudo docker run --name test-event-driver -d -p 2222:22 -p 5001:5001 -p 3306:3306 \ - -p 5432:5432 -p 28017:27017 -v ~/git-server/keys:/git-server/keys \ + -p 5432:5432 -p 28017:27017 -p 25:25 -v ~/git-server/keys:/git-server/keys \ -v ~/git-server/repos:/git-server/repos appsmith/test-event-driver:latest echo "Waiting for test event driver to start" diff --git a/app/client/cypress/support/commands.js b/app/client/cypress/support/commands.js index 063d4ea25b..5c764b4397 100644 --- a/app/client/cypress/support/commands.js +++ b/app/client/cypress/support/commands.js @@ -325,7 +325,7 @@ Cypress.Commands.add("launchApp", (appName) => { Cypress.Commands.add("AppSetupForRename", () => { cy.get(homePage.applicationName).then(($appName) => { if (!$appName.hasClass(homePage.editingAppName)) { - cy.get(homePage.applicationName).click(); + cy.get(homePage.applicationName).click({ force: true }); cy.get(homePage.portalMenuItem) .contains("Edit Name", { matchCase: false }) .click(); @@ -2482,6 +2482,19 @@ Cypress.Commands.add( .type(userMockDatabaseUsername); }, ); +Cypress.Commands.add( + "fillSMTPDatasourceForm", + (shouldAddTrailingSpaces = false) => { + const hostAddress = shouldAddTrailingSpaces + ? datasourceFormData["smtp-host"] + " " + : datasourceFormData["smtp-host"]; + cy.get(datasourceEditor.host).type(hostAddress); + cy.get(datasourceEditor.port).type(datasourceFormData["smtp-port"]); + cy.get(datasourceEditor.sectionAuthentication).click(); + cy.get(datasourceEditor.username).type(datasourceFormData["smtp-username"]); + cy.get(datasourceEditor.password).type(datasourceFormData["smtp-password"]); + }, +); Cypress.Commands.add("createPostgresDatasource", () => { cy.NavigateToDatasourceEditor(); @@ -3557,7 +3570,7 @@ Cypress.Commands.add( ); Cypress.Commands.add("createGitBranch", (branch) => { - cy.get(gitSyncLocators.branchButton).click(); + cy.get(gitSyncLocators.branchButton).click({ force: true }); cy.get(gitSyncLocators.branchSearchInput).type(`{selectall}${branch}{enter}`); // increasing timeout to reduce flakyness cy.get(".bp3-spinner", { timeout: 30000 }).should("exist"); @@ -3565,7 +3578,7 @@ Cypress.Commands.add("createGitBranch", (branch) => { }); Cypress.Commands.add("switchGitBranch", (branch, expectError) => { - cy.get(gitSyncLocators.branchButton).click(); + cy.get(gitSyncLocators.branchButton).click({ force: true }); cy.get(gitSyncLocators.branchSearchInput).type(`{selectall}${branch}`); cy.get(gitSyncLocators.branchListItem) .contains(branch)