Merge pull request #14851 from ToolJet/test/automation-marketplace-part-2

This commit is contained in:
Adish M 2026-01-05 18:33:52 +05:30 committed by GitHub
commit c4e21e5283
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
15 changed files with 1485 additions and 8 deletions

View file

@ -0,0 +1,134 @@
import { invalid } from "moment/moment";
export const elasticsearchUIConfig = {
defaultFields: [
{
type: "input",
fieldName: "Host",
validations: {
isRequired: false,
placeholder: "Enter host",
defaultValue: "localhost",
disabled: false
}
},
{
type: "input",
fieldName: "Port",
validations: {
isRequired: false,
placeholder: "Enter port",
defaultValue: "9200",
disabled: false
}
},
{
type: "toggle",
fieldName: "SSL",
validations: {
defaultValue: true,
disabled: false
}
},
{
type: "input",
fieldName: "Username",
validations: {
isRequired: false,
placeholder: "Enter username",
defaultValue: "",
disabled: false
}
},
{
type: "encrypted",
fieldName: "Password",
validations: {
isRequired: false,
placeholder: "**************",
defaultValue: "",
disabled: true,
hasEditButton: true,
showEncrypted: true,
hasEyeIcon: true
}
},
{
type: "dropdown",
fieldName: "SSL certificate",
validations: {
defaultValue: 'None',
disabled: false
}
}
]
};
export const elasticsearchFormConfig = {
valid: [
{
type: "input",
fieldName: "Host",
text: `${Cypress.env('elasticsearch_host')}`
},
{
type: "input",
fieldName: "Port",
text: "9200"
},
{
type: "toggle",
fieldName: "SSL",
shouldBeChecked: false
},
{
type: "input",
fieldName: "Username",
text: `${Cypress.env('elasticsearch_user')}`
},
{
type: "encrypted",
fieldName: "Password",
text: `${Cypress.env('elasticsearch_password')}`
}
],
invalidSsl: [
{
type: "toggle",
fieldName: "SSL",
shouldBeChecked: true
}
],
invalidHost: [
{
type: "input",
fieldName: "Host",
text: "invalid-host"
}
],
invalidUsername: [
{
type: "input",
fieldName: "Username",
text: "invalid-username"
}
],
invalidPassword: [
{
type: "encrypted",
fieldName: "Password",
text: "invalid-password"
}
],
invalidPort: [
{
type: "input",
fieldName: "Port",
text: "9999"
}
],
};

View file

@ -0,0 +1,258 @@
export const mongodbUIConfig = {
defaultFieldsManual: [
{
type: "dropdown",
fieldName: "Connection type",
validations: {
defaultValue: 'Manual connection',
disabled: false
}
},
{
type: "dropdown",
fieldName: "Connection format",
validations: {
defaultValue: 'Standard (mongodb)',
disabled: false
}
},
{
type: "input",
fieldName: "Host",
validations: {
isRequired: false,
placeholder: "Enter host",
defaultValue: "",
disabled: false
}
},
{
type: "input",
fieldName: "Port",
validations: {
isRequired: false,
placeholder: "Enter port",
defaultValue: "",
disabled: false
}
},
{
type: "input",
fieldName: "Database name",
validations: {
isRequired: false,
placeholder: "Name of the database",
defaultValue: "",
disabled: false
}
},
{
type: "input",
fieldName: "Username",
validations: {
isRequired: false,
placeholder: "Enter username",
defaultValue: "",
disabled: false
}
},
{
type: "encrypted",
fieldName: "Password",
validations: {
isRequired: false,
placeholder: "**************",
defaultValue: "",
disabled: true,
hasEditButton: true,
showEncrypted: true,
hasEyeIcon: true
}
},
{
type: "dropdown",
fieldName: "TLS/SSL certificate",
validations: {
defaultValue: 'None',
disabled: false
}
},
],
defaultFieldsConnectionString: [
{
type: "dropdown",
fieldName: "Connection type",
validations: {
defaultValue: 'Connect using connection string',
disabled: false
}
},
{
type: "dropdown",
fieldName: "Connection format",
validations: {
defaultValue: 'Standard (mongodb)',
disabled: false
}
},
{
type: "input",
fieldName: "Host",
validations: {
isRequired: false,
placeholder: "prod-db-1.company.com",
defaultValue: "",
disabled: false
}
},
{
type: "input",
fieldName: "Port",
validations: {
isRequired: false,
placeholder: "27017",
defaultValue: "",
disabled: false
}
},
{
type: "input",
fieldName: "Database name",
validations: {
isRequired: false,
placeholder: "customer_data",
defaultValue: "",
disabled: false
}
},
{
type: "input",
fieldName: "Username",
validations: {
isRequired: false,
placeholder: "admin",
defaultValue: "",
disabled: false
}
},
{
type: "encrypted",
fieldName: "Password",
validations: {
isRequired: false,
placeholder: "**************",
defaultValue: "",
disabled: true,
hasEditButton: true,
showEncrypted: true,
hasEyeIcon: true
}
},
{
type: "checkbox",
fieldName: "Use SSL/TLS",
validations: {
defaultValue: false,
disabled: false
}
},
]
};
export const mongodbFormConfig = {
valid: [
{
type: "dropdown",
fieldName: "Connection type",
text: "Manual connection"
},
{
type: "input",
fieldName: "Host",
text: `${Cypress.env('mongodb_host')}`
},
{
type: "input",
fieldName: "Port",
text: `${Cypress.env('mongodb_port')}`
},
{
type: "input",
fieldName: "Database name",
text: `${Cypress.env('mongodb_database')}`
},
{
type: "input",
fieldName: "Username",
text: `${Cypress.env('mongodb_user')}`
},
{
type: "encrypted",
fieldName: "Password",
text: `${Cypress.env('mongodb_password')}`
}
],
validConnectionString: [
{
type: "dropdown",
fieldName: "Connection type",
text: "Connect using connection string"
},
{
type: "encrypted",
fieldName: "Connection string",
text: `${Cypress.env('mongodb_connString')}`
}
],
invalidHost: [
{
type: "input",
fieldName: "Host",
text: "invalid-host"
}
],
invalidUsername: [
{
type: "input",
fieldName: "Username",
text: "invalid-username"
}
],
invalidPassword: [
{
type: "encrypted",
fieldName: "Password",
text: "invalid-password"
}
],
invalidPort: [
{
type: "input",
fieldName: "Port",
text: "9999"
}
],
invalidConnectionString: [
{
type: "dropdown",
fieldName: "Connection type",
text: "Connect using connection string"
},
{
type: "encrypted",
fieldName: "Connection string",
text: "mongodb://invalid-host:27017/test"
}
],
};

