mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Significant changes to use ReactJS extensively.
1. Replace the current layout library wcDocker with ReactJS based rc-dock. #6479 2. Have close buttons on individual panel tabs instead of common. #2821 3. Changes in the context menu on panel tabs - Add close, close all and close others menu items. #5394 4. Allow closing all the tabs, including SQL and Properties. #4733 5. Changes in docking behaviour of different tabs based on user requests and remove lock layout menu. 6. Fix an issue where the scroll position of panels was not remembered on Firefox. #2986 7. Reset layout now will not require page refresh and is done spontaneously. 8. Use the zustand store for storing preferences instead of plain JS objects. This will help reflecting preferences immediately. 9. The above fix incorrect format (no indent) of SQL stored functions/procedures. #6720 10. New version check is moved to an async request now instead of app start to improve startup performance. 11. Remove jQuery and Bootstrap completely. 12. Replace jasmine and karma test runner with jest. Migrate all the JS test cases to jest. This will save time in writing and debugging JS tests. 13. Other important code improvements and cleanup.
This commit is contained in:
@@ -10,21 +10,21 @@
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
|
||||
import Theme from 'sources/Theme';
|
||||
import {DebuggerContext, DebuggerEventsContext} from '../../../pgadmin/tools/debugger/static/js/components/DebuggerComponent';
|
||||
import { withBrowser } from '../genericFunctions';
|
||||
|
||||
export default function MockDebuggerComponent({value, eventsvalue, children}) {
|
||||
function MockDebuggerComponent({value, eventsvalue, children}) {
|
||||
return (
|
||||
<Theme>
|
||||
<DebuggerContext.Provider value={value}>
|
||||
<DebuggerEventsContext.Provider value={eventsvalue}>
|
||||
{children}
|
||||
</DebuggerEventsContext.Provider>
|
||||
</DebuggerContext.Provider>
|
||||
</Theme>
|
||||
<DebuggerContext.Provider value={value}>
|
||||
<DebuggerEventsContext.Provider value={eventsvalue}>
|
||||
{children}
|
||||
</DebuggerEventsContext.Provider>
|
||||
</DebuggerContext.Provider>
|
||||
);
|
||||
}
|
||||
|
||||
export default withBrowser(MockDebuggerComponent);
|
||||
|
||||
MockDebuggerComponent.propTypes = {
|
||||
value: PropTypes.any,
|
||||
eventsvalue: PropTypes.any,
|
||||
|
||||
@@ -7,249 +7,33 @@
|
||||
//
|
||||
//////////////////////////////////////////////////////////////
|
||||
|
||||
import $ from 'jquery';
|
||||
window.jQuery = window.$ = $;
|
||||
|
||||
import 'wcdocker';
|
||||
import '../helper/enzyme.helper';
|
||||
|
||||
import jasmineEnzyme from 'jasmine-enzyme';
|
||||
import url_for from 'sources/url_for';
|
||||
import FunctionArguments from '../../../pgadmin/tools/debugger/static/js/debugger_ui';
|
||||
import { withBrowser } from '../genericFunctions';
|
||||
import DebuggerArgumentComponent from '../../../pgadmin/tools/debugger/static/js/components/DebuggerArgumentComponent';
|
||||
import MockAdapter from 'axios-mock-adapter';
|
||||
import axios from 'axios';
|
||||
|
||||
import url_for from 'sources/url_for';
|
||||
import pgAdmin from 'sources/pgadmin';
|
||||
|
||||
import { messages } from '../fake_messages';
|
||||
import FunctionArguments from '../../../pgadmin/tools/debugger/static/js/debugger_ui';
|
||||
import {TreeFake} from '../tree/tree_fake';
|
||||
|
||||
import { TreeFake } from '../tree/tree_fake';
|
||||
|
||||
describe('Debugger Component', () => {
|
||||
let funcArgs;
|
||||
let mountDOM;
|
||||
let tree;
|
||||
let networkMock;
|
||||
const MockDebuggerArgumentComponent = withBrowser(DebuggerArgumentComponent);
|
||||
|
||||
beforeEach(() => {
|
||||
jasmineEnzyme();
|
||||
// Element for mount wcDocker panel
|
||||
mountDOM = $('<div class="dockerContainer">');
|
||||
$(document.body).append(mountDOM);
|
||||
const div = document.createElement('div');
|
||||
div.id = 'debugger-main-container';
|
||||
document.body.appendChild(div);
|
||||
|
||||
$(document.body).append($('<div id="debugger-main-container">'));
|
||||
jest.mock('../../../pgadmin/tools/debugger/static/js/components/DebuggerArgumentComponent', ()=>MockDebuggerArgumentComponent);
|
||||
|
||||
/* messages used by validators */
|
||||
pgAdmin.Browser = pgAdmin.Browser || {};
|
||||
pgAdmin.Browser.messages = pgAdmin.Browser.messages || messages;
|
||||
pgAdmin.Browser.utils = pgAdmin.Browser.utils || {};
|
||||
pgAdmin.Browser.stdH = pgAdmin.Browser.stdH || {
|
||||
sm: 200,
|
||||
md: 400,
|
||||
lg: 550,
|
||||
default: 550,
|
||||
};
|
||||
pgAdmin.Browser.stdW = pgAdmin.Browser.stdW || {
|
||||
sm: 500,
|
||||
md: 700,
|
||||
lg: 900,
|
||||
default: 500,
|
||||
};
|
||||
funcArgs = new FunctionArguments();
|
||||
pgAdmin.Browser.preferences_cache = [
|
||||
{
|
||||
'id': 115,
|
||||
'cid': 13,
|
||||
'name': 'btn_step_into',
|
||||
'label': 'Accesskey (Step into)',
|
||||
'type': 'keyboardshortcut',
|
||||
'help_str': null,
|
||||
'control_props': {},
|
||||
'min_val': null,
|
||||
'max_val': null,
|
||||
'options': null,
|
||||
'select': null,
|
||||
'value': {
|
||||
'key': {
|
||||
'key_code': 73,
|
||||
'char': 'i'
|
||||
}
|
||||
},
|
||||
'fields': [
|
||||
{
|
||||
'name': 'key',
|
||||
'type': 'keyCode',
|
||||
'label': 'Key'
|
||||
}
|
||||
],
|
||||
'disabled': false,
|
||||
'dependents': null,
|
||||
'mid': 83,
|
||||
'module': 'debugger',
|
||||
}, {
|
||||
'id': 116,
|
||||
'cid': 13,
|
||||
'name': 'btn_step_over',
|
||||
'label': 'Accesskey (Step over)',
|
||||
'type': 'keyboardshortcut',
|
||||
'help_str': null,
|
||||
'control_props': {},
|
||||
'min_val': null,
|
||||
'max_val': null,
|
||||
'options': null,
|
||||
'select': null,
|
||||
'value': {
|
||||
'key': {
|
||||
'key_code': 79,
|
||||
'char': 'o'
|
||||
}
|
||||
},
|
||||
'fields': [
|
||||
{
|
||||
'name': 'key',
|
||||
'type': 'keyCode',
|
||||
'label': 'Key'
|
||||
}
|
||||
],
|
||||
'disabled': false,
|
||||
'dependents': null,
|
||||
'mid': 83,
|
||||
'module': 'debugger',
|
||||
},
|
||||
{
|
||||
'id': 113,
|
||||
'cid': 13,
|
||||
'name': 'btn_start',
|
||||
'label': 'Accesskey (Continue/Start)',
|
||||
'type': 'keyboardshortcut',
|
||||
'help_str': null,
|
||||
'control_props': {},
|
||||
'min_val': null,
|
||||
'max_val': null,
|
||||
'options': null,
|
||||
'select': null,
|
||||
'value': {
|
||||
'key': {
|
||||
'key_code': 67,
|
||||
'char': 'c'
|
||||
}
|
||||
},
|
||||
'fields': [
|
||||
{
|
||||
'name': 'key',
|
||||
'type': 'keyCode',
|
||||
'label': 'Key'
|
||||
}
|
||||
],
|
||||
'disabled': false,
|
||||
'dependents': null,
|
||||
'mid': 83,
|
||||
'module': 'debugger',
|
||||
}, {
|
||||
'id': 114,
|
||||
'cid': 13,
|
||||
'name': 'btn_stop',
|
||||
'label': 'Accesskey (Stop)',
|
||||
'type': 'keyboardshortcut',
|
||||
'help_str': null,
|
||||
'control_props': {},
|
||||
'min_val': null,
|
||||
'max_val': null,
|
||||
'options': null,
|
||||
'select': null,
|
||||
'value': {
|
||||
'key': {
|
||||
'key_code': 83,
|
||||
'char': 's'
|
||||
}
|
||||
},
|
||||
'fields': [
|
||||
{
|
||||
'name': 'key',
|
||||
'type': 'keyCode',
|
||||
'label': 'Key'
|
||||
}
|
||||
],
|
||||
'disabled': false,
|
||||
'dependents': null,
|
||||
'mid': 83,
|
||||
'module': 'debugger',
|
||||
}, {
|
||||
'id': 117,
|
||||
'cid': 13,
|
||||
'name': 'btn_toggle_breakpoint',
|
||||
'label': 'Accesskey (Toggle breakpoint)',
|
||||
'type': 'keyboardshortcut',
|
||||
'help_str': null,
|
||||
'control_props': {},
|
||||
'min_val': null,
|
||||
'max_val': null,
|
||||
'options': null,
|
||||
'select': null,
|
||||
'value': {
|
||||
'key': {
|
||||
'key_code': 84,
|
||||
'char': 't'
|
||||
}
|
||||
},
|
||||
'fields': [
|
||||
{
|
||||
'name': 'key',
|
||||
'type': 'keyCode',
|
||||
'label': 'Key'
|
||||
}
|
||||
],
|
||||
'disabled': false,
|
||||
'dependents': null,
|
||||
'mid': 83,
|
||||
'module': 'debugger',
|
||||
}, {
|
||||
'id': 118,
|
||||
'cid': 13,
|
||||
'name': 'btn_clear_breakpoints',
|
||||
'label': 'Accesskey (Clear all breakpoints)',
|
||||
'type': 'keyboardshortcut',
|
||||
'help_str': null,
|
||||
'control_props': {},
|
||||
'min_val': null,
|
||||
'max_val': null,
|
||||
'options': null,
|
||||
'select': null,
|
||||
'value': {
|
||||
'key': {
|
||||
'key_code': 88,
|
||||
'char': 'x'
|
||||
}
|
||||
},
|
||||
'fields': [
|
||||
{
|
||||
'name': 'key',
|
||||
'type': 'keyCode',
|
||||
'label': 'Key'
|
||||
}
|
||||
],
|
||||
'disabled': false,
|
||||
'dependents': null,
|
||||
'mid': 83,
|
||||
'module': 'debugger',
|
||||
}
|
||||
|
||||
];
|
||||
// eslint-disable-next-line
|
||||
let docker = new wcDocker(
|
||||
'.dockerContainer', {
|
||||
allowContextMenu: false,
|
||||
allowCollapse: false,
|
||||
loadingClass: 'pg-sp-icon',
|
||||
});
|
||||
|
||||
tree = new TreeFake();
|
||||
pgAdmin.Browser.tree = tree;
|
||||
pgAdmin.Browser.docker = docker;
|
||||
networkMock = new MockAdapter(axios);
|
||||
pgAdmin.Browser.tree = new TreeFake(pgAdmin.Browser);
|
||||
});
|
||||
|
||||
it('Debugger Args', () => {
|
||||
it('Debugger Args', async () => {
|
||||
networkMock.onGet(url_for('debugger.init', {'function': 1, 'schema': 1, 'database': 1, 'server': 1})).reply(200, {'success':1,'errormsg':'','info':'','result':null,'data':{'debug_info':[{'name':'_test2','prosrc':'begin\nselect \'1\';\nend','lanname':'plpgsql','proretset':false,'prorettype':1043,'rettype':'varchar','proargtypenames':'date','proargtypes':'1082','proargnames':'test_date','proargmodes':null,'pkg':0,'pkgname':'','pkgconsoid':0,'schema':2200,'schemaname':'public','isfunc':true,'signature':'test_date date','proargdefaults':null,'pronargdefaults':0,'require_input':true}],'trans_id':'7165'}});
|
||||
|
||||
let debugInfo = {
|
||||
@@ -274,7 +58,6 @@ describe('Debugger Component', () => {
|
||||
'pronargdefaults': 0,
|
||||
'require_input': true,
|
||||
};
|
||||
|
||||
funcArgs.show(debugInfo, 0, false, '123');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -7,250 +7,39 @@
|
||||
//
|
||||
//////////////////////////////////////////////////////////////
|
||||
|
||||
import $ from 'jquery';
|
||||
window.jQuery = window.$ = $;
|
||||
import 'bootstrap';
|
||||
import 'wcdocker';
|
||||
import '../helper/enzyme.helper';
|
||||
|
||||
import React from 'react';
|
||||
import { createMount } from '@material-ui/core/test-utils';
|
||||
import jasmineEnzyme from 'jasmine-enzyme';
|
||||
import { act, render } from '@testing-library/react';
|
||||
|
||||
import MockAdapter from 'axios-mock-adapter';
|
||||
import axios from 'axios';
|
||||
|
||||
import url_for from 'sources/url_for';
|
||||
import pgAdmin from 'sources/pgadmin';
|
||||
|
||||
import { messages } from '../fake_messages';
|
||||
|
||||
import DebuggerComponent from '../../../pgadmin/tools/debugger/static/js/components/DebuggerComponent';
|
||||
import FunctionArguments from '../../../pgadmin/tools/debugger/static/js/debugger_ui';
|
||||
import Debugger from '../../../pgadmin/tools/debugger/static/js/DebuggerModule';
|
||||
import {TreeFake} from '../tree/tree_fake';
|
||||
import Theme from '../../../pgadmin/static/js/Theme';
|
||||
|
||||
|
||||
describe('Debugger Component', () => {
|
||||
let mount;
|
||||
|
||||
let funcArgs;
|
||||
let debuggerInstance;
|
||||
let nodeInfo;
|
||||
let mountDOM;
|
||||
let tree;
|
||||
let params;
|
||||
let networkMock;
|
||||
|
||||
/* Use createMount so that material ui components gets the required context */
|
||||
/* https://material-ui.com/guides/testing/#api */
|
||||
beforeAll(() => {
|
||||
mount = createMount();
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
jasmineEnzyme();
|
||||
// Element for mount wcDocker panel
|
||||
mountDOM = $('<div class="dockerContainer">');
|
||||
$(document.body).append(mountDOM);
|
||||
const div = document.createElement('div');
|
||||
div.id = 'debugger-main-container';
|
||||
document.body.appendChild(div);
|
||||
|
||||
$(document.body).append($('<div id="debugger-main-container">'));
|
||||
|
||||
/* messages used by validators */
|
||||
pgAdmin.Browser = pgAdmin.Browser || {};
|
||||
pgAdmin.Browser.messages = pgAdmin.Browser.messages || messages;
|
||||
pgAdmin.Browser.utils = pgAdmin.Browser.utils || {};
|
||||
funcArgs = new FunctionArguments();
|
||||
debuggerInstance = new Debugger(pgAdmin, pgAdmin.Browser);
|
||||
nodeInfo = { parent: {} };
|
||||
pgAdmin.Browser.preferences_cache = [
|
||||
{
|
||||
'id': 115,
|
||||
'cid': 13,
|
||||
'name': 'btn_step_into',
|
||||
'label': 'Accesskey (Step into)',
|
||||
'type': 'keyboardshortcut',
|
||||
'help_str': null,
|
||||
'control_props': {},
|
||||
'min_val': null,
|
||||
'max_val': null,
|
||||
'options': null,
|
||||
'select': null,
|
||||
'value': {
|
||||
'key': {
|
||||
'key_code': 73,
|
||||
'char': 'i'
|
||||
}
|
||||
},
|
||||
'fields': [
|
||||
{
|
||||
'name': 'key',
|
||||
'type': 'keyCode',
|
||||
'label': 'Key'
|
||||
}
|
||||
],
|
||||
'disabled': false,
|
||||
'dependents': null,
|
||||
'mid': 83,
|
||||
'module': 'debugger',
|
||||
}, {
|
||||
'id': 116,
|
||||
'cid': 13,
|
||||
'name': 'btn_step_over',
|
||||
'label': 'Accesskey (Step over)',
|
||||
'type': 'keyboardshortcut',
|
||||
'help_str': null,
|
||||
'control_props': {},
|
||||
'min_val': null,
|
||||
'max_val': null,
|
||||
'options': null,
|
||||
'select': null,
|
||||
'value': {
|
||||
'key': {
|
||||
'key_code': 79,
|
||||
'char': 'o'
|
||||
}
|
||||
},
|
||||
'fields': [
|
||||
{
|
||||
'name': 'key',
|
||||
'type': 'keyCode',
|
||||
'label': 'Key'
|
||||
}
|
||||
],
|
||||
'disabled': false,
|
||||
'dependents': null,
|
||||
'mid': 83,
|
||||
'module': 'debugger',
|
||||
},
|
||||
{
|
||||
'id': 113,
|
||||
'cid': 13,
|
||||
'name': 'btn_start',
|
||||
'label': 'Accesskey (Continue/Start)',
|
||||
'type': 'keyboardshortcut',
|
||||
'help_str': null,
|
||||
'control_props': {},
|
||||
'min_val': null,
|
||||
'max_val': null,
|
||||
'options': null,
|
||||
'select': null,
|
||||
'value': {
|
||||
'key': {
|
||||
'key_code': 67,
|
||||
'char': 'c'
|
||||
}
|
||||
},
|
||||
'fields': [
|
||||
{
|
||||
'name': 'key',
|
||||
'type': 'keyCode',
|
||||
'label': 'Key'
|
||||
}
|
||||
],
|
||||
'disabled': false,
|
||||
'dependents': null,
|
||||
'mid': 83,
|
||||
'module': 'debugger',
|
||||
}, {
|
||||
'id': 114,
|
||||
'cid': 13,
|
||||
'name': 'btn_stop',
|
||||
'label': 'Accesskey (Stop)',
|
||||
'type': 'keyboardshortcut',
|
||||
'help_str': null,
|
||||
'control_props': {},
|
||||
'min_val': null,
|
||||
'max_val': null,
|
||||
'options': null,
|
||||
'select': null,
|
||||
'value': {
|
||||
'key': {
|
||||
'key_code': 83,
|
||||
'char': 's'
|
||||
}
|
||||
},
|
||||
'fields': [
|
||||
{
|
||||
'name': 'key',
|
||||
'type': 'keyCode',
|
||||
'label': 'Key'
|
||||
}
|
||||
],
|
||||
'disabled': false,
|
||||
'dependents': null,
|
||||
'mid': 83,
|
||||
'module': 'debugger',
|
||||
}, {
|
||||
'id': 117,
|
||||
'cid': 13,
|
||||
'name': 'btn_toggle_breakpoint',
|
||||
'label': 'Accesskey (Toggle breakpoint)',
|
||||
'type': 'keyboardshortcut',
|
||||
'help_str': null,
|
||||
'control_props': {},
|
||||
'min_val': null,
|
||||
'max_val': null,
|
||||
'options': null,
|
||||
'select': null,
|
||||
'value': {
|
||||
'key': {
|
||||
'key_code': 84,
|
||||
'char': 't'
|
||||
}
|
||||
},
|
||||
'fields': [
|
||||
{
|
||||
'name': 'key',
|
||||
'type': 'keyCode',
|
||||
'label': 'Key'
|
||||
}
|
||||
],
|
||||
'disabled': false,
|
||||
'dependents': null,
|
||||
'mid': 83,
|
||||
'module': 'debugger',
|
||||
}, {
|
||||
'id': 118,
|
||||
'cid': 13,
|
||||
'name': 'btn_clear_breakpoints',
|
||||
'label': 'Accesskey (Clear all breakpoints)',
|
||||
'type': 'keyboardshortcut',
|
||||
'help_str': null,
|
||||
'control_props': {},
|
||||
'min_val': null,
|
||||
'max_val': null,
|
||||
'options': null,
|
||||
'select': null,
|
||||
'value': {
|
||||
'key': {
|
||||
'key_code': 88,
|
||||
'char': 'x'
|
||||
}
|
||||
},
|
||||
'fields': [
|
||||
{
|
||||
'name': 'key',
|
||||
'type': 'keyCode',
|
||||
'label': 'Key'
|
||||
}
|
||||
],
|
||||
'disabled': false,
|
||||
'dependents': null,
|
||||
'mid': 83,
|
||||
'module': 'debugger',
|
||||
}
|
||||
|
||||
];
|
||||
// eslint-disable-next-line
|
||||
let docker = new wcDocker(
|
||||
'.dockerContainer', {
|
||||
allowContextMenu: false,
|
||||
allowCollapse: false,
|
||||
loadingClass: 'pg-sp-icon',
|
||||
});
|
||||
|
||||
tree = new TreeFake();
|
||||
pgAdmin.Browser.tree = tree;
|
||||
pgAdmin.Browser.docker = docker;
|
||||
|
||||
params = {
|
||||
transId: 1234,
|
||||
@@ -260,26 +49,25 @@ describe('Debugger Component', () => {
|
||||
networkMock = new MockAdapter(axios);
|
||||
});
|
||||
|
||||
it('DebuggerInit Indirect', () => {
|
||||
it('DebuggerInit Indirect', async () => {
|
||||
params.directDebugger.debug_type = 1;
|
||||
networkMock.onPost(url_for('debugger.start_listener', {'trans_id': params.transId})).reply(200, {'success':1,'errormsg':'','info':'','result':null,'data':{'status':true,'result':2}});
|
||||
networkMock.onGet(url_for('debugger.messages', {'trans_id': params.transId})).reply(200, {'success':1,'errormsg':'','info':'','result':null,'data':{'status':'Success','result':'10'}});
|
||||
networkMock.onGet(url_for('debugger.execute_query', {'trans_id': params.transId, 'query_type': 'get_stack_info'})).reply(200, {'success':1,'errormsg':'','info':'','result':null,'data':{'status':'Success','result':[{'level':0,'targetname':'_test()','func':3138947,'linenumber':9,'args':''}]}});
|
||||
networkMock.onGet(url_for('debugger.poll_result', {'trans_id': params.transId})).reply(200, {'success':0,'errormsg':'','info':'','result':null,'data':{'status':'Success','result':[{'pldbg_wait_for_target':28298}]}});
|
||||
let ctrl = mount(
|
||||
<Theme>
|
||||
<DebuggerComponent
|
||||
pgAdmin={pgAdmin}
|
||||
panel={document.getElementById('debugger-main-container')}
|
||||
selectedNodeInfo={nodeInfo}
|
||||
layout={''}
|
||||
params={params}
|
||||
>
|
||||
</DebuggerComponent>
|
||||
</Theme>
|
||||
);
|
||||
|
||||
ctrl.find('PgIconButton[data-test="debugger-contiue"]').props().onClick();
|
||||
await act(async () => {
|
||||
render(
|
||||
<Theme>
|
||||
<DebuggerComponent
|
||||
pgAdmin={pgAdmin}
|
||||
panel={document.getElementById('debugger-main-container')}
|
||||
selectedNodeInfo={nodeInfo}
|
||||
layout={''}
|
||||
params={params}
|
||||
/>
|
||||
</Theme>
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -7,50 +7,30 @@
|
||||
//
|
||||
//////////////////////////////////////////////////////////////
|
||||
|
||||
import $ from 'jquery';
|
||||
window.jQuery = window.$ = $;
|
||||
|
||||
import 'wcdocker';
|
||||
import '../helper/enzyme.helper';
|
||||
|
||||
import React from 'react';
|
||||
import { createMount } from '@material-ui/core/test-utils';
|
||||
import jasmineEnzyme from 'jasmine-enzyme';
|
||||
import { render } from '@testing-library/react';
|
||||
|
||||
import MockAdapter from 'axios-mock-adapter';
|
||||
import axios from 'axios';
|
||||
|
||||
import url_for from 'sources/url_for';
|
||||
import pgAdmin from 'sources/pgadmin';
|
||||
|
||||
import { messages } from '../fake_messages';
|
||||
import FunctionArguments from '../../../pgadmin/tools/debugger/static/js/debugger_ui';
|
||||
import Debugger from '../../../pgadmin/tools/debugger/static/js/DebuggerModule';
|
||||
import { TreeFake } from '../tree/tree_fake';
|
||||
import MockDebuggerComponent from './MockDebuggerComponent';
|
||||
import EventBus from '../../../pgadmin/static/js/helpers/EventBus';
|
||||
import { Stack } from '../../../pgadmin/tools/debugger/static/js/components/Stack';
|
||||
|
||||
|
||||
describe('Debugger Stack', () => {
|
||||
let mount;
|
||||
|
||||
let funcArgs;
|
||||
let debuggerInstance;
|
||||
let mountDOM;
|
||||
let tree;
|
||||
let params;
|
||||
let networkMock;
|
||||
let pref;
|
||||
|
||||
/* Use createMount so that material ui components gets the required context */
|
||||
/* https://material-ui.com/guides/testing/#api */
|
||||
beforeAll(() => {
|
||||
mount = createMount();
|
||||
});
|
||||
|
||||
afterAll(() => {
|
||||
mount.cleanUp();
|
||||
networkMock.restore();
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
networkMock.restore();
|
||||
@@ -58,211 +38,12 @@ describe('Debugger Stack', () => {
|
||||
|
||||
|
||||
beforeEach(() => {
|
||||
jasmineEnzyme();
|
||||
// Element for mount wcDocker panel
|
||||
mountDOM = $('<div class="dockerContainer">');
|
||||
$(document.body).append(mountDOM);
|
||||
const div = document.createElement('div');
|
||||
div.id = 'debugger-main-container';
|
||||
document.body.appendChild(div);
|
||||
|
||||
$(document.body).append($('<div id="debugger-main-container">'));
|
||||
|
||||
/* messages used by validators */
|
||||
pgAdmin.Browser = pgAdmin.Browser || {};
|
||||
pgAdmin.Browser.messages = pgAdmin.Browser.messages || messages;
|
||||
pgAdmin.Browser.utils = pgAdmin.Browser.utils || {};
|
||||
funcArgs = new FunctionArguments();
|
||||
debuggerInstance = new Debugger(pgAdmin, pgAdmin.Browser);
|
||||
pref = [
|
||||
{
|
||||
'id': 115,
|
||||
'cid': 13,
|
||||
'name': 'btn_step_into',
|
||||
'label': 'Accesskey (Step into)',
|
||||
'type': 'keyboardshortcut',
|
||||
'help_str': null,
|
||||
'control_props': {},
|
||||
'min_val': null,
|
||||
'max_val': null,
|
||||
'options': null,
|
||||
'select': null,
|
||||
'value': {
|
||||
'key': {
|
||||
'key_code': 73,
|
||||
'char': 'i'
|
||||
}
|
||||
},
|
||||
'fields': [
|
||||
{
|
||||
'name': 'key',
|
||||
'type': 'keyCode',
|
||||
'label': 'Key'
|
||||
}
|
||||
],
|
||||
'disabled': false,
|
||||
'dependents': null,
|
||||
'mid': 83,
|
||||
'module': 'debugger',
|
||||
}, {
|
||||
'id': 116,
|
||||
'cid': 13,
|
||||
'name': 'btn_step_over',
|
||||
'label': 'Accesskey (Step over)',
|
||||
'type': 'keyboardshortcut',
|
||||
'help_str': null,
|
||||
'control_props': {},
|
||||
'min_val': null,
|
||||
'max_val': null,
|
||||
'options': null,
|
||||
'select': null,
|
||||
'value': {
|
||||
'key': {
|
||||
'key_code': 79,
|
||||
'char': 'o'
|
||||
}
|
||||
},
|
||||
'fields': [
|
||||
{
|
||||
'name': 'key',
|
||||
'type': 'keyCode',
|
||||
'label': 'Key'
|
||||
}
|
||||
],
|
||||
'disabled': false,
|
||||
'dependents': null,
|
||||
'mid': 83,
|
||||
'module': 'debugger',
|
||||
},
|
||||
{
|
||||
'id': 113,
|
||||
'cid': 13,
|
||||
'name': 'btn_start',
|
||||
'label': 'Accesskey (Continue/Start)',
|
||||
'type': 'keyboardshortcut',
|
||||
'help_str': null,
|
||||
'control_props': {},
|
||||
'min_val': null,
|
||||
'max_val': null,
|
||||
'options': null,
|
||||
'select': null,
|
||||
'value': {
|
||||
'key': {
|
||||
'key_code': 67,
|
||||
'char': 'c'
|
||||
}
|
||||
},
|
||||
'fields': [
|
||||
{
|
||||
'name': 'key',
|
||||
'type': 'keyCode',
|
||||
'label': 'Key'
|
||||
}
|
||||
],
|
||||
'disabled': false,
|
||||
'dependents': null,
|
||||
'mid': 83,
|
||||
'module': 'debugger',
|
||||
}, {
|
||||
'id': 114,
|
||||
'cid': 13,
|
||||
'name': 'btn_stop',
|
||||
'label': 'Accesskey (Stop)',
|
||||
'type': 'keyboardshortcut',
|
||||
'help_str': null,
|
||||
'control_props': {},
|
||||
'min_val': null,
|
||||
'max_val': null,
|
||||
'options': null,
|
||||
'select': null,
|
||||
'value': {
|
||||
'key': {
|
||||
'key_code': 83,
|
||||
'char': 's'
|
||||
}
|
||||
},
|
||||
'fields': [
|
||||
{
|
||||
'name': 'key',
|
||||
'type': 'keyCode',
|
||||
'label': 'Key'
|
||||
}
|
||||
],
|
||||
'disabled': false,
|
||||
'dependents': null,
|
||||
'mid': 83,
|
||||
'module': 'debugger',
|
||||
}, {
|
||||
'id': 117,
|
||||
'cid': 13,
|
||||
'name': 'btn_toggle_breakpoint',
|
||||
'label': 'Accesskey (Toggle breakpoint)',
|
||||
'type': 'keyboardshortcut',
|
||||
'help_str': null,
|
||||
'control_props': {},
|
||||
'min_val': null,
|
||||
'max_val': null,
|
||||
'options': null,
|
||||
'select': null,
|
||||
'value': {
|
||||
'key': {
|
||||
'key_code': 84,
|
||||
'char': 't'
|
||||
}
|
||||
},
|
||||
'fields': [
|
||||
{
|
||||
'name': 'key',
|
||||
'type': 'keyCode',
|
||||
'label': 'Key'
|
||||
}
|
||||
],
|
||||
'disabled': false,
|
||||
'dependents': null,
|
||||
'mid': 83,
|
||||
'module': 'debugger',
|
||||
}, {
|
||||
'id': 118,
|
||||
'cid': 13,
|
||||
'name': 'btn_clear_breakpoints',
|
||||
'label': 'Accesskey (Clear all breakpoints)',
|
||||
'type': 'keyboardshortcut',
|
||||
'help_str': null,
|
||||
'control_props': {},
|
||||
'min_val': null,
|
||||
'max_val': null,
|
||||
'options': null,
|
||||
'select': null,
|
||||
'value': {
|
||||
'key': {
|
||||
'key_code': 88,
|
||||
'char': 'x'
|
||||
}
|
||||
},
|
||||
'fields': [
|
||||
{
|
||||
'name': 'key',
|
||||
'type': 'keyCode',
|
||||
'label': 'Key'
|
||||
}
|
||||
],
|
||||
'disabled': false,
|
||||
'dependents': null,
|
||||
'mid': 83,
|
||||
'module': 'debugger',
|
||||
}
|
||||
|
||||
];
|
||||
|
||||
pgAdmin.Browser.preferences_cache = pref;
|
||||
// eslint-disable-next-line
|
||||
let docker = new wcDocker(
|
||||
'.dockerContainer', {
|
||||
allowContextMenu: false,
|
||||
allowCollapse: false,
|
||||
loadingClass: 'pg-sp-icon',
|
||||
});
|
||||
|
||||
tree = new TreeFake();
|
||||
pgAdmin.Browser.tree = tree;
|
||||
pgAdmin.Browser.docker = docker;
|
||||
|
||||
params = {
|
||||
transId: 1234,
|
||||
@@ -274,7 +55,7 @@ describe('Debugger Stack', () => {
|
||||
|
||||
it('Statck Init', () => {
|
||||
networkMock.onGet(url_for('debugger.select_frame', { 'trans_id': params.transId, 'frame_id': 3 })).reply(200, {'success':0,'errormsg':'','info':'','result':null,'data':{'status':true,'result':[{'func':3138947,'targetname':'_test()','linenumber':10,'src':'\nDECLARE\n v_deptno NUMERIC;\n v_empno NUMERIC;\n v_ename VARCHAR;\n v_rows INTEGER;\n r_emp_query EMP_QUERY_TYPE;\nBEGIN\n v_deptno := 30;\n v_empno := 0;\n v_ename := \'Martin\';\n r_emp_query := emp_query(v_deptno, v_empno, v_ename);\n RAISE INFO \'Department : %\', v_deptno;\n RAISE INFO \'Employee No: %\', (r_emp_query).empno;\n RAISE INFO \'Name : %\', (r_emp_query).ename;\n RAISE INFO \'Job : %\', (r_emp_query).job;\n RAISE INFO \'Hire Date : %\', (r_emp_query).hiredate;\n RAISE INFO \'Salary : %\', (r_emp_query).sal;\n RETURN \'1\';\nEXCEPTION\n WHEN OTHERS THEN\n RAISE INFO \'The following is SQLERRM : %\', SQLERRM;\n RAISE INFO \'The following is SQLSTATE: %\', SQLSTATE;\n RETURN \'1\';\nEND;\n','args':''}]}});
|
||||
mount(
|
||||
render(
|
||||
<MockDebuggerComponent value={{
|
||||
docker: '',
|
||||
api: networkMock,
|
||||
|
||||
@@ -7,261 +7,91 @@
|
||||
//
|
||||
//////////////////////////////////////////////////////////////
|
||||
|
||||
import $ from 'jquery';
|
||||
window.jQuery = window.$ = $;
|
||||
|
||||
import 'wcdocker';
|
||||
import '../helper/enzyme.helper';
|
||||
|
||||
import React from 'react';
|
||||
import { createMount } from '@material-ui/core/test-utils';
|
||||
import jasmineEnzyme from 'jasmine-enzyme';
|
||||
import { render } from '@testing-library/react';
|
||||
import userEvent from '@testing-library/user-event';
|
||||
|
||||
import MockAdapter from 'axios-mock-adapter';
|
||||
import axios from 'axios';
|
||||
|
||||
import url_for from 'sources/url_for';
|
||||
import pgAdmin from 'sources/pgadmin';
|
||||
|
||||
import { messages } from '../fake_messages';
|
||||
import FunctionArguments from '../../../pgadmin/tools/debugger/static/js/debugger_ui';
|
||||
import Debugger from '../../../pgadmin/tools/debugger/static/js/DebuggerModule';
|
||||
import { TreeFake } from '../tree/tree_fake';
|
||||
import MockDebuggerComponent from './MockDebuggerComponent';
|
||||
import EventBus from '../../../pgadmin/static/js/helpers/EventBus';
|
||||
import { ToolBar } from '../../../pgadmin/tools/debugger/static/js/components/ToolBar';
|
||||
import usePreferences from '../../../pgadmin/preferences/static/js/store';
|
||||
|
||||
|
||||
describe('Debugger Toolbar', () => {
|
||||
let mount;
|
||||
|
||||
let funcArgs;
|
||||
let debuggerInstance;
|
||||
let mountDOM;
|
||||
let tree;
|
||||
let params;
|
||||
let networkMock;
|
||||
let pref;
|
||||
|
||||
/* Use createMount so that material ui components gets the required context */
|
||||
/* https://material-ui.com/guides/testing/#api */
|
||||
beforeAll(() => {
|
||||
mount = createMount();
|
||||
});
|
||||
|
||||
afterAll(() => {
|
||||
mount.cleanUp();
|
||||
networkMock.restore();
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
networkMock.restore();
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
jasmineEnzyme();
|
||||
// Element for mount wcDocker panel
|
||||
mountDOM = $('<div class="dockerContainer">');
|
||||
$(document.body).append(mountDOM);
|
||||
|
||||
$(document.body).append($('<div id="debugger-main-container">'));
|
||||
|
||||
/* messages used by validators */
|
||||
pgAdmin.Browser = pgAdmin.Browser || {};
|
||||
pgAdmin.Browser.messages = pgAdmin.Browser.messages || messages;
|
||||
pgAdmin.Browser.utils = pgAdmin.Browser.utils || {};
|
||||
const div = document.createElement('div');
|
||||
div.id = 'debugger-main-container';
|
||||
document.body.appendChild(div);
|
||||
|
||||
|
||||
funcArgs = new FunctionArguments();
|
||||
debuggerInstance = new Debugger(pgAdmin, pgAdmin.Browser);
|
||||
pref = [
|
||||
{
|
||||
'id': 115,
|
||||
'cid': 13,
|
||||
'name': 'btn_step_into',
|
||||
'label': 'Accesskey (Step into)',
|
||||
'type': 'keyboardshortcut',
|
||||
'help_str': null,
|
||||
'control_props': {},
|
||||
'min_val': null,
|
||||
'max_val': null,
|
||||
'options': null,
|
||||
'select': null,
|
||||
'value': {
|
||||
jest.spyOn(usePreferences.getState(), 'getPreferencesForModule').mockReturnValue({
|
||||
breadcrumbs_enable: true,
|
||||
breadcrumbs_show_comment: true,
|
||||
});
|
||||
pref = {
|
||||
debugger: {
|
||||
btn_step_into: {
|
||||
'key': {
|
||||
'key_code': 73,
|
||||
'char': 'i'
|
||||
}
|
||||
},
|
||||
'fields': [
|
||||
{
|
||||
'name': 'key',
|
||||
'type': 'keyCode',
|
||||
'label': 'Key'
|
||||
}
|
||||
],
|
||||
'disabled': false,
|
||||
'dependents': null,
|
||||
'mid': 83,
|
||||
'module': 'debugger',
|
||||
}, {
|
||||
'id': 116,
|
||||
'cid': 13,
|
||||
'name': 'btn_step_over',
|
||||
'label': 'Accesskey (Step over)',
|
||||
'type': 'keyboardshortcut',
|
||||
'help_str': null,
|
||||
'control_props': {},
|
||||
'min_val': null,
|
||||
'max_val': null,
|
||||
'options': null,
|
||||
'select': null,
|
||||
'value': {
|
||||
btn_step_over: {
|
||||
'key': {
|
||||
'key_code': 79,
|
||||
'char': 'o'
|
||||
}
|
||||
},
|
||||
'fields': [
|
||||
{
|
||||
'name': 'key',
|
||||
'type': 'keyCode',
|
||||
'label': 'Key'
|
||||
}
|
||||
],
|
||||
'disabled': false,
|
||||
'dependents': null,
|
||||
'mid': 83,
|
||||
'module': 'debugger',
|
||||
},
|
||||
{
|
||||
'id': 113,
|
||||
'cid': 13,
|
||||
'name': 'btn_start',
|
||||
'label': 'Accesskey (Continue/Start)',
|
||||
'type': 'keyboardshortcut',
|
||||
'help_str': null,
|
||||
'control_props': {},
|
||||
'min_val': null,
|
||||
'max_val': null,
|
||||
'options': null,
|
||||
'select': null,
|
||||
'value': {
|
||||
btn_start: {
|
||||
'key': {
|
||||
'key_code': 67,
|
||||
'char': 'c'
|
||||
}
|
||||
},
|
||||
'fields': [
|
||||
{
|
||||
'name': 'key',
|
||||
'type': 'keyCode',
|
||||
'label': 'Key'
|
||||
}
|
||||
],
|
||||
'disabled': false,
|
||||
'dependents': null,
|
||||
'mid': 83,
|
||||
'module': 'debugger',
|
||||
}, {
|
||||
'id': 114,
|
||||
'cid': 13,
|
||||
'name': 'btn_stop',
|
||||
'label': 'Accesskey (Stop)',
|
||||
'type': 'keyboardshortcut',
|
||||
'help_str': null,
|
||||
'control_props': {},
|
||||
'min_val': null,
|
||||
'max_val': null,
|
||||
'options': null,
|
||||
'select': null,
|
||||
'value': {
|
||||
btn_stop: {
|
||||
'key': {
|
||||
'key_code': 83,
|
||||
'char': 's'
|
||||
}
|
||||
},
|
||||
'fields': [
|
||||
{
|
||||
'name': 'key',
|
||||
'type': 'keyCode',
|
||||
'label': 'Key'
|
||||
}
|
||||
],
|
||||
'disabled': false,
|
||||
'dependents': null,
|
||||
'mid': 83,
|
||||
'module': 'debugger',
|
||||
}, {
|
||||
'id': 117,
|
||||
'cid': 13,
|
||||
'name': 'btn_toggle_breakpoint',
|
||||
'label': 'Accesskey (Toggle breakpoint)',
|
||||
'type': 'keyboardshortcut',
|
||||
'help_str': null,
|
||||
'control_props': {},
|
||||
'min_val': null,
|
||||
'max_val': null,
|
||||
'options': null,
|
||||
'select': null,
|
||||
'value': {
|
||||
btn_toggle_breakpoint: {
|
||||
'key': {
|
||||
'key_code': 84,
|
||||
'char': 't'
|
||||
}
|
||||
},
|
||||
'fields': [
|
||||
{
|
||||
'name': 'key',
|
||||
'type': 'keyCode',
|
||||
'label': 'Key'
|
||||
}
|
||||
],
|
||||
'disabled': false,
|
||||
'dependents': null,
|
||||
'mid': 83,
|
||||
'module': 'debugger',
|
||||
}, {
|
||||
'id': 118,
|
||||
'cid': 13,
|
||||
'name': 'btn_clear_breakpoints',
|
||||
'label': 'Accesskey (Clear all breakpoints)',
|
||||
'type': 'keyboardshortcut',
|
||||
'help_str': null,
|
||||
'control_props': {},
|
||||
'min_val': null,
|
||||
'max_val': null,
|
||||
'options': null,
|
||||
'select': null,
|
||||
'value': {
|
||||
btn_clear_breakpoints: {
|
||||
'key': {
|
||||
'key_code': 88,
|
||||
'char': 'x'
|
||||
}
|
||||
},
|
||||
'fields': [
|
||||
{
|
||||
'name': 'key',
|
||||
'type': 'keyCode',
|
||||
'label': 'Key'
|
||||
}
|
||||
],
|
||||
'disabled': false,
|
||||
'dependents': null,
|
||||
'mid': 83,
|
||||
'module': 'debugger',
|
||||
}
|
||||
|
||||
];
|
||||
|
||||
pgAdmin.Browser.preferences_cache = pref;
|
||||
// eslint-disable-next-line
|
||||
let docker = new wcDocker(
|
||||
'.dockerContainer', {
|
||||
allowContextMenu: false,
|
||||
allowCollapse: false,
|
||||
loadingClass: 'pg-sp-icon',
|
||||
});
|
||||
|
||||
tree = new TreeFake();
|
||||
pgAdmin.Browser.tree = tree;
|
||||
pgAdmin.Browser.docker = docker;
|
||||
};
|
||||
|
||||
params = {
|
||||
transId: 1234,
|
||||
@@ -271,125 +101,124 @@ describe('Debugger Toolbar', () => {
|
||||
networkMock = new MockAdapter(axios);
|
||||
});
|
||||
|
||||
it('Toolbar clearbreakpoints', () => {
|
||||
it('Toolbar clearbreakpoints', async () => {
|
||||
networkMock.onGet(url_for('debugger.clear_all_breakpoint', { 'trans_id': params.transId })).reply(200, { 'success': 1, 'errormsg': '', 'info': '', 'result': null, 'data': { 'status': true, 'result': 2 } });
|
||||
let ctrl = mount(
|
||||
let ctrl = render(
|
||||
<MockDebuggerComponent value={{
|
||||
docker: '',
|
||||
api: networkMock,
|
||||
modal: {},
|
||||
params: params,
|
||||
preferences: pgAdmin.Browser.preferences_cache,
|
||||
preferences: pref,
|
||||
}}
|
||||
eventsvalue={new EventBus()}>
|
||||
<ToolBar></ToolBar>
|
||||
</MockDebuggerComponent>
|
||||
);
|
||||
ctrl.find('PgIconButton[data-test="clear-breakpoint"]').props().onClick();
|
||||
const user = userEvent.setup();
|
||||
await user.click(ctrl.container.querySelector('[data-test="clear-breakpoint"]'));
|
||||
});
|
||||
|
||||
it('Toolbar Stop Debugger', () => {
|
||||
it('Toolbar Stop Debugger', async () => {
|
||||
networkMock.onGet(url_for('debugger.execute_query', { 'trans_id': params.transId, 'query_type': 'abort_target'})).reply(200, {'success':1,'errormsg':'','info':'Debugging aborted successfully.','result':null,'data':{'status':'Success','result':{'columns':[{'name':'pldbg_abort_target','type_code':16,'display_size':null,'internal_size':1,'precision':null,'scale':null,'null_ok':null,'table_oid':null,'table_column':null,'display_name':'pldbg_abort_target'}],'rows':[{'pldbg_abort_target':true}]}}});
|
||||
let ctrl = mount(
|
||||
render(
|
||||
<MockDebuggerComponent value={{
|
||||
docker: '',
|
||||
api: networkMock,
|
||||
modal: {},
|
||||
params: params,
|
||||
preferences: pgAdmin.Browser.preferences_cache,
|
||||
preferences: pref,
|
||||
}}
|
||||
eventsvalue={new EventBus()}>
|
||||
<ToolBar></ToolBar>
|
||||
</MockDebuggerComponent>
|
||||
);
|
||||
ctrl.find('PgIconButton[data-test="stop-debugger"]').props().onClick();
|
||||
});
|
||||
|
||||
|
||||
it('Toolbar Toggle Breakpoint', () => {
|
||||
it('Toolbar Toggle Breakpoint', async () => {
|
||||
networkMock.onGet(url_for('debugger.set_breakpoint', { 'trans_id': params.transId, 'line_no': '1', 'set_type': 1})).reply(200, {'success':1,'errormsg':'','info':'','result':null,'data':{'status':true,'result':[{'pldbg_set_breakpoint':true}]}});
|
||||
let ctrl = mount(
|
||||
render(
|
||||
<MockDebuggerComponent value={{
|
||||
docker: '',
|
||||
api: networkMock,
|
||||
modal: {},
|
||||
params: params,
|
||||
preferences: pgAdmin.Browser.preferences_cache,
|
||||
preferences: pref,
|
||||
}}
|
||||
eventsvalue={new EventBus()}>
|
||||
<ToolBar></ToolBar>
|
||||
</MockDebuggerComponent>
|
||||
);
|
||||
ctrl.find('PgIconButton[data-test="toggle-breakpoint"]').props().onClick();
|
||||
});
|
||||
|
||||
|
||||
it('Toolbar StepIn', () => {
|
||||
it('Toolbar StepIn', async () => {
|
||||
networkMock.onGet(url_for('debugger.execute_query', { 'trans_id': params.transId, 'query_type': 'step_into'})).reply(200, {'success':1,'errormsg':'','info':'','result':null,'data':{'status':true,'result':1}});
|
||||
let ctrl = mount(
|
||||
render(
|
||||
<MockDebuggerComponent value={{
|
||||
docker: '',
|
||||
api: networkMock,
|
||||
modal: {},
|
||||
params: params,
|
||||
preferences: pgAdmin.Browser.preferences_cache,
|
||||
preferences: pref,
|
||||
}}
|
||||
eventsvalue={new EventBus()}>
|
||||
<ToolBar></ToolBar>
|
||||
</MockDebuggerComponent>
|
||||
);
|
||||
ctrl.find('PgIconButton[data-test="step-in"]').props().onClick();
|
||||
});
|
||||
|
||||
it('Toolbar StepOver', () => {
|
||||
it('Toolbar StepOver', async () => {
|
||||
networkMock.onGet(url_for('debugger.execute_query', { 'trans_id': params.transId, 'query_type': 'step_over'})).reply(200, {'success':1,'errormsg':'','info':'','result':null,'data':{'status':true,'result':1}});
|
||||
let ctrl = mount(
|
||||
render(
|
||||
<MockDebuggerComponent value={{
|
||||
docker: '',
|
||||
api: networkMock,
|
||||
modal: {},
|
||||
params: params,
|
||||
preferences: pgAdmin.Browser.preferences_cache,
|
||||
preferences: pref,
|
||||
}}
|
||||
eventsvalue={new EventBus()}>
|
||||
<ToolBar></ToolBar>
|
||||
</MockDebuggerComponent>
|
||||
);
|
||||
ctrl.find('PgIconButton[data-test="step-over"]').props().onClick();
|
||||
});
|
||||
|
||||
it('Toolbar Contiue', () => {
|
||||
it('Toolbar Continue', async () => {
|
||||
networkMock.onGet(url_for('debugger.execute_query', { 'trans_id': params.transId, 'query_type': 'continue'})).reply(200, {'success':1,'errormsg':'','info':'','result':null,'data':{'status':true,'result':2}});
|
||||
let ctrl = mount(
|
||||
render(
|
||||
<MockDebuggerComponent value={{
|
||||
docker: '',
|
||||
api: networkMock,
|
||||
modal: {},
|
||||
params: params,
|
||||
preferences: pgAdmin.Browser.preferences_cache,
|
||||
preferences: pref,
|
||||
}}
|
||||
eventsvalue={new EventBus()}>
|
||||
<ToolBar></ToolBar>
|
||||
</MockDebuggerComponent>
|
||||
);
|
||||
ctrl.find('PgIconButton[data-test="debugger-contiue"]').props().onClick();
|
||||
});
|
||||
|
||||
it('Toolbar Help', () => {
|
||||
it('Toolbar Help', async () => {
|
||||
networkMock.onGet(url_for('help.static', {'filename': 'debugger.html'})).reply(200, {});
|
||||
let ctrl = mount(
|
||||
window.open = jest.fn();
|
||||
let ctrl = render(
|
||||
<MockDebuggerComponent value={{
|
||||
docker: '',
|
||||
api: networkMock,
|
||||
modal: {},
|
||||
params: params,
|
||||
preferences: pgAdmin.Browser.preferences_cache,
|
||||
preferences: pref,
|
||||
}}
|
||||
eventsvalue={new EventBus()}>
|
||||
<ToolBar></ToolBar>
|
||||
</MockDebuggerComponent>
|
||||
);
|
||||
ctrl.find('PgIconButton[data-test="debugger-help"]').props().onClick();
|
||||
const user = userEvent.setup();
|
||||
await user.click(ctrl.container.querySelector('[data-test="debugger-help"]'));
|
||||
window.open.mockClear();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
79
web/regression/javascript/debugger/debugger_utils_spec.js
Normal file
79
web/regression/javascript/debugger/debugger_utils_spec.js
Normal file
@@ -0,0 +1,79 @@
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// pgAdmin 4 - PostgreSQL Tools
|
||||
//
|
||||
// Copyright (C) 2013 - 2023, The pgAdmin Development Team
|
||||
// This software is released under the PostgreSQL Licence
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
import {
|
||||
getProcedureId,
|
||||
getFunctionId,
|
||||
} from '../../../pgadmin/tools/debugger/static/js/debugger_utils';
|
||||
|
||||
describe('getProcedureId', function () {
|
||||
let treeInfroProc = {
|
||||
'procedure': {
|
||||
'_id': 123,
|
||||
},
|
||||
};
|
||||
let treeInfroInvalidProcId = {
|
||||
'procedure': {
|
||||
'_id': null,
|
||||
},
|
||||
};
|
||||
let treeInfroEdbProc = {
|
||||
'edbproc': {
|
||||
'_id': 321,
|
||||
},
|
||||
};
|
||||
let fakeTreeInfro;
|
||||
|
||||
describe('Should return proper object id', function () {
|
||||
it('returns valid procedure id', function () {
|
||||
expect(getProcedureId(treeInfroProc)).toEqual(123);
|
||||
});
|
||||
|
||||
it('returns valid edbproc id', function () {
|
||||
expect(getProcedureId(treeInfroEdbProc)).toEqual(321);
|
||||
});
|
||||
|
||||
it('returns undefined for fake tree info', function () {
|
||||
expect(getProcedureId(fakeTreeInfro)).toEqual(undefined);
|
||||
});
|
||||
|
||||
it('returns undefined for invalid procedure id', function () {
|
||||
expect(getProcedureId(treeInfroInvalidProcId)).toEqual(undefined);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('getFunctionId', function () {
|
||||
let treeInfroFunc = {
|
||||
'function': {
|
||||
'_id': 123,
|
||||
},
|
||||
};
|
||||
let treeInfroInvalidFuncId = {
|
||||
'function': {
|
||||
'_id': null,
|
||||
},
|
||||
};
|
||||
|
||||
let fakeTreeInfro;
|
||||
|
||||
describe('Should return proper object id', function () {
|
||||
it('returns valid function id', function () {
|
||||
expect(getFunctionId(treeInfroFunc)).toEqual(123);
|
||||
});
|
||||
|
||||
it('returns undefined for fake tree info', function () {
|
||||
expect(getFunctionId(fakeTreeInfro)).toEqual(undefined);
|
||||
});
|
||||
|
||||
it('returns undefined for invalid function id', function () {
|
||||
expect(getFunctionId(treeInfroInvalidFuncId)).toEqual(undefined);
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user