From d727d66c175a911b467b73803f3767e0943da7da Mon Sep 17 00:00:00 2001 From: Aishwarya-U-R <91450662+Aishwarya-U-R@users.noreply.github.com> Date: Thu, 14 Jul 2022 08:33:48 +0530 Subject: [PATCH] test: Automated tests for Postgres Datatype - Array type (#15164) * Postgres Array DT scripted * Array spec updates * Arrayspec fix --- app/client/cypress/fixtures/ArrayDTdsl.json | 1220 +++++++++++++++++ .../ServerSideTests/DataTypes/Array_Spec.ts | 697 ++++++++++ .../GenerateCRUD/MySQL_Spec.ts | 2 +- .../GenerateCRUD/Postgres_Spec.ts | 2 +- .../ServerSideTests/QueryPane/Mongo_Spec.ts | 2 +- 5 files changed, 1920 insertions(+), 3 deletions(-) create mode 100644 app/client/cypress/fixtures/ArrayDTdsl.json create mode 100644 app/client/cypress/integration/Smoke_TestSuite/ServerSideTests/DataTypes/Array_Spec.ts diff --git a/app/client/cypress/fixtures/ArrayDTdsl.json b/app/client/cypress/fixtures/ArrayDTdsl.json new file mode 100644 index 0000000000..111e34bebb --- /dev/null +++ b/app/client/cypress/fixtures/ArrayDTdsl.json @@ -0,0 +1,1220 @@ +{ + "dsl": { + "widgetName": "MainContainer", + "backgroundColor": "none", + "rightColumn": 4896, + "snapColumns": 64, + "detachFromLayout": true, + "widgetId": "0", + "topRow": 0, + "bottomRow": 1320, + "containerStyle": "none", + "snapRows": 125, + "parentRowSpace": 1, + "type": "CANVAS_WIDGET", + "canExtend": true, + "version": 59, + "minHeight": 1292, + "dynamicTriggerPathList": [], + "parentColumnSpace": 1, + "dynamicBindingPathList": [], + "leftColumn": 0, + "children": [ + { + "boxShadow": "none", + "widgetName": "UpdateModal", + "isCanvas": true, + "displayName": "Modal", + "iconSVG": "/static/media/icon.4975978e.svg", + "topRow": 51, + "bottomRow": 75, + "parentRowSpace": 10, + "type": "MODAL_WIDGET", + "hideCard": false, + "shouldScrollContents": true, + "animateLoading": true, + "parentColumnSpace": 16.71875, + "dynamicTriggerPathList": [], + "leftColumn": 20, + "dynamicBindingPathList": [ + { + "key": "borderRadius" + } + ], + "children": [ + { + "boxShadow": "none", + "widgetName": "Canvas1Copy", + "displayName": "Canvas", + "topRow": 0, + "bottomRow": 470, + "parentRowSpace": 1, + "type": "CANVAS_WIDGET", + "canExtend": true, + "hideCard": true, + "shouldScrollContents": false, + "minHeight": 478, + "parentColumnSpace": 1, + "dynamicTriggerPathList": [], + "leftColumn": 0, + "dynamicBindingPathList": [ + { + "key": "borderRadius" + }, + { + "key": "accentColor" + } + ], + "children": [ + { + "boxShadow": "none", + "widgetName": "Updatename", + "displayName": "Input", + "iconSVG": "/static/media/icon.9f505595da61a34f563dba82adeb06ec.svg", + "searchTags": [ + "form", + "text input", + "number", + "textarea" + ], + "topRow": 8, + "bottomRow": 16, + "parentRowSpace": 10, + "labelWidth": 5, + "autoFocus": false, + "type": "INPUT_WIDGET_V2", + "hideCard": false, + "animateLoading": true, + "parentColumnSpace": 6.875, + "dynamicTriggerPathList": [], + "resetOnSubmit": true, + "leftColumn": 3, + "dynamicBindingPathList": [ + { + "key": "accentColor" + }, + { + "key": "borderRadius" + }, + { + "key": "defaultText" + }, + { + "key": "label" + } + ], + "labelPosition": "Top", + "labelStyle": "BOLD", + "labelTextColor": "#ef4444", + "inputType": "TEXT", + "isDisabled": false, + "key": "kmv6jiyxge", + "labelTextSize": "1.25rem", + "isRequired": false, + "isDeprecated": false, + "rightColumn": 61, + "widgetId": "en4wdvqg5p", + "accentColor": "{{appsmith.theme.colors.primaryColor}}", + "isVisible": true, + "label": "{{Table1.columnOrder[1].toString().charAt(0).toUpperCase() + Table1.columnOrder[1].toString().slice(1)}}", + "version": 2, + "parentId": "sdc2iv8uiq", + "labelAlignment": "left", + "renderMode": "CANVAS", + "isLoading": false, + "borderRadius": "{{appsmith.theme.borderRadius.appBorderRadius}}", + "iconAlign": "left", + "defaultText": "{{Table1.selectedRow.name}}" + }, + { + "boxShadow": "none", + "widgetName": "Updatepaybyquarter", + "displayName": "Input", + "iconSVG": "/static/media/icon.9f505595da61a34f563dba82adeb06ec.svg", + "searchTags": [ + "form", + "text input", + "number", + "textarea" + ], + "topRow": 18, + "bottomRow": 26, + "parentRowSpace": 10, + "labelWidth": 5, + "autoFocus": false, + "type": "INPUT_WIDGET_V2", + "hideCard": false, + "animateLoading": true, + "parentColumnSpace": 6.875, + "dynamicTriggerPathList": [], + "resetOnSubmit": true, + "leftColumn": 3, + "dynamicBindingPathList": [ + { + "key": "accentColor" + }, + { + "key": "borderRadius" + }, + { + "key": "defaultText" + }, + { + "key": "label" + } + ], + "labelPosition": "Top", + "labelStyle": "BOLD", + "labelTextColor": "#ef4444", + "inputType": "TEXT", + "isDisabled": false, + "key": "kmv6jiyxge", + "labelTextSize": "1.25rem", + "isRequired": false, + "isDeprecated": false, + "rightColumn": 61, + "widgetId": "d76ro6gj4f", + "accentColor": "{{appsmith.theme.colors.primaryColor}}", + "isVisible": true, + "label": "{{Table1.columnOrder[2].toString().charAt(0).toUpperCase() + Table1.columnOrder[2].toString().slice(1)}}", + "version": 2, + "parentId": "sdc2iv8uiq", + "labelAlignment": "left", + "renderMode": "CANVAS", + "isLoading": false, + "borderRadius": "{{appsmith.theme.borderRadius.appBorderRadius}}", + "iconAlign": "left", + "defaultText": "{{Table1.selectedRow.pay_by_quarter.toString()}}" + }, + { + "boxShadow": "none", + "widgetName": "Updateschedule", + "displayName": "Input", + "iconSVG": "/static/media/icon.9f505595da61a34f563dba82adeb06ec.svg", + "searchTags": [ + "form", + "text input", + "number", + "textarea" + ], + "topRow": 29, + "bottomRow": 37, + "parentRowSpace": 10, + "labelWidth": 5, + "autoFocus": false, + "type": "INPUT_WIDGET_V2", + "hideCard": false, + "animateLoading": true, + "parentColumnSpace": 6.875, + "dynamicTriggerPathList": [], + "resetOnSubmit": true, + "leftColumn": 3, + "dynamicBindingPathList": [ + { + "key": "accentColor" + }, + { + "key": "borderRadius" + }, + { + "key": "defaultText" + }, + { + "key": "label" + } + ], + "labelPosition": "Top", + "labelStyle": "BOLD", + "labelTextColor": "#ef4444", + "inputType": "TEXT", + "isDisabled": false, + "key": "kmv6jiyxge", + "labelTextSize": "1.25rem", + "isRequired": false, + "isDeprecated": false, + "rightColumn": 61, + "widgetId": "nw6zaman8m", + "accentColor": "{{appsmith.theme.colors.primaryColor}}", + "isVisible": true, + "label": "{{Table1.columnOrder[3].toString().charAt(0).toUpperCase() + Table1.columnOrder[3].toString().slice(1)}}", + "version": 2, + "parentId": "sdc2iv8uiq", + "labelAlignment": "left", + "renderMode": "CANVAS", + "isLoading": false, + "borderRadius": "{{appsmith.theme.borderRadius.appBorderRadius}}", + "iconAlign": "left", + "defaultText": "{{Table1.selectedRow.schedule.toString()}}" + }, + { + "boxShadow": "none", + "widgetName": "IconButton1Copy", + "onClick": "{{closeModal('UpdateModal')}}", + "buttonColor": "{{appsmith.theme.colors.primaryColor}}", + "displayName": "Icon Button", + "iconSVG": "/static/media/icon.1a0c634a.svg", + "topRow": 1, + "bottomRow": 5, + "type": "ICON_BUTTON_WIDGET", + "hideCard": false, + "animateLoading": true, + "dynamicTriggerPathList": [ + { + "key": "onClick" + } + ], + "leftColumn": 56, + "dynamicBindingPathList": [ + { + "key": "buttonColor" + }, + { + "key": "borderRadius" + } + ], + "iconSize": 24, + "isDisabled": false, + "key": "glch1esz5b", + "isDeprecated": false, + "rightColumn": 64, + "iconName": "cross", + "widgetId": "4fnws5ftg4", + "isVisible": true, + "version": 1, + "parentId": "sdc2iv8uiq", + "renderMode": "CANVAS", + "isLoading": false, + "borderRadius": "{{appsmith.theme.borderRadius.appBorderRadius}}", + "buttonVariant": "TERTIARY" + }, + { + "widgetName": "Text1Copy", + "displayName": "Text", + "iconSVG": "/static/media/icon.97c59b52.svg", + "topRow": 1, + "bottomRow": 5, + "type": "TEXT_WIDGET", + "hideCard": false, + "animateLoading": true, + "overflow": "NONE", + "fontFamily": "{{appsmith.theme.fontFamily.appFont}}", + "dynamicTriggerPathList": [], + "leftColumn": 1, + "dynamicBindingPathList": [ + { + "key": "fontFamily" + }, + { + "key": "borderRadius" + }, + { + "key": "text" + } + ], + "shouldTruncate": false, + "truncateButtonColor": "#FFC13D", + "text": "Update Data for SerialId # {{Table1.selectedRow.serialid}}", + "key": "orwoe8agwc", + "isDeprecated": false, + "rightColumn": 55, + "textAlign": "LEFT", + "widgetId": "3rncsabmka", + "isVisible": true, + "fontStyle": "BOLD", + "textColor": "#231F20", + "version": 1, + "parentId": "sdc2iv8uiq", + "renderMode": "CANVAS", + "isLoading": false, + "borderRadius": "{{appsmith.theme.borderRadius.appBorderRadius}}", + "fontSize": "1.5rem" + }, + { + "boxShadow": "none", + "widgetName": "runUpdateQuery", + "onClick": "{{updateRecord.run(() => {closeModal('UpdateModal'), () => {};selectRecords.run() })}}", + "buttonColor": "{{appsmith.theme.colors.primaryColor}}", + "dynamicPropertyPathList": [ + { + "key": "onClick" + } + ], + "displayName": "Button", + "iconSVG": "/static/media/icon.cca026338f1c8eb6df8ba03d084c2fca.svg", + "searchTags": [ + "click", + "submit" + ], + "topRow": 40, + "bottomRow": 44, + "parentRowSpace": 10, + "type": "BUTTON_WIDGET", + "hideCard": false, + "animateLoading": true, + "parentColumnSpace": 6.78125, + "dynamicTriggerPathList": [ + { + "key": "onClick" + } + ], + "leftColumn": 24, + "dynamicBindingPathList": [ + { + "key": "buttonColor" + }, + { + "key": "borderRadius" + } + ], + "text": "Update", + "isDisabled": false, + "key": "vx6ui4hudn", + "isDeprecated": false, + "rightColumn": 40, + "isDefaultClickDisabled": true, + "widgetId": "y0mz1fsilt", + "isVisible": true, + "recaptchaType": "V3", + "version": 1, + "parentId": "sdc2iv8uiq", + "renderMode": "CANVAS", + "isLoading": false, + "borderRadius": "{{appsmith.theme.borderRadius.appBorderRadius}}", + "buttonVariant": "PRIMARY", + "placement": "CENTER" + } + ], + "isDisabled": false, + "key": "jcn9nfbcoh", + "isDeprecated": false, + "rightColumn": 401.25, + "detachFromLayout": true, + "widgetId": "sdc2iv8uiq", + "accentColor": "{{appsmith.theme.colors.primaryColor}}", + "isVisible": true, + "version": 1, + "parentId": "bl75l6vmtq", + "renderMode": "CANVAS", + "isLoading": false, + "borderRadius": "{{appsmith.theme.borderRadius.appBorderRadius}}" + } + ], + "key": "n6csxgy8za", + "height": 478, + "isDeprecated": false, + "rightColumn": 44, + "backgroundColor": "#bbf7d0", + "detachFromLayout": true, + "widgetId": "bl75l6vmtq", + "canOutsideClickClose": true, + "canEscapeKeyClose": true, + "version": 2, + "parentId": "0", + "renderMode": "CANVAS", + "isLoading": false, + "borderRadius": "{{appsmith.theme.borderRadius.appBorderRadius}}", + "width": 446 + }, + { + "boxShadow": "{{appsmith.theme.boxShadow.appBoxShadow}}", + "isVisibleDownload": true, + "iconSVG": "/static/media/icon.db8a9cbd.svg", + "topRow": 7, + "isSortable": true, + "type": "TABLE_WIDGET", + "animateLoading": true, + "dynamicBindingPathList": [ + { + "key": "accentColor" + }, + { + "key": "borderRadius" + }, + { + "key": "boxShadow" + }, + { + "key": "childStylesheet.button.buttonColor" + }, + { + "key": "childStylesheet.button.borderRadius" + }, + { + "key": "childStylesheet.menuButton.menuColor" + }, + { + "key": "childStylesheet.menuButton.borderRadius" + }, + { + "key": "childStylesheet.iconButton.buttonColor" + }, + { + "key": "childStylesheet.iconButton.borderRadius" + }, + { + "key": "tableData" + }, + { + "key": "derivedColumns.customColumn1.buttonColor" + }, + { + "key": "primaryColumns.customColumn1.buttonColor" + }, + { + "key": "derivedColumns.customColumn1.borderRadius" + }, + { + "key": "primaryColumns.customColumn1.borderRadius" + }, + { + "key": "derivedColumns.customColumn1.boxShadow" + }, + { + "key": "primaryColumns.customColumn1.boxShadow" + }, + { + "key": "derivedColumns.customColumn1.buttonLabel" + }, + { + "key": "primaryColumns.customColumn1.buttonLabel" + }, + { + "key": "primaryColumns.name.computedValue" + }, + { + "key": "primaryColumns.pay_by_quarter.computedValue" + }, + { + "key": "primaryColumns.schedule.computedValue" + }, + { + "key": "primaryColumns.serialid.computedValue" + } + ], + "leftColumn": 4, + "delimiter": ",", + "accentColor": "{{appsmith.theme.colors.primaryColor}}", + "isVisibleFilters": true, + "isVisible": true, + "enableClientSideSearch": true, + "version": 3, + "totalRecordsCount": 0, + "isLoading": false, + "childStylesheet": { + "button": { + "buttonColor": "{{appsmith.theme.colors.primaryColor}}", + "borderRadius": "{{appsmith.theme.borderRadius.appBorderRadius}}", + "boxShadow": "none" + }, + "menuButton": { + "menuColor": "{{appsmith.theme.colors.primaryColor}}", + "borderRadius": "{{appsmith.theme.borderRadius.appBorderRadius}}", + "boxShadow": "none" + }, + "iconButton": { + "buttonColor": "{{appsmith.theme.colors.primaryColor}}", + "borderRadius": "{{appsmith.theme.borderRadius.appBorderRadius}}", + "boxShadow": "none" + } + }, + "borderRadius": "{{appsmith.theme.borderRadius.appBorderRadius}}", + "primaryColumnId": "serialid", + "columnSizeMap": { + "task": 245, + "step": 62, + "status": 75, + "serialid": 81, + "bigintid": 309, + "demimalid": 378, + "decimalid": 259, + "numericid": 270, + "info": 448, + "id": 60, + "details": 679, + "schedule": 296, + "pay_by_quarter": 197 + }, + "widgetName": "Table1", + "defaultPageSize": 0, + "columnOrder": [ + "serialid", + "name", + "pay_by_quarter", + "schedule", + "customColumn1" + ], + "dynamicPropertyPathList": [], + "displayName": "Table", + "bottomRow": 57, + "parentRowSpace": 10, + "defaultSelectedRow": "0", + "hideCard": false, + "parentColumnSpace": 16.71875, + "dynamicTriggerPathList": [ + { + "key": "primaryColumns.customColumn1.onClick" + } + ], + "primaryColumns": { + "customColumn1": { + "index": 4, + "width": 150, + "id": "customColumn1", + "columnType": "button", + "enableFilter": true, + "enableSort": true, + "isVisible": true, + "isDisabled": false, + "isCellVisible": true, + "isDerived": true, + "label": "delete", + "computedValue": "", + "buttonStyle": "rgb(3, 179, 101)", + "labelColor": "#FFFFFF", + "buttonColor": "{{Table1.sanitizedTableData.map((currentRow) => ( appsmith.theme.colors.primaryColor))}}", + "borderRadius": "{{Table1.sanitizedTableData.map((currentRow) => ( appsmith.theme.borderRadius.appBorderRadius))}}", + "boxShadow": "{{Table1.sanitizedTableData.map((currentRow) => ( 'none'))}}", + "iconName": "", + "buttonLabel": "{{Table1.sanitizedTableData.map((currentRow) => ( 'DeleteQuery'))}}", + "onClick": "{{deleteRecord.run(() => selectRecords.run(), () => {})}}" + }, + "name": { + "index": 0, + "width": 150, + "id": "name", + "horizontalAlignment": "LEFT", + "verticalAlignment": "CENTER", + "columnType": "text", + "textColor": "", + "textSize": "0.875rem", + "enableFilter": true, + "enableSort": true, + "isVisible": true, + "isDisabled": false, + "isCellVisible": true, + "isDerived": false, + "label": "name", + "computedValue": "{{Table1.sanitizedTableData.map((currentRow) => ( currentRow.name))}}", + "cellBackground": "" + }, + "pay_by_quarter": { + "index": 1, + "width": 150, + "id": "pay_by_quarter", + "horizontalAlignment": "LEFT", + "verticalAlignment": "CENTER", + "columnType": "text", + "textColor": "", + "textSize": "0.875rem", + "enableFilter": true, + "enableSort": true, + "isVisible": true, + "isDisabled": false, + "isCellVisible": true, + "isDerived": false, + "label": "pay_by_quarter", + "computedValue": "{{Table1.sanitizedTableData.map((currentRow) => ( currentRow.pay_by_quarter))}}", + "cellBackground": "" + }, + "schedule": { + "index": 2, + "width": 150, + "id": "schedule", + "horizontalAlignment": "LEFT", + "verticalAlignment": "CENTER", + "columnType": "text", + "textColor": "", + "textSize": "0.875rem", + "enableFilter": true, + "enableSort": true, + "isVisible": true, + "isDisabled": false, + "isCellVisible": true, + "isDerived": false, + "label": "schedule", + "computedValue": "{{Table1.sanitizedTableData.map((currentRow) => ( currentRow.schedule))}}", + "cellBackground": "" + }, + "serialid": { + "index": 0, + "width": 150, + "id": "serialid", + "horizontalAlignment": "LEFT", + "verticalAlignment": "CENTER", + "columnType": "text", + "textColor": "", + "textSize": "0.875rem", + "enableFilter": true, + "enableSort": true, + "isVisible": true, + "isDisabled": false, + "isCellVisible": true, + "isDerived": false, + "label": "serialid", + "computedValue": "{{Table1.sanitizedTableData.map((currentRow) => ( currentRow.serialid))}}", + "cellBackground": "" + } + }, + "key": "8l8hit8gra", + "derivedColumns": { + "customColumn1": { + "index": 4, + "width": 150, + "id": "customColumn1", + "columnType": "button", + "enableFilter": true, + "enableSort": true, + "isVisible": true, + "isDisabled": false, + "isCellVisible": true, + "isDerived": true, + "label": "delete", + "computedValue": "", + "buttonStyle": "rgb(3, 179, 101)", + "labelColor": "#FFFFFF", + "buttonColor": "{{Table1.sanitizedTableData.map((currentRow) => ( appsmith.theme.colors.primaryColor))}}", + "borderRadius": "{{Table1.sanitizedTableData.map((currentRow) => ( appsmith.theme.borderRadius.appBorderRadius))}}", + "boxShadow": "{{Table1.sanitizedTableData.map((currentRow) => ( 'none'))}}", + "iconName": "", + "buttonLabel": "{{Table1.sanitizedTableData.map((currentRow) => ( 'DeleteQuery'))}}" + } + }, + "isDeprecated": false, + "rightColumn": 60, + "textSize": "0.875rem", + "widgetId": "w9mvbp1g2t", + "tableData": "{{selectRecords.data}}", + "label": "Data", + "searchKey": "", + "parentId": "0", + "renderMode": "CANVAS", + "horizontalAlignment": "LEFT", + "isVisibleSearch": true, + "isVisiblePagination": true, + "verticalAlignment": "CENTER" + }, + { + "boxShadow": "none", + "widgetName": "InsertButton", + "onClick": "{{showModal('InsertModal')}}", + "buttonColor": "{{appsmith.theme.colors.primaryColor}}", + "dynamicPropertyPathList": [ + { + "key": "onClick" + } + ], + "displayName": "Button", + "iconSVG": "/static/media/icon.cca02633.svg", + "topRow": 2, + "bottomRow": 6, + "parentRowSpace": 10, + "type": "BUTTON_WIDGET", + "hideCard": false, + "animateLoading": true, + "parentColumnSpace": 16.71875, + "dynamicTriggerPathList": [ + { + "key": "onClick" + } + ], + "leftColumn": 4, + "dynamicBindingPathList": [ + { + "key": "buttonColor" + }, + { + "key": "borderRadius" + } + ], + "text": "Run InsertQuery", + "isDisabled": false, + "key": "7va5q4amde", + "isDeprecated": false, + "rightColumn": 20, + "isDefaultClickDisabled": true, + "widgetId": "jr1y6sdur4", + "isVisible": true, + "recaptchaType": "V3", + "version": 1, + "parentId": "0", + "renderMode": "CANVAS", + "isLoading": false, + "borderRadius": "{{appsmith.theme.borderRadius.appBorderRadius}}", + "buttonVariant": "PRIMARY", + "placement": "CENTER" + }, + { + "boxShadow": "none", + "widgetName": "UpdateButton", + "onClick": "{{showModal('UpdateModal')}}", + "buttonColor": "{{appsmith.theme.colors.primaryColor}}", + "dynamicPropertyPathList": [], + "displayName": "Button", + "iconSVG": "/static/media/icon.cca02633.svg", + "topRow": 2, + "bottomRow": 6, + "parentRowSpace": 10, + "type": "BUTTON_WIDGET", + "hideCard": false, + "animateLoading": true, + "parentColumnSpace": 16.71875, + "dynamicTriggerPathList": [ + { + "key": "onClick" + } + ], + "leftColumn": 44, + "dynamicBindingPathList": [ + { + "key": "buttonColor" + }, + { + "key": "borderRadius" + } + ], + "text": "Run UpdateQuery", + "isDisabled": false, + "key": "7va5q4amde", + "isDeprecated": false, + "rightColumn": 60, + "isDefaultClickDisabled": true, + "widgetId": "3k4fg1zx8x", + "isVisible": true, + "recaptchaType": "V3", + "version": 1, + "parentId": "0", + "renderMode": "CANVAS", + "isLoading": false, + "borderRadius": "{{appsmith.theme.borderRadius.appBorderRadius}}", + "buttonVariant": "PRIMARY", + "placement": "CENTER" + }, + { + "boxShadow": "none", + "widgetName": "InsertModal", + "isCanvas": true, + "displayName": "Modal", + "iconSVG": "/static/media/icon.4975978e.svg", + "topRow": 22, + "bottomRow": 46, + "parentRowSpace": 10, + "type": "MODAL_WIDGET", + "hideCard": false, + "shouldScrollContents": true, + "animateLoading": true, + "parentColumnSpace": 16.71875, + "dynamicTriggerPathList": [], + "leftColumn": 20, + "dynamicBindingPathList": [ + { + "key": "borderRadius" + } + ], + "children": [ + { + "boxShadow": "none", + "widgetName": "Canvas1", + "displayName": "Canvas", + "topRow": 0, + "bottomRow": 430, + "parentRowSpace": 1, + "type": "CANVAS_WIDGET", + "canExtend": true, + "hideCard": true, + "shouldScrollContents": false, + "minHeight": 430, + "parentColumnSpace": 1, + "dynamicTriggerPathList": [], + "leftColumn": 0, + "dynamicBindingPathList": [ + { + "key": "borderRadius" + }, + { + "key": "accentColor" + } + ], + "children": [ + { + "boxShadow": "none", + "widgetName": "Insertschedule", + "displayName": "Input", + "iconSVG": "/static/media/icon.9f505595da61a34f563dba82adeb06ec.svg", + "searchTags": [ + "form", + "text input", + "number", + "textarea" + ], + "topRow": 25, + "bottomRow": 33, + "parentRowSpace": 10, + "labelWidth": 5, + "autoFocus": false, + "type": "INPUT_WIDGET_V2", + "hideCard": false, + "animateLoading": true, + "parentColumnSpace": 6.875, + "dynamicTriggerPathList": [], + "resetOnSubmit": true, + "leftColumn": 3, + "dynamicBindingPathList": [ + { + "key": "accentColor" + }, + { + "key": "borderRadius" + }, + { + "key": "label" + } + ], + "labelPosition": "Top", + "labelStyle": "BOLD", + "labelTextColor": "#a855f7", + "inputType": "TEXT", + "placeholderText": "Give 2D array values in pairs", + "isDisabled": false, + "key": "kmv6jiyxge", + "labelTextSize": "1.25rem", + "isRequired": false, + "isDeprecated": false, + "rightColumn": 61, + "widgetId": "652em4vx0a", + "accentColor": "{{appsmith.theme.colors.primaryColor}}", + "isVisible": true, + "label": "{{Table1.columnOrder[3].toString().charAt(0).toUpperCase() + Table1.columnOrder[3].toString().slice(1)}}", + "version": 2, + "parentId": "6otxv391ns", + "labelAlignment": "left", + "renderMode": "CANVAS", + "isLoading": false, + "borderRadius": "{{appsmith.theme.borderRadius.appBorderRadius}}", + "iconAlign": "left", + "defaultText": "" + }, + { + "boxShadow": "none", + "widgetName": "Insertpaybyquarter", + "displayName": "Input", + "iconSVG": "/static/media/icon.9f505595da61a34f563dba82adeb06ec.svg", + "searchTags": [ + "form", + "text input", + "number", + "textarea" + ], + "topRow": 16, + "bottomRow": 24, + "parentRowSpace": 10, + "labelWidth": 5, + "autoFocus": false, + "type": "INPUT_WIDGET_V2", + "hideCard": false, + "animateLoading": true, + "parentColumnSpace": 6.875, + "dynamicTriggerPathList": [], + "resetOnSubmit": true, + "leftColumn": 3, + "dynamicBindingPathList": [ + { + "key": "accentColor" + }, + { + "key": "borderRadius" + }, + { + "key": "label" + } + ], + "labelPosition": "Top", + "labelStyle": "BOLD", + "labelTextColor": "#a855f7", + "inputType": "TEXT", + "placeholderText": "Give 1D array values", + "isDisabled": false, + "key": "kmv6jiyxge", + "labelTextSize": "1.25rem", + "isRequired": false, + "isDeprecated": false, + "rightColumn": 61, + "widgetId": "k968xa75wv", + "accentColor": "{{appsmith.theme.colors.primaryColor}}", + "isVisible": true, + "label": "{{Table1.columnOrder[2].toString().charAt(0).toUpperCase() + Table1.columnOrder[2].toString().slice(1)}}", + "version": 2, + "parentId": "6otxv391ns", + "labelAlignment": "left", + "renderMode": "CANVAS", + "isLoading": false, + "borderRadius": "{{appsmith.theme.borderRadius.appBorderRadius}}", + "iconAlign": "left", + "defaultText": "" + }, + { + "boxShadow": "none", + "widgetName": "IconButton1", + "onClick": "{{closeModal('InsertModal')}}", + "buttonColor": "{{appsmith.theme.colors.primaryColor}}", + "displayName": "Icon Button", + "iconSVG": "/static/media/icon.1a0c634a.svg", + "topRow": 1, + "bottomRow": 5, + "type": "ICON_BUTTON_WIDGET", + "hideCard": false, + "animateLoading": true, + "leftColumn": 54, + "dynamicBindingPathList": [ + { + "key": "buttonColor" + }, + { + "key": "borderRadius" + } + ], + "iconSize": 24, + "isDisabled": false, + "key": "glch1esz5b", + "isDeprecated": false, + "rightColumn": 62, + "iconName": "cross", + "widgetId": "jqcrr1o8or", + "isVisible": true, + "version": 1, + "parentId": "6otxv391ns", + "renderMode": "CANVAS", + "isLoading": false, + "borderRadius": "{{appsmith.theme.borderRadius.appBorderRadius}}", + "buttonVariant": "TERTIARY" + }, + { + "widgetName": "Text1", + "displayName": "Text", + "iconSVG": "/static/media/icon.97c59b52.svg", + "topRow": 1, + "bottomRow": 5, + "type": "TEXT_WIDGET", + "hideCard": false, + "animateLoading": true, + "overflow": "NONE", + "fontFamily": "{{appsmith.theme.fontFamily.appFont}}", + "dynamicTriggerPathList": [], + "leftColumn": 1, + "dynamicBindingPathList": [ + { + "key": "fontFamily" + }, + { + "key": "borderRadius" + } + ], + "shouldTruncate": false, + "truncateButtonColor": "#FFC13D", + "text": "Insert Record", + "key": "orwoe8agwc", + "isDeprecated": false, + "rightColumn": 41, + "textAlign": "LEFT", + "widgetId": "achn17gfze", + "isVisible": true, + "fontStyle": "BOLD", + "textColor": "#231F20", + "version": 1, + "parentId": "6otxv391ns", + "renderMode": "CANVAS", + "isLoading": false, + "borderRadius": "{{appsmith.theme.borderRadius.appBorderRadius}}", + "fontSize": "1.5rem" + }, + { + "boxShadow": "none", + "widgetName": "Insertname", + "displayName": "Input", + "iconSVG": "/static/media/icon.9f505595da61a34f563dba82adeb06ec.svg", + "searchTags": [ + "form", + "text input", + "number", + "textarea" + ], + "topRow": 7, + "bottomRow": 15, + "parentRowSpace": 10, + "labelWidth": 5, + "autoFocus": false, + "type": "INPUT_WIDGET_V2", + "hideCard": false, + "animateLoading": true, + "parentColumnSpace": 6.875, + "dynamicTriggerPathList": [], + "resetOnSubmit": true, + "leftColumn": 3, + "dynamicBindingPathList": [ + { + "key": "accentColor" + }, + { + "key": "borderRadius" + }, + { + "key": "label" + }, + { + "key": "placeholderText" + } + ], + "labelPosition": "Top", + "labelStyle": "BOLD", + "labelTextColor": "#a855f7", + "inputType": "TEXT", + "placeholderText": "{{Table1.selectedRow.name}}", + "isDisabled": false, + "key": "kmv6jiyxge", + "labelTextSize": "1.25rem", + "isRequired": false, + "isDeprecated": false, + "rightColumn": 61, + "widgetId": "nyzerfj1xc", + "accentColor": "{{appsmith.theme.colors.primaryColor}}", + "isVisible": true, + "label": "{{Table1.columnOrder[1].toString().charAt(0).toUpperCase() + Table1.columnOrder[1].toString().slice(1)}}", + "version": 2, + "parentId": "6otxv391ns", + "labelAlignment": "left", + "renderMode": "CANVAS", + "isLoading": false, + "borderRadius": "{{appsmith.theme.borderRadius.appBorderRadius}}", + "iconAlign": "left", + "defaultText": "" + }, + { + "boxShadow": "none", + "widgetName": "runInsertQuery", + "onClick": "{{insertRecord.run(() => {selectRecords.run();resetWidget('InsertModal', true);closeModal('InsertModal'), () => {};})}}", + "buttonColor": "{{appsmith.theme.colors.primaryColor}}", + "dynamicPropertyPathList": [ + { + "key": "onClick" + } + ], + "displayName": "Button", + "iconSVG": "/static/media/icon.cca026338f1c8eb6df8ba03d084c2fca.svg", + "searchTags": [ + "click", + "submit" + ], + "topRow": 36, + "bottomRow": 40, + "parentRowSpace": 10, + "type": "BUTTON_WIDGET", + "hideCard": false, + "animateLoading": true, + "parentColumnSpace": 6.5, + "dynamicTriggerPathList": [ + { + "key": "onClick" + } + ], + "leftColumn": 22, + "dynamicBindingPathList": [ + { + "key": "buttonColor" + }, + { + "key": "borderRadius" + } + ], + "text": "Insert", + "isDisabled": false, + "key": "vx6ui4hudn", + "isDeprecated": false, + "rightColumn": 38, + "isDefaultClickDisabled": true, + "widgetId": "4l11iasf7j", + "isVisible": true, + "recaptchaType": "V3", + "version": 1, + "parentId": "6otxv391ns", + "renderMode": "CANVAS", + "isLoading": false, + "borderRadius": "{{appsmith.theme.borderRadius.appBorderRadius}}", + "buttonVariant": "PRIMARY", + "placement": "CENTER" + } + ], + "isDisabled": false, + "key": "jcn9nfbcoh", + "isDeprecated": false, + "rightColumn": 401.25, + "detachFromLayout": true, + "widgetId": "6otxv391ns", + "accentColor": "{{appsmith.theme.colors.primaryColor}}", + "isVisible": true, + "version": 1, + "parentId": "rhom101hjk", + "renderMode": "CANVAS", + "isLoading": false, + "borderRadius": "{{appsmith.theme.borderRadius.appBorderRadius}}" + } + ], + "key": "n6csxgy8za", + "height": 430, + "isDeprecated": false, + "rightColumn": 44, + "backgroundColor": "#fef9c3", + "detachFromLayout": true, + "widgetId": "rhom101hjk", + "canOutsideClickClose": true, + "canEscapeKeyClose": true, + "version": 2, + "parentId": "0", + "renderMode": "CANVAS", + "isLoading": false, + "borderRadius": "{{appsmith.theme.borderRadius.appBorderRadius}}", + "width": 428 + }, + { + "boxShadow": "none", + "widgetName": "IconButton2", + "onClick": "{{deleteAllRecords.run(() => selectRecords.run(), () => {})}}", + "buttonColor": "{{appsmith.theme.colors.primaryColor}}", + "displayName": "Icon Button", + "iconSVG": "/static/media/icon.1a0c634a.svg", + "topRow": 2, + "bottomRow": 6, + "parentRowSpace": 10, + "type": "ICON_BUTTON_WIDGET", + "hideCard": false, + "animateLoading": true, + "parentColumnSpace": 16.71875, + "dynamicTriggerPathList": [ + { + "key": "onClick" + } + ], + "leftColumn": 30, + "dynamicBindingPathList": [ + { + "key": "buttonColor" + }, + { + "key": "borderRadius" + } + ], + "isDisabled": false, + "key": "8he4nv2fbs", + "isDeprecated": false, + "rightColumn": 34, + "iconName": "delete", + "widgetId": "30jhk2thdb", + "isVisible": true, + "version": 1, + "parentId": "0", + "renderMode": "CANVAS", + "isLoading": false, + "borderRadius": "{{appsmith.theme.borderRadius.appBorderRadius}}", + "buttonVariant": "PRIMARY" + } + ] + } +} diff --git a/app/client/cypress/integration/Smoke_TestSuite/ServerSideTests/DataTypes/Array_Spec.ts b/app/client/cypress/integration/Smoke_TestSuite/ServerSideTests/DataTypes/Array_Spec.ts new file mode 100644 index 0000000000..30060e9cb4 --- /dev/null +++ b/app/client/cypress/integration/Smoke_TestSuite/ServerSideTests/DataTypes/Array_Spec.ts @@ -0,0 +1,697 @@ +import { ObjectsRegistry } from "../../../../support/Objects/Registry"; + +let guid: any, dsName: any, query: string; +const agHelper = ObjectsRegistry.AggregateHelper, + ee = ObjectsRegistry.EntityExplorer, + dataSources = ObjectsRegistry.DataSources, + propPane = ObjectsRegistry.PropertyPane, + table = ObjectsRegistry.Table, + locator = ObjectsRegistry.CommonLocators, + deployMode = ObjectsRegistry.DeployMode; + +describe("Postgres - Datatype Array types tests", function() { + before(() => { + agHelper.GenerateUUID(); + cy.get("@guid").then((uid) => { + dataSources.NavigateToDSCreateNew(); + dataSources.CreatePlugIn("PostgreSQL"); + guid = uid; + agHelper.RenameWithInPane("Postgres " + guid, false); + dataSources.FillPostgresDSForm(); + dataSources.TestSaveDatasource(); + cy.wrap("Postgres " + guid).as("dsName"); + }); + cy.get("@dsName").then(($dsName) => { + dsName = $dsName; + }); + }); + + it("0. Importing App & setting theme", () => { + cy.fixture("ArrayDTdsl").then((val: any) => { + agHelper.AddDsl(val); + }); + ee.NavigateToSwitcher("widgets"); + propPane.ChangeColor(-31, "Primary"); + propPane.ChangeColor(-27, "Background"); + }); + + it("1. Creating table query - arraytypes", () => { + query = `CREATE TABLE arraytypes (serialId SERIAL not null primary key, name text, pay_by_quarter integer[], schedule text[][]);`; + dataSources.NavigateFromActiveDS(dsName, true); + agHelper.GetNClick(dataSources._templateMenu); + agHelper.RenameWithInPane("createTable"); + dataSources.EnterQuery(query); + dataSources.RunQuery(); + + ee.ActionContextMenuByEntityName(dsName, "Refresh"); + agHelper.AssertElementVisible( + ee._entityNameInExplorer("public.arraytypes"), + ); + }); + + it("2. Creating SELECT query - arraytypes + Bug 14493", () => { + ee.ActionTemplateMenuByEntityName("public.arraytypes", "SELECT"); + agHelper.RenameWithInPane("selectRecords"); + dataSources.RunQuery(); + agHelper + .GetText(dataSources._noRecordFound) + .then(($noRecMsg) => expect($noRecMsg).to.eq("No data records to show")); + }); + + it("3. Creating all queries - arraytypes", () => { + query = `INSERT INTO arraytypes ("name", "pay_by_quarter", "schedule") VALUES ('{{Insertname.text}}', ARRAY{{Insertpaybyquarter.text.split(',').map(Number)}}, ARRAY[['{{Insertschedule.text.split(',').slice(0,2).toString()}}'],['{{Insertschedule.text.split(',').slice(2,4).toString()}}']]);`; + ee.CreateNewDsQuery(dsName); + agHelper.RenameWithInPane("insertRecord"); + agHelper.GetNClick(dataSources._templateMenu); + dataSources.EnterQuery(query); + dataSources.ToggleUsePreparedStatement(false); + + query = `UPDATE public."arraytypes" SET "name" = '{{Updatename.text}}', "pay_by_quarter" = ARRAY{{Updatepaybyquarter.text.split(',').map(Number)}}, + "schedule" = ARRAY[['{{Updateschedule.text.split(',').slice(0,2).toString()}}'],['{{Updateschedule.text.split(',').slice(2,4).toString()}}']] WHERE serialid = {{Table1.selectedRow.serialid}};`; + ee.CreateNewDsQuery(dsName); + agHelper.RenameWithInPane("updateRecord"); + agHelper.GetNClick(dataSources._templateMenu); + dataSources.EnterQuery(query); + dataSources.ToggleUsePreparedStatement(false); + + query = `DELETE FROM public."arraytypes" WHERE serialId = {{Table1.selectedRow.serialid}}`; + ee.CreateNewDsQuery(dsName); + agHelper.RenameWithInPane("deleteRecord"); + agHelper.GetNClick(dataSources._templateMenu); + dataSources.EnterQuery(query); + + query = `DELETE FROM public."arraytypes"`; + ee.CreateNewDsQuery(dsName); + agHelper.RenameWithInPane("deleteAllRecords"); + agHelper.GetNClick(dataSources._templateMenu); + dataSources.EnterQuery(query); + + query = `drop table public."arraytypes"`; + ee.CreateNewDsQuery(dsName); + agHelper.RenameWithInPane("dropTable"); + agHelper.GetNClick(dataSources._templateMenu); + dataSources.EnterQuery(query); + + ee.ExpandCollapseEntity("QUERIES/JS", false); + ee.ExpandCollapseEntity(dsName, false); + }); + + it("4. Inserting record - arraytypes", () => { + ee.SelectEntityByName("Page1"); + deployMode.DeployApp(); + table.WaitForTableEmpty(); //asserting table is empty before inserting! + agHelper.ClickButton("Run InsertQuery"); + agHelper.AssertElementVisible(locator._modal); + + agHelper.EnterInputText("Name", "Lily Bush"); + agHelper.EnterInputText("Pay_by_quarter", "100,200,300,400"); + agHelper.EnterInputText("Schedule", "Arrival,Breakfast,Meeting,Lunch"); + + agHelper.ClickButton("Insert"); + agHelper.AssertElementAbsence(locator._toastMsg); //Assert that Insert did not fail + agHelper.AssertElementVisible(locator._spanButton("Run InsertQuery")); + table.ReadTableRowColumnData(0, 0, 2000).then(($cellData) => { + expect($cellData).to.eq("1"); //asserting serial column is inserting fine in sequence + }); + table.ReadTableRowColumnData(0, 1, 200).then(($cellData) => { + expect($cellData).not.to.eq(""); + }); + }); + + it("5. Inserting another record - arraytypes", () => { + agHelper.ClickButton("Run InsertQuery"); + agHelper.AssertElementVisible(locator._modal); + + agHelper.EnterInputText("Name", "Josh William"); + agHelper.EnterInputText("Pay_by_quarter", "8700,5454,9898,23257"); + agHelper.EnterInputText("Schedule", "Stand up,Update,Report,Executive"); + + agHelper.ClickButton("Insert"); + agHelper.AssertElementVisible(locator._spanButton("Run InsertQuery")); + table.ReadTableRowColumnData(1, 0, 2000).then(($cellData) => { + expect($cellData).to.eq("2"); //asserting serial column is inserting fine in sequence + }); + table.ReadTableRowColumnData(1, 1, 200).then(($cellData) => { + expect($cellData).not.to.eq(""); + }); + }); + + it("6. Inserting another record - arraytypes", () => { + agHelper.ClickButton("Run InsertQuery"); + agHelper.AssertElementVisible(locator._modal); + + agHelper.EnterInputText("Name", "Mary Clark"); + agHelper.EnterInputText("Pay_by_quarter", "9898,21726,87387,8372837"); + agHelper.EnterInputText( + "Schedule", + "Travel,Meet Sales,Take Action,Sky Rocket", + ); + + agHelper.ClickButton("Insert"); + agHelper.AssertElementVisible(locator._spanButton("Run InsertQuery")); + table.ReadTableRowColumnData(2, 0, 2000).then(($cellData) => { + expect($cellData).to.eq("3"); //asserting serial column is inserting fine in sequence + }); + table.ReadTableRowColumnData(2, 1, 200).then(($cellData) => { + expect($cellData).not.to.eq(""); + }); + }); + + it("7. Updating record - arraytypes", () => { + table.SelectTableRow(1); + agHelper.ClickButton("Run UpdateQuery"); + agHelper.AssertElementVisible(locator._modal); + + agHelper.EnterInputText("Name", "Josh Clarion", true); + agHelper.EnterInputText("Pay_by_quarter", "3232,3232,4567,12234", true); + agHelper.EnterInputText( + "Schedule", + "Breakfat,Presentation,Consulting,Training", + true, + ); + + agHelper.ClickButton("Update"); + agHelper.AssertElementAbsence(locator._toastMsg); //Assert that Update did not fail + agHelper.AssertElementVisible(locator._spanButton("Run UpdateQuery")); + table.ReadTableRowColumnData(1, 0, 2000).then(($cellData) => { + expect($cellData).to.eq("3"); + }); + table.ReadTableRowColumnData(2, 0, 2000).then(($cellData) => { + expect($cellData).to.eq("2"); //Since recently updated column to pushed to last! + }); + table.ReadTableRowColumnData(2, 1, 200).then(($cellData) => { + expect($cellData).not.to.eq(""); + }); + }); + + it("8. Validating JSON functions", () => { + deployMode.NavigateBacktoEditor(); + table.WaitUntilTableLoad(); + ee.ExpandCollapseEntity("QUERIES/JS"); + dataSources.NavigateFromActiveDS(dsName, true); + agHelper.RenameWithInPane("verifyArrayFunctions"); + + query = `SELECT name FROM arraytypes WHERE pay_by_quarter[1] <> pay_by_quarter[2];`; + agHelper.GetNClick(dataSources._templateMenu); + dataSources.EnterQuery(query); + dataSources.RunQuery(); + dataSources.AssertQueryResponseHeaders(["name"]); + dataSources.ReadQueryTableResponse(0).then(($cellData) => { + expect($cellData).to.eq("Lily Bush"); + }); + dataSources.ReadQueryTableResponse(1).then(($cellData) => { + expect($cellData).to.eq("Mary Clark"); + }); + + query = `SELECT pay_by_quarter[3] FROM arraytypes;`; + dataSources.EnterQuery(query); + dataSources.RunQuery(); + dataSources.AssertQueryResponseHeaders(["pay_by_quarter"]); + dataSources.ReadQueryTableResponse(0).then(($cellData) => { + expect($cellData).to.eq("300"); + }); + dataSources.ReadQueryTableResponse(1).then(($cellData) => { + expect($cellData).to.eq("87387"); + }); + dataSources.ReadQueryTableResponse(2).then(($cellData) => { + expect($cellData).to.eq("4567"); + }); + + //Verifying OR + query = `SELECT * FROM arraytypes WHERE pay_by_quarter[1] = 300 OR pay_by_quarter[2] = 200 OR pay_by_quarter[3] = 4567 OR pay_by_quarter[4] = 10000;`; + dataSources.EnterQuery(query); + dataSources.RunQuery(); + dataSources.AssertQueryResponseHeaders([ + "serialid", + "name", + "pay_by_quarter", + "schedule", + ]); + dataSources.ReadQueryTableResponse(0).then(($cellData) => { + expect($cellData).to.eq("1"); + }); + dataSources.ReadQueryTableResponse(1).then(($cellData) => { + expect($cellData).to.eq("Lily Bush"); + }); + dataSources.ReadQueryTableResponse(4).then(($cellData) => { + expect($cellData).to.eq("2"); + }); + dataSources.ReadQueryTableResponse(5).then(($cellData) => { + expect($cellData).to.eq("Josh Clarion"); + }); + + //Verifying && + query = `SELECT * FROM arraytypes WHERE pay_by_quarter && ARRAY[87387];`; + dataSources.EnterQuery(query); + dataSources.RunQuery(); + dataSources.AssertQueryResponseHeaders([ + "serialid", + "name", + "pay_by_quarter", + "schedule", + ]); + dataSources.ReadQueryTableResponse(0).then(($cellData) => { + expect($cellData).to.eq("3"); + }); + dataSources.ReadQueryTableResponse(1).then(($cellData) => { + expect($cellData).to.eq("Mary Clark"); + }); + dataSources.ReadQueryTableResponse(2).then(($cellData) => { + expect($cellData).to.eq("[9898,21726,87387,8372837]"); + }); + dataSources.ReadQueryTableResponse(3).then(($cellData) => { + expect($cellData).to.eq( + `[["Travel,Meet Sales"],["Take Action,Sky Rocket"]]`, + ); + }); + + //Verifying ANY + query = `SELECT * FROM arraytypes WHERE 9898 = ANY (pay_by_quarter);`; + dataSources.EnterQuery(query); + dataSources.RunQuery(); + dataSources.AssertQueryResponseHeaders([ + "serialid", + "name", + "pay_by_quarter", + "schedule", + ]); + dataSources.ReadQueryTableResponse(0).then(($cellData) => { + expect($cellData).to.eq("3"); + }); + dataSources.ReadQueryTableResponse(1).then(($cellData) => { + expect($cellData).to.eq("Mary Clark"); + }); + + //Verifying generate_script + query = `SELECT * FROM + (SELECT pay_by_quarter, + generate_subscripts(pay_by_quarter, 1) AS position + FROM arraytypes) AS foo + WHERE pay_by_quarter[position] = 100;`; + dataSources.EnterQuery(query); + dataSources.RunQuery(); + dataSources.AssertQueryResponseHeaders(["pay_by_quarter", "position"]); + dataSources.ReadQueryTableResponse(0).then(($cellData) => { + expect($cellData).to.eq("[100,200,300,400]"); + }); + dataSources.ReadQueryTableResponse(1).then(($cellData) => { + expect($cellData).to.eq("1"); + }); + + query = `SELECT * FROM + (SELECT pay_by_quarter, + generate_subscripts(pay_by_quarter, 1) AS position + FROM arraytypes) AS foo + WHERE pay_by_quarter[position] = 3232;`; + dataSources.EnterQuery(query); + dataSources.RunQuery(); + dataSources.AssertQueryResponseHeaders(["pay_by_quarter", "position"]); + dataSources.ReadQueryTableResponse(0).then(($cellData) => { + expect($cellData).to.eq("[3232,3232,4567,12234]"); + }); + dataSources.ReadQueryTableResponse(1).then(($cellData) => { + expect($cellData).to.eq("1"); + }); + dataSources.ReadQueryTableResponse(2).then(($cellData) => { + expect($cellData).to.eq("[3232,3232,4567,12234]"); + }); + dataSources.ReadQueryTableResponse(3).then(($cellData) => { + expect($cellData).to.eq("2"); + }); + + //Verifying ALL + query = `SELECT * FROM arraytypes WHERE 100 = ALL (pay_by_quarter);`; + dataSources.EnterQuery(query); + dataSources.RunQuery(); + agHelper + .GetText(dataSources._noRecordFound) + .then(($noRecMsg) => expect($noRecMsg).to.eq("No data records to show")); + + //Verifying unnest + query = `SELECT name, unnest(schedule) FROM arraytypes;`; + dataSources.EnterQuery(query); + dataSources.RunQuery(); + dataSources.AssertQueryResponseHeaders(["name", "unnest"]); + dataSources.ReadQueryTableResponse(0).then(($cellData) => { + expect($cellData).to.eq("Lily Bush"); + }); + dataSources.ReadQueryTableResponse(1).then(($cellData) => { + expect($cellData).to.eq("Arrival,Breakfast"); + }); + dataSources.ReadQueryTableResponse(4).then(($cellData) => { + expect($cellData).to.eq("Mary Clark"); + }); + dataSources.ReadQueryTableResponse(5).then(($cellData) => { + expect($cellData).to.eq("Travel,Meet Sales"); + }); + dataSources.ReadQueryTableResponse(10).then(($cellData) => { + expect($cellData).to.eq("Josh Clarion"); + }); + dataSources.ReadQueryTableResponse(11).then(($cellData) => { + expect($cellData).to.eq("Consulting,Training"); + }); + + //Verifying index access + query = `SELECT schedule[1:2][1:1] FROM arraytypes WHERE name = 'Lily Bush';`; + dataSources.EnterQuery(query); + dataSources.RunQuery(); + dataSources.AssertQueryResponseHeaders(["schedule"]); + dataSources.ReadQueryTableResponse(0).then(($cellData) => { + expect($cellData).to.eq(`[["Arrival,Breakfast"],["Meeting,Lunch"]]`); + }); + + //Verifying index access + query = `SELECT schedule[1:2][2] FROM arraytypes WHERE name = 'Josh Clarion';`; + dataSources.EnterQuery(query); + dataSources.RunQuery(); + dataSources.AssertQueryResponseHeaders(["schedule"]); + dataSources.ReadQueryTableResponse(0).then(($cellData) => { + expect($cellData).to.eq( + `[["Breakfat,Presentation"],["Consulting,Training"]]`, + ); + }); + + query = `SELECT schedule[:1][1:] FROM arraytypes WHERE name = 'Mary Clark';`; + dataSources.EnterQuery(query); + dataSources.RunQuery(); + dataSources.AssertQueryResponseHeaders(["schedule"]); + dataSources.ReadQueryTableResponse(0).then(($cellData) => { + expect($cellData).to.eq(`[["Travel,Meet Sales"]]`); + }); + + query = `SELECT schedule[2:2][:] FROM arraytypes WHERE name = 'Mary Clark';`; + dataSources.EnterQuery(query); + dataSources.RunQuery(); + dataSources.AssertQueryResponseHeaders(["schedule"]); + dataSources.ReadQueryTableResponse(0).then(($cellData) => { + expect($cellData).to.eq(`[["Take Action,Sky Rocket"]]`); + }); + + //Verifying array_dims + query = `SELECT array_dims(schedule) FROM arraytypes WHERE name = 'Lily Bush';`; + dataSources.EnterQuery(query); + dataSources.RunQuery(); + dataSources.AssertQueryResponseHeaders(["array_dims"]); + dataSources.ReadQueryTableResponse(0).then(($cellData) => { + expect($cellData).to.eq("[1:2][1:1]"); + }); + + //Verifying array_length + query = `SELECT array_length(schedule, 1) FROM arraytypes WHERE name = 'Mary Clark';`; + dataSources.EnterQuery(query); + dataSources.RunQuery(); + dataSources.AssertQueryResponseHeaders(["array_length"]); + dataSources.ReadQueryTableResponse(0).then(($cellData) => { + expect($cellData).to.eq(`2`); + }); + + //Verifying array_upper, cardinality + query = `SELECT array_upper(pay_by_quarter, 1), cardinality(schedule) FROM arraytypes WHERE name = 'Josh Clarion';`; + dataSources.EnterQuery(query); + dataSources.RunQuery(); + dataSources.AssertQueryResponseHeaders(["array_upper", "cardinality"]); + dataSources.ReadQueryTableResponse(0).then(($cellData) => { + expect($cellData).to.eq("4"); + }); + dataSources.ReadQueryTableResponse(1).then(($cellData) => { + expect($cellData).to.eq("2"); + }); + + //Verifying || + query = `SELECT ARRAY[1,2] || ARRAY[3,4] as "Test ||", ARRAY[5,6] || ARRAY[[1,2],[3,4]] as "Test || of 2D Array", ARRAY[1, 2] || '{3, 4}' as "Test || with {}"`; + dataSources.EnterQuery(query); + dataSources.RunQuery(); + dataSources.AssertQueryResponseHeaders([ + "Test ||", + "Test || of 2D Array", + "Test || with {}", + ]); + dataSources.ReadQueryTableResponse(0).then(($cellData) => { + expect($cellData).to.eq("[1,2,3,4]"); + }); + dataSources.ReadQueryTableResponse(1).then(($cellData) => { + expect($cellData).to.eq("[[5,6],[1,2],[3,4]]"); + }); + dataSources.ReadQueryTableResponse(2).then(($cellData) => { + expect($cellData).to.eq("[1,2,3,4]"); + }); + + //Verifying array_dims + query = `SELECT array_dims(1 || '[0:1]={2,3}'::int[]) as "array_dims1", array_dims(ARRAY[1,2] || 3) as "array_dims2", array_dims(ARRAY[1,2] || ARRAY[3,4,5]) as "array_dims3", array_dims(ARRAY[[1,2],[3,4]] || ARRAY[[5,6],[7,8],[9,0]]) as "array_dims4";`; + dataSources.EnterQuery(query); + dataSources.RunQuery(); + dataSources.AssertQueryResponseHeaders([ + "array_dims1", + "array_dims2", + "array_dims3", + "array_dims4", + ]); + dataSources.ReadQueryTableResponse(0).then(($cellData) => { + expect($cellData).to.eq("[0:2]"); + }); + dataSources.ReadQueryTableResponse(1).then(($cellData) => { + expect($cellData).to.eq("[1:3]"); + }); + dataSources.ReadQueryTableResponse(2).then(($cellData) => { + expect($cellData).to.eq("[1:5]"); + }); + dataSources.ReadQueryTableResponse(3).then(($cellData) => { + expect($cellData).to.eq("[1:5][1:2]"); + }); + + //Verifying array_prepend, array_append + query = `SELECT array_prepend(1, ARRAY[2,3]) as "array_prepend", array_append(ARRAY[1,2], 3) as "array_append";`; + dataSources.EnterQuery(query); + dataSources.RunQuery(); + dataSources.AssertQueryResponseHeaders(["array_prepend", "array_append"]); + dataSources.ReadQueryTableResponse(0).then(($cellData) => { + expect($cellData).to.eq("[1,2,3]"); + }); + dataSources.ReadQueryTableResponse(1).then(($cellData) => { + expect($cellData).to.eq("[1,2,3]"); + }); + + //Verifying array_cat + query = `SELECT array_cat(ARRAY[1,2], ARRAY[3,4]) as "array_cat1", array_cat(ARRAY[[1,2],[3,4]], ARRAY[5,6]) as "array_cat2", array_cat(ARRAY[5,6], ARRAY[[1,2],[3,4]]) as "array_cat3"`; + dataSources.EnterQuery(query); + dataSources.RunQuery(); + dataSources.AssertQueryResponseHeaders([ + "array_cat1", + "array_cat2", + "array_cat3", + ]); + dataSources.ReadQueryTableResponse(0).then(($cellData) => { + expect($cellData).to.eq("[1,2,3,4]"); + }); + dataSources.ReadQueryTableResponse(1).then(($cellData) => { + expect($cellData).to.eq("[[1,2],[3,4],[5,6]]"); + }); + dataSources.ReadQueryTableResponse(2).then(($cellData) => { + expect($cellData).to.eq("[[5,6],[1,2],[3,4]]"); + }); + + //Verifying || with NULL + query = `SELECT ARRAY[1, 2] || NULL as "|| with NULL", array_append(ARRAY[1, 2], NULL) as "array_append";;`; + dataSources.EnterQuery(query); + dataSources.RunQuery(); + dataSources.AssertQueryResponseHeaders(["|| with NULL", "array_append"]); + dataSources.ReadQueryTableResponse(0).then(($cellData) => { + expect($cellData).to.eq("[1,2]"); + }); + dataSources.ReadQueryTableResponse(1).then(($cellData) => { + expect($cellData).to.eq("[1,2,null]"); + }); + + //Verifying array_position, array_positions + query = `SELECT array_position(ARRAY['sun','mon','tue','wed','thu','fri','sat'], 'sat'), array_positions(ARRAY[1, 4, 3, 1, 3, 4, 2, 1], 1);`; + dataSources.EnterQuery(query); + dataSources.RunQuery(); + dataSources.AssertQueryResponseHeaders([ + "array_position", + "array_positions", + ]); + dataSources.ReadQueryTableResponse(0).then(($cellData) => { + expect($cellData).to.eq("7"); + }); + dataSources.ReadQueryTableResponse(1).then(($cellData) => { + expect($cellData).to.eq("[1,4,8]"); + }); + + //Verifying input & output syntaxes + query = `SELECT f1[1][-2][3] AS e1, f1[1][-1][5] AS e2 FROM (SELECT '[1:1][-2:-1] [3:5]={ {{1,2,3},{4,5,6} } }'::int[] AS f1) AS ss;`; + dataSources.EnterQuery(query); + dataSources.RunQuery(); + dataSources.AssertQueryResponseHeaders(["e1", "e2"]); + dataSources.ReadQueryTableResponse(0).then(($cellData) => { + expect($cellData).to.eq("1"); + }); + dataSources.ReadQueryTableResponse(1).then(($cellData) => { + expect($cellData).to.eq("6"); + }); + + //Verifying array_remove + query = `SELECT array_remove(ARRAY['sun','mon','tue','wed','thu','fri','sat'], 'wed') as "array_remove"`; + dataSources.EnterQuery(query); + dataSources.RunQuery(); + dataSources.AssertQueryResponseHeaders(["array_remove"]); + dataSources.ReadQueryTableResponse(0).then(($cellData) => { + expect($cellData).to.eq(`["sun","mon","tue","thu","fri","sat"]`); + }); + + //Verifying array_replace + query = `select ARRAY[1,2,3,2,5] as "before_replace", array_replace(ARRAY[1,2,3,2,5], 2, 10) as two_becomes_ten;`; + dataSources.EnterQuery(query); + dataSources.RunQuery(); + dataSources.AssertQueryResponseHeaders([ + "before_replace", + "two_becomes_ten", + ]); + dataSources.ReadQueryTableResponse(0).then(($cellData) => { + expect($cellData).to.eq(`[1,2,3,2,5]`); + }); + dataSources.ReadQueryTableResponse(1).then(($cellData) => { + expect($cellData).to.eq(`[1,10,3,10,5]`); + }); + + //Verifying operators + query = `select ARRAY[1.1,2.1,3.1]::int[] = ARRAY[1,2,3] as "=", ARRAY[1,2,3] <> ARRAY[1,2,4] as "<>", ARRAY[1,2,3] < ARRAY[1,2,4] as "<", ARRAY[1,4,3] > ARRAY[1,2,4] as ">", ARRAY[1,2,3] <= ARRAY[1,2,3] as "<=", ARRAY[1,4,3] >= ARRAY[1,4,3] as ">=", ARRAY[1,4,3] @> ARRAY[3,1,3] as "@>", ARRAY[2,2,7] <@ ARRAY[1,7,4,2,6] as "<@", ARRAY[1,4,3] && ARRAY[2,1] as "&&"`; + dataSources.EnterQuery(query); + dataSources.RunQuery(); + dataSources.AssertQueryResponseHeaders([ + "=", + "<>", + "<", + ">", + "<=", + ">=", + "@>", + "<@", + "&&", + ]); + dataSources.ReadQueryTableResponse(0).then(($cellData) => { + expect($cellData).to.eq("true"); + }); + dataSources.ReadQueryTableResponse(8).then(($cellData) => { + expect($cellData).to.eq("true"); + }); + + //Verifying array_to_string + query = `SELECT array_to_string(ARRAY[1, 2, 3, NULL, 5], ',', '*') as array_to_string, string_to_array('xx~^~yy~^~zz', '~^~', 'yy') as string_to_array;`; + dataSources.EnterQuery(query); + dataSources.RunQuery(); + dataSources.AssertQueryResponseHeaders([ + "array_to_string", + "string_to_array", + ]); + dataSources.ReadQueryTableResponse(0).then(($cellData) => { + expect($cellData).to.eq("1,2,3,*,5"); + }); + dataSources.ReadQueryTableResponse(1).then(($cellData) => { + expect($cellData).to.eq(`["xx",null,"zz"]`); + }); + + //Verifying error + query = `SELECT ARRAY[1, 2] || '7';`; + dataSources.EnterQuery(query); + cy.get(locator._codeMirrorTextArea).focus(); + dataSources.RunQuery(); + agHelper + .GetText(dataSources._queryError) + .then(($errorText) => + expect($errorText).to.contain( + `ERROR: malformed array literal: "7"\n Detail: Array value must start with "{" or dimension information`, + ), + ); + + agHelper.ActionContextMenuWithInPane("Delete"); + ee.ExpandCollapseEntity("QUERIES/JS", false); + }); + + it("9. Deleting records - arraytypes", () => { + ee.SelectEntityByName("Page1"); + deployMode.DeployApp(); + table.WaitUntilTableLoad(); + table.SelectTableRow(1); + agHelper.ClickButton("DeleteQuery", 1); + agHelper.ValidateNetworkStatus("@postExecute", 200); + agHelper.ValidateNetworkStatus("@postExecute", 200); + agHelper.Sleep(2500); //Allwowing time for delete to be success + table.ReadTableRowColumnData(1, 0, 2000).then(($cellData) => { + expect($cellData).not.to.eq("3"); //asserting 2nd record is deleted + }); + table.ReadTableRowColumnData(1, 0, 200).then(($cellData) => { + expect($cellData).to.eq("2"); + }); + }); + + it("10. Deleting all records from table - arraytypes", () => { + agHelper.GetNClick(locator._deleteIcon); + agHelper.AssertElementVisible(locator._spanButton("Run InsertQuery")); + agHelper.Sleep(2000); + table.WaitForTableEmpty(); + }); + + it("11. Inserting another record (to check serial column) - arraytypes", () => { + agHelper.ClickButton("Run InsertQuery"); + agHelper.AssertElementVisible(locator._modal); + + agHelper.EnterInputText("Name", "Bob Sim"); + agHelper.EnterInputText("Pay_by_quarter", "121,3234,4454,21213"); + agHelper.EnterInputText("Schedule", "Travel,Chillax,Hire,Give rewards"); + + agHelper.ClickButton("Insert"); + agHelper.AssertElementVisible(locator._spanButton("Run InsertQuery")); + table.ReadTableRowColumnData(0, 0, 2000).then(($cellData) => { + expect($cellData).to.eq("4"); //asserting serial column is inserting fine in sequence + }); + table.ReadTableRowColumnData(0, 1, 200).then(($cellData) => { + expect($cellData).not.to.eq(""); + }); + }); + + it("12. Validate Drop of the Newly Created - arraytypes - Table from Postgres datasource", () => { + deployMode.NavigateBacktoEditor(); + ee.ExpandCollapseEntity("QUERIES/JS"); + ee.SelectEntityByName("dropTable"); + dataSources.RunQuery(); + dataSources.ReadQueryTableResponse(0).then(($cellData) => { + expect($cellData).to.eq("0"); //Success response for dropped table! + }); + ee.ExpandCollapseEntity("QUERIES/JS", false); + ee.ExpandCollapseEntity("DATASOURCES"); + ee.ExpandCollapseEntity(dsName); + ee.ActionContextMenuByEntityName(dsName, "Refresh"); + agHelper.AssertElementAbsence( + ee._entityNameInExplorer("public.arraytypes"), + ); + ee.ExpandCollapseEntity(dsName, false); + ee.ExpandCollapseEntity("DATASOURCES", false); + }); + + it("13. Verify Deletion of all created queries", () => { + dataSources.DeleteDatasouceFromWinthinDS(dsName, 409); //Since all queries exists + ee.ExpandCollapseEntity("QUERIES/JS"); + ee.ActionContextMenuByEntityName("createTable", "Delete", "Are you sure?"); + ee.ActionContextMenuByEntityName( + "deleteAllRecords", + "Delete", + "Are you sure?", + ); + ee.ActionContextMenuByEntityName("deleteRecord", "Delete", "Are you sure?"); + ee.ActionContextMenuByEntityName("dropTable", "Delete", "Are you sure?"); + ee.ActionContextMenuByEntityName("insertRecord", "Delete", "Are you sure?"); + ee.ActionContextMenuByEntityName( + "selectRecords", + "Delete", + "Are you sure?", + ); + ee.ActionContextMenuByEntityName("updateRecord", "Delete", "Are you sure?"); + }); + + it("14. Verify Deletion of datasource", () => { + deployMode.DeployApp(); + deployMode.NavigateBacktoEditor(); + ee.ExpandCollapseEntity("QUERIES/JS"); + dataSources.DeleteDatasouceFromWinthinDS(dsName, 200); + }); +}); diff --git a/app/client/cypress/integration/Smoke_TestSuite/ServerSideTests/GenerateCRUD/MySQL_Spec.ts b/app/client/cypress/integration/Smoke_TestSuite/ServerSideTests/GenerateCRUD/MySQL_Spec.ts index 950ef5a588..94910c6f15 100644 --- a/app/client/cypress/integration/Smoke_TestSuite/ServerSideTests/GenerateCRUD/MySQL_Spec.ts +++ b/app/client/cypress/integration/Smoke_TestSuite/ServerSideTests/GenerateCRUD/MySQL_Spec.ts @@ -600,7 +600,7 @@ describe("Validate MySQL Generate CRUD with JSON Form", () => { agHelper.GetNClick(dataSources._templateMenu); agHelper.RenameWithInPane("DropStores"); dataSources.EnterQuery(deleteTblQuery); - cy.get(".CodeMirror textarea").focus(); + cy.get(locator._codeMirrorTextArea).focus(); //agHelper.VerifyEvaluatedValue(tableCreateQuery); dataSources.RunQuery(false); diff --git a/app/client/cypress/integration/Smoke_TestSuite/ServerSideTests/GenerateCRUD/Postgres_Spec.ts b/app/client/cypress/integration/Smoke_TestSuite/ServerSideTests/GenerateCRUD/Postgres_Spec.ts index 0c61408b13..aeccf19b8e 100644 --- a/app/client/cypress/integration/Smoke_TestSuite/ServerSideTests/GenerateCRUD/Postgres_Spec.ts +++ b/app/client/cypress/integration/Smoke_TestSuite/ServerSideTests/GenerateCRUD/Postgres_Spec.ts @@ -707,7 +707,7 @@ describe("Validate Postgres Generate CRUD with JSON Form", () => { agHelper.GetNClick(dataSources._templateMenu); agHelper.RenameWithInPane("DropVessels"); dataSources.EnterQuery(deleteTblQuery); - cy.get(".CodeMirror textarea").focus(); + cy.get(locator._codeMirrorTextArea).focus(); //agHelper.VerifyEvaluatedValue(tableCreateQuery); dataSources.RunQuery(false); diff --git a/app/client/cypress/integration/Smoke_TestSuite/ServerSideTests/QueryPane/Mongo_Spec.ts b/app/client/cypress/integration/Smoke_TestSuite/ServerSideTests/QueryPane/Mongo_Spec.ts index f3551dc0c0..05ab586d2b 100644 --- a/app/client/cypress/integration/Smoke_TestSuite/ServerSideTests/QueryPane/Mongo_Spec.ts +++ b/app/client/cypress/integration/Smoke_TestSuite/ServerSideTests/QueryPane/Mongo_Spec.ts @@ -664,7 +664,7 @@ describe("Validate Mongo Query Pane Validations", () => { agHelper.GetNClick(dataSources._templateMenu); agHelper.RenameWithInPane("DropAuthorNAwards"); dataSources.EnterQuery(dropCollection); - cy.get(".CodeMirror textarea").focus(); + cy.get(locator._codeMirrorTextArea).focus(); //agHelper.VerifyEvaluatedValue(tableCreateQuery); dataSources.RunQuery(false);