From a7fd7d67b3e35c408149add465c3895016a19b3c Mon Sep 17 00:00:00 2001 From: Aditya Toshniwal Date: Mon, 25 Jul 2022 11:48:27 +0530 Subject: [PATCH] 1. Intermittently failing test cases. 2. Dialog vertical position should be more on the upper side. 3. File not supported error is not showing. refs #7313 --- web/pgadmin/static/js/helpers/ModalProvider.jsx | 2 +- .../sqleditor/static/js/components/sections/Query.jsx | 7 ++++++- web/regression/javascript/file_manager/FileManager.spec.js | 6 ++++-- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/web/pgadmin/static/js/helpers/ModalProvider.jsx b/web/pgadmin/static/js/helpers/ModalProvider.jsx index 510cb96dc..6c1f41b2d 100644 --- a/web/pgadmin/static/js/helpers/ModalProvider.jsx +++ b/web/pgadmin/static/js/helpers/ModalProvider.jsx @@ -168,7 +168,7 @@ function PaperComponent(props) { return props.isfullscreen == 'true' ? { x: 0, y: 0 } : dialogPosition && { x: dialogPosition.x, y: dialogPosition.y }; }; - const y_position = props.height ? (window.innerHeight/2) - (props.height/2) : (window.innerHeight/2) - (MIN_HEIGHT/2); + const y_position = window.innerHeight*0.02; // 2% of total height const x_position = props.width ? (window.innerWidth/2) - (props.width/2) : (window.innerWidth/2) - (MIN_WIDTH/2); return ( diff --git a/web/pgadmin/tools/sqleditor/static/js/components/sections/Query.jsx b/web/pgadmin/tools/sqleditor/static/js/components/sections/Query.jsx index 3c044c64f..5d3c3c2f3 100644 --- a/web/pgadmin/tools/sqleditor/static/js/components/sections/Query.jsx +++ b/web/pgadmin/tools/sqleditor/static/js/components/sections/Query.jsx @@ -349,7 +349,12 @@ export default function Query() { eventBus.registerListener(QUERY_TOOL_EVENTS.LOAD_FILE, (fileName)=>{ queryToolCtx.api.post(url_for('sqleditor.load_file'), { 'file_name': decodeURI(fileName), - }, {transformResponse: [(data) => { return data; }]}).then((res)=>{ + }, {transformResponse: [(data, headers) => { + if(headers['content-type'].includes('application/json')) { + return JSON.parse(data); + } + return data; + }]}).then((res)=>{ editor.current.setValue(res.data); //Check the file content for Trojan Source checkTrojanSource(res.data); diff --git a/web/regression/javascript/file_manager/FileManager.spec.js b/web/regression/javascript/file_manager/FileManager.spec.js index f0cc29bfb..1f2bdcf66 100644 --- a/web/regression/javascript/file_manager/FileManager.spec.js +++ b/web/regression/javascript/file_manager/FileManager.spec.js @@ -98,7 +98,6 @@ describe('FileManger', ()=>{ beforeAll(()=>{ mount = createMount(); networkMock = new MockAdapter(axios); - networkMock.onPost('/file_manager/init').reply(200, {'data': configData}); networkMock.onPost(`/file_manager/filemanager/${transId}/`).reply(200, {data: {result: files}}); networkMock.onPost(`/file_manager/save_file_dialog_view/${transId}`).reply(200, {}); networkMock.onDelete(`/file_manager/delete_trans_id/${transId}`).reply(200, {}); @@ -130,14 +129,17 @@ describe('FileManger', ()=>{ }; it('init', (done)=>{ + networkMock.onPost('/file_manager/init').reply(200, {'data': configData}); let ctrl = ctrlMount({}); setTimeout(()=>{ + ctrl.update(); + ctrl.find('button[name="menu-options"]').simulate('click'); + ctrl.find('Memo(MenuItem)[data-label="List View"]').simulate('click'); ctrl.update(); expect(ctrl.find('ListView').length).toBe(1); expect(ctrl.find('GridView').length).toBe(0); expect(ctrl.find('InputText[data-label="file-path"]').prop('value')).toBe('/home/current'); ctrl.find('button[name="menu-options"]').simulate('click'); - ctrl.update(); ctrl.find('Memo(MenuItem)[data-label="Grid View"]').simulate('click'); setTimeout(()=>{ ctrl.update();