View file

@ -0,0 +1,170 @@
export const mssqlUIConfig = {
defaultFields: [
{
type: "input",
fieldName: "Host",
validations: {
isRequired: true,
placeholder: "Enter host",
defaultValue: "localhost",
disabled: false
}
},
{
type: "input",
fieldName: "Instance",
validations: {
isRequired: false,
placeholder: "Enter the name of the database instance",
defaultValue: "",
disabled: false
}
},
{
type: "input",
fieldName: "Port",
validations: {
isRequired: true,
placeholder: "Enter port",
defaultValue: "1433",
disabled: false
}
},
{
type: "input",
fieldName: "Database name",
validations: {
isRequired: true,
placeholder: "Name of the database",
defaultValue: "",
disabled: false
}
},
{
type: "input",
fieldName: "Username",
validations: {
isRequired: true,
placeholder: "Enter username",
defaultValue: "",
disabled: false
}
},
{
type: "encrypted",
fieldName: "Password",
validations: {
isRequired: true,
placeholder: "**************",
defaultValue: "",
disabled: true,
hasEditButton: true,
showEncrypted: true,
hasEyeIcon: true
}
},
{
type: "toggle",
fieldName: "Azure (encrypt connection)",
validations: {
defaultValue: false,
disabled: false
}
},
{
type: "keyValue",
fieldName: "Connection options",
validations: {
hasAddButton: true,
rows: [
{
key: "",
value: "",
keyPlaceholder: "Key",
valuePlaceholder: "Value",
hasDeleteButton: true
}
]
}
}
]
};
export const mssqlFormConfig = {
valid: [
{
type: "input",
fieldName: "Host",
text: `${Cypress.env('sqlserver_host')}`
},
{
type: "input",
fieldName: "Instance",
text: `${Cypress.env('sqlserver_instance')}`
},
{
type: "input",
fieldName: "Port",
text: "1433"
},
{
type: "input",
fieldName: "Database name",
text: `${Cypress.env('sqlserver_db')}`
},
{
type: "input",
fieldName: "Username",
text: `${Cypress.env('sqlserver_user')}`
},
{
type: "encrypted",
fieldName: "Password",
text: `${Cypress.env('sqlserver_password')}`
},
{
type: "toggle",
fieldName: "Azure (encrypt connection)",
shouldBeChecked: false
}
],
invalidHost: [
{
type: "input",
fieldName: "Host",
text: "invalid-host"
}
],
invalidUsername: [
{
type: "input",
fieldName: "Username",
text: "invalid-username"
}
],
invalidPassword: [
{
type: "encrypted",
fieldName: "Password",
text: "invalid-password"
}
],
invalidPort: [
{
type: "input",
fieldName: "Port",
text: "9999"
}
],
invalidDatabase: [
{
type: "input",
fieldName: "Database name",
text: "nonexistent_database"
}
],
};

View file

@ -0,0 +1,172 @@
export const mysqlUIConfig = {
defaultFields: [
{
type: "toggle",
fieldName: "Allow dynamic connection parameters",
validations: {
defaultValue: false,
disabled: false
}
},
{
type: "dropdown",
fieldName: "Connection type",
validations: {
defaultValue: 'Hostname',
disabled: false
}
},
{
type: "input",
fieldName: "Host",
validations: {
isRequired: true,
placeholder: "Enter host",
defaultValue: "localhost",
disabled: false
}
},
{
type: "input",
fieldName: "Port",
validations: {
isRequired: true,
placeholder: "Enter port",
defaultValue: "3306",
disabled: false
}
},
{
type: "input",
fieldName: "Database name",
validations: {
isRequired: true,
placeholder: "Name of the database",
defaultValue: "",
disabled: false
}
},
{
type: "input",
fieldName: "Username",
validations: {
isRequired: true,
placeholder: "Enter username",
defaultValue: "",
disabled: false
}
},
{
type: "toggle",
fieldName: "SSL",
validations: {
defaultValue: false,
disabled: false
}
},
{
type: "encrypted",
fieldName: "Password",
validations: {
isRequired: true,
placeholder: "**************",
defaultValue: "",
disabled: true,
hasEditButton: true,
showEncrypted: true,
hasEyeIcon: true
}
},
{
type: "dropdown",
fieldName: "SSL certificate",
validations: {
defaultValue: 'None',
disabled: false
}
}
]
};
export const mysqlFormConfig = {
valid: [
{
type: "input",
fieldName: "Host",
text: `${Cypress.env('mysql_host')}`
},
{
type: "input",
fieldName: "Port",
text: `${Cypress.env('mysql_port')}`
},
{
type: "input",
fieldName: "Database name",
text: 'test_db'
},
{
type: "toggle",
fieldName: "SSL",
shouldBeChecked: false
},
{
type: "input",
fieldName: "Username",
text: `${Cypress.env('mysql_user')}`
},
{
type: "encrypted",
fieldName: "Password",
text: `${Cypress.env('mysql_password')}`
}
],
invalidHost: [
{
type: "input",
fieldName: "Host",
text: "invalid-host"
}
],
invalidUsername: [
{
type: "input",
fieldName: "Username",
text: "invalid-username"
}
],
invalidPassword: [
{
type: "encrypted",
fieldName: "Password",
text: "invalid-password"
}
],
invalidPort: [
{
type: "input",
fieldName: "Port",
text: "9999"
}
],
invalidDatabase: [
{
type: "input",
fieldName: "Database name",
text: "nonexistent_database"
}
],
invalidSsl: [
{
type: "toggle",
fieldName: "SSL",
shouldBeChecked: true
}
],
};

