2025-12-05 16:43:00 +00:00
|
|
|
import { Environments, WidgetPositions } from "Constants/constants/multiEnv";
|
2025-06-30 09:41:11 +00:00
|
|
|
import { commonSelectors, commonWidgetSelector } from "Selectors/common";
|
2025-12-05 16:43:00 +00:00
|
|
|
import { commonEeSelectors, multiEnvSelector, versionModalSelector } from "Selectors/eeCommon";
|
2025-06-30 09:41:11 +00:00
|
|
|
import { appVersionSelectors } from "Selectors/exportImport";
|
2025-11-04 11:21:53 +00:00
|
|
|
import { appEditorSelector } from "Selectors/multiEnv";
|
2025-12-05 16:43:00 +00:00
|
|
|
import { appVersionText } from "Texts/exportImport";
|
2025-06-30 09:41:11 +00:00
|
|
|
|
|
|
|
|
export const promoteApp = () => {
|
2025-11-12 18:35:21 +00:00
|
|
|
cy.get(commonEeSelectors.promoteButton).click();
|
|
|
|
|
cy.get(commonEeSelectors.promoteButton).eq(1).click();
|
|
|
|
|
cy.waitForAppLoad();
|
|
|
|
|
cy.wait(3000);
|
2025-06-30 09:41:11 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export const releaseApp = () => {
|
2025-12-05 16:43:00 +00:00
|
|
|
cy.get(multiEnvSelector.environmentsTag("production")).click();
|
|
|
|
|
|
2025-11-12 18:35:21 +00:00
|
|
|
cy.get(commonSelectors.releaseButton).click();
|
|
|
|
|
cy.get(commonSelectors.yesButton).click();
|
|
|
|
|
cy.verifyToastMessage(commonSelectors.toastMessage, "Version v1 released");
|
|
|
|
|
cy.wait(500);
|
2025-06-30 09:41:11 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export const launchApp = () => {
|
2025-11-12 18:35:21 +00:00
|
|
|
cy.url().then((url) => {
|
|
|
|
|
const parts = url.split("/");
|
|
|
|
|
const value = parts[parts.length - 1];
|
|
|
|
|
cy.visit(`/applications/${value}`);
|
|
|
|
|
cy.wait(3000);
|
|
|
|
|
});
|
2025-06-30 09:41:11 +00:00
|
|
|
};
|
|
|
|
|
|
2025-12-05 16:43:00 +00:00
|
|
|
export const createVersionFromDraft = (version) => {
|
|
|
|
|
cy.get(multiEnvSelector.environmentsTag("development")).click();
|
|
|
|
|
cy.get(versionModalSelector.saveVersionButton(version)).click();
|
|
|
|
|
cy.get(versionModalSelector.createVersionModal.saveButton).click();
|
|
|
|
|
cy.get(versionModalSelector.versionLockInfoText, { timeout: 10000 }).verifyVisibleElement(
|
|
|
|
|
"have.text",
|
|
|
|
|
"This version is locked. To make edits, create a draft version."
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
2025-06-30 09:41:11 +00:00
|
|
|
export const appPromote = (fromEnv, toEnv) => {
|
2025-11-12 18:35:21 +00:00
|
|
|
const commonActions = () => {
|
2025-12-05 16:43:00 +00:00
|
|
|
cy.get(multiEnvSelector.environmentsTag(fromEnv)).click();
|
|
|
|
|
|
|
|
|
|
cy.waitForElement(commonEeSelectors.promoteVersionButton);
|
2025-11-21 13:01:40 +00:00
|
|
|
cy.wait(200);
|
2025-12-05 16:43:00 +00:00
|
|
|
cy.get(commonEeSelectors.promoteVersionButton, { timeout: 10000 }).click();
|
|
|
|
|
cy.get(commonEeSelectors.promoteButton, { timeout: 10000 }).click();
|
2025-11-12 18:35:21 +00:00
|
|
|
cy.waitForAppLoad();
|
|
|
|
|
cy.wait(2000);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const transitions = {
|
|
|
|
|
[Environments.development]: {
|
|
|
|
|
[Environments.staging]: commonActions,
|
|
|
|
|
[Environments.production]: () => {
|
|
|
|
|
commonActions();
|
|
|
|
|
appPromote("staging", "production");
|
|
|
|
|
},
|
|
|
|
|
release: () => {
|
|
|
|
|
commonActions();
|
|
|
|
|
commonActions();
|
|
|
|
|
cy.get(commonSelectors.releaseButton).click();
|
|
|
|
|
cy.get(commonSelectors.yesButton).click();
|
|
|
|
|
cy.wait(500);
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
staging: {
|
|
|
|
|
production: commonActions,
|
|
|
|
|
release: () => {
|
|
|
|
|
commonActions();
|
|
|
|
|
cy.get(commonSelectors.releaseButton).click();
|
|
|
|
|
cy.get(commonSelectors.yesButton).click();
|
|
|
|
|
cy.wait(500);
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const transition = transitions[fromEnv]?.[toEnv];
|
|
|
|
|
transition();
|
2025-06-30 09:41:11 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export const createNewVersion = (value, newVersion = [], version) => {
|
2025-11-12 18:35:21 +00:00
|
|
|
cy.get('[data-cy="list-current-env-name"]').click();
|
|
|
|
|
cy.get(appEditorSelector.editor.pages.envNameList).eq(0).click();
|
|
|
|
|
cy.get(appVersionSelectors.currentVersionField(value)).click();
|
|
|
|
|
cy.get(appVersionSelectors.createNewVersionButton).click();
|
|
|
|
|
cy.get(appVersionSelectors.createVersionInputField).click();
|
|
|
|
|
cy.contains(`[id*="react-select-"]`, version).click();
|
|
|
|
|
cy.get(appVersionSelectors.versionNameInputField).click().type(newVersion[0]);
|
|
|
|
|
cy.get(appVersionSelectors.createNewVersionButton).click();
|
|
|
|
|
cy.waitForAppLoad();
|
|
|
|
|
cy.verifyToastMessage(
|
|
|
|
|
commonSelectors.toastMessage,
|
|
|
|
|
appVersionText.createdToastMessage
|
|
|
|
|
);
|
|
|
|
|
cy.get(appVersionSelectors.currentVersionField(newVersion[0])).should(
|
|
|
|
|
"be.visible"
|
|
|
|
|
);
|
2025-06-30 09:41:11 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export const selectVersion = (value, newVersion = []) => {
|
2025-11-12 18:35:21 +00:00
|
|
|
cy.get(appVersionSelectors.currentVersionField(value)).click();
|
|
|
|
|
cy.get(".react-select__menu-list .app-version-name")
|
|
|
|
|
.contains(newVersion[0])
|
|
|
|
|
.click();
|
|
|
|
|
cy.waitForAppLoad();
|
2025-06-30 09:41:11 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export const selectEnv = (envName) => {
|
2025-11-12 18:35:21 +00:00
|
|
|
const envIndex = {
|
|
|
|
|
development: 0,
|
|
|
|
|
staging: 1,
|
|
|
|
|
production: 2,
|
|
|
|
|
}[envName];
|
|
|
|
|
|
|
|
|
|
const isValidEnvName = (envName) =>
|
|
|
|
|
envName === "development" ||
|
|
|
|
|
envName === "staging" ||
|
|
|
|
|
envName === "production";
|
|
|
|
|
|
|
|
|
|
if (isValidEnvName(envName)) {
|
|
|
|
|
cy.wait(1000);
|
2025-11-20 13:13:57 +00:00
|
|
|
cy.waitForElement('[data-cy="list-current-env-name"]');
|
2025-11-12 18:35:21 +00:00
|
|
|
cy.get('[data-cy="list-current-env-name"]').click();
|
|
|
|
|
cy.wait(500);
|
|
|
|
|
const envSelector = `${appEditorSelector.editor.pages.envNameList}:eq(${envIndex})`;
|
|
|
|
|
cy.get(envSelector).click();
|
|
|
|
|
cy.waitForAppLoad();
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export const setupPostgreSQLDataSource = (
|
|
|
|
|
dsName,
|
|
|
|
|
secretConstantName,
|
|
|
|
|
dbNameConstant
|
|
|
|
|
) => {
|
2025-12-05 12:55:11 +00:00
|
|
|
cy.apiCreateDataSource(
|
2025-11-12 18:35:21 +00:00
|
|
|
`${Cypress.env("server_host")}/api/data-sources`,
|
|
|
|
|
dsName,
|
|
|
|
|
"postgresql",
|
|
|
|
|
[
|
|
|
|
|
{ key: "connection_type", value: "manual", encrypted: false },
|
|
|
|
|
{
|
|
|
|
|
key: "host",
|
|
|
|
|
value: `{{secrets.${secretConstantName}}}`,
|
|
|
|
|
encrypted: false,
|
|
|
|
|
},
|
|
|
|
|
{ key: "port", value: 5432, encrypted: false },
|
|
|
|
|
{ key: "ssl_enabled", value: false, encrypted: false },
|
|
|
|
|
{
|
|
|
|
|
key: "database",
|
|
|
|
|
value: `{{constants.${dbNameConstant}}}`,
|
|
|
|
|
encrypted: false,
|
|
|
|
|
},
|
|
|
|
|
{ key: "ssl_certificate", value: "none", encrypted: false },
|
|
|
|
|
{ key: "username", value: Cypress.env("pg_user"), encrypted: false },
|
|
|
|
|
{ key: "password", value: Cypress.env("pg_password"), encrypted: false },
|
|
|
|
|
{ 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 },
|
|
|
|
|
{ key: "connection_string", value: null, encrypted: true },
|
|
|
|
|
]
|
|
|
|
|
);
|
2025-10-29 14:06:19 +00:00
|
|
|
};
|
|
|
|
|
|
2025-11-12 18:35:21 +00:00
|
|
|
export const createAppWithComponents = (
|
|
|
|
|
appName,
|
|
|
|
|
dsName,
|
|
|
|
|
dbNameConstant,
|
|
|
|
|
tableNameConstant,
|
|
|
|
|
globalConstantName
|
|
|
|
|
) => {
|
|
|
|
|
return cy.apiCreateApp(appName).then(() => {
|
|
|
|
|
cy.apiAddQueryToApp({
|
|
|
|
|
queryName: "psql",
|
|
|
|
|
options: {
|
|
|
|
|
mode: "sql",
|
|
|
|
|
transformationLanguage: "javascript",
|
|
|
|
|
enableTransformation: false,
|
|
|
|
|
query: `SELECT * FROM {{constants.${tableNameConstant}}} WHERE constant = '{{constants.${globalConstantName}}}';`,
|
|
|
|
|
runOnPageLoad: true,
|
|
|
|
|
},
|
|
|
|
|
dataSourceName: dsName,
|
|
|
|
|
dsKind: "postgresql",
|
2025-10-29 14:06:19 +00:00
|
|
|
});
|
2025-11-12 18:35:21 +00:00
|
|
|
cy.apiAddComponentToApp(
|
|
|
|
|
appName,
|
|
|
|
|
"constant_data",
|
|
|
|
|
WidgetPositions.constantData,
|
|
|
|
|
"Text",
|
|
|
|
|
`{{constants.${dbNameConstant}}}`
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
cy.apiAddComponentToApp(
|
|
|
|
|
appName,
|
|
|
|
|
"query_data",
|
|
|
|
|
WidgetPositions.queryData,
|
|
|
|
|
"Text",
|
|
|
|
|
`{{JSON.stringify(queries.psql.data)}}`
|
|
|
|
|
);
|
|
|
|
|
});
|
2025-10-29 14:06:19 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export const verifyEnvironmentData = (expectedDbValue, expectedQueryValue) => {
|
2025-11-12 18:35:21 +00:00
|
|
|
cy.get(commonWidgetSelector.draggableWidget("constant_data"))
|
|
|
|
|
.should("be.visible")
|
|
|
|
|
.should("contain.text", expectedDbValue);
|
|
|
|
|
cy.get(commonWidgetSelector.draggableWidget("query_data")).should(
|
|
|
|
|
"contain.text",
|
|
|
|
|
expectedQueryValue
|
|
|
|
|
);
|
2025-10-29 14:06:19 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export const selectEnvironment = (envName) => {
|
2025-11-12 18:35:21 +00:00
|
|
|
cy.get(multiEnvSelector.previewSettings).click({ timeout: 10000 });
|
2025-11-13 12:55:04 +00:00
|
|
|
cy.forceClickOnCanvas();
|
|
|
|
|
cy.wait(1000);
|
|
|
|
|
cy.get(multiEnvSelector.previewSettings).click({ timeout: 10000 });
|
|
|
|
|
|
2025-11-12 18:35:21 +00:00
|
|
|
cy.get(multiEnvSelector.envContainer).click({ timeout: 10000 });
|
|
|
|
|
cy.get(multiEnvSelector.envNameList)
|
|
|
|
|
.contains(envName)
|
|
|
|
|
.click({ timeout: 10000 });
|
2025-10-29 14:06:19 +00:00
|
|
|
};
|
|
|
|
|
|
2025-11-04 12:16:06 +00:00
|
|
|
export const releaseAndVisitApp = (appSlug) => {
|
2025-12-05 16:43:00 +00:00
|
|
|
cy.get(multiEnvSelector.environmentsTag("production")).click();
|
2025-11-12 18:35:21 +00:00
|
|
|
cy.get(commonSelectors.releaseButton).click();
|
|
|
|
|
cy.get(commonSelectors.yesButton).click();
|
|
|
|
|
cy.verifyToastMessage(commonSelectors.toastMessage, "Version v1 released");
|
2025-10-29 14:06:19 +00:00
|
|
|
|
2025-11-12 18:35:21 +00:00
|
|
|
cy.get(commonWidgetSelector.shareAppButton).click();
|
|
|
|
|
cy.get(commonWidgetSelector.makePublicAppToggle).check();
|
|
|
|
|
cy.clearAndType(commonWidgetSelector.appNameSlugInput, appSlug);
|
2025-10-29 14:06:19 +00:00
|
|
|
|
2025-11-12 18:35:21 +00:00
|
|
|
cy.get(commonSelectors.appSlugAccept)
|
|
|
|
|
.should("be.visible")
|
|
|
|
|
.and("have.text", "Slug accepted!");
|
|
|
|
|
cy.apiLogout();
|
2025-10-29 14:06:19 +00:00
|
|
|
|
2025-11-12 18:35:21 +00:00
|
|
|
cy.visitSlug({
|
|
|
|
|
actualUrl: `${Cypress.config("baseUrl")}/applications/${appSlug}`,
|
|
|
|
|
});
|
2025-10-29 14:06:19 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export const verifyQueryEditorDisabled = () => {
|
2025-11-12 18:35:21 +00:00
|
|
|
cy.get(appEditorSelector.editor.queryDetailsContainer).should(
|
|
|
|
|
"have.class",
|
|
|
|
|
"disabled"
|
|
|
|
|
);
|
2025-10-29 14:06:19 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export const verifyGlobalSettingsDisabled = () => {
|
2025-12-05 16:43:00 +00:00
|
|
|
cy.get(versionModalSelector.versionLockInfoText, { timeout: 10000 }).verifyVisibleElement(
|
|
|
|
|
"have.text",
|
|
|
|
|
"This version is locked. To make edits, create a draft version."
|
|
|
|
|
);
|
2025-11-12 18:35:21 +00:00
|
|
|
cy.get(appEditorSelector.settings.settingsSidebarIcon).click({ force: true });
|
|
|
|
|
cy.get(appEditorSelector.settings.maintenanceToggle)
|
|
|
|
|
.parents(".disabled")
|
|
|
|
|
.should("exist");
|
|
|
|
|
cy.get(appEditorSelector.settings.maxCanvasWidthInput)
|
|
|
|
|
.parents(".disabled")
|
|
|
|
|
.should("exist");
|
|
|
|
|
cy.get(appEditorSelector.settings.appSlugInput).should("not.be.disabled");
|
2025-10-29 14:06:19 +00:00
|
|
|
};
|
|
|
|
|
|
2025-11-04 12:16:06 +00:00
|
|
|
export const verifyInspectorMenuHasNoDeleteOption = () => {
|
2025-11-12 18:35:21 +00:00
|
|
|
cy.get(appEditorSelector.editor.inspector.buttonAria).click({
|
|
|
|
|
timeout: 1000,
|
|
|
|
|
});
|
|
|
|
|
cy.get(appEditorSelector.editor.inspector.componentsNode)
|
|
|
|
|
.should("be.visible")
|
|
|
|
|
.click({ timeout: 1000 });
|
|
|
|
|
cy.get(appEditorSelector.editor.inspector.componentsNode)
|
|
|
|
|
.eq(2)
|
|
|
|
|
.should("be.visible")
|
|
|
|
|
.click({ timeout: 1000 });
|
|
|
|
|
cy.get(appEditorSelector.editor.inspector.menuIcon).click({ force: true });
|
|
|
|
|
cy.get(appEditorSelector.editor.inspector.popoverBody).should("be.visible");
|
|
|
|
|
cy.notVisible(appEditorSelector.editor.inspector.anyDeleteInPopover);
|
|
|
|
|
cy.get(appEditorSelector.editor.inspector.popoverBody).should(
|
|
|
|
|
"not.contain.text",
|
|
|
|
|
"Delete"
|
|
|
|
|
);
|
|
|
|
|
cy.forceClickOnCanvas();
|
2025-10-29 14:06:19 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export const verifyComponentsManagerDisabled = () => {
|
2025-11-26 05:39:23 +00:00
|
|
|
//cy.get(".widgets-list").should("have.css", "pointer-events", "none");
|
2025-11-12 18:35:21 +00:00
|
|
|
cy.get(appEditorSelector.editor.components.componentsPlusButton).click();
|
2025-10-29 14:06:19 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export const verifyPageSettingsDisabled = () => {
|
2025-11-12 18:35:21 +00:00
|
|
|
cy.get(appEditorSelector.editor.pages.pagesTabButton).click();
|
2025-12-05 16:43:00 +00:00
|
|
|
cy.get(versionModalSelector.versionLockInfoText).verifyVisibleElement(
|
|
|
|
|
"have.text",
|
|
|
|
|
"This version is locked. To make edits, create a draft version."
|
2025-11-12 18:35:21 +00:00
|
|
|
);
|
2025-12-05 16:43:00 +00:00
|
|
|
cy.get("#page-settings-tabpane-properties .disabled", {
|
|
|
|
|
timeout: 8000,
|
|
|
|
|
}).should("exist");
|
2025-11-12 18:35:21 +00:00
|
|
|
cy.get("#page-settings-tabpane-styles .disabled").should("exist");
|
|
|
|
|
cy.forceClickOnCanvas();
|
2025-10-29 14:06:19 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export const verifyComponentInspectorDisabled = () => {
|
2025-11-12 18:35:21 +00:00
|
|
|
cy.get(commonWidgetSelector.draggableWidget("button1")).click();
|
|
|
|
|
cy.wait(500);
|
2025-12-05 16:43:00 +00:00
|
|
|
cy.get(versionModalSelector.versionLockInfoText).verifyVisibleElement(
|
|
|
|
|
"have.text",
|
|
|
|
|
"This version is locked. To make edits, create a draft version."
|
2025-11-12 18:35:21 +00:00
|
|
|
);
|
|
|
|
|
cy.get("#inspector-tabpane-properties .disabled").should("exist");
|
|
|
|
|
cy.get("#inspector-tabpane-styles .disabled").should("exist");
|
|
|
|
|
cy.forceClickOnCanvas();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export const setupWorkspaceConstant = (
|
|
|
|
|
constantName,
|
|
|
|
|
values,
|
|
|
|
|
tag = "Global"
|
|
|
|
|
) => {
|
|
|
|
|
const getValue = (env) => values[env] || values;
|
|
|
|
|
cy.apiCreateWorkspaceConstant(
|
|
|
|
|
constantName,
|
|
|
|
|
getValue(Environments.development),
|
|
|
|
|
[tag],
|
|
|
|
|
[Environments.development]
|
|
|
|
|
).then((res) => {
|
|
|
|
|
const constantId = res.body.constant.id;
|
|
|
|
|
cy.apiUpdateWsConstant(
|
|
|
|
|
constantId,
|
|
|
|
|
getValue(Environments.staging),
|
|
|
|
|
Environments.staging
|
|
|
|
|
);
|
|
|
|
|
cy.apiUpdateWsConstant(
|
|
|
|
|
constantId,
|
|
|
|
|
getValue(Environments.production),
|
|
|
|
|
Environments.production
|
|
|
|
|
);
|
|
|
|
|
});
|
2025-10-31 07:11:04 +00:00
|
|
|
};
|