2022-04-11 03:30:37 +00:00
|
|
|
/* eslint-disable cypress/no-unnecessary-waiting */
|
|
|
|
|
/* eslint-disable cypress/no-assigning-return-values */
|
|
|
|
|
|
2023-11-28 11:11:54 +00:00
|
|
|
import { AppSidebar, AppSidebarButton } from "./Pages/EditorNavigation";
|
2023-11-15 02:31:12 +00:00
|
|
|
|
2022-04-11 03:30:37 +00:00
|
|
|
require("cy-verify-downloads").addCustomCommand();
|
|
|
|
|
require("cypress-file-upload");
|
2022-12-05 05:58:17 +00:00
|
|
|
import { ObjectsRegistry } from "../support/Objects/Registry";
|
2024-03-15 05:43:14 +00:00
|
|
|
import { agHelper } from "./Objects/ObjectsCore";
|
2022-04-11 03:30:37 +00:00
|
|
|
const datasourceEditor = require("../locators/DatasourcesEditor.json");
|
|
|
|
|
const datasourceFormData = require("../fixtures/datasources.json");
|
2022-07-08 14:31:12 +00:00
|
|
|
const apiWidgetslocator = require("../locators/apiWidgetslocator.json");
|
2022-09-09 15:59:47 +00:00
|
|
|
const apiEditorLocators = require("../locators/ApiEditor");
|
2022-12-05 05:58:17 +00:00
|
|
|
const dataSources = ObjectsRegistry.DataSources;
|
2022-04-11 03:30:37 +00:00
|
|
|
|
2023-05-19 18:37:06 +00:00
|
|
|
const backgroundColorBlack = "rgb(76, 86, 100)";
|
|
|
|
|
const backgroundColorGray1 = "rgb(241, 245, 249)";
|
|
|
|
|
const backgroundColorGray2 = "rgba(0, 0, 0, 0)";
|
|
|
|
|
const backgroundColorGray8 = "rgb(106, 117, 133)";
|
2022-06-16 06:18:44 +00:00
|
|
|
|
2022-04-11 03:30:37 +00:00
|
|
|
export const initLocalstorage = () => {
|
|
|
|
|
cy.window().then((window) => {
|
|
|
|
|
window.localStorage.setItem("ShowCommentsButtonToolTip", "");
|
|
|
|
|
window.localStorage.setItem("updateDismissed", "true");
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Cypress.Commands.add("NavigateToDatasourceEditor", () => {
|
2023-05-19 18:37:06 +00:00
|
|
|
dataSources.NavigateToDSCreateNew();
|
2022-04-11 03:30:37 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Cypress.Commands.add("testDatasource", (expectedRes = true) => {
|
|
|
|
|
cy.get(".t--test-datasource").click({ force: true });
|
2023-06-15 13:21:11 +00:00
|
|
|
cy.wait("@testDatasource")
|
|
|
|
|
.its("response.body.data.success")
|
|
|
|
|
.should("eq", expectedRes);
|
2022-04-11 03:30:37 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Cypress.Commands.add("saveDatasource", () => {
|
|
|
|
|
cy.get(".t--save-datasource").click({ force: true });
|
2023-06-15 13:21:11 +00:00
|
|
|
cy.wait("@saveDatasource")
|
|
|
|
|
.its("response.body.responseMeta.status")
|
|
|
|
|
.should("eq", 201);
|
2022-04-11 03:30:37 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Cypress.Commands.add("testSaveDatasource", (expectedRes = true) => {
|
|
|
|
|
cy.testDatasource(expectedRes);
|
|
|
|
|
cy.saveDatasource();
|
|
|
|
|
// cy.get(datasourceEditor.datasourceCard)
|
|
|
|
|
// .last()
|
|
|
|
|
// .click();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Cypress.Commands.add(
|
|
|
|
|
"fillPostgresDatasourceForm",
|
|
|
|
|
(shouldAddTrailingSpaces = false) => {
|
|
|
|
|
const hostAddress = shouldAddTrailingSpaces
|
|
|
|
|
? datasourceFormData["postgres-host"] + " "
|
|
|
|
|
: datasourceFormData["postgres-host"];
|
|
|
|
|
const databaseName = shouldAddTrailingSpaces
|
|
|
|
|
? datasourceFormData["postgres-databaseName"] + " "
|
|
|
|
|
: datasourceFormData["postgres-databaseName"];
|
|
|
|
|
|
2024-04-30 07:45:11 +00:00
|
|
|
agHelper.ClearNType(datasourceEditor.host, hostAddress);
|
|
|
|
|
agHelper.ClearNType(
|
|
|
|
|
datasourceEditor.port,
|
|
|
|
|
datasourceFormData["postgres-port"],
|
|
|
|
|
);
|
|
|
|
|
agHelper.ClearNType(datasourceEditor.databaseName, databaseName);
|
|
|
|
|
agHelper.ClearNType(
|
|
|
|
|
datasourceEditor.username,
|
2022-04-11 03:30:37 +00:00
|
|
|
datasourceFormData["postgres-username"],
|
|
|
|
|
);
|
2024-04-30 07:45:11 +00:00
|
|
|
agHelper.ClearNType(
|
|
|
|
|
datasourceEditor.password,
|
2022-04-11 03:30:37 +00:00
|
|
|
datasourceFormData["postgres-password"],
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
|
2022-05-18 17:35:03 +00:00
|
|
|
Cypress.Commands.add(
|
|
|
|
|
"fillElasticDatasourceForm",
|
|
|
|
|
(shouldAddTrailingSpaces = false) => {
|
|
|
|
|
// we are using postgresql data for elastic search,
|
|
|
|
|
// in the future, this should be changed, just for testing purposes
|
|
|
|
|
const hostAddress = "https://localhost";
|
2023-05-19 18:37:06 +00:00
|
|
|
const headerValue = "Bearer token";
|
2022-05-18 17:35:03 +00:00
|
|
|
|
2024-04-30 07:45:11 +00:00
|
|
|
agHelper.ClearNType(datasourceEditor.host, hostAddress);
|
|
|
|
|
agHelper.ClearNType(
|
|
|
|
|
datasourceEditor.port,
|
|
|
|
|
datasourceFormData["postgres-port"],
|
|
|
|
|
);
|
2022-05-18 17:35:03 +00:00
|
|
|
cy.get(datasourceEditor.sectionAuthentication).click();
|
2024-04-30 07:45:11 +00:00
|
|
|
agHelper.ClearNType(
|
|
|
|
|
datasourceEditor.username,
|
2022-05-18 17:35:03 +00:00
|
|
|
datasourceFormData["postgres-username"],
|
|
|
|
|
);
|
2024-04-30 07:45:11 +00:00
|
|
|
agHelper.ClearNType(
|
|
|
|
|
datasourceEditor.password,
|
2022-05-18 17:35:03 +00:00
|
|
|
datasourceFormData["postgres-password"],
|
|
|
|
|
);
|
2024-04-30 07:45:11 +00:00
|
|
|
agHelper.ClearNType(datasourceEditor.headers, headerValue);
|
2022-05-18 17:35:03 +00:00
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
|
2022-04-11 03:30:37 +00:00
|
|
|
Cypress.Commands.add(
|
|
|
|
|
"fillMySQLDatasourceForm",
|
|
|
|
|
(shouldAddTrailingSpaces = false) => {
|
|
|
|
|
const hostAddress = shouldAddTrailingSpaces
|
|
|
|
|
? datasourceFormData["mysql-host"] + " "
|
|
|
|
|
: datasourceFormData["mysql-host"];
|
|
|
|
|
const databaseName = shouldAddTrailingSpaces
|
|
|
|
|
? datasourceFormData["mysql-databaseName"] + " "
|
|
|
|
|
: datasourceFormData["mysql-databaseName"];
|
|
|
|
|
|
2024-04-30 07:45:11 +00:00
|
|
|
agHelper.ClearNType(datasourceEditor.host, hostAddress);
|
|
|
|
|
agHelper.ClearNType(
|
|
|
|
|
datasourceEditor.port,
|
|
|
|
|
datasourceFormData["mysql-port"],
|
|
|
|
|
);
|
|
|
|
|
agHelper.ClearNType(datasourceEditor.databaseName, databaseName);
|
|
|
|
|
agHelper.ClearNType(
|
|
|
|
|
datasourceEditor.username,
|
2022-04-11 03:30:37 +00:00
|
|
|
datasourceFormData["mysql-username"],
|
|
|
|
|
);
|
2024-04-30 07:45:11 +00:00
|
|
|
agHelper.ClearNType(
|
|
|
|
|
datasourceEditor.password,
|
2022-04-11 03:30:37 +00:00
|
|
|
datasourceFormData["mysql-password"],
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
Cypress.Commands.add(
|
|
|
|
|
"fillMsSQLDatasourceForm",
|
|
|
|
|
(shouldAddTrailingSpaces = false) => {
|
|
|
|
|
const hostAddress = shouldAddTrailingSpaces
|
|
|
|
|
? datasourceFormData["mssql-host"] + " "
|
|
|
|
|
: datasourceFormData["mssql-host"];
|
|
|
|
|
const databaseName = shouldAddTrailingSpaces
|
|
|
|
|
? datasourceFormData["mssql-databaseName"] + " "
|
|
|
|
|
: datasourceFormData["mssql-databaseName"];
|
|
|
|
|
|
2024-04-30 07:45:11 +00:00
|
|
|
agHelper.ClearNType(datasourceEditor.host, hostAddress);
|
|
|
|
|
agHelper.ClearNType(
|
|
|
|
|
datasourceEditor.port,
|
|
|
|
|
datasourceFormData["mssql-port"],
|
|
|
|
|
);
|
|
|
|
|
agHelper.ClearNType(datasourceEditor.databaseName, databaseName);
|
|
|
|
|
agHelper.ClearNType(
|
|
|
|
|
datasourceEditor.username,
|
2022-04-11 03:30:37 +00:00
|
|
|
datasourceFormData["mssql-username"],
|
|
|
|
|
);
|
2024-04-30 07:45:11 +00:00
|
|
|
agHelper.ClearNType(
|
|
|
|
|
datasourceEditor.password,
|
2022-04-11 03:30:37 +00:00
|
|
|
datasourceFormData["mssql-password"],
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
Cypress.Commands.add(
|
|
|
|
|
"fillArangoDBDatasourceForm",
|
|
|
|
|
(shouldAddTrailingSpaces = false) => {
|
|
|
|
|
const hostAddress = shouldAddTrailingSpaces
|
|
|
|
|
? datasourceFormData["arango-host"] + " "
|
|
|
|
|
: datasourceFormData["arango-host"];
|
|
|
|
|
const databaseName = shouldAddTrailingSpaces
|
|
|
|
|
? datasourceFormData["arango-databaseName"] + " "
|
|
|
|
|
: datasourceFormData["arango-databaseName"];
|
|
|
|
|
|
2024-04-30 07:45:11 +00:00
|
|
|
agHelper.ClearNType(datasourceEditor.host, hostAddress);
|
|
|
|
|
agHelper.ClearNType(
|
|
|
|
|
datasourceEditor.port,
|
|
|
|
|
datasourceFormData["arango-port"],
|
|
|
|
|
);
|
|
|
|
|
agHelper.ClearNType(datasourceEditor.databaseName, databaseName);
|
|
|
|
|
agHelper.ClearNType(
|
|
|
|
|
datasourceEditor.username,
|
2022-04-11 03:30:37 +00:00
|
|
|
datasourceFormData["arango-username"],
|
|
|
|
|
);
|
2024-04-30 07:45:11 +00:00
|
|
|
agHelper.ClearNType(
|
|
|
|
|
datasourceEditor.password,
|
2022-04-11 03:30:37 +00:00
|
|
|
datasourceFormData["arango-password"],
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
Cypress.Commands.add(
|
|
|
|
|
"fillRedshiftDatasourceForm",
|
|
|
|
|
(shouldAddTrailingSpaces = false) => {
|
|
|
|
|
const hostAddress = shouldAddTrailingSpaces
|
|
|
|
|
? datasourceFormData["redshift-host"] + " "
|
|
|
|
|
: datasourceFormData["redshift-host"];
|
|
|
|
|
const databaseName = shouldAddTrailingSpaces
|
|
|
|
|
? datasourceFormData["redshift-databaseName"] + " "
|
|
|
|
|
: datasourceFormData["redshift-databaseName"];
|
|
|
|
|
|
2024-04-30 07:45:11 +00:00
|
|
|
agHelper.ClearNType(datasourceEditor.host, hostAddress);
|
|
|
|
|
agHelper.ClearNType(
|
|
|
|
|
datasourceEditor.port,
|
|
|
|
|
datasourceFormData["redshift-port"],
|
|
|
|
|
);
|
|
|
|
|
agHelper.ClearNType(datasourceEditor.databaseName, databaseName);
|
|
|
|
|
agHelper.ClearNType(
|
|
|
|
|
datasourceEditor.username,
|
2022-04-11 03:30:37 +00:00
|
|
|
datasourceFormData["redshift-username"],
|
|
|
|
|
);
|
2024-04-30 07:45:11 +00:00
|
|
|
agHelper.ClearNType(
|
|
|
|
|
datasourceEditor.password,
|
2022-04-11 03:30:37 +00:00
|
|
|
datasourceFormData["redshift-password"],
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
Cypress.Commands.add(
|
|
|
|
|
"fillSMTPDatasourceForm",
|
|
|
|
|
(shouldAddTrailingSpaces = false) => {
|
|
|
|
|
const hostAddress = shouldAddTrailingSpaces
|
|
|
|
|
? datasourceFormData["smtp-host"] + " "
|
|
|
|
|
: datasourceFormData["smtp-host"];
|
2024-04-30 07:45:11 +00:00
|
|
|
agHelper.ClearNType(datasourceEditor.host, hostAddress);
|
|
|
|
|
agHelper.ClearNType(datasourceEditor.port, datasourceFormData["smtp-port"]);
|
2022-04-11 03:30:37 +00:00
|
|
|
cy.get(datasourceEditor.sectionAuthentication).click();
|
2024-04-30 07:45:11 +00:00
|
|
|
agHelper.ClearNType(
|
|
|
|
|
datasourceEditor.username,
|
|
|
|
|
datasourceFormData["smtp-username"],
|
|
|
|
|
);
|
|
|
|
|
agHelper.ClearNType(
|
|
|
|
|
datasourceEditor.password,
|
|
|
|
|
datasourceFormData["smtp-password"],
|
|
|
|
|
);
|
2022-04-11 03:30:37 +00:00
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
Cypress.Commands.add("createPostgresDatasource", () => {
|
2023-11-15 02:31:12 +00:00
|
|
|
dataSources.NavigateToDSCreateNew();
|
2024-03-15 05:43:14 +00:00
|
|
|
agHelper.GetNClick(datasourceEditor.PostgreSQL);
|
2022-04-11 03:30:37 +00:00
|
|
|
cy.fillPostgresDatasourceForm();
|
|
|
|
|
cy.testSaveDatasource();
|
|
|
|
|
});
|
|
|
|
|
|
2022-07-08 12:57:59 +00:00
|
|
|
// this can be modified further when google sheets automation is done.
|
|
|
|
|
Cypress.Commands.add("createGoogleSheetsDatasource", () => {
|
2023-11-15 02:31:12 +00:00
|
|
|
dataSources.NavigateToDSCreateNew();
|
2024-03-15 05:43:14 +00:00
|
|
|
agHelper.GetNClick(datasourceEditor.GoogleSheets);
|
2022-07-08 12:57:59 +00:00
|
|
|
});
|
|
|
|
|
|
2022-04-11 03:30:37 +00:00
|
|
|
Cypress.Commands.add("deleteDatasource", (datasourceName) => {
|
2023-11-15 02:31:12 +00:00
|
|
|
dataSources.DeleteDatasourceFromWithinDS(datasourceName);
|
2022-04-11 03:30:37 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Cypress.Commands.add("renameDatasource", (datasourceName) => {
|
|
|
|
|
cy.get(".t--edit-datasource-name").click();
|
|
|
|
|
cy.get(".t--edit-datasource-name input")
|
|
|
|
|
.clear()
|
|
|
|
|
.type(datasourceName, { force: true })
|
|
|
|
|
.should("have.value", datasourceName)
|
|
|
|
|
.blur();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Cypress.Commands.add("fillAmazonS3DatasourceForm", () => {
|
2024-04-30 07:45:11 +00:00
|
|
|
agHelper.ClearNType(datasourceEditor.projectID, Cypress.env("S3_ACCESS_KEY"));
|
|
|
|
|
agHelper.ClearNType(
|
|
|
|
|
datasourceEditor.serviceAccCredential,
|
|
|
|
|
Cypress.env("S3_SECRET_KEY"),
|
|
|
|
|
);
|
2022-04-11 03:30:37 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Cypress.Commands.add("ReconnectDatasource", (datasource) => {
|
|
|
|
|
cy.xpath(`//span[text()='${datasource}']`).click();
|
|
|
|
|
});
|
2022-06-16 06:18:44 +00:00
|
|
|
|
2022-07-08 14:31:12 +00:00
|
|
|
Cypress.Commands.add("createNewAuthApiDatasource", (renameVal) => {
|
|
|
|
|
cy.NavigateToAPI_Panel();
|
|
|
|
|
//Click on Authenticated API
|
|
|
|
|
cy.get(apiWidgetslocator.createAuthApiDatasource).click();
|
|
|
|
|
//Verify weather Authenticated API is successfully created.
|
2022-11-30 05:59:45 +00:00
|
|
|
// cy.wait("@saveDatasource").should(
|
|
|
|
|
// "have.nested.property",
|
|
|
|
|
// "response.body.responseMeta.status",
|
|
|
|
|
// 201,
|
|
|
|
|
// );
|
2022-07-08 14:31:12 +00:00
|
|
|
cy.get(datasourceEditor.datasourceTitleLocator).click();
|
|
|
|
|
cy.get(`${datasourceEditor.datasourceTitleLocator} input`)
|
|
|
|
|
.clear()
|
|
|
|
|
.type(renameVal, { force: true })
|
|
|
|
|
.blur();
|
|
|
|
|
//Fill dummy inputs and save
|
|
|
|
|
cy.fillAuthenticatedAPIForm();
|
|
|
|
|
cy.saveDatasource();
|
|
|
|
|
// Added because api name edit takes some time to
|
|
|
|
|
// reflect in api sidebar after the call passes.
|
|
|
|
|
// eslint-disable-next-line cypress/no-unnecessary-waiting
|
|
|
|
|
cy.wait(2000);
|
|
|
|
|
});
|
|
|
|
|
|
2022-06-16 06:18:44 +00:00
|
|
|
Cypress.Commands.add("datasourceCardContainerStyle", (tag) => {
|
|
|
|
|
cy.get(tag)
|
|
|
|
|
.should("have.css", "min-width", "150px")
|
2023-05-19 18:37:06 +00:00
|
|
|
.and(($el) => {
|
|
|
|
|
const borderRadius = $el.css("border-radius");
|
|
|
|
|
expect(borderRadius).to.match(/^(0px|4px)$/);
|
|
|
|
|
})
|
2022-06-16 06:18:44 +00:00
|
|
|
.and("have.css", "align-items", "center");
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Cypress.Commands.add("datasourceCardStyle", (tag) => {
|
|
|
|
|
cy.get(tag)
|
|
|
|
|
.should("have.css", "display", "flex")
|
|
|
|
|
.and("have.css", "justify-content", "space-between")
|
|
|
|
|
.and("have.css", "align-items", "center")
|
|
|
|
|
.and("have.css", "height", "64px")
|
|
|
|
|
.realHover()
|
|
|
|
|
.should("have.css", "background-color", backgroundColorGray1)
|
|
|
|
|
.and("have.css", "cursor", "pointer");
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Cypress.Commands.add("datasourceImageStyle", (tag) => {
|
|
|
|
|
cy.get(tag)
|
2023-05-19 18:37:06 +00:00
|
|
|
.should("have.css", "height", "34px")
|
2022-06-16 06:18:44 +00:00
|
|
|
.and("have.css", "max-width", "100%");
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Cypress.Commands.add("datasourceContentWrapperStyle", (tag) => {
|
|
|
|
|
cy.get(tag)
|
|
|
|
|
.should("have.css", "display", "flex")
|
|
|
|
|
.and("have.css", "align-items", "center")
|
|
|
|
|
.and("have.css", "gap", "13px")
|
|
|
|
|
.and("have.css", "padding-left", "13.5px");
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Cypress.Commands.add("datasourceIconWrapperStyle", (tag) => {
|
|
|
|
|
cy.get(tag)
|
|
|
|
|
.should("have.css", "background-color", backgroundColorGray2)
|
2023-05-19 18:37:06 +00:00
|
|
|
.and("have.css", "height", "34px")
|
|
|
|
|
.and("have.css", "border-radius", "0px")
|
|
|
|
|
.and("have.css", "display", "block")
|
|
|
|
|
.and("have.css", "align-items", "normal");
|
2022-06-16 06:18:44 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Cypress.Commands.add("datasourceNameStyle", (tag) => {
|
|
|
|
|
cy.get(tag)
|
|
|
|
|
.should("have.css", "color", backgroundColorBlack)
|
|
|
|
|
.and("have.css", "font-size", "16px")
|
|
|
|
|
.and("have.css", "font-weight", "400")
|
|
|
|
|
.and("have.css", "line-height", "24px")
|
|
|
|
|
.and("have.css", "letter-spacing", "-0.24px");
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Cypress.Commands.add("mockDatasourceDescriptionStyle", (tag) => {
|
|
|
|
|
cy.get(tag)
|
|
|
|
|
.should("have.css", "color", backgroundColorGray8)
|
|
|
|
|
.and("have.css", "font-size", "13px")
|
|
|
|
|
.and("have.css", "font-weight", "400")
|
|
|
|
|
.and("have.css", "line-height", "17px")
|
|
|
|
|
.and("have.css", "letter-spacing", "-0.24px");
|
|
|
|
|
});
|