View file

@ -0,0 +1,147 @@
export const redisUIConfig = {
defaultFields: [
{
type: "input",
fieldName: "Host",
validations: {
isRequired: false,
placeholder: "Enter host",
defaultValue: "localhost",
disabled: false
}
},
{
type: "input",
fieldName: "Port",
validations: {
isRequired: false,
placeholder: "Enter port",
defaultValue: "6379",
disabled: false
}
},
{
type: "input",
fieldName: "Database",
validations: {
isRequired: false,
placeholder: "Enter database name",
defaultValue: "",
disabled: false
}
},
{
type: "input",
fieldName: "Username",
validations: {
isRequired: false,
placeholder: "Enter username",
defaultValue: "",
disabled: false
}
},
{
type: "encrypted",
fieldName: "Password",
validations: {
isRequired: false,
placeholder: "**************",
defaultValue: "",
disabled: true,
hasEditButton: true,
showEncrypted: true,
hasEyeIcon: true
}
},
{
type: "toggle",
fieldName: "TLS",
validations: {
defaultValue: false,
disabled: false
}
},
{
type: "dropdown",
fieldName: "TLS certificate",
validations: {
defaultValue: 'None',
disabled: false
}
}
]
};
export const redisFormConfig = {
valid: [
{
type: "input",
fieldName: "Host",
text: `${Cypress.env('redis_host')}`
},
{
type: "input",
fieldName: "Port",
text: `${Cypress.env('redis_port')}`
},
{
type: "input",
fieldName: "Database",
text: `${Cypress.env('redis_database')}`
},
{
type: "input",
fieldName: "Username",
text: `${Cypress.env('redis_user')}`
},
{
type: "encrypted",
fieldName: "Password",
text: `${Cypress.env('redis_password')}`
},
{
type: "toggle",
fieldName: "TLS",
shouldBeChecked: false
}
],
invalidHost: [
{
type: "input",
fieldName: "Host",
text: "invalid-host"
}
],
invalidUsername: [
{
type: "input",
fieldName: "Username",
text: "invalid-username"
}
],
invalidPassword: [
{
type: "encrypted",
fieldName: "Password",
text: "invalid-password"
}
],
invalidPort: [
{
type: "input",
fieldName: "Port",
text: "9999"
}
],
invalidDatabase: [
{
type: "input",
fieldName: "Database",
text: "999"
}
],
};

View file

