pgadmin4/web/regression/javascript/schema_ui_files/pga_jobstep.ui.spec.js
Aditya Toshniwal 862f101772
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.
2023-10-23 17:43:17 +05:30

116 lines
3.4 KiB
JavaScript

/////////////////////////////////////////////////////////////
//
// pgAdmin 4 - PostgreSQL Tools
//
// Copyright (C) 2013 - 2023, The pgAdmin Development Team
// This software is released under the PostgreSQL Licence
//
//////////////////////////////////////////////////////////////
import PgaJobStepSchema from '../../../pgadmin/browser/server_groups/servers/pgagent/steps/static/js/pga_jobstep.ui';
import {genericBeforeEach, getCreateView, getEditView, getPropertiesView} from '../genericFunctions';
describe('PgaJobStepSchema', ()=>{
let schemaObj = new PgaJobStepSchema(
{
databases: ()=>[],
},
[],
{
jstdbname: 'postgres',
}
);
let getInitData = ()=>Promise.resolve({});
beforeEach(()=>{
genericBeforeEach();
});
it('create', async ()=>{
await getCreateView(schemaObj);
});
it('edit', async ()=>{
await getEditView(schemaObj, getInitData);
});
it('properties', async ()=>{
await getPropertiesView(schemaObj, getInitData);
});
it('validate', ()=>{
let state = {};
let setError = jest.fn();
state.name = 'my_step';
state.jstkind = true;
state.jstconntype = true;
setError.mockClear();
schemaObj.validate(state, setError);
expect(setError).toHaveBeenCalledWith('jstdbname', 'Please select a database.');
state.jstdbname = 'postgres';
setError.mockClear();
schemaObj.validate(state, setError);
expect(setError).toHaveBeenCalledWith('jstdbname', null);
state.jstconntype = false;
state.jstconnstr = null;
setError.mockClear();
schemaObj.validate(state, setError);
expect(setError).toHaveBeenCalledWith('jstconnstr', 'Please enter a connection string.');
state.jstconnstr = '**!!';
setError.mockClear();
schemaObj.validate(state, setError);
expect(setError).toHaveBeenCalledWith('jstconnstr', 'Please enter a valid connection string.');
state.jstconnstr = 'host:\'192.168.1.7\'';
setError.mockClear();
schemaObj.validate(state, setError);
expect(setError).toHaveBeenCalledWith('jstconnstr', 'Please enter a valid connection string.');
state.jstconnstr = 'host:\'192.168.1.7\'';
setError.mockClear();
schemaObj.validate(state, setError);
expect(setError).toHaveBeenCalledWith('jstconnstr', 'Please enter a valid connection string.');
state.jstconnstr = 'hostaddrtest=\'192.168.1.7\'';
setError.mockClear();
schemaObj.validate(state, setError);
expect(setError).toHaveBeenCalledWith('jstconnstr', 'Invalid parameter in the connection string - hostaddrtest.');
state.jstconnstr = 'host=\'192.168.1.7\' port=5432';
setError.mockClear();
schemaObj.validate(state, setError);
expect(setError).toHaveBeenCalledWith('jstconnstr', null);
state.jstcode = null;
setError.mockClear();
schemaObj.validate(state, setError);
expect(setError).toHaveBeenCalledWith('jstcode', 'Please specify code to execute.');
state.jstcode = 'PERFORM 1;';
setError.mockClear();
schemaObj.validate(state, setError);
expect(setError).toHaveBeenCalledWith('jstcode', null);
state.jstonerror = null;
setError.mockClear();
schemaObj.validate(state, setError);
expect(setError).toHaveBeenCalledWith('jstonerror', 'Please select valid on error option.');
state.jstonerror = 'f';
setError.mockClear();
schemaObj.validate(state, setError);
expect(setError).toHaveBeenCalledWith('jstonerror', null);
});
});