2022-05-18 10:39:42 +00:00
|
|
|
import { ObjectsRegistry } from "../Objects/Registry";
|
2023-03-16 18:28:32 +00:00
|
|
|
import { WIDGET } from "../../locators/WidgetLocators";
|
2023-06-15 13:21:11 +00:00
|
|
|
import { EntityItems } from "./AssertHelper";
|
2022-07-29 08:48:25 +00:00
|
|
|
|
2022-09-19 05:32:06 +00:00
|
|
|
const DataSourceKVP = {
|
2022-07-29 08:48:25 +00:00
|
|
|
Postgres: "PostgreSQL",
|
|
|
|
|
Mongo: "MongoDB",
|
|
|
|
|
MySql: "MySQL",
|
2023-03-15 05:03:34 +00:00
|
|
|
UnAuthenticatedGraphQL: "GraphQL API",
|
2023-03-16 18:28:32 +00:00
|
|
|
MsSql: "Microsoft SQL Server",
|
2023-03-18 19:42:01 +00:00
|
|
|
Airtable: "Airtable",
|
2023-03-28 20:07:07 +00:00
|
|
|
Arango: "ArangoDB",
|
2023-04-04 15:56:57 +00:00
|
|
|
Firestore: "Firestore",
|
2023-04-06 04:07:04 +00:00
|
|
|
Elasticsearch: "Elasticsearch",
|
2023-04-25 18:24:36 +00:00
|
|
|
Redis: "Redis",
|
2023-06-12 17:48:46 +00:00
|
|
|
Oracle: "Oracle",
|
2022-08-04 04:48:15 +00:00
|
|
|
}; //DataSources KeyValuePair
|
2022-07-29 08:48:25 +00:00
|
|
|
|
2023-03-16 18:28:32 +00:00
|
|
|
export enum Widgets {
|
|
|
|
|
Dropdown,
|
|
|
|
|
Table,
|
|
|
|
|
Chart,
|
|
|
|
|
Text,
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-18 19:42:01 +00:00
|
|
|
interface RunQueryParams {
|
|
|
|
|
toValidateResponse?: boolean;
|
|
|
|
|
expectedStatus?: boolean;
|
|
|
|
|
waitTimeInterval?: number;
|
|
|
|
|
}
|
2022-03-02 16:54:43 +00:00
|
|
|
export class DataSources {
|
2022-05-18 10:39:42 +00:00
|
|
|
private agHelper = ObjectsRegistry.AggregateHelper;
|
2022-05-31 05:33:59 +00:00
|
|
|
private table = ObjectsRegistry.Table;
|
2022-05-18 10:39:42 +00:00
|
|
|
private ee = ObjectsRegistry.EntityExplorer;
|
2022-05-31 05:33:59 +00:00
|
|
|
private locator = ObjectsRegistry.CommonLocators;
|
2023-03-15 05:03:34 +00:00
|
|
|
private apiPage = ObjectsRegistry.ApiPage;
|
2023-06-15 13:21:11 +00:00
|
|
|
private hp = ObjectsRegistry.DefaultHostPort;
|
2023-06-17 08:23:03 +00:00
|
|
|
private assertHelper = ObjectsRegistry.AssertHelper;
|
2022-05-18 10:39:42 +00:00
|
|
|
|
2023-05-19 18:37:06 +00:00
|
|
|
private _dsCreateNewTab = "[data-testid=t--tab-CREATE_NEW]";
|
|
|
|
|
private _addNewDataSource = ".t--entity-add-btn.datasources button";
|
2022-05-18 10:39:42 +00:00
|
|
|
private _createNewPlgin = (pluginName: string) =>
|
|
|
|
|
".t--plugin-name:contains('" + pluginName + "')";
|
2022-12-05 05:58:17 +00:00
|
|
|
private _collapseContainer = ".t--collapse-section-container";
|
2023-05-19 18:37:06 +00:00
|
|
|
private _collapseSettings =
|
|
|
|
|
"[data-testid='t--dropdown-connection.ssl.authType']";
|
2023-06-15 13:21:11 +00:00
|
|
|
public _host = "input[name='datasourceConfiguration.endpoints[0].host']";
|
|
|
|
|
public _port = "input[name='datasourceConfiguration.endpoints[0].port']";
|
2022-08-24 14:23:41 +00:00
|
|
|
_databaseName =
|
2022-05-18 10:39:42 +00:00
|
|
|
"input[name='datasourceConfiguration.authentication.databaseName']";
|
|
|
|
|
private _username =
|
|
|
|
|
"input[name='datasourceConfiguration.authentication.username']";
|
2023-05-19 18:37:06 +00:00
|
|
|
private _section = (name: string) =>
|
|
|
|
|
"//div[text()='" + name + "']/parent::div";
|
|
|
|
|
private _sectionState = (name: string) =>
|
|
|
|
|
this._section(name) +
|
|
|
|
|
"/following-sibling::div/div[@class ='bp3-collapse-body']";
|
2022-05-18 10:39:42 +00:00
|
|
|
private _password =
|
|
|
|
|
"input[name = 'datasourceConfiguration.authentication.password']";
|
|
|
|
|
private _testDs = ".t--test-datasource";
|
2023-02-02 13:50:36 +00:00
|
|
|
_saveAndAuthorizeDS = ".t--save-and-authorize-datasource";
|
2023-01-13 11:40:58 +00:00
|
|
|
_saveDs = ".t--save-datasource";
|
|
|
|
|
_datasourceCard = ".t--datasource";
|
2023-05-19 18:37:06 +00:00
|
|
|
_dsMenuoptions = "div.t--datasource-menu-option";
|
2022-12-08 07:21:58 +00:00
|
|
|
_editButton = ".t--edit-datasource";
|
2023-05-19 18:37:06 +00:00
|
|
|
_reconnectDataSourceModal = "[data-testid=t--tab-RECONNECT_DATASOURCES]";
|
2022-12-24 18:01:03 +00:00
|
|
|
_closeDataSourceModal = ".t--reconnect-close-btn";
|
2022-11-25 05:05:37 +00:00
|
|
|
_dsEntityItem = "[data-guided-tour-id='explorer-entity-Datasources']";
|
2022-08-27 12:40:11 +00:00
|
|
|
_activeDS = "[data-testid='active-datasource-name']";
|
2023-01-09 14:51:13 +00:00
|
|
|
_mockDatasourceName = "[data-testid=mockdatasource-name]";
|
2022-05-18 10:39:42 +00:00
|
|
|
_templateMenu = ".t--template-menu";
|
2022-07-29 08:48:25 +00:00
|
|
|
_templateMenuOption = (action: string) =>
|
|
|
|
|
"//div[contains(@class, 't--template-menu')]//div[text()='" + action + "']";
|
2023-02-02 07:59:24 +00:00
|
|
|
_createQuery = ".t--create-query";
|
2022-05-18 10:39:42 +00:00
|
|
|
_visibleTextSpan = (spanText: string) =>
|
|
|
|
|
"//span[contains(text(),'" + spanText + "')]";
|
2023-05-19 18:37:06 +00:00
|
|
|
_dsOptionMenuItem = (text: string) =>
|
|
|
|
|
"//div[@role='menuitem']//span[text()='" + text + "']";
|
2022-05-18 10:39:42 +00:00
|
|
|
_dropdownTitle = (ddTitle: string) =>
|
|
|
|
|
"//p[contains(text(),'" +
|
|
|
|
|
ddTitle +
|
2023-05-24 12:30:39 +00:00
|
|
|
"')]/ancestor::div[@class='form-config-top']/following-sibling::div[@class='t--form-control-DROP_DOWN']//input | //label[text()='" +
|
|
|
|
|
ddTitle +
|
|
|
|
|
"']/following-sibling::span//button";
|
2023-05-19 18:37:06 +00:00
|
|
|
_reconnectModal = "[data-testid='reconnect-datasource-modal']";
|
|
|
|
|
_dropdown = (ddTitle: string) =>
|
|
|
|
|
"//span[contains(@title, '" +
|
|
|
|
|
ddTitle +
|
|
|
|
|
"') and text() = '" +
|
|
|
|
|
ddTitle +
|
|
|
|
|
"']";
|
2022-05-18 10:39:42 +00:00
|
|
|
_activeDSListReconnectModal = (dbName: string) =>
|
|
|
|
|
"//div[contains(@class, 't--ds-list')]//span[text()='" + dbName + "']";
|
2022-05-23 05:20:27 +00:00
|
|
|
_runQueryBtn = ".t--run-query";
|
|
|
|
|
_newDatabases = "#new-datasources";
|
2022-11-30 05:59:45 +00:00
|
|
|
_newDatasourceContainer = "#new-integrations-wrapper";
|
2023-05-19 18:37:06 +00:00
|
|
|
_selectDatasourceDropdown = "[data-testid=t--datasource-dropdown]";
|
|
|
|
|
_selectTableDropdown =
|
|
|
|
|
"[data-testid=t--table-dropdown] .rc-select-selection-item";
|
|
|
|
|
_selectSheetNameDropdown = "[data-testid=t--sheetName-dropdown]";
|
|
|
|
|
_selectTableHeaderIndexInput = "[data-testid=t--tableHeaderIndex]";
|
|
|
|
|
_dropdownOption = ".rc-select-item-option-content";
|
|
|
|
|
_generatePageBtn = "[data-testid=t--generate-page-form-submit]";
|
2022-05-31 05:33:59 +00:00
|
|
|
_selectedRow = ".tr.selected-row";
|
|
|
|
|
_activeTab = "span:contains('Active')";
|
2023-03-05 03:22:42 +00:00
|
|
|
_selectedActiveTab = "li[aria-selected='true'] " + this._activeTab;
|
2023-05-29 05:40:41 +00:00
|
|
|
_contextMenuDSReviewPage = "[data-testid='t--context-menu-trigger']";
|
2023-05-22 12:05:59 +00:00
|
|
|
_contextMenuDelete = ".t--datasource-option-delete";
|
2022-05-31 05:33:59 +00:00
|
|
|
_datasourceCardGeneratePageBtn = ".t--generate-template";
|
2023-05-19 18:37:06 +00:00
|
|
|
_queryOption = (option: string) =>
|
|
|
|
|
"//div[contains(@class, 'rc-select-item-option-content') and text() = '" +
|
|
|
|
|
option +
|
2023-05-24 12:30:39 +00:00
|
|
|
"'] | //a[contains(@class, 'single-select')]//div[text()='" +
|
|
|
|
|
option +
|
2023-05-19 18:37:06 +00:00
|
|
|
"']";
|
2022-05-31 05:33:59 +00:00
|
|
|
_queryTableResponse =
|
|
|
|
|
"//div[@data-guided-tour-id='query-table-response']//div[@class='tbody']//div[@class ='td']";
|
2022-06-17 11:31:40 +00:00
|
|
|
_queryResponseHeader = (header: string) =>
|
|
|
|
|
"//div[@data-guided-tour-id='query-table-response']//div[@class='table']//div[@role ='columnheader']//span[text()='" +
|
|
|
|
|
header +
|
|
|
|
|
"']";
|
2022-05-31 05:33:59 +00:00
|
|
|
_refreshIcon = "button .bp3-icon-refresh";
|
|
|
|
|
_addIcon = "button .bp3-icon-add";
|
2023-05-19 18:37:06 +00:00
|
|
|
_queryError = "[data-testid='t--query-error']";
|
|
|
|
|
_queryEditorTabs = (responseType: string) =>
|
|
|
|
|
"//button[@role='tab' or @role='tablist']//span[text()='" +
|
|
|
|
|
responseType +
|
|
|
|
|
"']";
|
2022-06-06 05:59:15 +00:00
|
|
|
_queryResponse = (responseType: string) =>
|
2023-05-19 18:37:06 +00:00
|
|
|
"//div[@data-testid='t--response-tab-segmented-control']//span[text()='" +
|
|
|
|
|
responseType +
|
|
|
|
|
"']";
|
2022-06-06 05:59:15 +00:00
|
|
|
_queryRecordResult = (recordCount: number) =>
|
2022-10-20 12:08:48 +00:00
|
|
|
`//div/span[text()='Result:']/span[contains(text(),' ${recordCount} Record')]`;
|
2022-06-16 06:50:02 +00:00
|
|
|
_noRecordFound = "span[data-testid='no-data-table-message']";
|
2022-06-17 06:12:18 +00:00
|
|
|
_usePreparedStatement =
|
|
|
|
|
"input[name='actionConfiguration.pluginSpecifiedTemplates[0].value'][type='checkbox']";
|
2022-07-16 10:41:17 +00:00
|
|
|
_queriesOnPageText = (dsName: string) =>
|
|
|
|
|
".t--datasource-name:contains('" + dsName + "') .t--queries-for-DB";
|
2022-07-29 08:48:25 +00:00
|
|
|
_mockDB = (dbName: string) =>
|
|
|
|
|
"//span[text()='" +
|
|
|
|
|
dbName +
|
|
|
|
|
"']/ancestor::div[contains(@class, 't--mock-datasource')][1]";
|
2023-03-15 05:03:34 +00:00
|
|
|
private _createBlankGraphQL = ".t--createBlankApiGraphqlCard";
|
2023-03-28 20:07:07 +00:00
|
|
|
private _createBlankCurl = ".t--createBlankCurlCard";
|
2023-03-15 05:03:34 +00:00
|
|
|
private _graphQLHeaderKey = "input[name='headers[0].key']";
|
|
|
|
|
private _graphQLHeaderValue = "input[name='headers[0].value']";
|
|
|
|
|
_graphqlQueryEditor = ".t--graphql-query-editor";
|
|
|
|
|
_graphqlVariableEditor = ".t--graphql-variable-editor";
|
2022-09-09 15:59:47 +00:00
|
|
|
_graphqlPagination = {
|
2023-05-19 18:37:06 +00:00
|
|
|
_limitVariable: ".t--apiFormPaginationLimitVariable .rc-select-selector",
|
2022-09-09 15:59:47 +00:00
|
|
|
_limitValue: ".t--apiFormPaginationLimitValue .CodeMirror textarea",
|
2023-05-19 18:37:06 +00:00
|
|
|
_offsetVariable: ".t--apiFormPaginationOffsetVariable .rc-select-selector",
|
2022-09-09 15:59:47 +00:00
|
|
|
_offsetValue: ".t--apiFormPaginationOffsetValue .CodeMirror textarea",
|
|
|
|
|
_prevLimitVariable: ".t--apiFormPaginationPrevLimitVariable",
|
|
|
|
|
_prevLimitValue: ".t--apiFormPaginationPrevLimitValue .CodeMirror textarea",
|
|
|
|
|
_prevCursorVariable: ".t--apiFormPaginationPrevCursorVariable",
|
|
|
|
|
_prevCursorValue:
|
|
|
|
|
".t--apiFormPaginationPrevCursorValue .CodeMirror textarea",
|
|
|
|
|
_nextLimitVariable: ".t--apiFormPaginationNextLimitVariable",
|
|
|
|
|
_nextLimitValue: ".t--apiFormPaginationNextLimitValue .CodeMirror textarea",
|
|
|
|
|
_nextCursorVariable: ".t--apiFormPaginationNextCursorVariable",
|
|
|
|
|
_nextCursorValue:
|
|
|
|
|
".t--apiFormPaginationNextCursorValue .CodeMirror textarea",
|
|
|
|
|
};
|
2022-08-04 04:48:15 +00:00
|
|
|
_queryDoc = ".t--datasource-documentation-link";
|
|
|
|
|
_globalSearchModal = ".t--global-search-modal";
|
|
|
|
|
_globalSearchInput = (inputText: string) =>
|
|
|
|
|
"//input[@id='global-search'][@value='" + inputText + "']";
|
|
|
|
|
_gsScopeDropdown =
|
2023-05-19 18:37:06 +00:00
|
|
|
"[data-testid='datasourceConfiguration.authentication.scopeString']";
|
|
|
|
|
_gsScopeOptions = ".ads-v2-select__dropdown .rc-select-item-option";
|
2022-08-24 14:23:41 +00:00
|
|
|
private _queryTimeout =
|
|
|
|
|
"//input[@name='actionConfiguration.timeoutInMillisecond']";
|
2022-11-25 05:05:37 +00:00
|
|
|
_getStructureReq = "/api/v1/datasources/*/structure?ignoreCache=true";
|
2022-12-30 10:23:24 +00:00
|
|
|
_editDatasourceFromActiveTab = (dsName: string) =>
|
|
|
|
|
".t--datasource-name:contains('" + dsName + "')";
|
2023-03-16 18:28:32 +00:00
|
|
|
private _suggestedWidget = (widgetType: string) =>
|
|
|
|
|
".t--suggested-widget-" + widgetType + "";
|
2022-12-30 10:23:24 +00:00
|
|
|
|
2023-03-28 20:07:07 +00:00
|
|
|
private _curlTextArea =
|
|
|
|
|
"//label[text()='Paste CURL Code Here']/parent::form/div";
|
|
|
|
|
_noSchemaAvailable = (dbName: string) =>
|
|
|
|
|
"//div[text()='" +
|
|
|
|
|
dbName +
|
|
|
|
|
"']/ancestor::div[contains(@class, 't--entity-item')]/following-sibling::div//p[text()='Schema not available']";
|
2022-12-30 10:23:24 +00:00
|
|
|
// Authenticated API locators
|
2023-03-10 11:39:06 +00:00
|
|
|
private _authApiDatasource = ".t--createAuthApiDatasource";
|
2023-05-19 18:37:06 +00:00
|
|
|
private _authType = "[data-testid=authType]";
|
|
|
|
|
private _oauth2 = ".rc-select-item-option:contains('OAuth 2.0')";
|
|
|
|
|
private _accessTokenUrl =
|
|
|
|
|
"[data-testid='authentication.accessTokenUrl'] input";
|
|
|
|
|
private _scope = "[data-testid='authentication.scopeString'] input";
|
|
|
|
|
private _clientID = "[data-testid='authentication.clientId'] input";
|
|
|
|
|
private _clientSecret = "[data-testid='authentication.clientSecret'] input";
|
2023-03-10 11:39:06 +00:00
|
|
|
private _clientCredentails =
|
2023-05-19 18:37:06 +00:00
|
|
|
".rc-select-item-option:contains('Client Credentials')";
|
2022-12-30 10:23:24 +00:00
|
|
|
private _authorizationCode =
|
2023-05-19 18:37:06 +00:00
|
|
|
".rc-select-item-option:contains('Authorization Code')";
|
|
|
|
|
private _grantType = "[data-testid='authentication.grantType']";
|
2022-12-30 10:23:24 +00:00
|
|
|
private _authorizationURL =
|
2023-05-19 18:37:06 +00:00
|
|
|
"[data-testid='authentication.authorizationUrl'] input";
|
2023-03-10 11:39:06 +00:00
|
|
|
private _consent = '[name="confirm"]';
|
|
|
|
|
private _consentSubmit = "//button[text()='Submit']";
|
2022-12-13 11:46:56 +00:00
|
|
|
public _datasourceModalSave = ".t--datasource-modal-save";
|
|
|
|
|
public _datasourceModalDoNotSave = ".t--datasource-modal-do-not-save";
|
2023-05-22 12:05:59 +00:00
|
|
|
public _cancelEditDatasourceButton = ".t--cancel-edit-datasource";
|
2023-03-16 18:28:32 +00:00
|
|
|
public _urlInputControl = "input[name='url']";
|
2023-06-14 06:46:09 +00:00
|
|
|
public _mongoCollectionPath = "t--actionConfiguration.formData.collection";
|
|
|
|
|
private _getJSONswitchLocator = (fieldLocator: string) =>
|
|
|
|
|
`[data-testid='${fieldLocator}.data-JS']`;
|
2023-04-04 15:56:57 +00:00
|
|
|
_nestedWhereClauseKey = (index: number) =>
|
|
|
|
|
".t--actionConfiguration\\.formData\\.where\\.data\\.children\\[" +
|
|
|
|
|
index +
|
|
|
|
|
"\\]\\.key";
|
|
|
|
|
_nestedWhereClauseValue = (index: number) =>
|
|
|
|
|
".t--actionConfiguration\\.formData\\.where\\.data\\.children\\[" +
|
|
|
|
|
index +
|
|
|
|
|
"\\]\\.value";
|
|
|
|
|
_whereDelete = (index: number) =>
|
2023-05-19 18:37:06 +00:00
|
|
|
"[data-testid='t--where-clause-delete-[" + index + "]']";
|
2022-05-31 05:33:59 +00:00
|
|
|
|
2023-04-06 04:07:04 +00:00
|
|
|
_bodyCodeMirror = "//div[contains(@class, 't--actionConfiguration.body')]";
|
|
|
|
|
|
2023-03-16 18:28:32 +00:00
|
|
|
public AssertDSEditViewMode(mode: "Edit" | "View") {
|
|
|
|
|
if (mode == "Edit") this.agHelper.AssertElementAbsence(this._editButton);
|
|
|
|
|
else if (mode == "View") this.agHelper.AssertElementExist(this._editButton);
|
2022-12-02 03:06:22 +00:00
|
|
|
}
|
|
|
|
|
|
2023-05-11 18:45:06 +00:00
|
|
|
public GeneratePageWithDB(datasourceName: any, tableName: string) {
|
2023-05-19 18:37:06 +00:00
|
|
|
this.ee.AddNewPage("Generate page with data");
|
2023-05-11 18:45:06 +00:00
|
|
|
this.agHelper.GetNClick(this._selectDatasourceDropdown);
|
|
|
|
|
this.agHelper.GetNClickByContains(
|
|
|
|
|
this.locator._dropdownText,
|
|
|
|
|
datasourceName,
|
|
|
|
|
);
|
2023-05-19 18:37:06 +00:00
|
|
|
this.agHelper.GetNClick(this._selectTableDropdown, 0, true);
|
|
|
|
|
cy.get(
|
|
|
|
|
`div[role="listbox"] p[kind="span"]:contains("${tableName}")`,
|
|
|
|
|
).click();
|
2023-05-11 18:45:06 +00:00
|
|
|
this.agHelper.GetNClick(this._generatePageBtn);
|
2023-06-18 04:55:16 +00:00
|
|
|
this.assertHelper.AssertNetworkStatus("@replaceLayoutWithCRUDPage", 201);
|
2023-05-19 18:37:06 +00:00
|
|
|
this.agHelper.GetNClick(this.locator._visibleTextSpan("Got it"));
|
2023-05-11 18:45:06 +00:00
|
|
|
}
|
|
|
|
|
|
2023-01-09 14:51:13 +00:00
|
|
|
public GeneratePageWithMockDB() {
|
2023-05-19 18:37:06 +00:00
|
|
|
this.ee.AddNewPage("Generate page with data");
|
2023-01-09 14:51:13 +00:00
|
|
|
this.agHelper.GetNClick(this._selectDatasourceDropdown);
|
2023-06-15 13:21:11 +00:00
|
|
|
this.agHelper.GetNClickByContains(
|
|
|
|
|
this._dropdownOption,
|
|
|
|
|
"Connect new datasource",
|
|
|
|
|
);
|
|
|
|
|
this.agHelper.GetNClick(this._mockDB("Users"));
|
|
|
|
|
this.agHelper.Sleep(500);
|
2023-06-18 04:55:16 +00:00
|
|
|
this.assertHelper.AssertNetworkStatus("@getDatasourceStructure"); //Making sure table dropdown is populated
|
2023-05-19 18:37:06 +00:00
|
|
|
this.agHelper.GetNClick(this._selectTableDropdown, 0, true);
|
2023-06-15 13:21:11 +00:00
|
|
|
this.agHelper.GetNClickByContains(this._dropdownOption, "public.users");
|
2023-01-09 14:51:13 +00:00
|
|
|
this.agHelper.GetNClick(this._generatePageBtn);
|
2023-06-18 04:55:16 +00:00
|
|
|
this.assertHelper.AssertNetworkStatus("@replaceLayoutWithCRUDPage", 201);
|
2023-05-19 18:37:06 +00:00
|
|
|
this.agHelper.GetNClick(this.locator._visibleTextSpan("Got it"));
|
2023-01-09 14:51:13 +00:00
|
|
|
}
|
|
|
|
|
|
2022-05-31 05:33:59 +00:00
|
|
|
public StartDataSourceRoutes() {
|
2022-11-30 05:59:45 +00:00
|
|
|
cy.intercept("POST", "/api/v1/datasources").as("saveDatasource");
|
2022-05-31 05:33:59 +00:00
|
|
|
cy.intercept("POST", "/api/v1/datasources/test").as("testDatasource");
|
2022-11-30 05:59:45 +00:00
|
|
|
cy.intercept("PUT", "/api/v1/datasources/*").as("updateDatasource");
|
2022-05-31 05:33:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private ReplaceApplicationIdForInterceptPages(fixtureFile: any) {
|
|
|
|
|
let currentAppId, currentURL;
|
|
|
|
|
cy.readFile(
|
|
|
|
|
fixtureFile,
|
|
|
|
|
// (err: string) => {
|
|
|
|
|
// if (err) {
|
|
|
|
|
// return console.error(err);
|
|
|
|
|
// }}
|
|
|
|
|
).then((data) => {
|
|
|
|
|
cy.url().then((url) => {
|
|
|
|
|
currentURL = url;
|
|
|
|
|
const myRegexp = /applications(.*)/;
|
|
|
|
|
const match = myRegexp.exec(currentURL);
|
|
|
|
|
cy.log(currentURL + "currentURL from intercept is");
|
|
|
|
|
currentAppId = match ? match[1].split("/")[1] : null;
|
|
|
|
|
data.data.page.applicationId = currentAppId;
|
|
|
|
|
cy.writeFile(fixtureFile, JSON.stringify(data));
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public StartInterceptRoutesForMySQL() {
|
|
|
|
|
//All stubbing - updating app id to current app id for Delete app by api call to be successfull:
|
|
|
|
|
|
|
|
|
|
this.ReplaceApplicationIdForInterceptPages(
|
|
|
|
|
"cypress/fixtures/mySQL_PUT_replaceLayoutWithCRUD.json",
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
cy.intercept("POST", "/api/v1/datasources/test", {
|
|
|
|
|
fixture: "testAction.json",
|
|
|
|
|
}).as("testDatasource");
|
|
|
|
|
cy.intercept("GET", "/api/v1/datasources/*/structure?ignoreCache=*", {
|
|
|
|
|
fixture: "mySQL_GET_selectTableDropdown.json",
|
|
|
|
|
}).as("getDatasourceStructure");
|
|
|
|
|
cy.intercept("PUT", "/api/v1/pages/crud-page/*", {
|
|
|
|
|
fixture: "mySQL_PUT_replaceLayoutWithCRUD.json",
|
|
|
|
|
}).as("replaceLayoutWithCRUDPage");
|
|
|
|
|
cy.intercept("GET", "/api/v1/actions*", {
|
|
|
|
|
fixture: "mySQL_GET_Actions.json",
|
|
|
|
|
}).as("getActions");
|
|
|
|
|
cy.intercept("POST", "/api/v1/actions/execute", {
|
|
|
|
|
fixture: "mySQL_POST_Execute.json",
|
|
|
|
|
}).as("postExecute");
|
|
|
|
|
cy.intercept("POST", "/api/v1/pages/crud-page", {
|
|
|
|
|
fixture: "mySQL_PUT_replaceLayoutWithCRUD.json",
|
|
|
|
|
}).as("replaceLayoutWithCRUDPage");
|
|
|
|
|
}
|
2022-05-18 10:39:42 +00:00
|
|
|
|
2022-06-06 05:59:15 +00:00
|
|
|
public StartInterceptRoutesForMongo() {
|
|
|
|
|
//All stubbing
|
|
|
|
|
this.ReplaceApplicationIdForInterceptPages(
|
|
|
|
|
"cypress/fixtures/mongo_PUT_replaceLayoutWithCRUD.json",
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
cy.intercept("POST", "/api/v1/datasources/test", {
|
|
|
|
|
fixture: "testAction.json",
|
|
|
|
|
}).as("testDatasource");
|
|
|
|
|
cy.intercept("GET", "/api/v1/datasources/*/structure?ignoreCache=*", {
|
|
|
|
|
fixture: "mongo_GET_selectTableDropdown.json",
|
|
|
|
|
}).as("getDatasourceStructure");
|
|
|
|
|
cy.intercept("PUT", "/api/v1/pages/crud-page/*", {
|
|
|
|
|
fixture: "mongo_PUT_replaceLayoutWithCRUD.json",
|
|
|
|
|
}).as("replaceLayoutWithCRUDPage");
|
|
|
|
|
cy.intercept("GET", "/api/v1/actions*", {
|
|
|
|
|
fixture: "mongo_GET_Actions.json",
|
|
|
|
|
}).as("getActions");
|
|
|
|
|
cy.intercept("POST", "/api/v1/actions/execute", {
|
|
|
|
|
fixture: "mongo_POST_Actions.json",
|
|
|
|
|
}).as("postExecute");
|
|
|
|
|
cy.intercept("POST", "/api/v1/pages/crud-page", {
|
|
|
|
|
fixture: "mongo_PUT_replaceLayoutWithCRUD.json",
|
|
|
|
|
}).as("post_replaceLayoutCRUDStub");
|
|
|
|
|
}
|
|
|
|
|
|
2022-08-04 04:48:15 +00:00
|
|
|
public StartInterceptRoutesForFirestore() {
|
|
|
|
|
//All stubbing
|
|
|
|
|
cy.intercept("POST", "/api/v1/datasources/test", {
|
|
|
|
|
fixture: "testAction.json",
|
|
|
|
|
}).as("testDatasource");
|
|
|
|
|
}
|
|
|
|
|
|
2022-08-24 14:23:41 +00:00
|
|
|
public CreatePlugIn(pluginName: string, waitForToastDisappear = false) {
|
2022-05-31 05:33:59 +00:00
|
|
|
cy.get(this._createNewPlgin(pluginName))
|
|
|
|
|
.parent("div")
|
|
|
|
|
.trigger("click", { force: true });
|
2022-11-30 05:59:45 +00:00
|
|
|
this.agHelper.Sleep();
|
|
|
|
|
//this.agHelper.WaitUntilEleAppear(this.locator._toastMsg);
|
2022-09-07 18:25:55 +00:00
|
|
|
this.agHelper.AssertElementAbsence(
|
|
|
|
|
this.locator._specificToast("Duplicate key error"),
|
|
|
|
|
);
|
2022-12-09 05:06:52 +00:00
|
|
|
this.agHelper.PressEscape();
|
2022-11-30 05:59:45 +00:00
|
|
|
// if (waitForToastDisappear)
|
|
|
|
|
// this.agHelper.WaitUntilToastDisappear("datasource created");
|
|
|
|
|
// else this.agHelper.AssertContains("datasource created");
|
2022-05-18 10:39:42 +00:00
|
|
|
}
|
|
|
|
|
|
2022-12-02 03:06:22 +00:00
|
|
|
public EditDatasource() {
|
|
|
|
|
this.agHelper.GetNClick(this._editButton);
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-05 05:58:17 +00:00
|
|
|
public ExpandSection(index: number) {
|
chore: upgrade to prettier v2 + enforce import types (#21013)Co-authored-by: Satish Gandham <hello@satishgandham.com> Co-authored-by: Satish Gandham <satish.iitg@gmail.com>
## Description
This PR upgrades Prettier to v2 + enforces TypeScript’s [`import
type`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-8.html#type-only-imports-and-export)
syntax where applicable. It’s submitted as a separate PR so we can merge
it easily.
As a part of this PR, we reformat the codebase heavily:
- add `import type` everywhere where it’s required, and
- re-format the code to account for Prettier 2’s breaking changes:
https://prettier.io/blog/2020/03/21/2.0.0.html#breaking-changes
This PR is submitted against `release` to make sure all new code by team
members will adhere to new formatting standards, and we’ll have fewer
conflicts when merging `bundle-optimizations` into `release`. (I’ll
merge `release` back into `bundle-optimizations` once this PR is
merged.)
### Why is this needed?
This PR is needed because, for the Lodash optimization from
https://github.com/appsmithorg/appsmith/commit/7cbb12af886621256224be0c93e6a465dd710ad3,
we need to use `import type`. Otherwise, `babel-plugin-lodash` complains
that `LoDashStatic` is not a lodash function.
However, just using `import type` in the current codebase will give you
this:
<img width="962" alt="Screenshot 2023-03-08 at 17 45 59"
src="https://user-images.githubusercontent.com/2953267/223775744-407afa0c-e8b9-44a1-90f9-b879348da57f.png">
That’s because Prettier 1 can’t parse `import type` at all. To parse it,
we need to upgrade to Prettier 2.
### Why enforce `import type`?
Apart from just enabling `import type` support, this PR enforces
specifying `import type` everywhere it’s needed. (Developers will get
immediate TypeScript and ESLint errors when they forget to do so.)
I’m doing this because I believe `import type` improves DX and makes
refactorings easier.
Let’s say you had a few imports like below. Can you tell which of these
imports will increase the bundle size? (Tip: it’s not all of them!)
```ts
// app/client/src/workers/Linting/utils.ts
import { Position } from "codemirror";
import { LintError as JSHintError, LintOptions } from "jshint";
import { get, isEmpty, isNumber, keys, last, set } from "lodash";
```
It’s pretty hard, right?
What about now?
```ts
// app/client/src/workers/Linting/utils.ts
import type { Position } from "codemirror";
import type { LintError as JSHintError, LintOptions } from "jshint";
import { get, isEmpty, isNumber, keys, last, set } from "lodash";
```
Now, it’s clear that only `lodash` will be bundled.
This helps developers to see which imports are problematic, but it
_also_ helps with refactorings. Now, if you want to see where
`codemirror` is bundled, you can just grep for `import \{.*\} from
"codemirror"` – and you won’t get any type-only imports.
This also helps (some) bundlers. Upon transpiling, TypeScript erases
type-only imports completely. In some environment (not ours), this makes
the bundle smaller, as the bundler doesn’t need to bundle type-only
imports anymore.
## Type of change
- Chore (housekeeping or task changes that don't impact user perception)
## How Has This Been Tested?
This was tested to not break the build.
### Test Plan
> Add Testsmith test cases links that relate to this PR
### Issues raised during DP testing
> Link issues raised during DP testing for better visiblity and tracking
(copy link from comments dropped on this PR)
## Checklist:
### Dev activity
- [x] My code follows the style guidelines of this project
- [ ] I have performed a self-review of my own code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my
feature works
- [ ] New and existing unit tests pass locally with my changes
- [ ] PR is being merged under a feature flag
### QA activity:
- [ ] Test plan has been approved by relevant developers
- [ ] Test plan has been peer reviewed by QA
- [ ] Cypress test cases have been added and approved by either SDET or
manual QA
- [ ] Organized project review call with relevant stakeholders after
Round 1/2 of QA
- [ ] Added Test Plan Approved label after reveiwing all Cypress test
---------
Co-authored-by: Satish Gandham <hello@satishgandham.com>
Co-authored-by: Satish Gandham <satish.iitg@gmail.com>
2023-03-16 11:41:47 +00:00
|
|
|
cy.get(this._collapseContainer).eq(index).click();
|
2023-05-19 18:37:06 +00:00
|
|
|
cy.get(this._collapseSettings).should("be.visible");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ExpandSectionByName(sectionName: string) {
|
|
|
|
|
// Click on collapse section only if it collapsed, if it is expanded we ignore
|
|
|
|
|
this.agHelper
|
|
|
|
|
.GetElement(this._sectionState(sectionName))
|
|
|
|
|
.invoke("attr", "aria-hidden")
|
|
|
|
|
.then((hidden: any) => {
|
|
|
|
|
if (hidden == "true") {
|
|
|
|
|
this.agHelper.GetNClick(this._section(sectionName));
|
2022-12-05 05:58:17 +00:00
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public AssertSectionCollapseState(index: number, collapsed = false) {
|
2023-05-19 18:37:06 +00:00
|
|
|
if (collapsed) {
|
|
|
|
|
cy.get(this._collapseSettings).should("not.be.visible");
|
|
|
|
|
} else {
|
|
|
|
|
cy.get(this._collapseSettings).should("be.visible");
|
|
|
|
|
}
|
2022-12-05 05:58:17 +00:00
|
|
|
}
|
|
|
|
|
|
2022-05-18 10:39:42 +00:00
|
|
|
public NavigateToDSCreateNew() {
|
2023-05-19 18:37:06 +00:00
|
|
|
this.ee.HoverOnEntityItem("Datasources");
|
|
|
|
|
Cypress._.times(2, () => {
|
|
|
|
|
this.agHelper.GetNClick(this._addNewDataSource, 0, true);
|
|
|
|
|
this.agHelper.Sleep();
|
|
|
|
|
});
|
2023-06-15 13:21:11 +00:00
|
|
|
this.agHelper.RemoveTooltip("Add a new datasource");
|
2023-02-02 13:50:36 +00:00
|
|
|
cy.get(this._newDatasourceContainer).scrollTo("bottom", {
|
|
|
|
|
ensureScrollable: false,
|
|
|
|
|
});
|
2022-05-23 05:20:27 +00:00
|
|
|
cy.get(this._newDatabases).should("be.visible");
|
2022-05-18 10:39:42 +00:00
|
|
|
}
|
|
|
|
|
|
2022-10-20 12:08:48 +00:00
|
|
|
CreateMockDB(dbName: "Users" | "Movies"): Cypress.Chainable<string> {
|
|
|
|
|
this.NavigateToDSCreateNew();
|
|
|
|
|
this.agHelper.GetNClick(this._mockDB(dbName));
|
2023-06-17 08:23:03 +00:00
|
|
|
this.assertHelper.AssertNetworkStatus("@getMockDb"); //To return the right mock DB name
|
2022-10-20 12:08:48 +00:00
|
|
|
return cy
|
2023-06-17 08:23:03 +00:00
|
|
|
.get("@getMockDb")
|
|
|
|
|
.then(($createdMock: any) => $createdMock.response?.body.data.name);
|
2022-10-20 12:08:48 +00:00
|
|
|
}
|
|
|
|
|
|
2022-07-20 18:01:50 +00:00
|
|
|
public FillPostgresDSForm(
|
|
|
|
|
shouldAddTrailingSpaces = false,
|
|
|
|
|
username = "",
|
|
|
|
|
password = "",
|
|
|
|
|
) {
|
2022-05-18 10:39:42 +00:00
|
|
|
const hostAddress = shouldAddTrailingSpaces
|
2023-06-15 13:21:11 +00:00
|
|
|
? this.hp.postgres_host + " "
|
|
|
|
|
: this.hp.postgres_host;
|
2022-05-18 10:39:42 +00:00
|
|
|
const databaseName = shouldAddTrailingSpaces
|
2023-06-15 13:21:11 +00:00
|
|
|
? this.hp.postgres_databaseName + " "
|
|
|
|
|
: this.hp.postgres_databaseName;
|
2023-05-19 18:37:06 +00:00
|
|
|
this.agHelper.UpdateInputValue(
|
|
|
|
|
this._port,
|
2023-06-15 13:21:11 +00:00
|
|
|
this.hp.postgres_port.toString(),
|
2023-05-19 18:37:06 +00:00
|
|
|
);
|
2023-06-15 13:21:11 +00:00
|
|
|
this.agHelper.UpdateInputValue(this._host, hostAddress);
|
chore: upgrade to prettier v2 + enforce import types (#21013)Co-authored-by: Satish Gandham <hello@satishgandham.com> Co-authored-by: Satish Gandham <satish.iitg@gmail.com>
## Description
This PR upgrades Prettier to v2 + enforces TypeScript’s [`import
type`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-8.html#type-only-imports-and-export)
syntax where applicable. It’s submitted as a separate PR so we can merge
it easily.
As a part of this PR, we reformat the codebase heavily:
- add `import type` everywhere where it’s required, and
- re-format the code to account for Prettier 2’s breaking changes:
https://prettier.io/blog/2020/03/21/2.0.0.html#breaking-changes
This PR is submitted against `release` to make sure all new code by team
members will adhere to new formatting standards, and we’ll have fewer
conflicts when merging `bundle-optimizations` into `release`. (I’ll
merge `release` back into `bundle-optimizations` once this PR is
merged.)
### Why is this needed?
This PR is needed because, for the Lodash optimization from
https://github.com/appsmithorg/appsmith/commit/7cbb12af886621256224be0c93e6a465dd710ad3,
we need to use `import type`. Otherwise, `babel-plugin-lodash` complains
that `LoDashStatic` is not a lodash function.
However, just using `import type` in the current codebase will give you
this:
<img width="962" alt="Screenshot 2023-03-08 at 17 45 59"
src="https://user-images.githubusercontent.com/2953267/223775744-407afa0c-e8b9-44a1-90f9-b879348da57f.png">
That’s because Prettier 1 can’t parse `import type` at all. To parse it,
we need to upgrade to Prettier 2.
### Why enforce `import type`?
Apart from just enabling `import type` support, this PR enforces
specifying `import type` everywhere it’s needed. (Developers will get
immediate TypeScript and ESLint errors when they forget to do so.)
I’m doing this because I believe `import type` improves DX and makes
refactorings easier.
Let’s say you had a few imports like below. Can you tell which of these
imports will increase the bundle size? (Tip: it’s not all of them!)
```ts
// app/client/src/workers/Linting/utils.ts
import { Position } from "codemirror";
import { LintError as JSHintError, LintOptions } from "jshint";
import { get, isEmpty, isNumber, keys, last, set } from "lodash";
```
It’s pretty hard, right?
What about now?
```ts
// app/client/src/workers/Linting/utils.ts
import type { Position } from "codemirror";
import type { LintError as JSHintError, LintOptions } from "jshint";
import { get, isEmpty, isNumber, keys, last, set } from "lodash";
```
Now, it’s clear that only `lodash` will be bundled.
This helps developers to see which imports are problematic, but it
_also_ helps with refactorings. Now, if you want to see where
`codemirror` is bundled, you can just grep for `import \{.*\} from
"codemirror"` – and you won’t get any type-only imports.
This also helps (some) bundlers. Upon transpiling, TypeScript erases
type-only imports completely. In some environment (not ours), this makes
the bundle smaller, as the bundler doesn’t need to bundle type-only
imports anymore.
## Type of change
- Chore (housekeeping or task changes that don't impact user perception)
## How Has This Been Tested?
This was tested to not break the build.
### Test Plan
> Add Testsmith test cases links that relate to this PR
### Issues raised during DP testing
> Link issues raised during DP testing for better visiblity and tracking
(copy link from comments dropped on this PR)
## Checklist:
### Dev activity
- [x] My code follows the style guidelines of this project
- [ ] I have performed a self-review of my own code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my
feature works
- [ ] New and existing unit tests pass locally with my changes
- [ ] PR is being merged under a feature flag
### QA activity:
- [ ] Test plan has been approved by relevant developers
- [ ] Test plan has been peer reviewed by QA
- [ ] Cypress test cases have been added and approved by either SDET or
manual QA
- [ ] Organized project review call with relevant stakeholders after
Round 1/2 of QA
- [ ] Added Test Plan Approved label after reveiwing all Cypress test
---------
Co-authored-by: Satish Gandham <hello@satishgandham.com>
Co-authored-by: Satish Gandham <satish.iitg@gmail.com>
2023-03-16 11:41:47 +00:00
|
|
|
cy.get(this._databaseName).clear().type(databaseName);
|
2023-05-19 18:37:06 +00:00
|
|
|
this.ExpandSectionByName("Authentication");
|
2022-07-20 18:01:50 +00:00
|
|
|
cy.get(this._username).type(
|
2023-06-15 13:21:11 +00:00
|
|
|
username == "" ? this.hp.postgres_username : username,
|
2022-07-20 18:01:50 +00:00
|
|
|
);
|
|
|
|
|
cy.get(this._password).type(
|
2023-06-15 13:21:11 +00:00
|
|
|
password == "" ? this.hp.postgres_username : password,
|
2022-07-20 18:01:50 +00:00
|
|
|
);
|
2022-05-18 10:39:42 +00:00
|
|
|
}
|
|
|
|
|
|
2023-06-12 17:48:46 +00:00
|
|
|
public FillOracleDSForm(
|
|
|
|
|
shouldAddTrailingSpaces = false,
|
|
|
|
|
username = "",
|
|
|
|
|
password = "",
|
|
|
|
|
) {
|
|
|
|
|
const hostAddress = shouldAddTrailingSpaces
|
2023-06-15 13:21:11 +00:00
|
|
|
? this.hp.oracle_host + " "
|
|
|
|
|
: this.hp.oracle_host;
|
2023-06-12 17:48:46 +00:00
|
|
|
const databaseName = shouldAddTrailingSpaces
|
2023-06-15 13:21:11 +00:00
|
|
|
? this.hp.oracle_name + " "
|
|
|
|
|
: this.hp.oracle_name;
|
2023-06-12 17:48:46 +00:00
|
|
|
this.agHelper.UpdateInputValue(this._host, hostAddress);
|
2023-06-15 13:21:11 +00:00
|
|
|
this.agHelper.UpdateInputValue(this._port, this.hp.oracle_port.toString());
|
2023-06-12 17:48:46 +00:00
|
|
|
cy.get(this._databaseName).clear().type(databaseName);
|
|
|
|
|
this.ExpandSectionByName("Authentication");
|
|
|
|
|
cy.get(this._username).type(
|
2023-06-15 13:21:11 +00:00
|
|
|
username == "" ? this.hp.oracle_username : username,
|
2023-06-12 17:48:46 +00:00
|
|
|
);
|
|
|
|
|
cy.get(this._password).type(
|
2023-06-15 13:21:11 +00:00
|
|
|
password == "" ? this.hp.oracle_password : password,
|
2023-06-12 17:48:46 +00:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-23 05:20:27 +00:00
|
|
|
public FillMongoDSForm(shouldAddTrailingSpaces = false) {
|
|
|
|
|
const hostAddress = shouldAddTrailingSpaces
|
2023-06-15 13:21:11 +00:00
|
|
|
? this.hp.mongo_host + " "
|
|
|
|
|
: this.hp.mongo_host;
|
2023-05-19 18:37:06 +00:00
|
|
|
this.agHelper.UpdateInputValue(this._host, hostAddress);
|
2023-06-15 13:21:11 +00:00
|
|
|
this.agHelper.UpdateInputValue(this._port, this.hp.mongo_port.toString());
|
2023-05-19 18:37:06 +00:00
|
|
|
this.ExpandSectionByName("Authentication");
|
2023-06-15 13:21:11 +00:00
|
|
|
cy.get(this._databaseName).clear().type(this.hp.mongo_databaseName);
|
2022-05-23 05:20:27 +00:00
|
|
|
}
|
|
|
|
|
|
2022-05-31 05:33:59 +00:00
|
|
|
public FillMySqlDSForm(shouldAddTrailingSpaces = false) {
|
|
|
|
|
const hostAddress = shouldAddTrailingSpaces
|
2023-06-15 13:21:11 +00:00
|
|
|
? this.hp.mysql_host + " "
|
|
|
|
|
: this.hp.mysql_host;
|
2022-05-31 05:33:59 +00:00
|
|
|
const databaseName = shouldAddTrailingSpaces
|
2023-06-15 13:21:11 +00:00
|
|
|
? this.hp.mysql_databaseName + " "
|
|
|
|
|
: this.hp.mysql_databaseName;
|
2023-05-19 18:37:06 +00:00
|
|
|
|
|
|
|
|
this.agHelper.UpdateInputValue(this._host, hostAddress);
|
2023-06-15 13:21:11 +00:00
|
|
|
this.agHelper.UpdateInputValue(this._port, this.hp.mysql_port.toString());
|
chore: upgrade to prettier v2 + enforce import types (#21013)Co-authored-by: Satish Gandham <hello@satishgandham.com> Co-authored-by: Satish Gandham <satish.iitg@gmail.com>
## Description
This PR upgrades Prettier to v2 + enforces TypeScript’s [`import
type`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-8.html#type-only-imports-and-export)
syntax where applicable. It’s submitted as a separate PR so we can merge
it easily.
As a part of this PR, we reformat the codebase heavily:
- add `import type` everywhere where it’s required, and
- re-format the code to account for Prettier 2’s breaking changes:
https://prettier.io/blog/2020/03/21/2.0.0.html#breaking-changes
This PR is submitted against `release` to make sure all new code by team
members will adhere to new formatting standards, and we’ll have fewer
conflicts when merging `bundle-optimizations` into `release`. (I’ll
merge `release` back into `bundle-optimizations` once this PR is
merged.)
### Why is this needed?
This PR is needed because, for the Lodash optimization from
https://github.com/appsmithorg/appsmith/commit/7cbb12af886621256224be0c93e6a465dd710ad3,
we need to use `import type`. Otherwise, `babel-plugin-lodash` complains
that `LoDashStatic` is not a lodash function.
However, just using `import type` in the current codebase will give you
this:
<img width="962" alt="Screenshot 2023-03-08 at 17 45 59"
src="https://user-images.githubusercontent.com/2953267/223775744-407afa0c-e8b9-44a1-90f9-b879348da57f.png">
That’s because Prettier 1 can’t parse `import type` at all. To parse it,
we need to upgrade to Prettier 2.
### Why enforce `import type`?
Apart from just enabling `import type` support, this PR enforces
specifying `import type` everywhere it’s needed. (Developers will get
immediate TypeScript and ESLint errors when they forget to do so.)
I’m doing this because I believe `import type` improves DX and makes
refactorings easier.
Let’s say you had a few imports like below. Can you tell which of these
imports will increase the bundle size? (Tip: it’s not all of them!)
```ts
// app/client/src/workers/Linting/utils.ts
import { Position } from "codemirror";
import { LintError as JSHintError, LintOptions } from "jshint";
import { get, isEmpty, isNumber, keys, last, set } from "lodash";
```
It’s pretty hard, right?
What about now?
```ts
// app/client/src/workers/Linting/utils.ts
import type { Position } from "codemirror";
import type { LintError as JSHintError, LintOptions } from "jshint";
import { get, isEmpty, isNumber, keys, last, set } from "lodash";
```
Now, it’s clear that only `lodash` will be bundled.
This helps developers to see which imports are problematic, but it
_also_ helps with refactorings. Now, if you want to see where
`codemirror` is bundled, you can just grep for `import \{.*\} from
"codemirror"` – and you won’t get any type-only imports.
This also helps (some) bundlers. Upon transpiling, TypeScript erases
type-only imports completely. In some environment (not ours), this makes
the bundle smaller, as the bundler doesn’t need to bundle type-only
imports anymore.
## Type of change
- Chore (housekeeping or task changes that don't impact user perception)
## How Has This Been Tested?
This was tested to not break the build.
### Test Plan
> Add Testsmith test cases links that relate to this PR
### Issues raised during DP testing
> Link issues raised during DP testing for better visiblity and tracking
(copy link from comments dropped on this PR)
## Checklist:
### Dev activity
- [x] My code follows the style guidelines of this project
- [ ] I have performed a self-review of my own code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my
feature works
- [ ] New and existing unit tests pass locally with my changes
- [ ] PR is being merged under a feature flag
### QA activity:
- [ ] Test plan has been approved by relevant developers
- [ ] Test plan has been peer reviewed by QA
- [ ] Cypress test cases have been added and approved by either SDET or
manual QA
- [ ] Organized project review call with relevant stakeholders after
Round 1/2 of QA
- [ ] Added Test Plan Approved label after reveiwing all Cypress test
---------
Co-authored-by: Satish Gandham <hello@satishgandham.com>
Co-authored-by: Satish Gandham <satish.iitg@gmail.com>
2023-03-16 11:41:47 +00:00
|
|
|
cy.get(this._databaseName).clear().type(databaseName);
|
2023-05-19 18:37:06 +00:00
|
|
|
this.ExpandSectionByName("Authentication");
|
2023-06-15 13:21:11 +00:00
|
|
|
cy.get(this._username).type(this.hp.mysql_username);
|
|
|
|
|
cy.get(this._password).type(this.hp.mysql_password);
|
2022-05-31 05:33:59 +00:00
|
|
|
}
|
|
|
|
|
|
2023-03-16 18:28:32 +00:00
|
|
|
public FillMsSqlDSForm() {
|
2023-06-15 13:21:11 +00:00
|
|
|
this.agHelper.UpdateInputValue(this._host, this.hp.mssql_host);
|
|
|
|
|
this.agHelper.UpdateInputValue(this._port, this.hp.mssql_port.toString());
|
2023-03-16 18:28:32 +00:00
|
|
|
this.agHelper.ClearTextField(this._databaseName);
|
|
|
|
|
// this.agHelper.UpdateInputValue(
|
|
|
|
|
// this._databaseName,
|
|
|
|
|
// datasourceFormData["mssql-databaseName"],
|
|
|
|
|
// ); //Commenting until MsSQL is init loaded into container
|
2023-05-19 18:37:06 +00:00
|
|
|
this.ExpandSectionByName("Authentication");
|
2023-06-15 13:21:11 +00:00
|
|
|
this.agHelper.UpdateInputValue(this._username, this.hp.mssql_username);
|
|
|
|
|
this.agHelper.UpdateInputValue(this._password, this.hp.mssql_password);
|
2023-03-16 18:28:32 +00:00
|
|
|
}
|
|
|
|
|
|
2023-03-18 19:42:01 +00:00
|
|
|
public FillAirtableDSForm() {
|
|
|
|
|
this.ValidateNSelectDropdown(
|
2023-06-01 14:23:35 +00:00
|
|
|
"Authentication type",
|
2023-05-19 18:37:06 +00:00
|
|
|
"Please select an option",
|
2023-06-15 10:04:08 +00:00
|
|
|
"Personal access token",
|
2023-03-18 19:42:01 +00:00
|
|
|
);
|
|
|
|
|
this.agHelper.UpdateInput(
|
2023-06-01 14:23:35 +00:00
|
|
|
this.locator._inputFieldByName("Bearer token"),
|
2023-03-18 19:42:01 +00:00
|
|
|
Cypress.env("AIRTABLE_BEARER"),
|
|
|
|
|
);
|
|
|
|
|
this.agHelper.Sleep();
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-28 20:07:07 +00:00
|
|
|
public FillArangoDSForm() {
|
2023-06-15 13:21:11 +00:00
|
|
|
this.agHelper.UpdateInputValue(this._host, this.hp.arango_host);
|
|
|
|
|
this.agHelper.UpdateInputValue(this._port, this.hp.arango_port.toString());
|
2023-03-28 20:07:07 +00:00
|
|
|
//Validating db name is _system, currently unable to create DB via curl in Arango
|
|
|
|
|
this.agHelper
|
|
|
|
|
.GetText(this._databaseName, "val")
|
|
|
|
|
.then(($dbName) => expect($dbName).to.eq("_system"));
|
2023-05-19 18:37:06 +00:00
|
|
|
this.ExpandSectionByName("Authentication");
|
2023-06-15 13:21:11 +00:00
|
|
|
this.agHelper.UpdateInputValue(this._username, this.hp.arango_username);
|
|
|
|
|
this.agHelper.UpdateInputValue(this._password, this.hp.arango_password);
|
2023-03-28 20:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public FillCurlNImport(value: string) {
|
|
|
|
|
this.NavigateToDSCreateNew();
|
|
|
|
|
this.agHelper.GetNClick(this._createBlankCurl);
|
|
|
|
|
this.ImportCurlNRun(value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ImportCurlNRun(value: string) {
|
|
|
|
|
this.agHelper.UpdateTextArea(this._curlTextArea, value);
|
2023-05-19 18:37:06 +00:00
|
|
|
this.agHelper.Sleep(500); //Clicking import after value settled
|
2023-03-28 20:07:07 +00:00
|
|
|
this.agHelper.ClickButton("Import");
|
|
|
|
|
this.apiPage.RunAPI();
|
|
|
|
|
}
|
|
|
|
|
|
2022-08-04 04:48:15 +00:00
|
|
|
public FillFirestoreDSForm() {
|
2023-04-04 15:56:57 +00:00
|
|
|
this.agHelper.UpdateInput(
|
|
|
|
|
this.locator._inputFieldByName("Database URL"),
|
2023-06-15 13:21:11 +00:00
|
|
|
this.hp.firestore_database_url,
|
2023-04-04 15:56:57 +00:00
|
|
|
);
|
|
|
|
|
this.agHelper.UpdateInput(
|
|
|
|
|
this.locator._inputFieldByName("Project Id"),
|
2023-06-15 13:21:11 +00:00
|
|
|
this.hp.firestore_projectID,
|
2022-08-04 04:48:15 +00:00
|
|
|
);
|
2023-04-04 15:56:57 +00:00
|
|
|
// cy.fixture("firestore-ServiceAccCreds").then((json: any) => {
|
|
|
|
|
// let ServiceAccCreds = JSON.parse(
|
|
|
|
|
// JSON.stringify(json.serviceAccCredentials),
|
|
|
|
|
// );
|
|
|
|
|
// ServiceAccCreds.private_key = Cypress.env("FIRESTORE_PRIVATE_KEY");
|
|
|
|
|
// //cy.log("ServiceAccCreds is " + JSON.stringify(ServiceAccCreds));
|
|
|
|
|
// cy.log(
|
|
|
|
|
// "ServiceAccCreds.private_key is " +
|
|
|
|
|
// JSON.stringify(ServiceAccCreds.private_key),
|
|
|
|
|
// );
|
|
|
|
|
this.agHelper.UpdateFieldLongInput(
|
2023-05-19 18:37:06 +00:00
|
|
|
this.locator._inputFieldByName("Service account credentials"),
|
2023-04-04 15:56:57 +00:00
|
|
|
JSON.stringify(Cypress.env("FIRESTORE_PRIVATE_KEY")),
|
2022-08-04 04:48:15 +00:00
|
|
|
);
|
2023-04-04 15:56:57 +00:00
|
|
|
//});
|
2022-08-04 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
2023-04-06 04:07:04 +00:00
|
|
|
public FillElasticSearchDSForm() {
|
2023-06-15 13:21:11 +00:00
|
|
|
this.agHelper.UpdateInputValue(this._host, this.hp.elastic_host);
|
2023-04-06 04:07:04 +00:00
|
|
|
|
2023-06-15 13:21:11 +00:00
|
|
|
this.agHelper.UpdateInputValue(this._port, this.hp.elastic_port.toString());
|
2023-05-19 18:37:06 +00:00
|
|
|
this.ExpandSectionByName("Authentication");
|
2023-06-15 13:21:11 +00:00
|
|
|
this.agHelper.UpdateInputValue(this._username, this.hp.elastic_username);
|
|
|
|
|
this.agHelper.UpdateInputValue(this._password, this.hp.elastic_password);
|
2023-04-06 04:07:04 +00:00
|
|
|
}
|
|
|
|
|
|
2023-03-15 05:03:34 +00:00
|
|
|
public FillUnAuthenticatedGraphQLDSForm() {
|
|
|
|
|
this.agHelper.GetNClick(this._createBlankGraphQL);
|
2023-06-15 13:21:11 +00:00
|
|
|
this.apiPage.EnterURL(this.hp.GraphqlApiUrl_TED);
|
2023-06-18 04:55:16 +00:00
|
|
|
this.assertHelper.AssertNetworkStatus("@createNewApi", 201);
|
2023-03-15 05:03:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public CreateNFillAuthenticatedGraphQLDSForm(
|
|
|
|
|
dataSourceName: string,
|
|
|
|
|
hKey: string,
|
|
|
|
|
hValue: string,
|
|
|
|
|
) {
|
|
|
|
|
this.NavigateToDSCreateNew();
|
|
|
|
|
this.CreatePlugIn("Authenticated GraphQL API");
|
|
|
|
|
this.agHelper.UpdateInput(
|
|
|
|
|
this.locator._inputFieldByName("URL"),
|
2023-06-15 13:21:11 +00:00
|
|
|
this.hp.GraphqlApiUrl_TED,
|
2023-03-15 05:03:34 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
|
|
this.agHelper.UpdateInputValue(this._graphQLHeaderKey, hKey);
|
|
|
|
|
this.agHelper.UpdateInputValue(this._graphQLHeaderValue, hValue);
|
|
|
|
|
cy.get("@guid").then((uid: any) => {
|
|
|
|
|
dataSourceName = dataSourceName + " " + uid;
|
|
|
|
|
this.agHelper.RenameWithInPane(dataSourceName, false);
|
|
|
|
|
this.SaveDatasource();
|
|
|
|
|
cy.wrap(dataSourceName).as("dsName");
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2023-04-25 18:24:36 +00:00
|
|
|
public FillRedisDSForm() {
|
2023-06-15 13:21:11 +00:00
|
|
|
this.agHelper.UpdateInputValue(this._host, this.hp.redis_host);
|
|
|
|
|
this.agHelper.UpdateInputValue(this._port, this.hp.redis_port.toString());
|
2023-04-25 18:24:36 +00:00
|
|
|
}
|
|
|
|
|
|
2022-05-18 10:39:42 +00:00
|
|
|
public TestSaveDatasource(expectedRes = true) {
|
|
|
|
|
this.TestDatasource(expectedRes);
|
|
|
|
|
this.SaveDatasource();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public TestDatasource(expectedRes = true) {
|
2022-08-24 14:23:41 +00:00
|
|
|
this.agHelper.GetNClick(this._testDs, 0, false, 0);
|
2023-06-15 13:21:11 +00:00
|
|
|
this.agHelper.AssertNetworkDataSuccess("@testDatasource", expectedRes);
|
2023-01-05 12:36:26 +00:00
|
|
|
if (expectedRes) {
|
|
|
|
|
this.agHelper.AssertContains("datasource is valid");
|
|
|
|
|
}
|
2022-05-18 10:39:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public SaveDatasource() {
|
2022-11-30 05:59:45 +00:00
|
|
|
this.agHelper.GetNClick(this._saveDs);
|
2023-06-18 04:55:16 +00:00
|
|
|
this.assertHelper.AssertNetworkStatus("@saveDatasource", 201);
|
2022-11-30 05:59:45 +00:00
|
|
|
this.agHelper.AssertContains("datasource created");
|
2022-05-18 10:39:42 +00:00
|
|
|
|
|
|
|
|
// cy.wait("@saveDatasource")
|
|
|
|
|
// .then((xhr) => {
|
|
|
|
|
// cy.log(JSON.stringify(xhr.response!.body));
|
|
|
|
|
// }).should("have.nested.property", "response.body.responseMeta.status", 200);
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-28 05:12:27 +00:00
|
|
|
public AuthAPISaveAndAuthorize() {
|
|
|
|
|
cy.get(this._saveAndAuthorizeDS).click();
|
2023-06-18 04:55:16 +00:00
|
|
|
this.assertHelper.AssertNetworkStatus("@saveDatasource", 201);
|
2022-11-30 05:59:45 +00:00
|
|
|
}
|
|
|
|
|
|
2022-12-30 10:23:24 +00:00
|
|
|
public UpdateDatasource() {
|
2022-11-30 05:59:45 +00:00
|
|
|
this.agHelper.GetNClick(this._saveDs);
|
2023-06-18 04:55:16 +00:00
|
|
|
// this.assertHelper.AssertNetworkStatus("@updateDatasource", 200);
|
2022-11-30 05:59:45 +00:00
|
|
|
this.agHelper.AssertContains("datasource updated");
|
2022-11-28 05:12:27 +00:00
|
|
|
}
|
|
|
|
|
|
2023-05-19 18:37:06 +00:00
|
|
|
public ClickActiveTabDSContextMenu(datasourceName: string) {
|
2022-07-16 10:41:17 +00:00
|
|
|
this.NavigateToActiveTab();
|
2022-05-18 10:39:42 +00:00
|
|
|
cy.get(this._datasourceCard)
|
|
|
|
|
.contains(datasourceName)
|
2023-05-19 18:37:06 +00:00
|
|
|
.parents(this._datasourceCard)
|
|
|
|
|
.find(this._dsMenuoptions)
|
2022-05-18 10:39:42 +00:00
|
|
|
.scrollIntoView()
|
|
|
|
|
.should("be.visible")
|
2023-05-19 18:37:06 +00:00
|
|
|
.click();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public DeleteDatasouceFromActiveTab(
|
|
|
|
|
datasourceName: string,
|
|
|
|
|
expectedRes = 200 || 409 || [200 | 409],
|
|
|
|
|
) {
|
|
|
|
|
this.ClickActiveTabDSContextMenu(datasourceName);
|
|
|
|
|
this.agHelper.GetNClick(this._dsOptionMenuItem("Delete"), 0, false, 200);
|
|
|
|
|
this.agHelper.GetNClick(this._dsOptionMenuItem("Are you sure?"));
|
|
|
|
|
this.ValidateDSDeletion(expectedRes);
|
|
|
|
|
}
|
|
|
|
|
|
2023-05-22 12:05:59 +00:00
|
|
|
public DeleteDatasouceFromWinthinDS(
|
|
|
|
|
datasourceName: string,
|
|
|
|
|
expectedRes: number | number[] = 200 || 409 || [200 | 409],
|
|
|
|
|
) {
|
|
|
|
|
this.NavigateToActiveTab();
|
|
|
|
|
cy.get(this._datasourceCard)
|
|
|
|
|
.contains(datasourceName)
|
|
|
|
|
.scrollIntoView()
|
|
|
|
|
.should("be.visible")
|
|
|
|
|
.click();
|
|
|
|
|
this.agHelper.Sleep(); //for the Datasource page to open
|
|
|
|
|
this.DeleteDSDirectly(expectedRes);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public DeleteDSDirectly(
|
|
|
|
|
expectedRes: number | number[] = 200 || 409 || [200 | 409],
|
|
|
|
|
) {
|
|
|
|
|
this.agHelper.GetNClick(this._cancelEditDatasourceButton, 0, false, 200);
|
|
|
|
|
cy.get(this._contextMenuDSReviewPage).click({ force: true });
|
|
|
|
|
this.agHelper.GetNClick(this._contextMenuDelete);
|
|
|
|
|
this.agHelper.GetNClick(this.locator._visibleTextSpan("Are you sure?"));
|
|
|
|
|
this.ValidateDSDeletion(expectedRes);
|
|
|
|
|
}
|
2023-06-15 13:21:11 +00:00
|
|
|
|
|
|
|
|
public DeleteDSFromEntityExplorer(
|
|
|
|
|
dsName: string,
|
|
|
|
|
expectedRes: number | number[] = 200,
|
|
|
|
|
) {
|
|
|
|
|
this.ee.SelectEntityByName(dsName, "Datasources");
|
|
|
|
|
this.ee.ActionContextMenuByEntityName({
|
|
|
|
|
entityNameinLeftSidebar: dsName,
|
|
|
|
|
action: "Delete",
|
|
|
|
|
entityType: EntityItems.Datasource,
|
|
|
|
|
});
|
|
|
|
|
this.ValidateDSDeletion(expectedRes);
|
|
|
|
|
}
|
|
|
|
|
|
2023-05-22 12:05:59 +00:00
|
|
|
public ValidateDSDeletion(expectedRes: number | number[] = 200) {
|
2023-05-19 18:37:06 +00:00
|
|
|
let toValidateRes = expectedRes == 200 || expectedRes == 409 ? true : false;
|
|
|
|
|
if (toValidateRes) {
|
|
|
|
|
if (expectedRes == 200)
|
|
|
|
|
this.agHelper.AssertContains("datasource deleted successfully");
|
|
|
|
|
else this.agHelper.AssertContains("action(s) using it.");
|
2023-06-18 04:55:16 +00:00
|
|
|
this.assertHelper.AssertNetworkStatus(
|
2023-05-22 12:05:59 +00:00
|
|
|
"@deleteDatasource",
|
|
|
|
|
expectedRes as number,
|
|
|
|
|
);
|
2023-05-19 18:37:06 +00:00
|
|
|
} else {
|
2023-06-15 13:21:11 +00:00
|
|
|
cy.wait("@deleteDatasource")
|
|
|
|
|
.its("response.body.responseMeta.status")
|
|
|
|
|
.should("be.oneOf", [200, 409]);
|
2023-05-19 18:37:06 +00:00
|
|
|
}
|
2022-05-31 05:33:59 +00:00
|
|
|
}
|
|
|
|
|
|
2022-07-16 10:41:17 +00:00
|
|
|
public NavigateToActiveTab() {
|
2023-03-10 11:39:06 +00:00
|
|
|
this.agHelper.GetElement(this.locator._body).then(($body) => {
|
2023-03-05 03:22:42 +00:00
|
|
|
if ($body.find(this._selectedActiveTab).length == 0) {
|
|
|
|
|
this.NavigateToDSCreateNew();
|
|
|
|
|
this.agHelper.GetNClick(this._activeTab, 0, true);
|
|
|
|
|
}
|
|
|
|
|
});
|
2022-07-16 10:41:17 +00:00
|
|
|
}
|
|
|
|
|
|
2022-05-31 05:33:59 +00:00
|
|
|
public NavigateFromActiveDS(datasourceName: string, createQuery: boolean) {
|
2022-09-19 05:32:06 +00:00
|
|
|
const btnLocator =
|
2022-05-31 05:33:59 +00:00
|
|
|
createQuery == true
|
|
|
|
|
? this._createQuery
|
|
|
|
|
: this._datasourceCardGeneratePageBtn;
|
|
|
|
|
|
2023-06-15 13:21:11 +00:00
|
|
|
this.AssertDSActive(datasourceName)
|
2022-05-31 05:33:59 +00:00
|
|
|
.scrollIntoView()
|
|
|
|
|
.should("be.visible")
|
|
|
|
|
.closest(this._datasourceCard)
|
|
|
|
|
.within(() => {
|
2023-06-15 13:21:11 +00:00
|
|
|
this.agHelper.GetNClick(btnLocator, 0, true);
|
2022-05-31 05:33:59 +00:00
|
|
|
});
|
2023-06-15 13:21:11 +00:00
|
|
|
this.agHelper.Sleep(3000); //for the CreateQuery/GeneratePage page to load
|
|
|
|
|
createQuery &&
|
|
|
|
|
this.agHelper.AssertElementVisible(
|
|
|
|
|
this.locator._spanButton("Run"),
|
|
|
|
|
0,
|
|
|
|
|
20000,
|
|
|
|
|
);
|
|
|
|
|
!createQuery &&
|
2023-06-18 04:55:16 +00:00
|
|
|
this.assertHelper.AssertNetworkStatus("@getDatasourceStructure", 200); //Making sure table dropdown is populated
|
2023-06-15 13:21:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public AssertDSActive(dsName: string) {
|
|
|
|
|
this.ee.NavigateToSwitcher("Explorer", 0, true);
|
|
|
|
|
this.ee.ExpandCollapseEntity("Datasources", false);
|
|
|
|
|
//this.ee.SelectEntityByName(datasourceName, "Datasources");
|
|
|
|
|
//this.ee.ExpandCollapseEntity(datasourceName, false);
|
|
|
|
|
this.NavigateToActiveTab();
|
|
|
|
|
return this.agHelper.GetNAssertContains(this._datasourceCard, dsName);
|
2022-05-18 10:39:42 +00:00
|
|
|
}
|
|
|
|
|
|
2023-03-05 03:22:42 +00:00
|
|
|
public CreateQueryFromActiveTab(
|
|
|
|
|
datasourceName: string,
|
|
|
|
|
toNavigateToActive = true,
|
|
|
|
|
) {
|
|
|
|
|
if (toNavigateToActive) this.NavigateToActiveTab();
|
2022-08-27 12:40:11 +00:00
|
|
|
cy.get(this._datasourceCard, { withinSubject: null })
|
|
|
|
|
.find(this._activeDS)
|
2022-07-29 08:48:25 +00:00
|
|
|
.contains(datasourceName)
|
|
|
|
|
.scrollIntoView()
|
|
|
|
|
.should("be.visible")
|
|
|
|
|
.closest(this._datasourceCard)
|
2023-05-25 01:14:48 +00:00
|
|
|
.scrollIntoView()
|
2022-07-29 08:48:25 +00:00
|
|
|
.within(() => {
|
2023-06-15 13:21:11 +00:00
|
|
|
this.agHelper.GetNClick(this._createQuery, 0, true);
|
2022-07-29 08:48:25 +00:00
|
|
|
});
|
|
|
|
|
this.agHelper.Sleep(2000); //for the CreateQuery
|
2023-06-18 04:55:16 +00:00
|
|
|
//this.assertHelper.AssertNetworkStatus("@createNewApi", 201);//throwing 404 in CI sometimes
|
2023-06-15 13:21:11 +00:00
|
|
|
this.agHelper.AssertElementVisible(
|
|
|
|
|
this.locator._spanButton("Run"),
|
|
|
|
|
0,
|
|
|
|
|
20000,
|
|
|
|
|
);
|
2022-07-29 08:48:25 +00:00
|
|
|
}
|
|
|
|
|
|
2023-03-05 03:22:42 +00:00
|
|
|
CreateQueryAfterDSSaved(query = "", queryName = "") {
|
|
|
|
|
this.agHelper.GetNClick(this._createQuery);
|
2023-06-18 04:55:16 +00:00
|
|
|
//this.assertHelper.AssertNetworkStatus("@createNewApi", 201);
|
2023-06-15 13:21:11 +00:00
|
|
|
this.agHelper.AssertElementVisible(
|
|
|
|
|
this.locator._spanButton("Run"),
|
|
|
|
|
0,
|
|
|
|
|
20000,
|
|
|
|
|
);
|
2023-03-05 03:22:42 +00:00
|
|
|
if (queryName) this.agHelper.RenameWithInPane(queryName);
|
|
|
|
|
if (query) {
|
|
|
|
|
this.EnterQuery(query);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-10-20 12:08:48 +00:00
|
|
|
DeleteQuery(queryName: string) {
|
|
|
|
|
this.ee.ExpandCollapseEntity("Queries/JS");
|
2023-06-15 13:21:11 +00:00
|
|
|
this.ee.ActionContextMenuByEntityName({
|
|
|
|
|
entityNameinLeftSidebar: queryName,
|
|
|
|
|
action: "Delete",
|
|
|
|
|
entityType: EntityItems.Query,
|
|
|
|
|
});
|
2022-10-20 12:08:48 +00:00
|
|
|
}
|
|
|
|
|
|
2022-05-18 10:39:42 +00:00
|
|
|
public ValidateNSelectDropdown(
|
|
|
|
|
ddTitle: string,
|
2023-05-19 18:37:06 +00:00
|
|
|
currentValue: string,
|
2022-05-18 10:39:42 +00:00
|
|
|
newValue = "",
|
|
|
|
|
) {
|
|
|
|
|
if (currentValue)
|
|
|
|
|
cy.xpath(this._visibleTextSpan(currentValue))
|
2023-05-19 18:37:06 +00:00
|
|
|
//.scrollIntoView()
|
|
|
|
|
.should("exist", currentValue + " dropdown value not present");
|
|
|
|
|
if (newValue != "") {
|
2023-05-24 12:30:39 +00:00
|
|
|
this.agHelper.GetNClick(this._dropdownTitle(ddTitle));
|
2023-05-19 18:37:06 +00:00
|
|
|
//cy.xpath(this._dropdown(currentValue)).last().click({ force: true });
|
|
|
|
|
//to expand the dropdown
|
2023-05-24 12:30:39 +00:00
|
|
|
//this.agHelper.GetNClick(this._queryOption(newValue))
|
2023-05-19 18:37:06 +00:00
|
|
|
cy.xpath(this._queryOption(newValue)).last().click({ force: true }); //to select the new value
|
2022-04-03 16:43:20 +00:00
|
|
|
}
|
2022-05-18 10:39:42 +00:00
|
|
|
}
|
|
|
|
|
|
2022-07-29 08:48:25 +00:00
|
|
|
public ReconnectDataSource(dbName: string, dsName: "PostgreSQL" | "MySQL") {
|
2022-05-31 05:33:59 +00:00
|
|
|
this.agHelper.AssertElementVisible(this._reconnectModal);
|
2023-06-08 09:10:38 +00:00
|
|
|
this.agHelper.AssertElementVisible(this._testDs); //Making sure modal is fully loaded
|
2022-07-29 08:48:25 +00:00
|
|
|
cy.xpath(this._activeDSListReconnectModal(dsName)).should("be.visible");
|
2022-05-18 10:39:42 +00:00
|
|
|
cy.xpath(this._activeDSListReconnectModal(dbName)).should("be.visible"); //.click()
|
2023-05-19 18:37:06 +00:00
|
|
|
this.ValidateNSelectDropdown("Connection mode", "Read / Write");
|
2022-07-29 08:48:25 +00:00
|
|
|
if (dsName == "PostgreSQL") this.FillPostgresDSForm();
|
|
|
|
|
else if (dsName == "MySQL") this.FillMySqlDSForm();
|
2022-05-18 10:39:42 +00:00
|
|
|
cy.get(this._saveDs).click();
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-18 19:42:01 +00:00
|
|
|
RunQuery({
|
2023-03-11 07:01:39 +00:00
|
|
|
expectedStatus = true,
|
2023-03-23 11:32:18 +00:00
|
|
|
toValidateResponse = true,
|
2022-08-24 14:23:41 +00:00
|
|
|
waitTimeInterval = 500,
|
2023-03-18 19:42:01 +00:00
|
|
|
}: Partial<RunQueryParams> = {}) {
|
2022-08-24 14:23:41 +00:00
|
|
|
this.agHelper.GetNClick(this._runQueryBtn, 0, true, waitTimeInterval);
|
2023-06-15 13:21:11 +00:00
|
|
|
this.agHelper.AssertElementAbsence(
|
|
|
|
|
this.locator._cancelActionExecution,
|
|
|
|
|
10000,
|
|
|
|
|
); //For the run to give response
|
2022-08-24 14:23:41 +00:00
|
|
|
if (toValidateResponse) {
|
2023-03-18 19:42:01 +00:00
|
|
|
this.agHelper.Sleep();
|
2023-06-15 13:21:11 +00:00
|
|
|
this.agHelper.AssertNetworkExecutionSuccess(
|
2022-08-24 14:23:41 +00:00
|
|
|
"@postExecute",
|
|
|
|
|
expectedStatus,
|
|
|
|
|
);
|
|
|
|
|
}
|
2022-05-31 05:33:59 +00:00
|
|
|
}
|
|
|
|
|
|
2023-06-08 09:09:19 +00:00
|
|
|
AssertRunButtonDisability(disabled = false) {
|
|
|
|
|
let query = "";
|
|
|
|
|
if (disabled) {
|
|
|
|
|
query = "be.disabled";
|
|
|
|
|
} else {
|
|
|
|
|
query = "not.be.disabled";
|
|
|
|
|
}
|
|
|
|
|
cy.get(this._runQueryBtn).should(query);
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-31 05:33:59 +00:00
|
|
|
public ReadQueryTableResponse(index: number, timeout = 100) {
|
|
|
|
|
//timeout can be sent higher values incase of larger tables
|
|
|
|
|
this.agHelper.Sleep(timeout); //Settling time for table!
|
chore: upgrade to prettier v2 + enforce import types (#21013)Co-authored-by: Satish Gandham <hello@satishgandham.com> Co-authored-by: Satish Gandham <satish.iitg@gmail.com>
## Description
This PR upgrades Prettier to v2 + enforces TypeScript’s [`import
type`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-8.html#type-only-imports-and-export)
syntax where applicable. It’s submitted as a separate PR so we can merge
it easily.
As a part of this PR, we reformat the codebase heavily:
- add `import type` everywhere where it’s required, and
- re-format the code to account for Prettier 2’s breaking changes:
https://prettier.io/blog/2020/03/21/2.0.0.html#breaking-changes
This PR is submitted against `release` to make sure all new code by team
members will adhere to new formatting standards, and we’ll have fewer
conflicts when merging `bundle-optimizations` into `release`. (I’ll
merge `release` back into `bundle-optimizations` once this PR is
merged.)
### Why is this needed?
This PR is needed because, for the Lodash optimization from
https://github.com/appsmithorg/appsmith/commit/7cbb12af886621256224be0c93e6a465dd710ad3,
we need to use `import type`. Otherwise, `babel-plugin-lodash` complains
that `LoDashStatic` is not a lodash function.
However, just using `import type` in the current codebase will give you
this:
<img width="962" alt="Screenshot 2023-03-08 at 17 45 59"
src="https://user-images.githubusercontent.com/2953267/223775744-407afa0c-e8b9-44a1-90f9-b879348da57f.png">
That’s because Prettier 1 can’t parse `import type` at all. To parse it,
we need to upgrade to Prettier 2.
### Why enforce `import type`?
Apart from just enabling `import type` support, this PR enforces
specifying `import type` everywhere it’s needed. (Developers will get
immediate TypeScript and ESLint errors when they forget to do so.)
I’m doing this because I believe `import type` improves DX and makes
refactorings easier.
Let’s say you had a few imports like below. Can you tell which of these
imports will increase the bundle size? (Tip: it’s not all of them!)
```ts
// app/client/src/workers/Linting/utils.ts
import { Position } from "codemirror";
import { LintError as JSHintError, LintOptions } from "jshint";
import { get, isEmpty, isNumber, keys, last, set } from "lodash";
```
It’s pretty hard, right?
What about now?
```ts
// app/client/src/workers/Linting/utils.ts
import type { Position } from "codemirror";
import type { LintError as JSHintError, LintOptions } from "jshint";
import { get, isEmpty, isNumber, keys, last, set } from "lodash";
```
Now, it’s clear that only `lodash` will be bundled.
This helps developers to see which imports are problematic, but it
_also_ helps with refactorings. Now, if you want to see where
`codemirror` is bundled, you can just grep for `import \{.*\} from
"codemirror"` – and you won’t get any type-only imports.
This also helps (some) bundlers. Upon transpiling, TypeScript erases
type-only imports completely. In some environment (not ours), this makes
the bundle smaller, as the bundler doesn’t need to bundle type-only
imports anymore.
## Type of change
- Chore (housekeeping or task changes that don't impact user perception)
## How Has This Been Tested?
This was tested to not break the build.
### Test Plan
> Add Testsmith test cases links that relate to this PR
### Issues raised during DP testing
> Link issues raised during DP testing for better visiblity and tracking
(copy link from comments dropped on this PR)
## Checklist:
### Dev activity
- [x] My code follows the style guidelines of this project
- [ ] I have performed a self-review of my own code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my
feature works
- [ ] New and existing unit tests pass locally with my changes
- [ ] PR is being merged under a feature flag
### QA activity:
- [ ] Test plan has been approved by relevant developers
- [ ] Test plan has been peer reviewed by QA
- [ ] Cypress test cases have been added and approved by either SDET or
manual QA
- [ ] Organized project review call with relevant stakeholders after
Round 1/2 of QA
- [ ] Added Test Plan Approved label after reveiwing all Cypress test
---------
Co-authored-by: Satish Gandham <hello@satishgandham.com>
Co-authored-by: Satish Gandham <satish.iitg@gmail.com>
2023-03-16 11:41:47 +00:00
|
|
|
return cy.xpath(this._queryTableResponse).eq(index).invoke("text");
|
2022-05-31 05:33:59 +00:00
|
|
|
}
|
|
|
|
|
|
2022-06-17 11:31:40 +00:00
|
|
|
public AssertQueryResponseHeaders(columnHeaders: string[]) {
|
|
|
|
|
columnHeaders.forEach(($header) =>
|
|
|
|
|
this.agHelper.AssertElementVisible(this._queryResponseHeader($header)),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-31 05:33:59 +00:00
|
|
|
public AssertJSONFormHeader(
|
|
|
|
|
rowindex: number,
|
|
|
|
|
colIndex: number,
|
|
|
|
|
headerString: string,
|
|
|
|
|
validateCellData: "" | string = "",
|
2022-06-06 05:59:15 +00:00
|
|
|
isMongo = false,
|
2022-05-31 05:33:59 +00:00
|
|
|
) {
|
2022-06-06 05:59:15 +00:00
|
|
|
let jsonHeaderString = "";
|
2022-05-31 05:33:59 +00:00
|
|
|
this.table.ReadTableRowColumnData(rowindex, colIndex).then(($cellData) => {
|
|
|
|
|
if (validateCellData) expect($cellData).to.eq(validateCellData);
|
2022-06-06 05:59:15 +00:00
|
|
|
|
|
|
|
|
jsonHeaderString =
|
|
|
|
|
isMongo == true
|
|
|
|
|
? "Update Document " + headerString + ": " + $cellData
|
|
|
|
|
: "Update Row " + headerString + ": " + $cellData;
|
2022-05-31 05:33:59 +00:00
|
|
|
this.agHelper
|
|
|
|
|
.GetText(this.locator._jsonFormHeader)
|
2022-06-06 05:59:15 +00:00
|
|
|
.then(($header: any) => expect($header).to.eq(jsonHeaderString));
|
2022-05-31 05:33:59 +00:00
|
|
|
});
|
2022-05-18 10:39:42 +00:00
|
|
|
}
|
2022-06-17 06:12:18 +00:00
|
|
|
|
|
|
|
|
public ToggleUsePreparedStatement(enable = true || false) {
|
|
|
|
|
if (enable)
|
|
|
|
|
cy.get(this._usePreparedStatement).check({
|
|
|
|
|
force: true,
|
|
|
|
|
});
|
|
|
|
|
else
|
|
|
|
|
cy.get(this._usePreparedStatement).uncheck({
|
|
|
|
|
force: true,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
this.agHelper.AssertAutoSave();
|
|
|
|
|
}
|
2022-07-06 05:54:00 +00:00
|
|
|
|
2023-02-10 10:41:17 +00:00
|
|
|
public EnterQuery(query: string, sleep = 500) {
|
2023-05-11 05:26:03 +00:00
|
|
|
this.agHelper.UpdateCodeInput(this.locator._codeEditorTarget, query);
|
2022-07-06 05:54:00 +00:00
|
|
|
this.agHelper.AssertAutoSave();
|
2023-02-02 07:59:24 +00:00
|
|
|
this.agHelper.Sleep(sleep); //waiting a bit before proceeding!
|
|
|
|
|
cy.wait("@saveAction");
|
2022-07-06 05:54:00 +00:00
|
|
|
}
|
2022-07-16 10:41:17 +00:00
|
|
|
|
|
|
|
|
public RunQueryNVerifyResponseViews(
|
2022-10-20 12:08:48 +00:00
|
|
|
expectedRecordsCount = 1,
|
2022-07-16 10:41:17 +00:00
|
|
|
tableCheck = true,
|
|
|
|
|
) {
|
|
|
|
|
this.RunQuery();
|
|
|
|
|
tableCheck &&
|
|
|
|
|
this.agHelper.AssertElementVisible(this._queryResponse("TABLE"));
|
|
|
|
|
this.agHelper.AssertElementVisible(this._queryResponse("JSON"));
|
|
|
|
|
this.agHelper.AssertElementVisible(this._queryResponse("RAW"));
|
2022-10-20 12:08:48 +00:00
|
|
|
this.CheckResponseRecordsCount(expectedRecordsCount);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public CheckResponseRecordsCount(expectedRecordCount: number) {
|
2022-07-16 10:41:17 +00:00
|
|
|
this.agHelper.AssertElementVisible(
|
2022-10-20 12:08:48 +00:00
|
|
|
this._queryRecordResult(expectedRecordCount),
|
2022-07-16 10:41:17 +00:00
|
|
|
);
|
|
|
|
|
}
|
2022-07-29 08:48:25 +00:00
|
|
|
|
2022-08-04 04:48:15 +00:00
|
|
|
public CreateDataSource(
|
2023-03-18 19:42:01 +00:00
|
|
|
dsType:
|
|
|
|
|
| "Postgres"
|
|
|
|
|
| "Mongo"
|
|
|
|
|
| "MySql"
|
|
|
|
|
| "UnAuthenticatedGraphQL"
|
|
|
|
|
| "MsSql"
|
2023-03-28 20:07:07 +00:00
|
|
|
| "Airtable"
|
2023-04-04 15:56:57 +00:00
|
|
|
| "Arango"
|
2023-04-06 04:07:04 +00:00
|
|
|
| "Firestore"
|
2023-04-25 18:24:36 +00:00
|
|
|
| "Elasticsearch"
|
2023-06-12 17:48:46 +00:00
|
|
|
| "Redis"
|
|
|
|
|
| "Oracle",
|
2022-08-04 04:48:15 +00:00
|
|
|
navigateToCreateNewDs = true,
|
2023-03-05 03:22:42 +00:00
|
|
|
testNSave = true,
|
2022-08-04 04:48:15 +00:00
|
|
|
) {
|
2022-07-29 08:48:25 +00:00
|
|
|
let guid: any;
|
2022-09-19 05:32:06 +00:00
|
|
|
let dataSourceName = "";
|
2022-07-29 08:48:25 +00:00
|
|
|
this.agHelper.GenerateUUID();
|
2023-03-15 05:03:34 +00:00
|
|
|
navigateToCreateNewDs && this.NavigateToDSCreateNew();
|
|
|
|
|
|
2022-07-29 08:48:25 +00:00
|
|
|
cy.get("@guid").then((uid) => {
|
2023-03-15 05:03:34 +00:00
|
|
|
if (DataSourceKVP[dsType] != "GraphQL API") {
|
|
|
|
|
this.CreatePlugIn(DataSourceKVP[dsType]);
|
|
|
|
|
guid = uid;
|
|
|
|
|
dataSourceName = dsType + " " + guid;
|
|
|
|
|
this.agHelper.RenameWithInPane(dataSourceName, false);
|
|
|
|
|
if (DataSourceKVP[dsType] == "PostgreSQL") this.FillPostgresDSForm();
|
2023-06-12 17:48:46 +00:00
|
|
|
else if (DataSourceKVP[dsType] == "Oracle") this.FillOracleDSForm();
|
2023-03-15 05:03:34 +00:00
|
|
|
else if (DataSourceKVP[dsType] == "MySQL") this.FillMySqlDSForm();
|
|
|
|
|
else if (DataSourceKVP[dsType] == "MongoDB") this.FillMongoDSForm();
|
2023-03-16 18:28:32 +00:00
|
|
|
else if (DataSourceKVP[dsType] == "Microsoft SQL Server")
|
|
|
|
|
this.FillMsSqlDSForm();
|
2023-03-18 19:42:01 +00:00
|
|
|
else if (DataSourceKVP[dsType] == "Airtable") this.FillAirtableDSForm();
|
2023-03-28 20:07:07 +00:00
|
|
|
else if (DataSourceKVP[dsType] == "ArangoDB") this.FillArangoDSForm();
|
2023-04-04 15:56:57 +00:00
|
|
|
else if (DataSourceKVP[dsType] == "Firestore")
|
|
|
|
|
this.FillFirestoreDSForm();
|
2023-04-06 04:07:04 +00:00
|
|
|
else if (DataSourceKVP[dsType] == "Elasticsearch")
|
|
|
|
|
this.FillElasticSearchDSForm();
|
2023-04-25 18:24:36 +00:00
|
|
|
else if (DataSourceKVP[dsType] == "Redis") this.FillRedisDSForm();
|
2023-03-15 05:03:34 +00:00
|
|
|
|
|
|
|
|
if (testNSave) {
|
|
|
|
|
this.TestSaveDatasource();
|
|
|
|
|
} else {
|
|
|
|
|
this.SaveDatasource();
|
|
|
|
|
}
|
|
|
|
|
} else if (DataSourceKVP[dsType] == "GraphQL API")
|
|
|
|
|
this.FillUnAuthenticatedGraphQLDSForm();
|
2022-09-19 05:32:06 +00:00
|
|
|
cy.wrap(dataSourceName).as("dsName");
|
2022-07-29 08:48:25 +00:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-05 03:22:42 +00:00
|
|
|
public CreateQueryFromOverlay(
|
|
|
|
|
dsName: string,
|
|
|
|
|
query = "",
|
|
|
|
|
queryName = "",
|
|
|
|
|
sleep = 500,
|
|
|
|
|
) {
|
2023-06-15 13:21:11 +00:00
|
|
|
this.agHelper.RemoveEvaluatedPopUp(); //to close the evaluated pop-up
|
2022-07-29 08:48:25 +00:00
|
|
|
this.ee.CreateNewDsQuery(dsName);
|
2022-09-19 05:32:06 +00:00
|
|
|
if (query) {
|
2023-03-05 03:22:42 +00:00
|
|
|
this.EnterQuery(query, sleep);
|
2022-09-19 05:32:06 +00:00
|
|
|
}
|
2023-05-19 18:37:06 +00:00
|
|
|
if (queryName) this.agHelper.RenameWithInPane(queryName);
|
2022-07-29 08:48:25 +00:00
|
|
|
}
|
2022-08-24 14:23:41 +00:00
|
|
|
|
2022-09-09 15:59:47 +00:00
|
|
|
public UpdateGraphqlQueryAndVariable(options?: {
|
|
|
|
|
query?: string;
|
|
|
|
|
variable?: string;
|
|
|
|
|
}) {
|
|
|
|
|
if (options?.query) {
|
2023-05-11 05:26:03 +00:00
|
|
|
this.agHelper.UpdateCodeInput(this._graphqlQueryEditor, options.query);
|
2022-09-09 15:59:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (options?.variable) {
|
2023-05-11 05:26:03 +00:00
|
|
|
this.agHelper.UpdateCodeInput(
|
|
|
|
|
this._graphqlVariableEditor,
|
|
|
|
|
options.variable as string,
|
|
|
|
|
);
|
2022-09-09 15:59:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.agHelper.Sleep();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public UpdateGraphqlPaginationParams(options: {
|
|
|
|
|
limit?: {
|
|
|
|
|
variable: string;
|
|
|
|
|
value: any;
|
|
|
|
|
};
|
|
|
|
|
offset?: {
|
|
|
|
|
variable: string;
|
|
|
|
|
value: any;
|
|
|
|
|
};
|
|
|
|
|
}) {
|
|
|
|
|
if (options.limit) {
|
2023-05-29 05:40:41 +00:00
|
|
|
// Select Limit variable from dropdown
|
2022-09-09 15:59:47 +00:00
|
|
|
cy.get(this._graphqlPagination._limitVariable).click({
|
|
|
|
|
force: true,
|
|
|
|
|
});
|
2023-05-19 18:37:06 +00:00
|
|
|
cy.get(".rc-select-item-option")
|
2022-09-09 15:59:47 +00:00
|
|
|
.contains(options.limit.variable)
|
|
|
|
|
.click({ force: true });
|
|
|
|
|
|
2023-05-29 05:40:41 +00:00
|
|
|
// Set the Limit value as 1
|
2022-09-09 15:59:47 +00:00
|
|
|
cy.get(this._graphqlPagination._limitValue)
|
|
|
|
|
.first()
|
|
|
|
|
.focus()
|
|
|
|
|
.type(options.limit.value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (options.offset) {
|
2023-05-29 05:40:41 +00:00
|
|
|
// Select Offset vaiable from dropdown
|
2022-09-09 15:59:47 +00:00
|
|
|
cy.get(this._graphqlPagination._offsetVariable).click({
|
|
|
|
|
force: true,
|
|
|
|
|
});
|
2023-05-19 18:37:06 +00:00
|
|
|
cy.get(".rc-select-item-option")
|
|
|
|
|
.eq(2)
|
2022-09-09 15:59:47 +00:00
|
|
|
.contains(options.offset.variable)
|
|
|
|
|
.click({ force: true });
|
|
|
|
|
|
2023-05-29 05:40:41 +00:00
|
|
|
// Set the Limit value as 1
|
2022-09-09 15:59:47 +00:00
|
|
|
cy.get(this._graphqlPagination._offsetValue)
|
|
|
|
|
.first()
|
|
|
|
|
.focus()
|
|
|
|
|
.type(options.offset.value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.agHelper.Sleep();
|
|
|
|
|
}
|
|
|
|
|
|
2022-08-24 14:23:41 +00:00
|
|
|
public SetQueryTimeout(queryTimeout = 20000) {
|
2023-05-19 18:37:06 +00:00
|
|
|
this.agHelper.GetNClick(this._queryEditorTabs("Settings"));
|
2022-08-24 14:23:41 +00:00
|
|
|
cy.xpath(this._queryTimeout)
|
|
|
|
|
.clear()
|
|
|
|
|
.type(queryTimeout.toString(), { delay: 0 }); //Delay 0 to work like paste!
|
|
|
|
|
this.agHelper.AssertAutoSave();
|
2023-05-19 18:37:06 +00:00
|
|
|
this.agHelper.GetNClick(this._queryEditorTabs("Query"));
|
2022-08-24 14:23:41 +00:00
|
|
|
}
|
2022-11-25 05:05:37 +00:00
|
|
|
|
|
|
|
|
//Update with new password in the datasource conf page
|
2023-02-02 07:59:24 +00:00
|
|
|
public UpdatePassword(newPassword: string) {
|
2023-05-19 18:37:06 +00:00
|
|
|
this.ExpandSectionByName("Authentication");
|
2022-11-25 05:05:37 +00:00
|
|
|
cy.get(this._password).type(newPassword);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//Fetch schema from server and validate UI for the updates
|
2023-02-02 07:59:24 +00:00
|
|
|
public VerifySchema(
|
2022-12-13 11:46:56 +00:00
|
|
|
dataSourceName: string,
|
|
|
|
|
schema: string,
|
|
|
|
|
isUpdate = false,
|
|
|
|
|
) {
|
2022-11-25 05:05:37 +00:00
|
|
|
cy.intercept("GET", this._getStructureReq).as("getDSStructure");
|
2022-11-30 05:59:45 +00:00
|
|
|
if (isUpdate) {
|
2022-12-30 10:23:24 +00:00
|
|
|
this.UpdateDatasource();
|
2022-11-30 05:59:45 +00:00
|
|
|
} else {
|
|
|
|
|
this.SaveDatasource();
|
|
|
|
|
}
|
2023-06-15 13:21:11 +00:00
|
|
|
this.ee.ActionContextMenuByEntityName({
|
|
|
|
|
entityNameinLeftSidebar: dataSourceName,
|
|
|
|
|
action: "Refresh",
|
|
|
|
|
});
|
2022-11-25 05:05:37 +00:00
|
|
|
cy.wait("@getDSStructure").then(() => {
|
|
|
|
|
cy.get(".bp3-collapse-body").contains(schema);
|
|
|
|
|
});
|
|
|
|
|
}
|
2022-11-30 05:59:45 +00:00
|
|
|
|
|
|
|
|
public SaveDSFromDialog(save = true) {
|
|
|
|
|
this.agHelper.GoBack();
|
2022-12-30 10:23:24 +00:00
|
|
|
this.agHelper.AssertElementVisible(this._datasourceModalDoNotSave);
|
|
|
|
|
this.agHelper.AssertElementVisible(this._datasourceModalSave);
|
2022-11-30 05:59:45 +00:00
|
|
|
if (save) {
|
|
|
|
|
this.agHelper.GetNClick(
|
2023-05-19 18:37:06 +00:00
|
|
|
this.locator._visibleTextSpan("Save"),
|
2022-11-30 05:59:45 +00:00
|
|
|
0,
|
2023-05-19 18:37:06 +00:00
|
|
|
true,
|
2022-11-30 05:59:45 +00:00
|
|
|
0,
|
|
|
|
|
);
|
2023-06-18 04:55:16 +00:00
|
|
|
this.assertHelper.AssertNetworkStatus("@saveDatasource", 201);
|
2022-11-30 05:59:45 +00:00
|
|
|
this.agHelper.AssertContains("datasource created");
|
|
|
|
|
} else
|
|
|
|
|
this.agHelper.GetNClick(
|
2023-05-19 18:37:06 +00:00
|
|
|
this.locator._visibleTextSpan("Don't save"),
|
2022-11-30 05:59:45 +00:00
|
|
|
0,
|
2023-05-19 18:37:06 +00:00
|
|
|
true,
|
2022-11-30 05:59:45 +00:00
|
|
|
0,
|
|
|
|
|
);
|
|
|
|
|
}
|
2022-12-22 08:30:49 +00:00
|
|
|
|
2022-12-30 10:23:24 +00:00
|
|
|
public getDSEntity(dSName: string) {
|
2022-12-22 08:30:49 +00:00
|
|
|
return `[data-guided-tour-id="explorer-entity-${dSName}"]`;
|
|
|
|
|
}
|
2022-12-30 10:23:24 +00:00
|
|
|
|
|
|
|
|
public FillAuthAPIUrl() {
|
2023-03-16 18:28:32 +00:00
|
|
|
this.agHelper.UpdateInput(
|
|
|
|
|
this.locator._inputFieldByName("URL"),
|
2023-06-15 13:21:11 +00:00
|
|
|
this.hp.authenticatedApiUrl,
|
2023-03-16 18:28:32 +00:00
|
|
|
);
|
2022-12-30 10:23:24 +00:00
|
|
|
}
|
|
|
|
|
|
2023-02-10 10:41:17 +00:00
|
|
|
public AssertCursorPositionForTextInput(
|
|
|
|
|
selector: string,
|
|
|
|
|
moveCursor: string,
|
|
|
|
|
typeText = "as",
|
|
|
|
|
cursorPosition = 0,
|
|
|
|
|
) {
|
2023-03-16 18:28:32 +00:00
|
|
|
this.agHelper
|
|
|
|
|
.GetElement(selector)
|
2023-02-10 10:41:17 +00:00
|
|
|
.type(moveCursor)
|
|
|
|
|
.type(typeText)
|
|
|
|
|
.should("have.prop", "selectionStart", cursorPosition);
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-30 10:23:24 +00:00
|
|
|
public AddOAuth2AuthorizationCodeDetails(
|
|
|
|
|
accessTokenUrl: string,
|
|
|
|
|
clientId: string,
|
|
|
|
|
clientSecret: string,
|
|
|
|
|
authURL: string,
|
|
|
|
|
) {
|
|
|
|
|
this.agHelper.GetNClick(this._authType);
|
|
|
|
|
this.agHelper.GetNClick(this._oauth2);
|
|
|
|
|
this.agHelper.GetNClick(this._grantType);
|
|
|
|
|
this.agHelper.GetNClick(this._authorizationCode);
|
|
|
|
|
this.agHelper.TypeText(this._accessTokenUrl, accessTokenUrl);
|
|
|
|
|
this.agHelper.TypeText(this._clientID, clientId);
|
|
|
|
|
this.agHelper.TypeText(this._clientSecret, clientSecret);
|
|
|
|
|
this.agHelper.TypeText(this._authorizationURL, authURL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public EditDSFromActiveTab(dsName: string) {
|
|
|
|
|
this.agHelper.GetNClick(this._editDatasourceFromActiveTab(dsName));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public FillMongoDatasourceFormWithURI(uri: string) {
|
2023-05-19 18:37:06 +00:00
|
|
|
this.ValidateNSelectDropdown(
|
|
|
|
|
"Use mongo connection string URI",
|
|
|
|
|
"No",
|
|
|
|
|
"Yes",
|
|
|
|
|
);
|
2023-03-18 19:42:01 +00:00
|
|
|
this.agHelper.UpdateInputValue(
|
2023-05-19 18:37:06 +00:00
|
|
|
this.locator._inputFieldByName("Connection string URI") + "//input",
|
2022-12-30 10:23:24 +00:00
|
|
|
uri,
|
|
|
|
|
);
|
|
|
|
|
}
|
2023-03-10 11:39:06 +00:00
|
|
|
|
|
|
|
|
public CreateOAuthClient(grantType: string) {
|
|
|
|
|
let clientId, clientSecret;
|
|
|
|
|
|
|
|
|
|
// Login to TED OAuth
|
|
|
|
|
let formData = new FormData();
|
2023-06-15 13:21:11 +00:00
|
|
|
formData.append("username", this.hp.OAuth_Username);
|
|
|
|
|
cy.request("POST", this.hp.OAuth_Host, formData).then((response) => {
|
|
|
|
|
expect(response.status).to.equal(200);
|
|
|
|
|
});
|
2023-03-10 11:39:06 +00:00
|
|
|
|
|
|
|
|
// Create client
|
|
|
|
|
let clientData = new FormData();
|
|
|
|
|
clientData.append("client_name", "appsmith_cs_post");
|
|
|
|
|
clientData.append("client_uri", "http://localhost/");
|
|
|
|
|
clientData.append("scope", "profile");
|
2023-06-15 13:21:11 +00:00
|
|
|
clientData.append("redirect_uri", this.hp.OAuth_RedirectUrl);
|
2023-03-10 11:39:06 +00:00
|
|
|
clientData.append("grant_type", grantType);
|
|
|
|
|
clientData.append("response_type", "code");
|
|
|
|
|
clientData.append("token_endpoint_auth_method", "client_secret_post");
|
2023-06-15 13:21:11 +00:00
|
|
|
cy.request("POST", this.hp.OAuth_Host + "/create_client", clientData).then(
|
|
|
|
|
(response) => {
|
|
|
|
|
expect(response.status).to.equal(200);
|
|
|
|
|
},
|
|
|
|
|
);
|
2023-03-10 11:39:06 +00:00
|
|
|
|
|
|
|
|
// Get Client Credentials
|
2023-06-15 13:21:11 +00:00
|
|
|
cy.request("GET", this.hp.OAuth_Host).then((response) => {
|
2023-03-10 11:39:06 +00:00
|
|
|
clientId = response.body.split("client_id: </strong>");
|
|
|
|
|
clientId = clientId[1].split("<strong>client_secret: </strong>");
|
|
|
|
|
clientSecret = clientId[1].split("<strong>");
|
|
|
|
|
clientSecret = clientSecret[0].trim();
|
|
|
|
|
clientId = clientId[0].trim();
|
|
|
|
|
cy.wrap(clientId).as("OAuthClientID");
|
|
|
|
|
cy.wrap(clientSecret).as("OAuthClientSecret");
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public CreateOAuthDatasource(
|
|
|
|
|
datasourceName: string,
|
|
|
|
|
grantType: "ClientCredentials" | "AuthCode",
|
|
|
|
|
clientId: string,
|
|
|
|
|
clientSecret: string,
|
|
|
|
|
) {
|
|
|
|
|
this.NavigateToDSCreateNew();
|
|
|
|
|
//Click on Authenticated API
|
2023-03-15 05:03:34 +00:00
|
|
|
this.agHelper.GetNClick(this._authApiDatasource, 0, true);
|
2023-03-10 11:39:06 +00:00
|
|
|
this.FillAPIOAuthForm(datasourceName, grantType, clientId, clientSecret);
|
|
|
|
|
|
|
|
|
|
// save datasource
|
|
|
|
|
this.agHelper.Sleep(500);
|
|
|
|
|
this.agHelper.GetNClick(this._saveAndAuthorizeDS);
|
|
|
|
|
|
|
|
|
|
//Accept consent
|
|
|
|
|
this.agHelper.GetNClick(this._consent);
|
|
|
|
|
this.agHelper.GetNClick(this._consentSubmit);
|
|
|
|
|
|
|
|
|
|
//Validate save
|
2023-06-18 04:55:16 +00:00
|
|
|
this.assertHelper.AssertNetworkStatus("@saveDatasource", 201);
|
2023-03-10 11:39:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public FillAPIOAuthForm(
|
|
|
|
|
dsName: string,
|
|
|
|
|
grantType: "ClientCredentials" | "AuthCode",
|
|
|
|
|
clientId: string,
|
|
|
|
|
clientSecret: string,
|
|
|
|
|
) {
|
2023-03-11 07:01:39 +00:00
|
|
|
if (dsName) this.agHelper.RenameWithInPane(dsName, false);
|
2023-03-10 11:39:06 +00:00
|
|
|
// Fill Auth Form
|
|
|
|
|
this.agHelper.UpdateInput(
|
|
|
|
|
this.locator._inputFieldByName("URL"),
|
2023-06-15 13:21:11 +00:00
|
|
|
this.hp.OAuth_ApiUrl,
|
2023-03-10 11:39:06 +00:00
|
|
|
);
|
|
|
|
|
this.agHelper.GetNClick(this._authType);
|
|
|
|
|
this.agHelper.GetNClick(this._oauth2);
|
|
|
|
|
this.agHelper.GetNClick(this._grantType);
|
|
|
|
|
if (grantType == "ClientCredentials")
|
|
|
|
|
this.agHelper.GetNClick(this._clientCredentails);
|
|
|
|
|
else if (grantType == "AuthCode")
|
|
|
|
|
this.agHelper.GetNClick(this._authorizationCode);
|
|
|
|
|
|
|
|
|
|
this.agHelper.UpdateInput(
|
2023-05-19 18:37:06 +00:00
|
|
|
this.locator._inputFieldByName("Access token URL"),
|
2023-06-15 13:21:11 +00:00
|
|
|
this.hp.OAUth_AccessTokenUrl,
|
2023-03-10 11:39:06 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
|
|
this.agHelper.UpdateInput(
|
|
|
|
|
this.locator._inputFieldByName("Client ID"),
|
|
|
|
|
clientId,
|
|
|
|
|
);
|
|
|
|
|
this.agHelper.UpdateInput(
|
2023-05-19 18:37:06 +00:00
|
|
|
this.locator._inputFieldByName("Client secret"),
|
2023-03-10 11:39:06 +00:00
|
|
|
clientSecret,
|
|
|
|
|
);
|
|
|
|
|
this.agHelper.UpdateInput(
|
|
|
|
|
this.locator._inputFieldByName("Scope(s)"),
|
|
|
|
|
"profile",
|
|
|
|
|
);
|
|
|
|
|
this.agHelper.UpdateInput(
|
|
|
|
|
this.locator._inputFieldByName("Authorization URL"),
|
2023-06-15 13:21:11 +00:00
|
|
|
this.hp.OAuth_AuthUrl,
|
2023-03-10 11:39:06 +00:00
|
|
|
);
|
|
|
|
|
}
|
2023-03-16 18:28:32 +00:00
|
|
|
|
|
|
|
|
public AddSuggesstedWidget(widget: Widgets) {
|
|
|
|
|
switch (widget) {
|
|
|
|
|
case Widgets.Dropdown:
|
|
|
|
|
this.agHelper.GetNClick(this._suggestedWidget("SELECT_WIDGET"));
|
|
|
|
|
this.agHelper.AssertElementVisible(
|
|
|
|
|
this.locator._widgetInCanvas(WIDGET.SELECT),
|
|
|
|
|
);
|
|
|
|
|
break;
|
|
|
|
|
case Widgets.Table:
|
|
|
|
|
this.agHelper.GetNClick(this._suggestedWidget("TABLE_WIDGET_V2"));
|
|
|
|
|
this.agHelper.AssertElementVisible(
|
|
|
|
|
this.locator._widgetInCanvas(WIDGET.TABLE),
|
|
|
|
|
);
|
|
|
|
|
break;
|
|
|
|
|
case Widgets.Chart:
|
|
|
|
|
this.agHelper.GetNClick(this._suggestedWidget("CHART_WIDGET"));
|
|
|
|
|
this.agHelper.AssertElementVisible(
|
|
|
|
|
this.locator._widgetInCanvas(WIDGET.CHART),
|
|
|
|
|
);
|
|
|
|
|
break;
|
|
|
|
|
case Widgets.Text:
|
|
|
|
|
this.agHelper.GetNClick(this._suggestedWidget("TEXT_WIDGET"));
|
|
|
|
|
this.agHelper.AssertElementVisible(
|
|
|
|
|
this.locator._widgetInCanvas(WIDGET.TEXT),
|
|
|
|
|
);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-06-14 06:46:09 +00:00
|
|
|
|
|
|
|
|
public EnterJSContext({
|
|
|
|
|
fieldLabel,
|
|
|
|
|
fieldProperty,
|
|
|
|
|
fieldValue,
|
|
|
|
|
}: {
|
|
|
|
|
fieldProperty: string;
|
|
|
|
|
fieldValue: string;
|
|
|
|
|
fieldLabel: string;
|
|
|
|
|
}) {
|
2023-06-15 13:21:11 +00:00
|
|
|
this.agHelper.Sleep();
|
|
|
|
|
this.agHelper
|
|
|
|
|
.GetElement(this._getJSONswitchLocator(fieldProperty))
|
|
|
|
|
.invoke("attr", "data-selected")
|
|
|
|
|
.then(($state: any) => {
|
|
|
|
|
if (!$state.includes("true"))
|
|
|
|
|
this.agHelper.GetNClick(
|
|
|
|
|
this._getJSONswitchLocator(fieldProperty),
|
|
|
|
|
0,
|
|
|
|
|
true,
|
|
|
|
|
);
|
|
|
|
|
else this.agHelper.Sleep(200);
|
|
|
|
|
});
|
2023-06-14 06:46:09 +00:00
|
|
|
this.agHelper.EnterValue(fieldValue, {
|
|
|
|
|
propFieldName: "",
|
|
|
|
|
directInput: false,
|
|
|
|
|
inputFieldName: fieldLabel,
|
|
|
|
|
});
|
|
|
|
|
}
|
2022-05-18 10:39:42 +00:00
|
|
|
}
|