@ -1,4 +1,9 @@
import { cyParamName } from "Selectors/common";
export const cyParamName = (paramName = "") => {
return String(paramName)
.toLowerCase()
.replace(/[^a-z0-9]+/g, "-")
.replace(/^-+|-+$/g, "");
};
export const dsCommonSelector = {
deleteDSButton: (datasourceName) => {
@ -55,5 +60,8 @@ export const dsCommonSelector = {
},
text: (fieldName) => {
return `[data-cy="${cyParamName(fieldName)}-text"]`;
},
checkboxInput: (checkboxName) => {
return `[data-cy="${cyParamName(checkboxName)}-checkbox-input"]`;
}
};

View file

@ -0,0 +1,108 @@
import { fake } from "Fixtures/fake";
import { dsCommonSelector } from "Selectors/marketplace/common";
import { verifyConnectionFormUI } from "Support/utils/marketplace/dataSource/datasourceformUIHelpers";
import { fillDSConnectionForm, verifyDSConnection } from "Support/utils/marketplace/dataSource/datasourceformFillHelpers";
import { elasticsearchUIConfig, elasticsearchFormConfig } from "Constants/constants/marketplace/datasources/elasticsearch";
const data = {};
describe("Elasticsearch", () => {
data.dataSourceName = fake.lastName
.toLowerCase()
.replaceAll("[^A-Za-z]", "");
const elasticsearchDataSourceName = `cypress-${data.dataSourceName}-elasticsearch`;
beforeEach(() => {
cy.apiLogin();
cy.viewport(1400, 1600);
});
afterEach(() => {
cy.apiDeleteDataSource(elasticsearchDataSourceName);
});
it("1. Elasticsearch - Verify connection form UI elements - ALL FIELDS", () => {
cy.apiCreateDataSource(
`${Cypress.env("server_host")}/api/data-sources`,
`${elasticsearchDataSourceName}`,
"elasticsearch",
[
{ key: "scheme", value: "http", encrypted: false },
{ key: "host", value: "localhost", encrypted: false },
{ key: "port", value: 9200, encrypted: false },
{ key: "ssl_enabled", value: true, encrypted: false },
{ key: "ssl_certificate", value: "none", encrypted: false },
{ key: "username", value: "", encrypted: false },
{ key: "password", value: "", encrypted: true },
{ key: "ca_cert", value: null, encrypted: false },
{ key: "client_key", value: null, encrypted: false },
{ key: "client_cert", value: null, encrypted: false },
{ key: "root_cert", value: null, encrypted: false },
]
);
cy.visit('/my-workspace/data-sources');
cy.waitForElement(dsCommonSelector.dataSourceNameButton(elasticsearchDataSourceName));
cy.get(dsCommonSelector.dataSourceNameButton(elasticsearchDataSourceName)).click();
verifyConnectionFormUI(elasticsearchUIConfig.defaultFields);
});
it("2. Elasticsearch - Verify data source connection with valid credentials", () => {
cy.apiCreateDataSource(
`${Cypress.env("server_host")}/api/data-sources`,
`${elasticsearchDataSourceName}`,
"elasticsearch",
[
{ key: "scheme", value: "http", encrypted: false },
{ key: "host", value: "localhost", encrypted: false },
{ key: "port", value: 9200, encrypted: false },
{ key: "ssl_enabled", value: false, encrypted: false },
{ key: "ssl_certificate", value: "none", encrypted: false },
{ key: "username", value: "", encrypted: false },
{ key: "password", value: "", encrypted: true },
{ key: "ca_cert", value: null, encrypted: false },
{ key: "client_key", value: null, encrypted: false },
{ key: "client_cert", value: null, encrypted: false },
{ key: "root_cert", value: null, encrypted: false },
]
);
cy.visit('/my-workspace/data-sources');
cy.waitForElement(dsCommonSelector.dataSourceNameButton(elasticsearchDataSourceName));
cy.get(dsCommonSelector.dataSourceNameButton(elasticsearchDataSourceName)).click();
fillDSConnectionForm(elasticsearchFormConfig, []);
verifyDSConnection();
});
it("3. Elasticsearch - Verify UI and connection together", () => {
cy.apiCreateDataSource(
`${Cypress.env("server_host")}/api/data-sources`,
`${elasticsearchDataSourceName}`,
"elasticsearch",
[
{ key: "scheme", value: "http", encrypted: false },
{ key: "host", value: "localhost", encrypted: false },
{ key: "port", value: 9200, encrypted: false },
{ key: "ssl_enabled", value: false, encrypted: false },
{ key: "ssl_certificate", value: "none", encrypted: false },
{ key: "username", value: "", encrypted: false },
{ key: "password", value: "", encrypted: true },
{ key: "ca_cert", value: null, encrypted: false },
{ key: "client_key", value: null, encrypted: false },
{ key: "client_cert", value: null, encrypted: false },
{ key: "root_cert", value: null, encrypted: false },
]
);
cy.visit('/my-workspace/data-sources');
cy.waitForElement(dsCommonSelector.dataSourceNameButton(elasticsearchDataSourceName));
cy.get(dsCommonSelector.dataSourceNameButton(elasticsearchDataSourceName)).click();
fillDSConnectionForm(elasticsearchFormConfig, elasticsearchFormConfig.invalidSsl);
verifyDSConnection("failed", "ConnectionError: write EPROTO 80A07CEF01000000:error:0A00010B:SSL routines:ssl3_get_record:wrong version number:../deps/openssl/openssl/ssl/record/ssl3_record.c:355:\n");
fillDSConnectionForm(elasticsearchFormConfig, elasticsearchFormConfig.invalidHost);
verifyDSConnection("failed", "ConnectionError: getaddrinfo ENOTFOUND invalid-host");
fillDSConnectionForm(elasticsearchFormConfig, elasticsearchFormConfig.invalidPort);
verifyDSConnection("failed", "TimeoutError: Request timed out");
});
});

View file

@ -0,0 +1,119 @@
import { fake } from "Fixtures/fake";
import { dsCommonSelector } from "Selectors/marketplace/common";
import { verifyConnectionFormUI } from "Support/utils/marketplace/dataSource/datasourceformUIHelpers";
import { fillDSConnectionForm, verifyDSConnection, fillDSConnectionDropdown } from "Support/utils/marketplace/dataSource/datasourceformFillHelpers";
import { mongodbUIConfig, mongodbFormConfig } from "Constants/constants/marketplace/datasources/mongodb";
const data = {};
describe("MongoDB", () => {
data.dataSourceName = fake.lastName
.toLowerCase()
.replaceAll("[^A-Za-z]", "");
const mongodbDataSourceName = `cypress-${data.dataSourceName}-mongodb`;
beforeEach(() => {
cy.apiLogin();
cy.viewport(1400, 1600);
});
afterEach(() => {
cy.apiDeleteDataSource(mongodbDataSourceName);
});
it("1. MongoDB - Verify connection form UI elements - ALL FIELDS", () => {
cy.apiCreateDataSource(
`${Cypress.env("server_host")}/api/data-sources`,
`${mongodbDataSourceName}`,
"mongodb",
[
{ key: "connection_type", value: "manual", encrypted: false },
{ key: "connection_format", value: "mongodb", encrypted: false },
{ key: "host", value: "", encrypted: false },
{ key: "port", value: "", encrypted: false },
{ key: "database", value: "", encrypted: false },
{ key: "username", value: "", encrypted: false },
{ key: "tls_certificate", value: "none", encrypted: false },
{ key: "password", value: null, encrypted: true },
{ key: "ca_cert", value: null, encrypted: true },
{ key: "client_key", value: null, encrypted: true },
{ key: "client_cert", value: null, encrypted: true },
{ key: "connection_string", value: null, encrypted: true },
]
);
cy.visit('/my-workspace/data-sources');
cy.waitForElement(dsCommonSelector.dataSourceNameButton(mongodbDataSourceName));
cy.get(dsCommonSelector.dataSourceNameButton(mongodbDataSourceName)).click();
verifyConnectionFormUI(mongodbUIConfig.defaultFieldsManual);
fillDSConnectionDropdown({ type: "dropdown", fieldName: "Connection type", text: "Connect using connection string" });
verifyConnectionFormUI(mongodbUIConfig.defaultFieldsConnectionString);
});
it("2. MongoDB - Verify data source connection with valid credentials", () => {
cy.apiCreateDataSource(
`${Cypress.env("server_host")}/api/data-sources`,
`${mongodbDataSourceName}`,
"mongodb",
[
{ key: "connection_type", value: "manual", encrypted: false },
{ key: "connection_format", value: "mongodb", encrypted: false },
{ key: "host", value: "", encrypted: false },
{ key: "port", value: "", encrypted: false },
{ key: "database", value: "", encrypted: false },
{ key: "username", value: "", encrypted: false },
{ key: "tls_certificate", value: "none", encrypted: false },
{ key: "password", value: null, encrypted: true },
{ key: "ca_cert", value: null, encrypted: true },
{ key: "client_key", value: null, encrypted: true },
{ key: "client_cert", value: null, encrypted: true },
{ key: "connection_string", value: null, encrypted: true },
]
);
cy.visit('/my-workspace/data-sources');
cy.waitForElement(dsCommonSelector.dataSourceNameButton(mongodbDataSourceName));
cy.get(dsCommonSelector.dataSourceNameButton(mongodbDataSourceName)).click();
fillDSConnectionForm(mongodbFormConfig.valid, []);
verifyDSConnection();
// Note: need to get new creds
// fillDSConnectionForm(mongodbFormConfig.validConnectionString, []);
// verifyDSConnection();
});
it("3. MongoDB - Verify UI and connection together", () => {
cy.apiCreateDataSource(
`${Cypress.env("server_host")}/api/data-sources`,
`${mongodbDataSourceName}`,
"mongodb",
[
{ key: "connection_type", value: "manual", encrypted: false },
{ key: "connection_format", value: "mongodb", encrypted: false },
{ key: "host", value: "", encrypted: false },
{ key: "port", value: "", encrypted: false },
{ key: "database", value: "", encrypted: false },
{ key: "username", value: "", encrypted: false },
{ key: "tls_certificate", value: "none", encrypted: false },
{ key: "password", value: null, encrypted: true },
{ key: "ca_cert", value: null, encrypted: true },
{ key: "client_key", value: null, encrypted: true },
{ key: "client_cert", value: null, encrypted: true },
{ key: "connection_string", value: null, encrypted: true },
]
);
cy.visit('/my-workspace/data-sources');
cy.waitForElement(dsCommonSelector.dataSourceNameButton(mongodbDataSourceName));
cy.get(dsCommonSelector.dataSourceNameButton(mongodbDataSourceName)).click();
fillDSConnectionForm(mongodbFormConfig, mongodbFormConfig.invalidHost);
verifyDSConnection("failed", "getaddrinfo ENOTFOUND invalid-host");
fillDSConnectionForm(mongodbFormConfig, mongodbFormConfig.invalidPort);
verifyDSConnection("failed", "connection timed out");
// Note: need to get new creds
// fillDSConnectionForm(mongodbFormConfig, mongodbFormConfig.validConnectionString);
// verifyDSConnection();
});
});

View file

@ -0,0 +1,98 @@
import { fake } from "Fixtures/fake";
import { dsCommonSelector } from "Selectors/marketplace/common";
import { verifyConnectionFormUI } from "Support/utils/marketplace/dataSource/datasourceformUIHelpers";
import { fillDSConnectionForm, verifyDSConnection } from "Support/utils/marketplace/dataSource/datasourceformFillHelpers";
import { mssqlUIConfig, mssqlFormConfig } from "Constants/constants/marketplace/datasources/mssql";
const data = {};
describe("MSSQL", () => {
data.dataSourceName = fake.lastName
.toLowerCase()
.replaceAll("[^A-Za-z]", "");
const mssqlDataSourceName = `cypress-${data.dataSourceName}-mssql`;
beforeEach(() => {
cy.apiLogin();
cy.viewport(1400, 1600);
});
afterEach(() => {
cy.apiDeleteDataSource(mssqlDataSourceName);
});
it("1. MSSQL - Verify connection form UI elements - ALL FIELDS", () => {
cy.apiCreateDataSource(
`${Cypress.env("server_host")}/api/data-sources`,
`${mssqlDataSourceName}`,
"mssql",
[
{ key: "host", value: "localhost", encrypted: false },
{ key: "port", value: 1433, encrypted: false },
{ key: "database", value: "", encrypted: false },
{ key: "azure", value: false, encrypted: false },
{ key: "password", value: null, encrypted: true },
]
);
cy.visit('/my-workspace/data-sources');
cy.waitForElement(dsCommonSelector.dataSourceNameButton(mssqlDataSourceName));
cy.get(dsCommonSelector.dataSourceNameButton(mssqlDataSourceName)).click();
verifyConnectionFormUI(mssqlUIConfig.defaultFields);
});
it("2. MSSQL - Verify data source connection with valid credentials", () => {
cy.apiCreateDataSource(
`${Cypress.env("server_host")}/api/data-sources`,
`${mssqlDataSourceName}`,
"mssql",
[
{ key: "host", value: "localhost", encrypted: false },
{ key: "port", value: 1433, encrypted: false },
{ key: "database", value: "", encrypted: false },
{ key: "azure", value: false, encrypted: false },
{ key: "password", value: null, encrypted: true },
]
);
cy.visit('/my-workspace/data-sources');
cy.waitForElement(dsCommonSelector.dataSourceNameButton(mssqlDataSourceName));
cy.get(dsCommonSelector.dataSourceNameButton(mssqlDataSourceName)).click();
fillDSConnectionForm(mssqlFormConfig, []);
verifyDSConnection();
});
it("3. MSSQL - Verify UI and connection together", () => {
cy.apiCreateDataSource(
`${Cypress.env("server_host")}/api/data-sources`,
`${mssqlDataSourceName}`,
"mssql",
[
{ key: "host", value: "localhost", encrypted: false },
{ key: "port", value: 1433, encrypted: false },
{ key: "database", value: "", encrypted: false },
{ key: "azure", value: false, encrypted: false },
{ key: "password", value: null, encrypted: true },
]
);
cy.visit('/my-workspace/data-sources');
cy.waitForElement(dsCommonSelector.dataSourceNameButton(mssqlDataSourceName));
cy.get(dsCommonSelector.dataSourceNameButton(mssqlDataSourceName)).click();
verifyConnectionFormUI(mssqlUIConfig.defaultFields);
fillDSConnectionForm(mssqlFormConfig, mssqlFormConfig.invalidHost);
verifyDSConnection("failed", "Failed to connect to invalid-host:1433 - getaddrinfo ENOTFOUND invalid-host");
fillDSConnectionForm(mssqlFormConfig, mssqlFormConfig.invalidUsername);
verifyDSConnection("failed", "Login failed for user 'invalid-username'.");
fillDSConnectionForm(mssqlFormConfig, mssqlFormConfig.invalidPassword);
verifyDSConnection("failed", "Login failed for user 'sa'.");
fillDSConnectionForm(mssqlFormConfig, mssqlFormConfig.invalidPort);
verifyDSConnection("failed", "Failed to connect to 9.234.17.31:9999 in 15000ms");
fillDSConnectionForm(mssqlFormConfig, mssqlFormConfig.invalidDatabase);
verifyDSConnection("failed", "Login failed for user 'sa'.");
});
});

View file

@ -0,0 +1,119 @@
import { fake } from "Fixtures/fake";
import { dsCommonSelector } from "Selectors/marketplace/common";
import { verifyConnectionFormUI } from "Support/utils/marketplace/dataSource/datasourceformUIHelpers";
import { fillDSConnectionForm, verifyDSConnection } from "Support/utils/marketplace/dataSource/datasourceformFillHelpers";
import { mysqlUIConfig, mysqlFormConfig } from "Constants/constants/marketplace/datasources/mysql";
const data = {};
describe("MySQL", () => {
data.dataSourceName = fake.lastName
.toLowerCase()
.replaceAll("[^A-Za-z]", "");
const mysqlDataSourceName = `cypress-${data.dataSourceName}-mysql`;
beforeEach(() => {
cy.apiLogin();
cy.viewport(1400, 1600);
});
afterEach(() => {
cy.apiDeleteDataSource(mysqlDataSourceName);
});
it("1. MySQL - Verify connection form UI elements - ALL FIELDS", () => {
cy.apiCreateDataSource(
`${Cypress.env("server_host")}/api/data-sources`,
`${mysqlDataSourceName}`,
"mysql",
[
{ key: "connection_type", value: "hostname", encrypted: false },
{ key: "host", value: "localhost", encrypted: false },
{ key: "port", value: 3306, encrypted: false },
{ key: "database", value: "", encrypted: false },
{ key: "username", value: "", encrypted: false },
{ key: "ssl_enabled", value: false, encrypted: false },
{ key: "ssl_certificate", value: "none", encrypted: false },
{ key: "password", value: null, encrypted: true },
{ key: "ca_cert", value: null, encrypted: true },
{ key: "client_key", value: null, encrypted: true },
{ key: "client_cert", value: null, encrypted: true },
{ key: "root_cert", value: null, encrypted: true },
]
);
cy.visit('/my-workspace/data-sources');
cy.waitForElement(dsCommonSelector.dataSourceNameButton(mysqlDataSourceName));
cy.get(dsCommonSelector.dataSourceNameButton(mysqlDataSourceName)).click();
verifyConnectionFormUI(mysqlUIConfig.defaultFields);
});
it("2. MySQL - Verify data source connection with valid credentials", () => {
cy.apiCreateDataSource(
`${Cypress.env("server_host")}/api/data-sources`,
`${mysqlDataSourceName}`,
"mysql",
[
{ key: "connection_type", value: "hostname", encrypted: false },
{ key: "host", value: "localhost", encrypted: false },
{ key: "port", value: 3306, encrypted: false },
{ key: "database", value: "", encrypted: false },
{ key: "username", value: "", encrypted: false },
{ key: "ssl_enabled", value: false, encrypted: false },
{ key: "ssl_certificate", value: "none", encrypted: false },
{ key: "password", value: null, encrypted: true },
{ key: "ca_cert", value: null, encrypted: true },
{ key: "client_key", value: null, encrypted: true },
{ key: "client_cert", value: null, encrypted: true },
{ key: "root_cert", value: null, encrypted: true },
]
);
cy.visit('/my-workspace/data-sources');
cy.waitForElement(dsCommonSelector.dataSourceNameButton(mysqlDataSourceName));
cy.get(dsCommonSelector.dataSourceNameButton(mysqlDataSourceName)).click();
fillDSConnectionForm(mysqlFormConfig, []);
verifyDSConnection();
});
it("3. MySQL - Verify UI and connection together", () => {
cy.apiCreateDataSource(
`${Cypress.env("server_host")}/api/data-sources`,
`${mysqlDataSourceName}`,
"mysql",
[
{ key: "connection_type", value: "hostname", encrypted: false },
{ key: "host", value: "localhost", encrypted: false },
{ key: "port", value: 3306, encrypted: false },
{ key: "database", value: "", encrypted: false },
{ key: "username", value: "", encrypted: false },
{ key: "ssl_enabled", value: false, encrypted: false },
{ key: "ssl_certificate", value: "none", encrypted: false },
{ key: "password", value: null, encrypted: true },
{ key: "ca_cert", value: null, encrypted: true },
{ key: "client_key", value: null, encrypted: true },
{ key: "client_cert", value: null, encrypted: true },
{ key: "root_cert", value: null, encrypted: true },
]
);
cy.visit('/my-workspace/data-sources');
cy.waitForElement(dsCommonSelector.dataSourceNameButton(mysqlDataSourceName));
cy.get(dsCommonSelector.dataSourceNameButton(mysqlDataSourceName)).click();
verifyConnectionFormUI(mysqlUIConfig.defaultFields);
fillDSConnectionForm(mysqlFormConfig, mysqlFormConfig.invalidHost);
verifyDSConnection("failed", "getaddrinfo ENOTFOUND invalid-host");
fillDSConnectionForm(mysqlFormConfig, mysqlFormConfig.invalidUsername);
verifyDSConnection("failed", "Access denied for user 'invalid-username'@'194.22.189.63' (using password: YES)");
fillDSConnectionForm(mysqlFormConfig, mysqlFormConfig.invalidPassword);
verifyDSConnection("failed", "Access denied for user 'root'@'194.22.189.63' (using password: YES)");
fillDSConnectionForm(mysqlFormConfig, mysqlFormConfig.invalidPort);
verifyDSConnection("failed", "connect ETIMEDOUT");
fillDSConnectionForm(mysqlFormConfig, mysqlFormConfig.invalidDatabase);
verifyDSConnection("failed", "Unknown database 'nonexistent_database'");
});
});

View file

@ -0,0 +1,105 @@
import { fake } from "Fixtures/fake";
import { dsCommonSelector } from "Selectors/marketplace/common";
import { verifyConnectionFormUI } from "Support/utils/marketplace/dataSource/datasourceformUIHelpers";
import { fillDSConnectionForm, verifyDSConnection } from "Support/utils/marketplace/dataSource/datasourceformFillHelpers";
import { redisUIConfig, redisFormConfig } from "Constants/constants/marketplace/datasources/redis";
const data = {};
describe("Redis", () => {
data.dataSourceName = fake.lastName
.toLowerCase()
.replaceAll("[^A-Za-z]", "");
const redisDataSourceName = `cypress-${data.dataSourceName}-redis`;
beforeEach(() => {
cy.apiLogin();
cy.viewport(1400, 1600);
});
afterEach(() => {
cy.apiDeleteDataSource(redisDataSourceName);
});
it("1. Redis - Verify connection form UI elements - ALL FIELDS", () => {
cy.apiCreateDataSource(
`${Cypress.env("server_host")}/api/data-sources`,
`${redisDataSourceName}`,
"redis",
[
{ key: "scheme", value: "redis", encrypted: false },
{ key: "host", value: "localhost", encrypted: false },
{ key: "port", value: 6379, encrypted: false },
{ key: "database", value: "", encrypted: false },
{ key: "username", value: "", encrypted: false },
{ key: "password", value: "", encrypted: false },
{ key: "tls_enabled", value: false, encrypted: false },
{ key: "tls_certificate", value: "none", encrypted: false },
{ key: "ca_cert", value: null, encrypted: false },
{ key: "client_key", value: null, encrypted: false },
{ key: "client_cert", value: null, encrypted: false },
]
);
cy.visit('/my-workspace/data-sources');
cy.waitForElement(dsCommonSelector.dataSourceNameButton(redisDataSourceName));
cy.get(dsCommonSelector.dataSourceNameButton(redisDataSourceName)).click();
verifyConnectionFormUI(redisUIConfig.defaultFields);
});
it("2. Redis - Verify data source connection with valid credentials", () => {
cy.apiCreateDataSource(
`${Cypress.env("server_host")}/api/data-sources`,
`${redisDataSourceName}`,
"redis",
[
{ key: "scheme", value: "redis", encrypted: false },
{ key: "host", value: "localhost", encrypted: false },
{ key: "port", value: 6379, encrypted: false },
{ key: "database", value: "", encrypted: false },
{ key: "username", value: "", encrypted: false },
{ key: "password", value: "", encrypted: false },
{ key: "tls_enabled", value: false, encrypted: false },
{ key: "tls_certificate", value: "none", encrypted: false },
{ key: "ca_cert", value: null, encrypted: false },
{ key: "client_key", value: null, encrypted: false },
{ key: "client_cert", value: null, encrypted: false },
]
);
cy.visit('/my-workspace/data-sources');
cy.waitForElement(dsCommonSelector.dataSourceNameButton(redisDataSourceName));
cy.get(dsCommonSelector.dataSourceNameButton(redisDataSourceName)).click();
fillDSConnectionForm(redisFormConfig, []);
verifyDSConnection();
});
it("3. Redis - Verify UI and connection together", () => {
cy.apiCreateDataSource(
`${Cypress.env("server_host")}/api/data-sources`,
`${redisDataSourceName}`,
"redis",
[
{ key: "scheme", value: "redis", encrypted: false },
{ key: "host", value: "localhost", encrypted: false },
{ key: "port", value: 6379, encrypted: false },
{ key: "database", value: "", encrypted: false },
{ key: "username", value: "", encrypted: false },
{ key: "password", value: "", encrypted: false },
{ key: "tls_enabled", value: false, encrypted: false },
{ key: "tls_certificate", value: "none", encrypted: false },
{ key: "ca_cert", value: null, encrypted: false },
{ key: "client_key", value: null, encrypted: false },
{ key: "client_cert", value: null, encrypted: false },
]
);
cy.visit('/my-workspace/data-sources');
cy.waitForElement(dsCommonSelector.dataSourceNameButton(redisDataSourceName));
cy.get(dsCommonSelector.dataSourceNameButton(redisDataSourceName)).click();
fillDSConnectionForm(redisFormConfig, redisFormConfig.invalidHost);
verifyDSConnection("failed", "Connection could not be established");
fillDSConnectionForm(redisFormConfig, redisFormConfig.invalidPort);
verifyDSConnection("failed", "Connection could not be established");
});
});

View file

@ -6,8 +6,9 @@ export const fillDSConnectionTextField = (field) => {
export const fillDSConnectionDropdown = (field) => {
cy.waitForElement(dsCommonSelector.dropdownField(field.fieldName))
cy.get(dsCommonSelector.dropdownField(field.fieldName))
.click();
cy.contains("[id*=react-select-]", field.option).click();
cy.contains("[id*=react-select-]", field.text).click();
};
export const toggleDSConnectionButton = (field) => {
@ -30,6 +31,16 @@ export const selectDSConnectionRadioButton = (field) => {
});
};
export const selectDSConnectionCheckbox = (field) => {
const shouldBeChecked = field.shouldBeChecked !== undefined ? field.shouldBeChecked : true;
cy.get(dsCommonSelector.checkboxInput(field.fieldName)).then(($checkbox) => {
const isChecked = $checkbox.is(":checked");
if (isChecked !== shouldBeChecked) {
cy.wrap($checkbox).click({ force: true });
}
});
};
export const fillDSConnectionKeyValuePairs = (field) => {
cy.get(dsCommonSelector.subSection(field.fieldName)).within(() => {
field.keyValueData.forEach((pair, index) => {
@ -80,11 +91,17 @@ export const saveAndDiscardDSChanges = (option) => {
};
export const verifyDSConnection = (expectedStatus = "success", customMessage = null) => {
cy.intercept('POST', '**/api/data-sources/*/test-connection').as('testConnection');
cy.waitForElement('[data-cy="test-connection-button"]', 60000);
cy.get('[data-cy="test-connection-button"]')
.should("be.visible")
.should("contain.text", "Test connection")
.click();
// Wait for the API call to complete
cy.wait('@testConnection', { timeout: 60000 });
switch (expectedStatus) {
case "success":
cy.get('[data-cy="test-connection-verified-text"]')
@ -93,12 +110,15 @@ export const verifyDSConnection = (expectedStatus = "success", customMessage = n
break;
case "failed":
cy.waitForElement('[data-cy="test-connection-failed-text"]', 60000);
cy.get('[data-cy="test-connection-failed-text"]')
.should("be.visible", { timeout: 10000 })
.scrollIntoView()
.should("be.visible", { timeout: 30000 })
.should("contain.text", "could not connect");
cy.get('[data-cy="connection-alert-text"]')
.should("be.visible", { timeout: 10000 })
.scrollIntoView()
.should("be.visible", { timeout: 40000 })
.verifyVisibleElement("have.text", customMessage);
break;
}
@ -141,6 +161,9 @@ const processFields = (fields) => {
case 'keyValue':
fillDSConnectionKeyValuePairs(field);
break;
case 'checkbox':
selectDSConnectionCheckbox(field);
break;
default:
throw new Error(`Unsupported field type: ${field.type}`);
}

View file

@ -1,5 +1,4 @@
import { dsCommonSelector } from "Selectors/marketplace/common";
import { cyParamName } from "Selectors/common";
import { dsCommonSelector, cyParamName } from "Selectors/marketplace/common";
export const verifyConnectionFormHeader = (data) => {
cy.waitForElement('[data-cy="data-source-name-input-field"]')
@ -193,6 +192,18 @@ export const verifyKeyValueFieldUI = (field) => {
}
});
};
export const verifyCheckboxFieldUI = (field) => {
const { fieldName, validations = {} } = field;
cy.get(dsCommonSelector.subSection(fieldName)).within(() => {
cy.get(dsCommonSelector.labelFieldName(fieldName)).should('be.visible');
const checkboxSelector = dsCommonSelector.checkboxInput(fieldName);
validateCheckedState(checkboxSelector, validations.value);
validateCheckedState(checkboxSelector, validations.defaultValue);
validateDisabledState(checkboxSelector, validations.disabled);
});
};
export const verifyConnectionFormUI = (fields) => {
fields.forEach((field) => {
@ -216,6 +227,9 @@ export const verifyConnectionFormUI = (fields) => {
case 'keyValue':
verifyKeyValueFieldUI(field);
break;
case 'checkbox':
verifyCheckboxFieldUI(field);
break;
default:
throw new Error(`Unsupported field type: ${field.type}`);
}

View file

@ -711,7 +711,7 @@ const DynamicForm = ({
return (
<div key={flipComponentDropdown.key}>
<div className={isHorizontalLayout ? '' : 'row'} data-cy={`${generateCypressDataCy(flipComponentDropdown.label)}-section`}>
<div className={isHorizontalLayout ? '' : 'row'} >
{flipComponentDropdown.commonFields && getLayout(flipComponentDropdown.commonFields)}
<div

View file

@ -1,4 +1,5 @@
import React from 'react';
import { generateCypressDataCy } from '../../modules/common/helpers/cypressHelpers.js';
export const Checkbox = ({ label, isChecked, onChange, key = '', value }) => {
const handleOnchange = (event) => {
@ -15,8 +16,9 @@ export const Checkbox = ({ label, isChecked, onChange, key = '', value }) => {
type="checkbox"
onChange={handleOnchange}
checked={isChecked}
data-cy={`${generateCypressDataCy(label)}-checkbox-input`}
/>
<label className="form-check-label">{label}</label>
<label className="form-check-label" data-cy={`label-${generateCypressDataCy(label)}`}>{label}</label>
</div>
);
};