mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2024-11-22 08:46:39 -06:00
862f101772
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.
225 lines
6.7 KiB
JavaScript
225 lines
6.7 KiB
JavaScript
/////////////////////////////////////////////////////////////
|
|
//
|
|
// pgAdmin 4 - PostgreSQL Tools
|
|
//
|
|
// Copyright (C) 2013 - 2023, The pgAdmin Development Team
|
|
// This software is released under the PostgreSQL Licence
|
|
//
|
|
//////////////////////////////////////////////////////////////
|
|
|
|
import React from 'react';
|
|
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 FunctionArguments from '../../../pgadmin/tools/debugger/static/js/debugger_ui';
|
|
import Debugger from '../../../pgadmin/tools/debugger/static/js/DebuggerModule';
|
|
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 funcArgs;
|
|
let debuggerInstance;
|
|
let params;
|
|
let networkMock;
|
|
let pref;
|
|
|
|
|
|
afterEach(() => {
|
|
networkMock.restore();
|
|
});
|
|
|
|
beforeEach(() => {
|
|
|
|
|
|
const div = document.createElement('div');
|
|
div.id = 'debugger-main-container';
|
|
document.body.appendChild(div);
|
|
|
|
|
|
funcArgs = new FunctionArguments();
|
|
debuggerInstance = new Debugger(pgAdmin, pgAdmin.Browser);
|
|
jest.spyOn(usePreferences.getState(), 'getPreferencesForModule').mockReturnValue({
|
|
breadcrumbs_enable: true,
|
|
breadcrumbs_show_comment: true,
|
|
});
|
|
pref = {
|
|
debugger: {
|
|
btn_step_into: {
|
|
'key': {
|
|
'key_code': 73,
|
|
'char': 'i'
|
|
}
|
|
},
|
|
btn_step_over: {
|
|
'key': {
|
|
'key_code': 79,
|
|
'char': 'o'
|
|
}
|
|
},
|
|
btn_start: {
|
|
'key': {
|
|
'key_code': 67,
|
|
'char': 'c'
|
|
}
|
|
},
|
|
btn_stop: {
|
|
'key': {
|
|
'key_code': 83,
|
|
'char': 's'
|
|
}
|
|
},
|
|
btn_toggle_breakpoint: {
|
|
'key': {
|
|
'key_code': 84,
|
|
'char': 't'
|
|
}
|
|
},
|
|
btn_clear_breakpoints: {
|
|
'key': {
|
|
'key_code': 88,
|
|
'char': 'x'
|
|
}
|
|
},
|
|
}
|
|
};
|
|
|
|
params = {
|
|
transId: 1234,
|
|
directDebugger: debuggerInstance,
|
|
funcArgsInstance: funcArgs
|
|
};
|
|
networkMock = new MockAdapter(axios);
|
|
});
|
|
|
|
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 = render(
|
|
<MockDebuggerComponent value={{
|
|
docker: '',
|
|
api: networkMock,
|
|
modal: {},
|
|
params: params,
|
|
preferences: pref,
|
|
}}
|
|
eventsvalue={new EventBus()}>
|
|
<ToolBar></ToolBar>
|
|
</MockDebuggerComponent>
|
|
);
|
|
const user = userEvent.setup();
|
|
await user.click(ctrl.container.querySelector('[data-test="clear-breakpoint"]'));
|
|
});
|
|
|
|
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}]}}});
|
|
render(
|
|
<MockDebuggerComponent value={{
|
|
docker: '',
|
|
api: networkMock,
|
|
modal: {},
|
|
params: params,
|
|
preferences: pref,
|
|
}}
|
|
eventsvalue={new EventBus()}>
|
|
<ToolBar></ToolBar>
|
|
</MockDebuggerComponent>
|
|
);
|
|
});
|
|
|
|
|
|
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}]}});
|
|
render(
|
|
<MockDebuggerComponent value={{
|
|
docker: '',
|
|
api: networkMock,
|
|
modal: {},
|
|
params: params,
|
|
preferences: pref,
|
|
}}
|
|
eventsvalue={new EventBus()}>
|
|
<ToolBar></ToolBar>
|
|
</MockDebuggerComponent>
|
|
);
|
|
});
|
|
|
|
|
|
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}});
|
|
render(
|
|
<MockDebuggerComponent value={{
|
|
docker: '',
|
|
api: networkMock,
|
|
modal: {},
|
|
params: params,
|
|
preferences: pref,
|
|
}}
|
|
eventsvalue={new EventBus()}>
|
|
<ToolBar></ToolBar>
|
|
</MockDebuggerComponent>
|
|
);
|
|
});
|
|
|
|
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}});
|
|
render(
|
|
<MockDebuggerComponent value={{
|
|
docker: '',
|
|
api: networkMock,
|
|
modal: {},
|
|
params: params,
|
|
preferences: pref,
|
|
}}
|
|
eventsvalue={new EventBus()}>
|
|
<ToolBar></ToolBar>
|
|
</MockDebuggerComponent>
|
|
);
|
|
});
|
|
|
|
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}});
|
|
render(
|
|
<MockDebuggerComponent value={{
|
|
docker: '',
|
|
api: networkMock,
|
|
modal: {},
|
|
params: params,
|
|
preferences: pref,
|
|
}}
|
|
eventsvalue={new EventBus()}>
|
|
<ToolBar></ToolBar>
|
|
</MockDebuggerComponent>
|
|
);
|
|
});
|
|
|
|
it('Toolbar Help', async () => {
|
|
networkMock.onGet(url_for('help.static', {'filename': 'debugger.html'})).reply(200, {});
|
|
window.open = jest.fn();
|
|
let ctrl = render(
|
|
<MockDebuggerComponent value={{
|
|
docker: '',
|
|
api: networkMock,
|
|
modal: {},
|
|
params: params,
|
|
preferences: pref,
|
|
}}
|
|
eventsvalue={new EventBus()}>
|
|
<ToolBar></ToolBar>
|
|
</MockDebuggerComponent>
|
|
);
|
|
const user = userEvent.setup();
|
|
await user.click(ctrl.container.querySelector('[data-test="debugger-help"]'));
|
|
window.open.mockClear();
|
|
});
|
|
});
|
|
|