mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Improved the extendability of the SchemaView and DataGridView. (#7876)
Restructured these modules for ease of maintenance and apply the single responsibility principle (wherever applicable). * SchemaView - Split the code based on the functionality and responsibility. - Introduced a new View 'InlineView' instead of using the 'nextInline' configuration of the fields to have a better, and manageable view. - Using the separate class 'SchemaState' for managing the data and states of the SchemaView (separated from the 'useSchemaState' custom hook). - Introduced three new custom hooks 'useFieldValue', 'useFieldOptions', 'useFieldError' for the individual control to use for each Schema Field. - Don't pass value as the parameter props, and let the 'useFieldValue' and other custom hooks to decide, whether to rerender the control itself or the whole dialog/view. (single responsibility principle) - Introduced a new data store with a subscription facility. - Moving the field metadata (option) evaluation to a separate place for better management, and each option can be defined for a particular kind of field (for example - collection, row, cell, general, etc). - Allow to provide custom control for all kind of Schema field. * DataGridView - Same as SchemaView, split the DataGridView call into smaller, manageable chunks. (For example - grid, row, mappedCell, etc). - Use context based approach for providing the row and table data instead of passing them as parameters to every component separately. - Have a facility to extend this feature separately in future. (for example - selectable cell, column grouping, etc.) - Separated the features like deletable, editable, reorder, expandable etc. cells using the above feature support. - Added ability to provide the CustomHeader, and CustomRow through the Schema field, which will extend the ability to customize better. - Removed the 'DataGridViewWithHeaderForm' as it has been achieved through providing 'CustomHeader', and also introduced 'DataGridFormHeader' (a custom header) to achieve the same feature as 'DataGridViewWithHeaderForm'.
This commit is contained in:
157
web/regression/javascript/SchemaView/store.spec.js
Normal file
157
web/regression/javascript/SchemaView/store.spec.js
Normal file
@@ -0,0 +1,157 @@
|
||||
/////////////////////////////////////////////////////////////
|
||||
//
|
||||
// pgAdmin 4 - PostgreSQL Tools
|
||||
//
|
||||
// Copyright (C) 2013 - 2024, The pgAdmin Development Team
|
||||
// This software is released under the PostgreSQL Licence
|
||||
//
|
||||
//////////////////////////////////////////////////////////////
|
||||
|
||||
import { isValueEqual } from '../../../pgadmin/static/js/SchemaView/common';
|
||||
import {
|
||||
createStore
|
||||
} from '../../../pgadmin/static/js/SchemaView/SchemaState/store';
|
||||
|
||||
const initData = {
|
||||
id: 1,
|
||||
field1: 'field1val',
|
||||
field2: 1,
|
||||
fieldcoll: [
|
||||
{field3: 1, field4: 'field4val1', field5: 'field5val1'},
|
||||
{field3: 2, field4: 'field4val2', field5: 'field5val2'},
|
||||
],
|
||||
field3: 3,
|
||||
field4: 'field4val',
|
||||
};
|
||||
|
||||
describe('store', ()=>{
|
||||
describe('', () => {
|
||||
|
||||
it('getState', () => {
|
||||
const store = createStore(initData);
|
||||
const data = store.getState();
|
||||
expect(isValueEqual(data, initData)).toBe(true);
|
||||
});
|
||||
|
||||
it('get', () => {
|
||||
const store = createStore(initData);
|
||||
|
||||
const firstField3 = store.get(['fieldcoll', 0, 'field3']);
|
||||
expect(firstField3 == 1).toBe(true);
|
||||
|
||||
const firstFieldCollRow = store.get(['fieldcoll', '0']);
|
||||
// Sending a copy of the data, and not itself.
|
||||
expect(isValueEqual(firstFieldCollRow, initData.fieldcoll[0])).toBe(true);
|
||||
});
|
||||
|
||||
it('setState', () => {
|
||||
const store = createStore(initData);
|
||||
const newData = {a: 1};
|
||||
|
||||
store.setState(newData);
|
||||
|
||||
const newState = store.getState();
|
||||
expect(Object.is(newState, newData)).toBe(false);
|
||||
expect(isValueEqual(newState, newData)).toBe(true);
|
||||
});
|
||||
|
||||
it ('set', () => {
|
||||
const store = createStore(initData);
|
||||
const newData = {a: 1};
|
||||
|
||||
store.set(newData);
|
||||
|
||||
let newState = store.getState();
|
||||
expect(Object.is(newState, newData)).toBe(false);
|
||||
expect(isValueEqual(newState, newData)).toBe(true);
|
||||
|
||||
store.set((prevState) => ({...prevState, initData}));
|
||||
|
||||
newState = store.getState();
|
||||
expect(Object.is(newState, initData)).toBe(false);
|
||||
expect(isValueEqual(newState, initData)).toBe(false);
|
||||
|
||||
delete newState['a'];
|
||||
|
||||
store.set(() => (newState));
|
||||
|
||||
newState = store.getState();
|
||||
expect(isValueEqual(newState, initData)).toBe(false);
|
||||
});
|
||||
|
||||
it ('subscribe', () => {
|
||||
const store = createStore(initData);
|
||||
const listener = jest.fn();
|
||||
|
||||
const unsubscribe1 = store.subscribe(listener);
|
||||
store.set((prevState) => (prevState));
|
||||
|
||||
expect(listener).not.toHaveBeenCalled();
|
||||
|
||||
store.set((prevState) => {
|
||||
prevState.id = 2;
|
||||
return prevState;
|
||||
});
|
||||
|
||||
expect(listener).toHaveBeenCalled();
|
||||
|
||||
const listenForFirstField3 = jest.fn();
|
||||
const unsubscribe2 = store.subscribeForPath(
|
||||
['fieldcoll', '0', 'field3'], listenForFirstField3
|
||||
);
|
||||
const listenForSecondField3 = jest.fn();
|
||||
const unsubscribe3 = store.subscribeForPath(
|
||||
['fieldcoll', '1', 'field3'], listenForSecondField3
|
||||
);
|
||||
let changeTo = 10;
|
||||
|
||||
store.set((prevState) => {
|
||||
prevState.fieldcoll[0].field3 = changeTo;
|
||||
return prevState;
|
||||
});
|
||||
|
||||
expect(listenForFirstField3).toHaveBeenCalled();
|
||||
expect(listener).toHaveBeenCalledTimes(2);
|
||||
expect(listenForSecondField3).not.toHaveBeenCalled();
|
||||
|
||||
store.set((prevState) => {
|
||||
// There is no actual change from previous state.
|
||||
prevState.fieldcoll[0].field3 = 10;
|
||||
return prevState;
|
||||
});
|
||||
|
||||
// Not expecting it be called.
|
||||
expect(listenForFirstField3).toHaveBeenCalledTimes(1);
|
||||
expect(listener).toHaveBeenCalledTimes(2);
|
||||
expect(listenForSecondField3).not.toHaveBeenCalled();
|
||||
|
||||
unsubscribe1();
|
||||
|
||||
store.set((prevState) => {
|
||||
prevState.fieldcoll[0].field3 = 50;
|
||||
return prevState;
|
||||
});
|
||||
|
||||
// Don't expect this to be called again.
|
||||
expect(listener).toHaveBeenCalledTimes(2);
|
||||
// Expect this one to be called
|
||||
expect(listenForFirstField3).toHaveBeenCalledTimes(2);
|
||||
expect(listenForSecondField3).not.toHaveBeenCalled();
|
||||
|
||||
unsubscribe2();
|
||||
|
||||
store.set((prevState) => {
|
||||
prevState.fieldcoll[0].field3 = 100;
|
||||
return prevState;
|
||||
});
|
||||
|
||||
// Don't expect any of them to be called.
|
||||
expect(listener).toHaveBeenCalledTimes(2);
|
||||
expect(listenForFirstField3).toHaveBeenCalledTimes(2);
|
||||
expect(listenForSecondField3).not.toHaveBeenCalled();
|
||||
|
||||
unsubscribe3();
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
@@ -13,7 +13,7 @@ import {genericBeforeEach, getCreateView, getEditView, getPropertiesView} from '
|
||||
|
||||
describe('AggregateSchema', ()=>{
|
||||
|
||||
let schemaObj = new AggregateSchema();
|
||||
let createSchemaObj = () => new AggregateSchema();
|
||||
let getInitData = ()=>Promise.resolve({});
|
||||
|
||||
|
||||
@@ -25,15 +25,15 @@ describe('AggregateSchema', ()=>{
|
||||
});
|
||||
|
||||
it('create', async ()=>{
|
||||
await getCreateView(schemaObj);
|
||||
await getCreateView(createSchemaObj());
|
||||
});
|
||||
|
||||
it('edit', async ()=>{
|
||||
await getEditView(schemaObj, getInitData);
|
||||
await getEditView(createSchemaObj(), getInitData);
|
||||
});
|
||||
|
||||
it('properties', async ()=>{
|
||||
await getPropertiesView(schemaObj, getInitData);
|
||||
await getPropertiesView(createSchemaObj(), getInitData);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -14,12 +14,13 @@ import {genericBeforeEach, getCreateView, getEditView, getPropertiesView} from '
|
||||
|
||||
describe('CastSchema', ()=>{
|
||||
|
||||
let schemaObj = new CastSchema(
|
||||
let createSchemaObj = () => new CastSchema(
|
||||
{
|
||||
getTypeOptions: ()=>[],
|
||||
getFuncOptions: ()=>[],
|
||||
},
|
||||
);
|
||||
const schemaObj = createSchemaObj();
|
||||
let getInitData = ()=>Promise.resolve({});
|
||||
|
||||
|
||||
@@ -29,15 +30,15 @@ describe('CastSchema', ()=>{
|
||||
});
|
||||
|
||||
it('create', async ()=>{
|
||||
await getCreateView(schemaObj);
|
||||
await getCreateView(createSchemaObj());
|
||||
});
|
||||
|
||||
it('edit', async ()=>{
|
||||
await getEditView(schemaObj, getInitData);
|
||||
await getEditView(createSchemaObj(), getInitData);
|
||||
});
|
||||
|
||||
it('properties', async ()=>{
|
||||
await getPropertiesView(schemaObj, getInitData);
|
||||
await getPropertiesView(createSchemaObj(), getInitData);
|
||||
});
|
||||
|
||||
it('srctyp depChange', ()=>{
|
||||
|
||||
@@ -13,7 +13,7 @@ import {genericBeforeEach, getCreateView, getEditView, getPropertiesView} from '
|
||||
|
||||
describe('CatalogSchema', ()=>{
|
||||
|
||||
let catalogObj = new CatalogSchema(
|
||||
let createCatalogObj = () => new CatalogSchema(
|
||||
{
|
||||
namespaceowner: '',
|
||||
}
|
||||
@@ -29,15 +29,15 @@ describe('CatalogSchema', ()=>{
|
||||
});
|
||||
|
||||
it('create', async ()=>{
|
||||
await getCreateView(catalogObj);
|
||||
await getCreateView(createCatalogObj());
|
||||
});
|
||||
|
||||
it('edit', async ()=>{
|
||||
await getEditView(catalogObj, getInitData);
|
||||
await getEditView(createCatalogObj(), getInitData);
|
||||
});
|
||||
|
||||
it('properties', async ()=>{
|
||||
await getPropertiesView(catalogObj, getInitData);
|
||||
await getPropertiesView(createCatalogObj(), getInitData);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -13,23 +13,19 @@ import {genericBeforeEach, getCreateView, getPropertiesView} from '../genericFun
|
||||
|
||||
describe('CatalogObjectColumn', ()=>{
|
||||
|
||||
let schemaObj = new CatalogObjectColumn();
|
||||
let createSchemaObj = () => new CatalogObjectColumn();
|
||||
let getInitData = ()=>Promise.resolve({});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
beforeEach(()=>{
|
||||
genericBeforeEach();
|
||||
});
|
||||
|
||||
it('create', async ()=>{
|
||||
await getCreateView(schemaObj);
|
||||
await getCreateView(createSchemaObj());
|
||||
});
|
||||
|
||||
it('properties', async ()=>{
|
||||
await getPropertiesView(schemaObj, getInitData);
|
||||
await getPropertiesView(createSchemaObj(), getInitData);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
@@ -35,7 +35,8 @@ function getFieldDepChange(schema, id) {
|
||||
|
||||
describe('CheckConstraintSchema', ()=>{
|
||||
|
||||
let schemaObj = new CheckConstraintSchema();
|
||||
let createSchemaObj = () => new CheckConstraintSchema();
|
||||
let schemaObj = createSchemaObj();
|
||||
let getInitData = ()=>Promise.resolve({});
|
||||
|
||||
|
||||
@@ -47,15 +48,15 @@ describe('CheckConstraintSchema', ()=>{
|
||||
});
|
||||
|
||||
it('create', async ()=>{
|
||||
await getCreateView(schemaObj);
|
||||
await getCreateView(createSchemaObj());
|
||||
});
|
||||
|
||||
it('edit', async ()=>{
|
||||
await getEditView(schemaObj, getInitData);
|
||||
await getEditView(createSchemaObj(), getInitData);
|
||||
});
|
||||
|
||||
it('properties', async ()=>{
|
||||
await getPropertiesView(schemaObj, getInitData);
|
||||
await getPropertiesView(createSchemaObj(), getInitData);
|
||||
});
|
||||
|
||||
it('create collection', async ()=>{
|
||||
|
||||
@@ -12,8 +12,7 @@ import CollationSchema from '../../../pgadmin/browser/server_groups/servers/data
|
||||
import {genericBeforeEach, getCreateView, getEditView, getPropertiesView} from '../genericFunctions';
|
||||
|
||||
describe('CollationsSchema', () => {
|
||||
|
||||
let schemaObj = new CollationSchema(
|
||||
const createSchemaObj = () => new CollationSchema(
|
||||
{
|
||||
rolesList: () => [],
|
||||
schemaList: () => [],
|
||||
@@ -24,24 +23,23 @@ describe('CollationsSchema', () => {
|
||||
schema: ''
|
||||
}
|
||||
);
|
||||
let schemaObj = createSchemaObj();
|
||||
let getInitData = () => Promise.resolve({});
|
||||
|
||||
|
||||
|
||||
beforeEach(() => {
|
||||
genericBeforeEach();
|
||||
});
|
||||
|
||||
it('create', () => {
|
||||
getCreateView(schemaObj);
|
||||
getCreateView(createSchemaObj());
|
||||
});
|
||||
|
||||
it('edit', () => {
|
||||
getEditView(schemaObj, getInitData);
|
||||
getEditView(createSchemaObj(), getInitData);
|
||||
});
|
||||
|
||||
it('properties', () => {
|
||||
getPropertiesView(schemaObj, getInitData);
|
||||
getPropertiesView(createSchemaObj(), getInitData);
|
||||
});
|
||||
|
||||
it('validate', () => {
|
||||
|
||||
@@ -46,13 +46,13 @@ function getFieldDepChange(schema, id) {
|
||||
}
|
||||
|
||||
describe('ColumnSchema', ()=>{
|
||||
|
||||
let schemaObj = new ColumnSchema(
|
||||
const createSchemaObj = () => new ColumnSchema(
|
||||
()=>new MockSchema(),
|
||||
{},
|
||||
()=>Promise.resolve([]),
|
||||
()=>Promise.resolve([]),
|
||||
);
|
||||
let schemaObj = createSchemaObj();
|
||||
let datatypes = [
|
||||
{value: 'numeric', length: true, precision: true, min_val: 1, max_val: 140391},
|
||||
{value: 'character varying', length: true, precision: false, min_val: 1, max_val: 140391},
|
||||
@@ -64,15 +64,15 @@ describe('ColumnSchema', ()=>{
|
||||
});
|
||||
|
||||
it('create', async ()=>{
|
||||
await getCreateView(schemaObj);
|
||||
await getCreateView(createSchemaObj());
|
||||
});
|
||||
|
||||
it('edit', async ()=>{
|
||||
await getEditView(schemaObj, getInitData);
|
||||
await getEditView(createSchemaObj(), getInitData);
|
||||
});
|
||||
|
||||
it('properties', async ()=>{
|
||||
await getPropertiesView(schemaObj, getInitData);
|
||||
await getPropertiesView(createSchemaObj(), getInitData);
|
||||
});
|
||||
|
||||
it('create collection', async ()=>{
|
||||
|
||||
@@ -13,7 +13,7 @@ import {genericBeforeEach, getCreateView, getEditView, getPropertiesView} from '
|
||||
|
||||
describe('CompoundTriggerSchema', ()=>{
|
||||
|
||||
let schemaObj = new CompoundTriggerSchema(
|
||||
const createSchemaObj = () => new CompoundTriggerSchema(
|
||||
{
|
||||
columns: [],
|
||||
},
|
||||
@@ -23,26 +23,23 @@ describe('CompoundTriggerSchema', ()=>{
|
||||
table: {}
|
||||
}
|
||||
);
|
||||
let schemaObj = createSchemaObj();
|
||||
let getInitData = ()=>Promise.resolve({});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
beforeEach(()=>{
|
||||
genericBeforeEach();
|
||||
});
|
||||
|
||||
it('create', async ()=>{
|
||||
await getCreateView(schemaObj);
|
||||
await getCreateView(createSchemaObj());
|
||||
});
|
||||
|
||||
it('edit', async ()=>{
|
||||
await getEditView(schemaObj, getInitData);
|
||||
await getEditView(createSchemaObj(), getInitData);
|
||||
});
|
||||
|
||||
it('properties', async ()=>{
|
||||
await getPropertiesView(schemaObj, getInitData);
|
||||
await getPropertiesView(createSchemaObj(), getInitData);
|
||||
});
|
||||
|
||||
it('validate', ()=>{
|
||||
|
||||
@@ -12,6 +12,7 @@ import _ from 'lodash';
|
||||
import BaseUISchema from 'sources/SchemaView/base_schema.ui';
|
||||
import DatabaseSchema from '../../../pgadmin/browser/server_groups/servers/databases/static/js/database.ui';
|
||||
import {genericBeforeEach, getCreateView, getEditView, getPropertiesView} from '../genericFunctions';
|
||||
import { initializeSchemaWithData } from './utils';
|
||||
|
||||
class MockSchema extends BaseUISchema {
|
||||
get baseFields() {
|
||||
@@ -21,7 +22,7 @@ class MockSchema extends BaseUISchema {
|
||||
|
||||
describe('DatabaseSchema', ()=>{
|
||||
|
||||
let schemaObj = new DatabaseSchema(
|
||||
const createSchemaObj = () => new DatabaseSchema(
|
||||
()=>new MockSchema(),
|
||||
()=>new MockSchema(),
|
||||
{
|
||||
@@ -35,30 +36,29 @@ describe('DatabaseSchema', ()=>{
|
||||
{
|
||||
datowner: 'postgres',
|
||||
}
|
||||
);
|
||||
);
|
||||
let schemaObj = createSchemaObj();
|
||||
let getInitData = ()=>Promise.resolve({});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
beforeEach(()=>{
|
||||
genericBeforeEach();
|
||||
});
|
||||
|
||||
it('create', async ()=>{
|
||||
await getCreateView(schemaObj);
|
||||
await getCreateView(createSchemaObj());
|
||||
});
|
||||
|
||||
it('edit', async ()=>{
|
||||
await getEditView(schemaObj, getInitData);
|
||||
await getEditView(createSchemaObj(), getInitData);
|
||||
});
|
||||
|
||||
it('properties', async ()=>{
|
||||
await getPropertiesView(schemaObj, getInitData);
|
||||
await getPropertiesView(createSchemaObj(), getInitData);
|
||||
});
|
||||
|
||||
it('schema_res depChange', ()=>{
|
||||
it('schema_res depChange', () => {
|
||||
initializeSchemaWithData(schemaObj, {});
|
||||
let depChange = _.find(schemaObj.fields, (f)=>f.id=='schema_res').depChange;
|
||||
depChange({schema_res: 'abc'});
|
||||
expect(schemaObj.informText).toBe('Please refresh the Schemas node to make changes to the schema restriction take effect.');
|
||||
|
||||
@@ -14,7 +14,7 @@ import {addNewDatagridRow, genericBeforeEach, getCreateView, getEditView, getPro
|
||||
|
||||
describe('DomainSchema', ()=>{
|
||||
|
||||
let schemaObj = new DomainSchema(
|
||||
const createSchemaObj = () => new DomainSchema(
|
||||
{
|
||||
role: ()=>[],
|
||||
schema: ()=>[],
|
||||
@@ -31,23 +31,20 @@ describe('DomainSchema', ()=>{
|
||||
let getInitData = ()=>Promise.resolve({});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
beforeEach(()=>{
|
||||
genericBeforeEach();
|
||||
});
|
||||
|
||||
it('create', async ()=>{
|
||||
await getCreateView(schemaObj);
|
||||
await getCreateView(createSchemaObj());
|
||||
});
|
||||
|
||||
it('edit', async ()=>{
|
||||
await getEditView(schemaObj, getInitData);
|
||||
await getEditView(createSchemaObj(), getInitData);
|
||||
});
|
||||
|
||||
it('properties', async ()=>{
|
||||
await getPropertiesView(schemaObj, getInitData);
|
||||
await getPropertiesView(createSchemaObj(), getInitData);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -13,27 +13,24 @@ import {genericBeforeEach, getCreateView, getEditView, getPropertiesView} from '
|
||||
|
||||
describe('DomainConstraintSchema', ()=>{
|
||||
|
||||
let schemaObj = new DomainConstraintSchema();
|
||||
let createSchemaObj = () => new DomainConstraintSchema();
|
||||
let getInitData = ()=>Promise.resolve({});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
beforeEach(()=>{
|
||||
genericBeforeEach();
|
||||
});
|
||||
|
||||
it('create', async ()=>{
|
||||
await getCreateView(schemaObj);
|
||||
await getCreateView(createSchemaObj());
|
||||
});
|
||||
|
||||
it('edit', async ()=>{
|
||||
await getEditView(schemaObj, getInitData);
|
||||
await getEditView(createSchemaObj(), getInitData);
|
||||
});
|
||||
|
||||
it('properties', async ()=>{
|
||||
await getPropertiesView(schemaObj, getInitData);
|
||||
await getPropertiesView(createSchemaObj(), getInitData);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -13,7 +13,8 @@ import {genericBeforeEach, getCreateView, getEditView, getPropertiesView} from '
|
||||
|
||||
describe('EDBFuncSchema', ()=>{
|
||||
|
||||
let edbFuncSchemaObj = new EDBFuncSchema(
|
||||
|
||||
let edbFuncSchemaObj = () => new EDBFuncSchema(
|
||||
{}, {
|
||||
name: 'sysfunc'
|
||||
}
|
||||
@@ -21,23 +22,20 @@ describe('EDBFuncSchema', ()=>{
|
||||
let getInitData = ()=>Promise.resolve({});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
beforeEach(()=>{
|
||||
genericBeforeEach();
|
||||
});
|
||||
|
||||
it('create', async ()=>{
|
||||
await getCreateView(edbFuncSchemaObj);
|
||||
await getCreateView(edbFuncSchemaObj());
|
||||
});
|
||||
|
||||
it('edit', async ()=>{
|
||||
await getEditView(edbFuncSchemaObj, getInitData);
|
||||
await getEditView(edbFuncSchemaObj(), getInitData);
|
||||
});
|
||||
|
||||
it('properties', async ()=>{
|
||||
await getPropertiesView(edbFuncSchemaObj, getInitData);
|
||||
await getPropertiesView(edbFuncSchemaObj(), getInitData);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -13,27 +13,23 @@ import {genericBeforeEach, getCreateView, getEditView, getPropertiesView} from '
|
||||
|
||||
describe('EDBVarSchema', ()=>{
|
||||
|
||||
let edbVarSchemaObj = new EDBVarSchema();
|
||||
let edbVarSchemaObj = () => new EDBVarSchema();
|
||||
let getInitData = ()=>Promise.resolve({});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
beforeEach(()=>{
|
||||
genericBeforeEach();
|
||||
});
|
||||
|
||||
it('create', async ()=>{
|
||||
await getCreateView(edbVarSchemaObj);
|
||||
await getCreateView(edbVarSchemaObj());
|
||||
});
|
||||
|
||||
it('edit', async ()=>{
|
||||
await getEditView(edbVarSchemaObj, getInitData);
|
||||
await getEditView(edbVarSchemaObj(), getInitData);
|
||||
});
|
||||
|
||||
it('properties', async ()=>{
|
||||
await getPropertiesView(edbVarSchemaObj, getInitData);
|
||||
await getPropertiesView(edbVarSchemaObj(), getInitData);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ import {genericBeforeEach, getCreateView, getEditView, getPropertiesView} from '
|
||||
|
||||
describe('EventTriggerSchema', ()=>{
|
||||
|
||||
let schemaObj = new EventTriggerSchema(
|
||||
const createSchemaObj = () => new EventTriggerSchema(
|
||||
{
|
||||
role: ()=>[],
|
||||
function_names: ()=>[],
|
||||
@@ -22,26 +22,24 @@ describe('EventTriggerSchema', ()=>{
|
||||
eventowner: 'postgres'
|
||||
}
|
||||
);
|
||||
let schemaObj = createSchemaObj();
|
||||
let getInitData = ()=>Promise.resolve({});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
beforeEach(()=>{
|
||||
genericBeforeEach();
|
||||
});
|
||||
|
||||
it('create', async ()=>{
|
||||
await getCreateView(schemaObj);
|
||||
await getCreateView(createSchemaObj());
|
||||
});
|
||||
|
||||
it('edit', async ()=>{
|
||||
await getEditView(schemaObj, getInitData);
|
||||
await getEditView(createSchemaObj(), getInitData);
|
||||
});
|
||||
|
||||
it('properties', async ()=>{
|
||||
await getPropertiesView(schemaObj, getInitData);
|
||||
await getPropertiesView(createSchemaObj(), getInitData);
|
||||
});
|
||||
|
||||
it('validate', ()=>{
|
||||
|
||||
@@ -40,13 +40,14 @@ function getFieldDepChange(schema, id) {
|
||||
|
||||
describe('ExclusionConstraintSchema', ()=>{
|
||||
|
||||
let schemaObj;
|
||||
const createSchemaObject = () => getNodeExclusionConstraintSchema(
|
||||
{}, {}, {Nodes: {table: {}}}
|
||||
);
|
||||
let getInitData = ()=>Promise.resolve({});
|
||||
|
||||
beforeAll(()=>{
|
||||
jest.spyOn(nodeAjax, 'getNodeAjaxOptions').mockReturnValue(Promise.resolve([]));
|
||||
jest.spyOn(nodeAjax, 'getNodeListByName').mockReturnValue(Promise.resolve([]));
|
||||
schemaObj = getNodeExclusionConstraintSchema({}, {}, {Nodes: {table: {}}});
|
||||
});
|
||||
|
||||
beforeEach(()=>{
|
||||
@@ -54,18 +55,19 @@ describe('ExclusionConstraintSchema', ()=>{
|
||||
});
|
||||
|
||||
it('create', async ()=>{
|
||||
await getCreateView(schemaObj);
|
||||
await getCreateView(createSchemaObject());
|
||||
});
|
||||
|
||||
it('edit', async ()=>{
|
||||
await getEditView(schemaObj, getInitData);
|
||||
await getEditView(createSchemaObject(), getInitData);
|
||||
});
|
||||
|
||||
it('properties', async ()=>{
|
||||
await getPropertiesView(schemaObj, getInitData);
|
||||
await getPropertiesView(createSchemaObject(), getInitData);
|
||||
});
|
||||
|
||||
it('create collection', async ()=>{
|
||||
let schemaObj = createSchemaObject();
|
||||
let schemaCollObj = new SchemaInColl(schemaObj);
|
||||
const {ctrl, user} = await getCreateView(schemaCollObj);
|
||||
/* Make sure you hit every corner */
|
||||
@@ -73,6 +75,7 @@ describe('ExclusionConstraintSchema', ()=>{
|
||||
});
|
||||
|
||||
it('changeColumnOptions', ()=>{
|
||||
let schemaObj = createSchemaObject();
|
||||
jest.spyOn(schemaObj.exHeaderSchema, 'changeColumnOptions');
|
||||
let columns = [{label: 'label', value: 'value'}];
|
||||
schemaObj.changeColumnOptions(columns);
|
||||
@@ -80,6 +83,7 @@ describe('ExclusionConstraintSchema', ()=>{
|
||||
});
|
||||
|
||||
describe('ExclusionColHeaderSchema', ()=>{
|
||||
let schemaObj = createSchemaObject();
|
||||
it('getNewData', ()=>{
|
||||
schemaObj.exHeaderSchema.columnOptions = [
|
||||
{label: 'id', value: 'id', datatype: 'numeric'},
|
||||
@@ -111,6 +115,7 @@ describe('ExclusionConstraintSchema', ()=>{
|
||||
});
|
||||
|
||||
describe('ExclusionColumnSchema', ()=>{
|
||||
let schemaObj = createSchemaObject();
|
||||
it('isEditable', ()=>{
|
||||
schemaObj.exColumnSchema.isNewExCons = false;
|
||||
expect(schemaObj.exColumnSchema.isEditable()).toBe(false);
|
||||
@@ -125,6 +130,7 @@ describe('ExclusionConstraintSchema', ()=>{
|
||||
});
|
||||
|
||||
it('depChange', ()=>{
|
||||
let schemaObj = createSchemaObject();
|
||||
let state = {columns: [{column: 'id'}]};
|
||||
|
||||
schemaObj.top = new TableSchema({}, null);
|
||||
@@ -169,6 +175,7 @@ describe('ExclusionConstraintSchema', ()=>{
|
||||
});
|
||||
|
||||
it('columns formatter', ()=>{
|
||||
let schemaObj = createSchemaObject();
|
||||
let formatter = _.find(schemaObj.fields, (f)=>f.id=='columns').cell().controlProps.formatter;
|
||||
expect(formatter.fromRaw([{
|
||||
column: 'lid',
|
||||
@@ -180,6 +187,7 @@ describe('ExclusionConstraintSchema', ()=>{
|
||||
});
|
||||
|
||||
describe('amname change', ()=>{
|
||||
let schemaObj = createSchemaObject();
|
||||
let confirmSpy;
|
||||
let deferredDepChange;
|
||||
let operClassOptions = [
|
||||
@@ -243,6 +251,7 @@ describe('ExclusionConstraintSchema', ()=>{
|
||||
});
|
||||
|
||||
it('validate', ()=>{
|
||||
let schemaObj = createSchemaObject();
|
||||
let state = {};
|
||||
let setError = jest.fn();
|
||||
|
||||
@@ -255,4 +264,3 @@ describe('ExclusionConstraintSchema', ()=>{
|
||||
expect(schemaObj.validate(state, setError)).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -13,32 +13,31 @@ import {genericBeforeEach, getCreateView, getEditView, getPropertiesView} from '
|
||||
|
||||
describe('ExtensionSchema', ()=>{
|
||||
|
||||
let schemaObj = new ExtensionsSchema(
|
||||
const createSchemaObj = () => new ExtensionsSchema(
|
||||
{
|
||||
extensionsList: ()=>[],
|
||||
schemaList: ()=>[],
|
||||
}
|
||||
);
|
||||
let schemaObj = createSchemaObj();
|
||||
let getInitData = ()=>Promise.resolve({});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
beforeEach(()=>{
|
||||
genericBeforeEach();
|
||||
});
|
||||
|
||||
it('create', async ()=>{
|
||||
await getCreateView(schemaObj);
|
||||
await getCreateView(createSchemaObj());
|
||||
});
|
||||
|
||||
it('edit', async ()=>{
|
||||
await getEditView(schemaObj, getInitData);
|
||||
await getEditView(createSchemaObj(), getInitData);
|
||||
});
|
||||
|
||||
it('properties', async ()=>{
|
||||
await getPropertiesView(schemaObj, getInitData);
|
||||
await getPropertiesView(createSchemaObj(), getInitData);
|
||||
});
|
||||
|
||||
it('validate', ()=>{
|
||||
|
||||
@@ -20,7 +20,7 @@ class MockSchema extends BaseUISchema {
|
||||
|
||||
describe('ForeignDataWrapperSchema', ()=>{
|
||||
|
||||
let schemaObj = new ForeignDataWrapperSchema(
|
||||
const createSchemaObj = () => new ForeignDataWrapperSchema(
|
||||
()=>new MockSchema(),
|
||||
{
|
||||
role: ()=>[],
|
||||
@@ -34,23 +34,20 @@ describe('ForeignDataWrapperSchema', ()=>{
|
||||
let getInitData = ()=>Promise.resolve({});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
beforeEach(()=>{
|
||||
genericBeforeEach();
|
||||
});
|
||||
|
||||
it('create', async ()=>{
|
||||
await getCreateView(schemaObj);
|
||||
await getCreateView(createSchemaObj());
|
||||
});
|
||||
|
||||
it('edit', async ()=>{
|
||||
await getEditView(schemaObj, getInitData);
|
||||
await getEditView(createSchemaObj(), getInitData);
|
||||
});
|
||||
|
||||
it('properties', async ()=>{
|
||||
await getPropertiesView(schemaObj, getInitData);
|
||||
await getPropertiesView(createSchemaObj(), getInitData);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -48,8 +48,6 @@ describe('ForeignKeySchema', ()=>{
|
||||
schemaObj = getNodeForeignKeySchema({}, {}, {Nodes: {table: {}}});
|
||||
});
|
||||
|
||||
|
||||
|
||||
beforeEach(()=>{
|
||||
genericBeforeEach();
|
||||
});
|
||||
|
||||
@@ -20,7 +20,7 @@ class MockSchema extends BaseUISchema {
|
||||
|
||||
describe('ForeignServerSchema', ()=>{
|
||||
|
||||
let schemaObj = new ForeignServerSchema(
|
||||
const createSchemaObj = () => new ForeignServerSchema(
|
||||
()=>new MockSchema(),
|
||||
{
|
||||
role: ()=>[],
|
||||
@@ -31,24 +31,20 @@ describe('ForeignServerSchema', ()=>{
|
||||
);
|
||||
let getInitData = ()=>Promise.resolve({});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
beforeEach(()=>{
|
||||
genericBeforeEach();
|
||||
});
|
||||
|
||||
it('create', async ()=>{
|
||||
await getCreateView(schemaObj);
|
||||
await getCreateView(createSchemaObj());
|
||||
});
|
||||
|
||||
it('edit', async ()=>{
|
||||
await getEditView(schemaObj, getInitData);
|
||||
await getEditView(createSchemaObj(), getInitData);
|
||||
});
|
||||
|
||||
it('properties', async ()=>{
|
||||
await getPropertiesView(schemaObj, getInitData);
|
||||
await getPropertiesView(createSchemaObj(), getInitData);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -19,8 +19,7 @@ class MockSchema extends BaseUISchema {
|
||||
}
|
||||
|
||||
describe('ForeignTableSchema', ()=>{
|
||||
|
||||
let schemaObj = new ForeignTableSchema(
|
||||
const createSchemaObj = () => new ForeignTableSchema(
|
||||
()=>new MockSchema(),
|
||||
()=>new MockSchema(),
|
||||
()=>new MockSchema(),
|
||||
@@ -38,6 +37,7 @@ describe('ForeignTableSchema', ()=>{
|
||||
}
|
||||
}
|
||||
);
|
||||
let schemaObj = createSchemaObj();
|
||||
let getInitData = ()=>Promise.resolve({});
|
||||
|
||||
beforeEach(()=>{
|
||||
@@ -45,15 +45,15 @@ describe('ForeignTableSchema', ()=>{
|
||||
});
|
||||
|
||||
it('create', async ()=>{
|
||||
await getCreateView(schemaObj);
|
||||
await getCreateView(createSchemaObj());
|
||||
});
|
||||
|
||||
it('edit', async ()=>{
|
||||
await getEditView(schemaObj, getInitData);
|
||||
await getEditView(createSchemaObj(), getInitData);
|
||||
});
|
||||
|
||||
it('properties', async ()=>{
|
||||
await getPropertiesView(schemaObj, getInitData);
|
||||
await getPropertiesView(createSchemaObj(), getInitData);
|
||||
});
|
||||
|
||||
it('validate', ()=>{
|
||||
|
||||
@@ -13,7 +13,7 @@ import {genericBeforeEach, getCreateView, getEditView, getPropertiesView} from '
|
||||
|
||||
describe('FTSConfigurationSchema', ()=>{
|
||||
|
||||
let schemaObj = new FTSConfigurationSchema(
|
||||
const createSchemaObj = () => new FTSConfigurationSchema(
|
||||
{
|
||||
role: ()=>[],
|
||||
schema: ()=>[],
|
||||
@@ -27,26 +27,23 @@ describe('FTSConfigurationSchema', ()=>{
|
||||
schema: 'public',
|
||||
}
|
||||
);
|
||||
let getInitData = ()=>Promise.resolve({});
|
||||
|
||||
|
||||
|
||||
|
||||
let schemaObj = createSchemaObj();
|
||||
let getInitData = () => Promise.resolve({});
|
||||
|
||||
beforeEach(()=>{
|
||||
genericBeforeEach();
|
||||
});
|
||||
|
||||
it('create', async ()=>{
|
||||
await getCreateView(schemaObj);
|
||||
await getCreateView(createSchemaObj());
|
||||
});
|
||||
|
||||
it('edit', async ()=>{
|
||||
await getEditView(schemaObj, getInitData);
|
||||
await getEditView(createSchemaObj(), getInitData);
|
||||
});
|
||||
|
||||
it('properties', async ()=>{
|
||||
await getPropertiesView(schemaObj, getInitData);
|
||||
await getPropertiesView(createSchemaObj(), getInitData);
|
||||
});
|
||||
|
||||
it('validate', ()=>{
|
||||
|
||||
@@ -12,8 +12,7 @@ import FTSDictionarySchema from '../../../pgadmin/browser/server_groups/servers/
|
||||
import {genericBeforeEach, getCreateView, getEditView, getPropertiesView} from '../genericFunctions';
|
||||
|
||||
describe('FTSDictionarySchema', ()=>{
|
||||
|
||||
let schemaObj = new FTSDictionarySchema(
|
||||
const createSchemaObj = () => new FTSDictionarySchema(
|
||||
{
|
||||
role: ()=>[],
|
||||
schema: ()=>[],
|
||||
@@ -28,23 +27,20 @@ describe('FTSDictionarySchema', ()=>{
|
||||
let getInitData = ()=>Promise.resolve({});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
beforeEach(()=>{
|
||||
genericBeforeEach();
|
||||
});
|
||||
|
||||
it('create', async ()=>{
|
||||
await getCreateView(schemaObj);
|
||||
await getCreateView(createSchemaObj());
|
||||
});
|
||||
|
||||
it('edit', async ()=>{
|
||||
await getEditView(schemaObj, getInitData);
|
||||
await getEditView(createSchemaObj(), getInitData);
|
||||
});
|
||||
|
||||
it('properties', async ()=>{
|
||||
await getPropertiesView(schemaObj, getInitData);
|
||||
await getPropertiesView(createSchemaObj(), getInitData);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -13,39 +13,35 @@ import {genericBeforeEach, getCreateView, getEditView, getPropertiesView} from '
|
||||
|
||||
describe('FTSParserSchema', ()=>{
|
||||
|
||||
let schemaObj = new FTSParserSchema(
|
||||
const createSchemaObj = () => new FTSParserSchema(
|
||||
{
|
||||
prsstartList: ()=> [{ label: '', value: ''}, { label: 'lb1', value: 'val1'}],
|
||||
prstokenList: ()=> [{ label: '', value: ''}, { label: 'lb1', value: 'val1'}],
|
||||
prsendList: ()=> [{ label: '', value: ''}, { label: 'lb1', value: 'val1'}],
|
||||
prslextypeList: ()=> [{ label: '', value: ''}, { label: 'lb1', value: 'val1'}],
|
||||
prsheadlineList: ()=> [{ label: '', value: ''}, { label: 'lb1', value: 'val1'}],
|
||||
schemaList: ()=> [],
|
||||
prsstartList: () => [{ label: '', value: ''}, { label: 'lb1', value: 'val1'}],
|
||||
prstokenList: () => [{ label: '', value: ''}, { label: 'lb1', value: 'val1'}],
|
||||
prsendList: () => [{ label: '', value: ''}, { label: 'lb1', value: 'val1'}],
|
||||
prslextypeList: () => [{ label: '', value: ''}, { label: 'lb1', value: 'val1'}],
|
||||
prsheadlineList: () => [{ label: '', value: ''}, { label: 'lb1', value: 'val1'}],
|
||||
schemaList: () => [],
|
||||
},
|
||||
{
|
||||
schema: 123
|
||||
}
|
||||
);
|
||||
let getInitData = ()=>Promise.resolve({});
|
||||
|
||||
|
||||
|
||||
|
||||
let getInitData = () => Promise.resolve({});
|
||||
|
||||
beforeEach(()=>{
|
||||
genericBeforeEach();
|
||||
});
|
||||
|
||||
it('create', async ()=>{
|
||||
await getCreateView(schemaObj);
|
||||
it('create', async () => {
|
||||
await getCreateView(createSchemaObj());
|
||||
});
|
||||
|
||||
it('edit', async ()=>{
|
||||
await getEditView(schemaObj, getInitData);
|
||||
it('edit', async () => {
|
||||
await getEditView(createSchemaObj(), getInitData);
|
||||
});
|
||||
|
||||
it('properties', async ()=>{
|
||||
await getPropertiesView(schemaObj, getInitData);
|
||||
it('properties', async () => {
|
||||
await getPropertiesView(createSchemaObj(), getInitData);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ class MockSchema extends BaseUISchema {
|
||||
describe('FunctionSchema', ()=>{
|
||||
|
||||
//Procedure schema
|
||||
let procedureSchemaObj = new FunctionSchema(
|
||||
const procedureSchemaObj = new FunctionSchema(
|
||||
()=>new MockSchema(),
|
||||
()=>new MockSchema(),
|
||||
{
|
||||
@@ -61,7 +61,7 @@ describe('FunctionSchema', ()=>{
|
||||
);
|
||||
|
||||
|
||||
let schemaObj = new FunctionSchema(
|
||||
const createSchemaObj = () => new FunctionSchema(
|
||||
() => new MockSchema(),
|
||||
() => new MockSchema(),
|
||||
{
|
||||
@@ -105,7 +105,8 @@ describe('FunctionSchema', ()=>{
|
||||
funcowner: 'postgres',
|
||||
pronamespace: 'public',
|
||||
}
|
||||
);
|
||||
);
|
||||
let schemaObj = createSchemaObj();
|
||||
let getInitData = ()=>Promise.resolve({});
|
||||
|
||||
|
||||
@@ -117,19 +118,19 @@ describe('FunctionSchema', ()=>{
|
||||
});
|
||||
|
||||
it('create', async ()=>{
|
||||
await getCreateView(schemaObj);
|
||||
await getCreateView(createSchemaObj());
|
||||
});
|
||||
|
||||
it('create', async ()=>{
|
||||
it('create procedure', async ()=>{
|
||||
await getCreateView(procedureSchemaObj);
|
||||
});
|
||||
|
||||
it('edit', async ()=>{
|
||||
await getEditView(schemaObj, getInitData);
|
||||
await getEditView(createSchemaObj(), getInitData);
|
||||
});
|
||||
|
||||
it('properties', async ()=>{
|
||||
await getPropertiesView(schemaObj, getInitData);
|
||||
await getPropertiesView(createSchemaObj(), getInitData);
|
||||
});
|
||||
|
||||
it('proiswindow visible', async ()=>{
|
||||
|
||||
@@ -13,19 +13,20 @@ import {genericBeforeEach, getCreateView} from '../genericFunctions';
|
||||
|
||||
describe('ImportExportServers', () => {
|
||||
|
||||
let schemaObj = new ImportExportSelectionSchema();
|
||||
|
||||
beforeEach(() => {
|
||||
genericBeforeEach();
|
||||
});
|
||||
|
||||
it('import', async () => {
|
||||
const schemaObj = new ImportExportSelectionSchema();
|
||||
await getCreateView(schemaObj);
|
||||
});
|
||||
|
||||
it('export', async () => {
|
||||
schemaObj = new ImportExportSelectionSchema(
|
||||
{imp_exp: 'e', filename: 'test.json'});
|
||||
const schemaObj = new ImportExportSelectionSchema({
|
||||
imp_exp: 'e', filename: 'test.json'
|
||||
});
|
||||
|
||||
await getCreateView(schemaObj);
|
||||
});
|
||||
|
||||
@@ -30,23 +30,23 @@ class SchemaInColl extends BaseUISchema {
|
||||
}
|
||||
|
||||
function getFieldDepChange(schema, id) {
|
||||
return _.find(schema.fields, (f)=>f.id==id)?.depChange;
|
||||
return _.find(schema.fields, (f) => f.id==id)?.depChange;
|
||||
}
|
||||
|
||||
describe('IndexSchema', ()=>{
|
||||
describe('IndexSchema', () => {
|
||||
let indexSchemaObj;
|
||||
let getInitData = ()=>Promise.resolve({});
|
||||
let getInitData = () => Promise.resolve({});
|
||||
|
||||
beforeAll(()=>{
|
||||
beforeAll(() => {
|
||||
jest.spyOn(nodeAjax, 'getNodeAjaxOptions').mockReturnValue(Promise.resolve([]));
|
||||
jest.spyOn(nodeAjax, 'getNodeListByName').mockReturnValue(Promise.resolve([]));
|
||||
indexSchemaObj = new IndexSchema(
|
||||
{
|
||||
tablespaceList: ()=>[],
|
||||
amnameList : ()=>[{label:'abc', value:'abc'}],
|
||||
columnList: ()=>[{label:'abc', value:'abc'}],
|
||||
collationList: ()=>[{label:'abc', value:'abc'}],
|
||||
opClassList: ()=>[{label:'abc', value:'abc'}]
|
||||
tablespaceList: () => [],
|
||||
amnameList : () => [{label:'abc', value:'abc'}],
|
||||
columnList: () => [{label:'abc', value:'abc'}],
|
||||
collationList: () => [{label:'abc', value:'abc'}],
|
||||
opClassList: () => [{label:'abc', value:'abc'}]
|
||||
},
|
||||
{
|
||||
node_info: {'server': { 'version': 110000} }
|
||||
@@ -57,23 +57,23 @@ describe('IndexSchema', ()=>{
|
||||
);
|
||||
});
|
||||
|
||||
beforeEach(()=>{
|
||||
beforeEach(() => {
|
||||
genericBeforeEach();
|
||||
});
|
||||
|
||||
it('create', async ()=>{
|
||||
it('create', async () => {
|
||||
await getCreateView(indexSchemaObj);
|
||||
});
|
||||
|
||||
it('edit', async ()=>{
|
||||
it('edit', async () => {
|
||||
await getEditView(indexSchemaObj, getInitData);
|
||||
});
|
||||
|
||||
it('properties', async ()=>{
|
||||
it('properties', async () => {
|
||||
await getPropertiesView(indexSchemaObj, getInitData);
|
||||
});
|
||||
|
||||
it('create collection', async ()=>{
|
||||
it('create collection', async () => {
|
||||
let schemaCollObj = new SchemaInColl(indexSchemaObj);
|
||||
let {ctrl, user} = await getCreateView(schemaCollObj);
|
||||
/* Make sure you hit every corner */
|
||||
@@ -82,15 +82,15 @@ describe('IndexSchema', ()=>{
|
||||
await addNewDatagridRow(user, ctrl);
|
||||
});
|
||||
|
||||
it('changeColumnOptions', ()=>{
|
||||
it('changeColumnOptions', () => {
|
||||
jest.spyOn(indexSchemaObj.indexHeaderSchema, 'changeColumnOptions');
|
||||
let columns = [{label: 'label', value: 'value'}];
|
||||
indexSchemaObj.changeColumnOptions(columns);
|
||||
expect(indexSchemaObj.indexHeaderSchema.changeColumnOptions).toHaveBeenCalledWith(columns);
|
||||
});
|
||||
|
||||
describe('IndexColHeaderSchema', ()=>{
|
||||
it('getNewData', ()=>{
|
||||
describe('IndexColHeaderSchema', () => {
|
||||
it('getNewData', () => {
|
||||
indexSchemaObj.indexHeaderSchema.columnOptions = [
|
||||
{label: 'id', value: 'id'},
|
||||
{label: 'name', value: 'name'}
|
||||
@@ -118,18 +118,18 @@ describe('IndexSchema', ()=>{
|
||||
});
|
||||
});
|
||||
|
||||
describe('IndexColumnSchema', ()=>{
|
||||
it('column schema colname editable', ()=>{
|
||||
indexSchemaObj.indexColumnSchema._top = {
|
||||
_sessData: { amname: 'btree' }
|
||||
describe('IndexColumnSchema', () => {
|
||||
it('column schema colname editable', () => {
|
||||
indexSchemaObj.indexColumnSchema.top = {
|
||||
sessData: { amname: 'btree' }
|
||||
};
|
||||
let cell = _.find(indexSchemaObj.indexColumnSchema.fields, (f)=>f.id=='op_class').cell;
|
||||
let cell = _.find(indexSchemaObj.indexColumnSchema.fields, (f) => f.id=='op_class').cell;
|
||||
cell();
|
||||
});
|
||||
|
||||
it('column schema sort_order depChange', ()=>{
|
||||
it('column schema sort_order depChange', () => {
|
||||
let topState = { amname: 'btree' };
|
||||
let depChange = _.find(indexSchemaObj.indexColumnSchema.fields, (f)=>f.id=='sort_order').depChange;
|
||||
let depChange = _.find(indexSchemaObj.indexColumnSchema.fields, (f) => f.id=='sort_order').depChange;
|
||||
|
||||
let state = { sort_order: true };
|
||||
depChange(state, {}, topState, { oldState: { sort_order: false } });
|
||||
@@ -140,13 +140,13 @@ describe('IndexSchema', ()=>{
|
||||
expect(state.is_sort_nulls_applicable).toBe(false);
|
||||
});
|
||||
|
||||
it('column schema sort_order editable', ()=>{
|
||||
indexSchemaObj.indexColumnSchema._top = {
|
||||
_sessData: { amname: 'btree' }
|
||||
it('column schema sort_order editable', () => {
|
||||
indexSchemaObj.indexColumnSchema.top = {
|
||||
sessData: { amname: 'btree' }
|
||||
};
|
||||
let state = {};
|
||||
jest.spyOn(indexSchemaObj.indexColumnSchema, 'inSchemaWithModelCheck').mockReturnValue(true);
|
||||
let editable = _.find(indexSchemaObj.indexColumnSchema.fields, (f)=>f.id=='sort_order').editable;
|
||||
let editable = _.find(indexSchemaObj.indexColumnSchema.fields, (f) => f.id=='sort_order').editable;
|
||||
let status = editable(state);
|
||||
expect(status).toBe(false);
|
||||
|
||||
@@ -154,18 +154,18 @@ describe('IndexSchema', ()=>{
|
||||
status = editable(state);
|
||||
expect(status).toBe(true);
|
||||
|
||||
indexSchemaObj.indexColumnSchema._top._sessData.amname = 'abc';
|
||||
indexSchemaObj.indexColumnSchema.top.sessData.amname = 'abc';
|
||||
status = editable(state);
|
||||
expect(status).toBe(false);
|
||||
});
|
||||
|
||||
it('column schema nulls editable', ()=>{
|
||||
indexSchemaObj.indexColumnSchema._top = {
|
||||
_sessData: { amname: 'btree' }
|
||||
it('column schema nulls editable', () => {
|
||||
indexSchemaObj.indexColumnSchema.top = {
|
||||
sessData: { amname: 'btree' }
|
||||
};
|
||||
let state = {};
|
||||
jest.spyOn(indexSchemaObj.indexColumnSchema, 'inSchemaWithModelCheck').mockReturnValue(true);
|
||||
let editable = _.find(indexSchemaObj.indexColumnSchema.fields, (f)=>f.id=='nulls').editable;
|
||||
let editable = _.find(indexSchemaObj.indexColumnSchema.fields, (f) => f.id=='nulls').editable;
|
||||
let status = editable(state);
|
||||
expect(status).toBe(false);
|
||||
|
||||
@@ -173,14 +173,14 @@ describe('IndexSchema', ()=>{
|
||||
status = editable(state);
|
||||
expect(status).toBe(true);
|
||||
|
||||
indexSchemaObj.indexColumnSchema._top._sessData.amname = 'abc';
|
||||
indexSchemaObj.indexColumnSchema.top.sessData.amname = 'abc';
|
||||
status = editable(state);
|
||||
expect(status).toBe(false);
|
||||
});
|
||||
|
||||
it('column schema setOpClassTypes', ()=>{
|
||||
indexSchemaObj.indexColumnSchema._top = {
|
||||
_sessData: { amname: 'btree' }
|
||||
it('column schema setOpClassTypes', () => {
|
||||
indexSchemaObj.indexColumnSchema.top = {
|
||||
sessData: { amname: 'btree' }
|
||||
};
|
||||
let options = [];
|
||||
indexSchemaObj.indexColumnSchema.op_class_types = [];
|
||||
@@ -195,15 +195,15 @@ describe('IndexSchema', ()=>{
|
||||
|
||||
});
|
||||
|
||||
it('depChange', ()=>{
|
||||
it('depChange', () => {
|
||||
let state = {};
|
||||
expect(getFieldDepChange(indexSchemaObj, 'description')(state)).toEqual({
|
||||
comment: '',
|
||||
});
|
||||
});
|
||||
|
||||
it('columns formatter', ()=>{
|
||||
let formatter = _.find(indexSchemaObj.fields, (f)=>f.id=='columns').cell().controlProps.formatter;
|
||||
it('columns formatter', () => {
|
||||
let formatter = _.find(indexSchemaObj.fields, (f) => f.id=='columns').cell().controlProps.formatter;
|
||||
expect(formatter.fromRaw([{
|
||||
colname: 'lid',
|
||||
},{
|
||||
@@ -213,7 +213,7 @@ describe('IndexSchema', ()=>{
|
||||
expect(formatter.fromRaw([])).toBe('');
|
||||
});
|
||||
|
||||
it('validate', ()=>{
|
||||
it('validate', () => {
|
||||
let state = { columns: [] };
|
||||
let setError = jest.fn();
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ class MockSchema extends BaseUISchema {
|
||||
|
||||
describe('LanguageSchema', ()=>{
|
||||
|
||||
let schemaObj = new LanguageSchema(
|
||||
const createSchemaObj = () => new LanguageSchema(
|
||||
()=>new MockSchema(),
|
||||
{
|
||||
lan_functions: ()=>[],
|
||||
@@ -35,26 +35,23 @@ describe('LanguageSchema', ()=>{
|
||||
},
|
||||
},
|
||||
);
|
||||
let schemaObj = createSchemaObj();
|
||||
let getInitData = ()=>Promise.resolve({});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
beforeEach(()=>{
|
||||
genericBeforeEach();
|
||||
});
|
||||
|
||||
it('create', async ()=>{
|
||||
await getCreateView(schemaObj);
|
||||
await getCreateView(createSchemaObj());
|
||||
});
|
||||
|
||||
it('edit', async ()=>{
|
||||
await getEditView(schemaObj, getInitData);
|
||||
await getEditView(createSchemaObj(), getInitData);
|
||||
});
|
||||
|
||||
it('properties', async ()=>{
|
||||
await getPropertiesView(schemaObj, getInitData);
|
||||
await getPropertiesView(createSchemaObj(), getInitData);
|
||||
});
|
||||
|
||||
it('validate', ()=>{
|
||||
|
||||
@@ -30,29 +30,24 @@ class SchemaInColl extends BaseUISchema {
|
||||
}
|
||||
|
||||
describe('MembershipSchema', ()=>{
|
||||
|
||||
let schemaObj = new MembershipSchema(
|
||||
()=>[]);
|
||||
const createSchemaObj = () => new MembershipSchema(()=>[]);
|
||||
let schemaObj = createSchemaObj();
|
||||
let getInitData = ()=>Promise.resolve({});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
beforeEach(()=>{
|
||||
genericBeforeEach();
|
||||
});
|
||||
|
||||
it('create', async ()=>{
|
||||
await getCreateView(schemaObj);
|
||||
await getCreateView(createSchemaObj());
|
||||
});
|
||||
|
||||
it('edit', async ()=>{
|
||||
await getEditView(schemaObj, getInitData);
|
||||
await getEditView(createSchemaObj(), getInitData);
|
||||
});
|
||||
|
||||
it('properties', async ()=>{
|
||||
await getPropertiesView(schemaObj, getInitData);
|
||||
await getPropertiesView(createSchemaObj(), getInitData);
|
||||
});
|
||||
|
||||
it('MembershipMemberSchema', async ()=>{
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
import BaseUISchema from 'sources/SchemaView/base_schema.ui';
|
||||
import MViewSchema from '../../../pgadmin/browser/server_groups/servers/databases/schemas/views/static/js/mview.ui';
|
||||
import {genericBeforeEach, getCreateView, getEditView, getPropertiesView} from '../genericFunctions';
|
||||
import { initializeSchemaWithData } from './utils';
|
||||
|
||||
class MockSchema extends BaseUISchema {
|
||||
get baseFields() {
|
||||
@@ -20,7 +21,7 @@ class MockSchema extends BaseUISchema {
|
||||
|
||||
describe('MaterializedViewSchema', ()=>{
|
||||
|
||||
let schemaObj = new MViewSchema(
|
||||
const createSchemaObject = () => new MViewSchema(
|
||||
()=>new MockSchema(),
|
||||
()=>new MockSchema(),
|
||||
{
|
||||
@@ -32,7 +33,8 @@ describe('MaterializedViewSchema', ()=>{
|
||||
owner: 'postgres',
|
||||
schema: 'public'
|
||||
}
|
||||
);
|
||||
);
|
||||
let schemaObj = createSchemaObject();
|
||||
let getInitData = ()=>Promise.resolve({});
|
||||
|
||||
beforeEach(()=>{
|
||||
@@ -40,18 +42,19 @@ describe('MaterializedViewSchema', ()=>{
|
||||
});
|
||||
|
||||
it('create', async ()=>{
|
||||
await getCreateView(schemaObj);
|
||||
await getCreateView(createSchemaObject());
|
||||
});
|
||||
|
||||
it('edit', async ()=>{
|
||||
await getEditView(schemaObj, getInitData);
|
||||
await getEditView(createSchemaObject(), getInitData);
|
||||
});
|
||||
|
||||
it('properties', async ()=>{
|
||||
await getPropertiesView(schemaObj, getInitData);
|
||||
await getPropertiesView(createSchemaObject(), getInitData);
|
||||
});
|
||||
|
||||
it('validate', ()=>{
|
||||
initializeSchemaWithData(schemaObj, {});
|
||||
let state = {};
|
||||
let setError = jest.fn();
|
||||
|
||||
|
||||
@@ -13,27 +13,23 @@ import {genericBeforeEach, getCreateView, getEditView, getPropertiesView} from '
|
||||
|
||||
describe('OperatorSchema', ()=>{
|
||||
|
||||
let schemaObj = new OperatorSchema();
|
||||
const createSchemaObject = () => new OperatorSchema();
|
||||
let getInitData = ()=>Promise.resolve({});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
beforeEach(()=>{
|
||||
genericBeforeEach();
|
||||
});
|
||||
|
||||
it('create', async ()=>{
|
||||
await getCreateView(schemaObj);
|
||||
await getCreateView(createSchemaObject());
|
||||
});
|
||||
|
||||
it('edit', async ()=>{
|
||||
await getEditView(schemaObj, getInitData);
|
||||
await getEditView(createSchemaObject(), getInitData);
|
||||
});
|
||||
|
||||
it('properties', async ()=>{
|
||||
await getPropertiesView(schemaObj, getInitData);
|
||||
await getPropertiesView(createSchemaObject(), getInitData);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -15,33 +15,32 @@ import { initializeSchemaWithData } from './utils';
|
||||
|
||||
describe('PackageSchema', ()=>{
|
||||
|
||||
let packageSchemaObj = new PackageSchema(
|
||||
(privileges)=>getNodePrivilegeRoleSchema({}, {server: {user: {name: 'postgres'}}}, {}, privileges),
|
||||
const createSchemaObject = () => new PackageSchema(
|
||||
(privileges) => getNodePrivilegeRoleSchema(
|
||||
{}, {server: {user: {name: 'postgres'}}}, {}, privileges
|
||||
),
|
||||
{
|
||||
schemas:() => [],
|
||||
node_info: {'schema': []}
|
||||
},
|
||||
);
|
||||
let packageSchemaObj = createSchemaObject();
|
||||
let getInitData = ()=>Promise.resolve({});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
beforeEach(()=>{
|
||||
genericBeforeEach();
|
||||
});
|
||||
|
||||
it('create', async ()=>{
|
||||
await getCreateView(packageSchemaObj);
|
||||
await getCreateView(createSchemaObject());
|
||||
});
|
||||
|
||||
it('edit', async ()=>{
|
||||
await getEditView(packageSchemaObj, getInitData);
|
||||
await getEditView(createSchemaObject(), getInitData);
|
||||
});
|
||||
|
||||
it('properties', async ()=>{
|
||||
await getPropertiesView(packageSchemaObj, getInitData);
|
||||
await getPropertiesView(createSchemaObject(), getInitData);
|
||||
});
|
||||
|
||||
it('pkgheadsrc depChange', ()=>{
|
||||
|
||||
@@ -15,47 +15,46 @@ import {genericBeforeEach, getCreateView, getEditView, getPropertiesView} from '
|
||||
|
||||
describe('PartitionTableSchema', ()=>{
|
||||
|
||||
let schemaObj;
|
||||
const createSchemaObject = () => getNodePartitionTableSchema({
|
||||
server: {
|
||||
_id: 1,
|
||||
},
|
||||
schema: {
|
||||
_label: 'public',
|
||||
}
|
||||
}, {}, {
|
||||
Nodes: {table: {}},
|
||||
serverInfo: {
|
||||
1: {
|
||||
user: {
|
||||
name: 'Postgres',
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
let schemaObj = createSchemaObject();
|
||||
let getInitData = ()=>Promise.resolve({});
|
||||
|
||||
beforeAll(()=>{
|
||||
jest.spyOn(nodeAjax, 'getNodeAjaxOptions').mockReturnValue(Promise.resolve([]));
|
||||
jest.spyOn(nodeAjax, 'getNodeListByName').mockReturnValue(Promise.resolve([]));
|
||||
schemaObj = getNodePartitionTableSchema({
|
||||
server: {
|
||||
_id: 1,
|
||||
},
|
||||
schema: {
|
||||
_label: 'public',
|
||||
}
|
||||
}, {}, {
|
||||
Nodes: {table: {}},
|
||||
serverInfo: {
|
||||
1: {
|
||||
user: {
|
||||
name: 'Postgres',
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
beforeEach(()=>{
|
||||
genericBeforeEach();
|
||||
});
|
||||
|
||||
it('create', async ()=>{
|
||||
await getCreateView(schemaObj);
|
||||
await getCreateView(createSchemaObject());
|
||||
});
|
||||
|
||||
it('edit', async ()=>{
|
||||
await getEditView(schemaObj, getInitData);
|
||||
await getEditView(createSchemaObject(), getInitData);
|
||||
});
|
||||
|
||||
it('properties', async ()=>{
|
||||
await getPropertiesView(schemaObj, getInitData);
|
||||
await getPropertiesView(createSchemaObject(), getInitData);
|
||||
});
|
||||
|
||||
it('depChange', ()=>{
|
||||
@@ -96,4 +95,3 @@ describe('PartitionTableSchema', ()=>{
|
||||
expect(schemaObj.validate(state, setError)).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ import { PartitionKeysSchema, PartitionsSchema } from '../../../pgadmin/browser/
|
||||
import {addNewDatagridRow, genericBeforeEach, getCreateView, getEditView, getPropertiesView} from '../genericFunctions';
|
||||
import { initializeSchemaWithData } from './utils';
|
||||
|
||||
|
||||
function getFieldDepChange(schema, id) {
|
||||
return _.find(schema.fields, (f)=>f.id==id)?.depChange;
|
||||
}
|
||||
@@ -41,24 +42,24 @@ class SchemaInColl extends BaseUISchema {
|
||||
|
||||
describe('PartitionKeysSchema', ()=>{
|
||||
|
||||
let schemaObj;
|
||||
const createSchemaObject = () => {
|
||||
let partitionObj = new PartitionKeysSchema();
|
||||
return new SchemaInColl(partitionObj);
|
||||
};
|
||||
let schemaObj = createSchemaObject();
|
||||
let getInitData = ()=>Promise.resolve({});
|
||||
|
||||
beforeAll(()=>{
|
||||
jest.spyOn(nodeAjax, 'getNodeAjaxOptions').mockReturnValue(Promise.resolve([]));
|
||||
jest.spyOn(nodeAjax, 'getNodeListByName').mockReturnValue(Promise.resolve([]));
|
||||
let partitionObj = new PartitionKeysSchema();
|
||||
schemaObj = new SchemaInColl(partitionObj);
|
||||
});
|
||||
|
||||
|
||||
|
||||
beforeEach(()=>{
|
||||
genericBeforeEach();
|
||||
});
|
||||
|
||||
it('create', async ()=>{
|
||||
const {ctrl, user} = await getCreateView(schemaObj);
|
||||
const {ctrl, user} = await getCreateView(createSchemaObject());
|
||||
|
||||
/* Make sure you hit every corner */
|
||||
|
||||
@@ -67,11 +68,11 @@ describe('PartitionKeysSchema', ()=>{
|
||||
});
|
||||
|
||||
it('edit', async ()=>{
|
||||
await getEditView(schemaObj, getInitData);
|
||||
await getEditView(createSchemaObject(), getInitData);
|
||||
});
|
||||
|
||||
it('properties', async ()=>{
|
||||
await getPropertiesView(schemaObj, getInitData);
|
||||
await getPropertiesView(createSchemaObject(), getInitData);
|
||||
});
|
||||
|
||||
it('depChange', ()=>{
|
||||
@@ -104,14 +105,17 @@ describe('PartitionKeysSchema', ()=>{
|
||||
|
||||
describe('PartitionsSchema', ()=>{
|
||||
|
||||
let schemaObj;
|
||||
const createSchemaObject = () => {
|
||||
let schemaObj = new PartitionsSchema();
|
||||
schemaObj.top = schemaObj;
|
||||
return schemaObj;
|
||||
};
|
||||
let schemaObj = createSchemaObject();
|
||||
let getInitData = ()=>Promise.resolve({});
|
||||
|
||||
beforeAll(()=>{
|
||||
jest.spyOn(nodeAjax, 'getNodeAjaxOptions').mockReturnValue(Promise.resolve([]));
|
||||
jest.spyOn(nodeAjax, 'getNodeListByName').mockReturnValue(Promise.resolve([]));
|
||||
schemaObj = new PartitionsSchema();
|
||||
schemaObj.top = schemaObj;
|
||||
});
|
||||
|
||||
|
||||
@@ -121,15 +125,15 @@ describe('PartitionsSchema', ()=>{
|
||||
});
|
||||
|
||||
it('create', async ()=>{
|
||||
await getCreateView(schemaObj);
|
||||
await getCreateView(createSchemaObject());
|
||||
});
|
||||
|
||||
it('edit', async ()=>{
|
||||
await getEditView(schemaObj, getInitData);
|
||||
await getEditView(createSchemaObject(), getInitData);
|
||||
});
|
||||
|
||||
it('properties', async ()=>{
|
||||
await getPropertiesView(schemaObj, getInitData);
|
||||
await getPropertiesView(createSchemaObject(), getInitData);
|
||||
});
|
||||
|
||||
it('create collection', async ()=>{
|
||||
|
||||
@@ -20,32 +20,28 @@ class MockSchema extends BaseUISchema {
|
||||
|
||||
describe('PgaJobSchema', ()=>{
|
||||
|
||||
let schemaObj = new PgaJobSchema(
|
||||
const createSchemaObject = () => new PgaJobSchema(
|
||||
{
|
||||
jobjclid:()=>[],
|
||||
},
|
||||
()=>new MockSchema(),
|
||||
);
|
||||
);
|
||||
let getInitData = ()=>Promise.resolve({});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
beforeEach(()=>{
|
||||
genericBeforeEach();
|
||||
});
|
||||
|
||||
it('create', async ()=>{
|
||||
await getCreateView(schemaObj);
|
||||
await getCreateView(createSchemaObject());
|
||||
});
|
||||
|
||||
it('edit', async ()=>{
|
||||
await getEditView(schemaObj, getInitData);
|
||||
await getEditView(createSchemaObject(), getInitData);
|
||||
});
|
||||
|
||||
it('properties', async ()=>{
|
||||
await getPropertiesView(schemaObj, getInitData);
|
||||
await getPropertiesView(createSchemaObject(), getInitData);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -13,22 +13,13 @@ import {genericBeforeEach, getCreateView, getEditView, getPropertiesView} from '
|
||||
|
||||
describe('PgaJobStepSchema', ()=>{
|
||||
|
||||
let schemaObj = new PgaJobStepSchema(
|
||||
{
|
||||
databases: ()=>[],
|
||||
},
|
||||
[],
|
||||
{
|
||||
jstdbname: 'postgres',
|
||||
}
|
||||
);
|
||||
let schemaObj;
|
||||
let getInitData = ()=>Promise.resolve({});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
beforeEach(()=>{
|
||||
schemaObj = new PgaJobStepSchema(
|
||||
{ databases: ()=>[] }, [], { jstdbname: 'postgres' }
|
||||
);
|
||||
genericBeforeEach();
|
||||
});
|
||||
|
||||
|
||||
@@ -10,34 +10,38 @@
|
||||
|
||||
import PgaJobScheduleSchema, { ExceptionsSchema } from '../../../pgadmin/browser/server_groups/servers/pgagent/schedules/static/js/pga_schedule.ui';
|
||||
import {genericBeforeEach, getCreateView, getEditView, getPropertiesView} from '../genericFunctions';
|
||||
import { initializeSchemaWithData } from './utils';
|
||||
|
||||
describe('PgaJobScheduleSchema', ()=>{
|
||||
|
||||
let schemaObj = new PgaJobScheduleSchema([], {
|
||||
const createSchemaObject = () => new PgaJobScheduleSchema([], {
|
||||
jscweekdays:[true,true,true,true,false,false,true],
|
||||
jscexceptions:[{'jexid':81,'jexdate':'2021-08-05','jextime':'12:55:00'},{'jexid':83,'jexdate':'2021-08-17','jextime':'20:00:00'}],
|
||||
jscexceptions:[
|
||||
{'jexid':81,'jexdate':'2021-08-05','jextime':'12:55:00'},
|
||||
{'jexid':83,'jexdate':'2021-08-17','jextime':'20:00:00'}
|
||||
],
|
||||
});
|
||||
let getInitData = ()=>Promise.resolve({});
|
||||
|
||||
|
||||
let getInitData = () => Promise.resolve({});
|
||||
|
||||
beforeEach(()=>{
|
||||
genericBeforeEach();
|
||||
});
|
||||
|
||||
it('create', async ()=>{
|
||||
await getCreateView(schemaObj);
|
||||
it('create', async () => {
|
||||
await getCreateView(createSchemaObject());
|
||||
});
|
||||
|
||||
it('edit', async ()=>{
|
||||
await getEditView(schemaObj, getInitData);
|
||||
it('edit', async () => {
|
||||
await getEditView(createSchemaObject(), getInitData);
|
||||
});
|
||||
|
||||
it('properties', async ()=>{
|
||||
await getPropertiesView(schemaObj, getInitData);
|
||||
it('properties', async () => {
|
||||
await getPropertiesView(createSchemaObject(), getInitData);
|
||||
});
|
||||
|
||||
it('validate', ()=>{
|
||||
it('validate', () => {
|
||||
let schemaObj = createSchemaObject();
|
||||
initializeSchemaWithData(schemaObj, {});
|
||||
let state = {};
|
||||
let setError = jest.fn();
|
||||
|
||||
@@ -59,28 +63,30 @@ describe('PgaJobScheduleSchema', ()=>{
|
||||
});
|
||||
});
|
||||
|
||||
describe('ExceptionsSchema', ()=>{
|
||||
describe('ExceptionsSchema', () => {
|
||||
|
||||
let schemaObj = new ExceptionsSchema();
|
||||
const createSchemaObject = () => new ExceptionsSchema();
|
||||
let getInitData = ()=>Promise.resolve({});
|
||||
|
||||
beforeEach(()=>{
|
||||
genericBeforeEach();
|
||||
});
|
||||
|
||||
it('create', async ()=>{
|
||||
await getCreateView(schemaObj);
|
||||
it('create', async () => {
|
||||
await getCreateView(createSchemaObject());
|
||||
});
|
||||
|
||||
it('edit', async ()=>{
|
||||
await getEditView(schemaObj, getInitData);
|
||||
it('edit', async () => {
|
||||
await getEditView(createSchemaObject(), getInitData);
|
||||
});
|
||||
|
||||
it('properties', async ()=>{
|
||||
await getPropertiesView(schemaObj, getInitData);
|
||||
it('properties', async () => {
|
||||
await getPropertiesView(createSchemaObject(), getInitData);
|
||||
});
|
||||
|
||||
it('validate', ()=>{
|
||||
it('validate', () => {
|
||||
let schemaObj = createSchemaObject();
|
||||
initializeSchemaWithData(schemaObj, {});
|
||||
let state = {};
|
||||
let setError = jest.fn();
|
||||
|
||||
@@ -95,4 +101,3 @@ describe('ExceptionsSchema', ()=>{
|
||||
expect(setError).toHaveBeenCalledWith('jscdate', null);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -47,8 +47,6 @@ describe('PrimaryKeySchema', ()=>{
|
||||
}, {});
|
||||
});
|
||||
|
||||
|
||||
|
||||
beforeEach(()=>{
|
||||
genericBeforeEach();
|
||||
});
|
||||
|
||||
@@ -15,20 +15,17 @@ import {addNewDatagridRow, genericBeforeEach, getCreateView, getEditView, getPro
|
||||
|
||||
describe('PrivilegeSchema', ()=>{
|
||||
|
||||
let schemaObj = new PrivilegeRoleSchema(
|
||||
()=>[],
|
||||
()=>[],
|
||||
null,
|
||||
{server: {user: {name: 'postgres'}}},
|
||||
['X']
|
||||
);
|
||||
let schemaObj;
|
||||
let getInitData = ()=>Promise.resolve({});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
beforeEach(()=>{
|
||||
schemaObj = new PrivilegeRoleSchema(
|
||||
()=>[],
|
||||
()=>[],
|
||||
null,
|
||||
{server: {user: {name: 'postgres'}}},
|
||||
['X']
|
||||
);
|
||||
genericBeforeEach();
|
||||
});
|
||||
|
||||
|
||||
@@ -13,30 +13,28 @@ import {genericBeforeEach, getCreateView, getEditView, getPropertiesView} from '
|
||||
|
||||
describe('PublicationSchema', ()=>{
|
||||
|
||||
let schemaObj = new PublicationSchema(
|
||||
{
|
||||
allTables: ()=>[],
|
||||
allSchemas:()=>[],
|
||||
getColumns: ()=>[],
|
||||
role: ()=>[],
|
||||
},
|
||||
{
|
||||
node_info: {
|
||||
connected: true,
|
||||
user: {id: 10, name: 'postgres', is_superuser: true, can_create_role: true, can_create_db: true},
|
||||
user_id: 1,
|
||||
username: 'postgres',
|
||||
version: 130005,
|
||||
},
|
||||
},
|
||||
);
|
||||
let schemaObj;
|
||||
let getInitData = ()=>Promise.resolve({});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
beforeEach(()=>{
|
||||
schemaObj = new PublicationSchema(
|
||||
{
|
||||
allTables: ()=>[],
|
||||
allSchemas:()=>[],
|
||||
getColumns: ()=>[],
|
||||
role: ()=>[],
|
||||
},
|
||||
{
|
||||
node_info: {
|
||||
connected: true,
|
||||
user: {id: 10, name: 'postgres', is_superuser: true, can_create_role: true, can_create_db: true},
|
||||
user_id: 1,
|
||||
username: 'postgres',
|
||||
version: 130005,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
genericBeforeEach();
|
||||
});
|
||||
|
||||
|
||||
@@ -13,14 +13,12 @@ import {genericBeforeEach, getCreateView, getEditView, getPropertiesView} from '
|
||||
|
||||
describe('ResourceGroupSchema', ()=>{
|
||||
|
||||
let schemaObj = new ResourceGroupSchema();
|
||||
let schemaObj;
|
||||
let getInitData = ()=>Promise.resolve({});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
beforeEach(()=>{
|
||||
beforeEach(() => {
|
||||
schemaObj = new ResourceGroupSchema();
|
||||
genericBeforeEach();
|
||||
});
|
||||
|
||||
|
||||
@@ -14,10 +14,7 @@ import {getCreateView} from '../genericFunctions';
|
||||
|
||||
describe('RestoreSchema', ()=>{
|
||||
|
||||
|
||||
|
||||
|
||||
let restoreSchemaObj = new RestoreSchema(
|
||||
const createSchemaObj = () => new RestoreSchema(
|
||||
()=>getRestoreSectionSchema({selectedNodeType: 'table'}),
|
||||
()=>getRestoreTypeObjSchema({selectedNodeType: 'table'}),
|
||||
()=>getRestoreSaveOptSchema({nodeInfo: {server: {version: 11000}}}),
|
||||
@@ -32,10 +29,11 @@ describe('RestoreSchema', ()=>{
|
||||
);
|
||||
|
||||
it('restore dialog', async ()=>{
|
||||
await getCreateView(restoreSchemaObj);
|
||||
await getCreateView(createSchemaObj());
|
||||
});
|
||||
|
||||
it('restore validate', () => {
|
||||
let restoreSchemaObj = createSchemaObj();
|
||||
let state = { file: undefined }; //validating for empty file
|
||||
let setError = jest.fn();
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ class MockSchema extends BaseUISchema {
|
||||
|
||||
describe('RoleSchema', ()=>{
|
||||
|
||||
let schemaObj = new RoleSchema(
|
||||
const createSchemaObject = () => new RoleSchema(
|
||||
()=>new MockSchema(),
|
||||
()=>new MockSchema(),
|
||||
{
|
||||
@@ -30,24 +30,20 @@ describe('RoleSchema', ()=>{
|
||||
);
|
||||
let getInitData = ()=>Promise.resolve({});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
beforeEach(()=>{
|
||||
genericBeforeEach();
|
||||
});
|
||||
|
||||
it('create', async ()=>{
|
||||
await getCreateView(schemaObj);
|
||||
await getCreateView(createSchemaObject());
|
||||
});
|
||||
|
||||
it('edit', async ()=>{
|
||||
await getEditView(schemaObj, getInitData);
|
||||
await getEditView(createSchemaObject(), getInitData);
|
||||
});
|
||||
|
||||
it('properties', async ()=>{
|
||||
await getPropertiesView(schemaObj, getInitData);
|
||||
await getPropertiesView(createSchemaObject(), getInitData);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ import {genericBeforeEach, getCreateView, getEditView, getPropertiesView} from '
|
||||
|
||||
describe('RowSecurityPolicySchema', ()=>{
|
||||
|
||||
let schemaObj = new RowSecurityPolicySchema(
|
||||
const createSchemaObject = () => new RowSecurityPolicySchema(
|
||||
{
|
||||
role: ()=>[],
|
||||
nodeInfo: {server: {version: 90400}},
|
||||
@@ -21,24 +21,20 @@ describe('RowSecurityPolicySchema', ()=>{
|
||||
);
|
||||
let getInitData = ()=>Promise.resolve({});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
beforeEach(()=>{
|
||||
genericBeforeEach();
|
||||
});
|
||||
|
||||
it('create', async ()=>{
|
||||
await getCreateView(schemaObj);
|
||||
await getCreateView(createSchemaObject());
|
||||
});
|
||||
|
||||
it('edit', async ()=>{
|
||||
await getEditView(schemaObj, getInitData);
|
||||
await getEditView(createSchemaObject(), getInitData);
|
||||
});
|
||||
|
||||
it('properties', async ()=>{
|
||||
await getPropertiesView(schemaObj, getInitData);
|
||||
await getPropertiesView(createSchemaObject(), getInitData);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ import {genericBeforeEach, getCreateView, getEditView, getPropertiesView} from '
|
||||
|
||||
describe('RuleSchema', ()=>{
|
||||
|
||||
let schemaObj = new RuleSchema(
|
||||
const createSchemaObject = () => new RuleSchema(
|
||||
{
|
||||
nodeInfo: {schema: {label: 'public'}, server: {version: 90400}},
|
||||
nodeData: {label: 'Test'}
|
||||
@@ -21,24 +21,20 @@ describe('RuleSchema', ()=>{
|
||||
);
|
||||
let getInitData = ()=>Promise.resolve({});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
beforeEach(()=>{
|
||||
genericBeforeEach();
|
||||
});
|
||||
|
||||
it('create', async ()=>{
|
||||
await getCreateView(schemaObj);
|
||||
await getCreateView(createSchemaObject());
|
||||
});
|
||||
|
||||
it('edit', async ()=>{
|
||||
await getEditView(schemaObj, getInitData);
|
||||
await getEditView(createSchemaObject(), getInitData);
|
||||
});
|
||||
|
||||
it('properties', async ()=>{
|
||||
await getPropertiesView(schemaObj, getInitData);
|
||||
await getPropertiesView(createSchemaObject(), getInitData);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -14,25 +14,23 @@ import {genericBeforeEach, getCreateView, getEditView, getPropertiesView} from '
|
||||
|
||||
describe('PGSchema', ()=>{
|
||||
|
||||
let schemaObj = new PGSchema(
|
||||
const createSchemaObject = () => new PGSchema(
|
||||
()=>getNodePrivilegeRoleSchema({}, {server: {user: {name: 'postgres'}}}, {}),
|
||||
{
|
||||
roles:() => [],
|
||||
namespaceowner: '',
|
||||
}
|
||||
);
|
||||
);
|
||||
let schemaObj = createSchemaObject();
|
||||
let getInitData = ()=>Promise.resolve({});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
beforeEach(()=>{
|
||||
genericBeforeEach();
|
||||
});
|
||||
|
||||
it('create', async ()=>{
|
||||
await getCreateView(schemaObj);
|
||||
await getCreateView(createSchemaObject());
|
||||
});
|
||||
|
||||
it('schema validate', () => {
|
||||
@@ -48,11 +46,11 @@ describe('PGSchema', ()=>{
|
||||
});
|
||||
|
||||
it('edit', async ()=>{
|
||||
await getEditView(schemaObj, getInitData);
|
||||
await getEditView(createSchemaObject(), getInitData);
|
||||
});
|
||||
|
||||
it('properties', async ()=>{
|
||||
await getPropertiesView(schemaObj, getInitData);
|
||||
await getPropertiesView(createSchemaObject(), getInitData);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ class MockSchema extends BaseUISchema {
|
||||
|
||||
describe('SequenceSchema', ()=>{
|
||||
|
||||
let schemaObj = new SequenceSchema(
|
||||
const createSchemaObject = () => new SequenceSchema(
|
||||
()=>new MockSchema(),
|
||||
{
|
||||
role: ()=>[],
|
||||
@@ -30,26 +30,23 @@ describe('SequenceSchema', ()=>{
|
||||
schema: 'public',
|
||||
}
|
||||
);
|
||||
let getInitData = ()=>Promise.resolve({});
|
||||
|
||||
|
||||
|
||||
|
||||
let schemaObj = createSchemaObject();
|
||||
let getInitData = () => Promise.resolve({});
|
||||
|
||||
beforeEach(()=>{
|
||||
genericBeforeEach();
|
||||
});
|
||||
|
||||
it('create', async ()=>{
|
||||
await getCreateView(schemaObj);
|
||||
await getCreateView(createSchemaObject());
|
||||
});
|
||||
|
||||
it('edit', async ()=>{
|
||||
await getEditView(schemaObj, getInitData);
|
||||
await getEditView(createSchemaObject(), getInitData);
|
||||
});
|
||||
|
||||
it('properties', async ()=>{
|
||||
await getPropertiesView(schemaObj, getInitData);
|
||||
await getPropertiesView(createSchemaObject(), getInitData);
|
||||
});
|
||||
|
||||
it('validate', ()=>{
|
||||
|
||||
@@ -14,11 +14,12 @@ import {genericBeforeEach, getCreateView, getEditView, getPropertiesView} from '
|
||||
|
||||
describe('ServerSchema', ()=>{
|
||||
|
||||
let schemaObj = new ServerSchema([{
|
||||
const createSchemaObject = () => new ServerSchema([{
|
||||
label: 'Servers', value: 1,
|
||||
}], 0, {
|
||||
user_id: 'jasmine',
|
||||
});
|
||||
let schemaObj = createSchemaObject();
|
||||
let getInitData = ()=>Promise.resolve({});
|
||||
|
||||
beforeEach(()=>{
|
||||
@@ -27,15 +28,15 @@ describe('ServerSchema', ()=>{
|
||||
});
|
||||
|
||||
it('create', async ()=>{
|
||||
await getCreateView(schemaObj);
|
||||
await getCreateView(createSchemaObject());
|
||||
});
|
||||
|
||||
it('edit', async ()=>{
|
||||
await getEditView(schemaObj, getInitData);
|
||||
await getEditView(createSchemaObject(), getInitData);
|
||||
});
|
||||
|
||||
it('properties', async ()=>{
|
||||
await getPropertiesView(schemaObj, getInitData);
|
||||
await getPropertiesView(createSchemaObject(), getInitData);
|
||||
});
|
||||
|
||||
it('validate', ()=>{
|
||||
|
||||
@@ -13,26 +13,22 @@ import {genericBeforeEach, getCreateView, getEditView, getPropertiesView} from '
|
||||
|
||||
describe('ServerGroupSchema', ()=>{
|
||||
|
||||
let schemaObj = new ServerGroupSchema();
|
||||
const createSchemaObject = () => new ServerGroupSchema();
|
||||
let getInitData = ()=>Promise.resolve({});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
beforeEach(()=>{
|
||||
genericBeforeEach();
|
||||
});
|
||||
|
||||
it('create', async ()=>{
|
||||
await getCreateView(schemaObj);
|
||||
await getCreateView(createSchemaObject());
|
||||
});
|
||||
|
||||
it('edit', async ()=>{
|
||||
await getEditView(schemaObj, getInitData);
|
||||
await getEditView(createSchemaObject(), getInitData);
|
||||
});
|
||||
|
||||
it('properties', async ()=>{
|
||||
await getPropertiesView(schemaObj, getInitData);
|
||||
await getPropertiesView(createSchemaObject(), getInitData);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -11,63 +11,60 @@
|
||||
import SubscriptionSchema from '../../../pgadmin/browser/server_groups/servers/databases/subscriptions/static/js/subscription.ui';
|
||||
import {genericBeforeEach, getCreateView, getEditView, getPropertiesView} from '../genericFunctions';
|
||||
|
||||
describe('SubscriptionSchema', ()=>{
|
||||
describe('SubscriptionSchema', () => {
|
||||
|
||||
let schemaObj = new SubscriptionSchema(
|
||||
{
|
||||
getPublication: ()=>[],
|
||||
role: ()=>[],
|
||||
},
|
||||
{
|
||||
node_info: {
|
||||
connected: true,
|
||||
user: {id: 10, name: 'postgres', is_superuser: true, can_create_role: true, can_create_db: true},
|
||||
user_id: 1,
|
||||
username: 'postgres',
|
||||
version: 130005,
|
||||
server: {host: '127.0.0.1', port: 5432},
|
||||
},
|
||||
},
|
||||
{
|
||||
subowner : 'postgres'
|
||||
}
|
||||
);
|
||||
let schemaObj;
|
||||
let getInitData = ()=>Promise.resolve({});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
beforeEach(()=>{
|
||||
beforeEach(() => {
|
||||
schemaObj = new SubscriptionSchema(
|
||||
{
|
||||
getPublication: ()=>[],
|
||||
role: ()=>[],
|
||||
},
|
||||
{
|
||||
node_info: {
|
||||
connected: true,
|
||||
user: {id: 10, name: 'postgres', is_superuser: true, can_create_role: true, can_create_db: true},
|
||||
user_id: 1,
|
||||
username: 'postgres',
|
||||
version: 130005,
|
||||
server: {host: '127.0.0.1', port: 5432},
|
||||
},
|
||||
},
|
||||
{
|
||||
subowner : 'postgres'
|
||||
}
|
||||
);
|
||||
genericBeforeEach();
|
||||
});
|
||||
|
||||
it('create', async ()=>{
|
||||
it('create', async () => {
|
||||
await getCreateView(schemaObj);
|
||||
});
|
||||
|
||||
it('edit', async ()=>{
|
||||
it('edit', async () => {
|
||||
await getEditView(schemaObj, getInitData);
|
||||
});
|
||||
|
||||
it('properties', async ()=>{
|
||||
it('properties', async () => {
|
||||
await getPropertiesView(schemaObj, getInitData);
|
||||
});
|
||||
|
||||
|
||||
it('copy_data_after_refresh readonly', ()=>{
|
||||
it('copy_data_after_refresh readonly', () => {
|
||||
let isReadonly = _.find(schemaObj.fields, (f)=>f.id=='copy_data_after_refresh').readonly;
|
||||
let status = isReadonly({host: '127.0.0.1', port : 5432});
|
||||
expect(status).toBe(true);
|
||||
});
|
||||
|
||||
it('copy_data_after_refresh readonly', ()=>{
|
||||
it('copy_data_after_refresh readonly', () => {
|
||||
let isReadonly = _.find(schemaObj.fields, (f)=>f.id=='copy_data_after_refresh').readonly;
|
||||
let status = isReadonly({refresh_pub : true});
|
||||
expect(status).toBe(false);
|
||||
});
|
||||
|
||||
it('validate', ()=>{
|
||||
it('validate', () => {
|
||||
let state = {};
|
||||
let setError = jest.fn();
|
||||
|
||||
@@ -88,4 +85,3 @@ describe('SubscriptionSchema', ()=>{
|
||||
expect(setError).toHaveBeenCalledWith('pub', 'Publication must be specified.');
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -11,45 +11,42 @@
|
||||
import SynonymSchema from '../../../pgadmin/browser/server_groups/servers/databases/schemas/synonyms/static/js/synonym.ui';
|
||||
import {genericBeforeEach, getCreateView, getEditView, getPropertiesView} from '../genericFunctions';
|
||||
|
||||
describe('SynonymSchema', ()=>{
|
||||
describe('SynonymSchema', () => {
|
||||
|
||||
let schemaObj = new SynonymSchema(
|
||||
{
|
||||
role: ()=>[],
|
||||
schema: ()=>[],
|
||||
synobjschema: ()=>[],
|
||||
getTargetObjectOptions: ()=>[],
|
||||
},
|
||||
[],
|
||||
{
|
||||
owner: 'postgres',
|
||||
schema: 'public',
|
||||
synobjschema: 'public',
|
||||
}
|
||||
);
|
||||
let schemaObj;
|
||||
let getInitData = ()=>Promise.resolve({});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
beforeEach(()=>{
|
||||
beforeEach(() => {
|
||||
schemaObj = new SynonymSchema(
|
||||
{
|
||||
role: ()=>[],
|
||||
schema: ()=>[],
|
||||
synobjschema: ()=>[],
|
||||
getTargetObjectOptions: ()=>[],
|
||||
},
|
||||
[],
|
||||
{
|
||||
owner: 'postgres',
|
||||
schema: 'public',
|
||||
synobjschema: 'public',
|
||||
}
|
||||
);
|
||||
genericBeforeEach();
|
||||
});
|
||||
|
||||
it('create', async ()=>{
|
||||
it('create', async () => {
|
||||
await getCreateView(schemaObj);
|
||||
});
|
||||
|
||||
it('edit', async ()=>{
|
||||
it('edit', async () => {
|
||||
await getEditView(schemaObj, getInitData);
|
||||
});
|
||||
|
||||
it('properties', async ()=>{
|
||||
it('properties', async () => {
|
||||
await getPropertiesView(schemaObj, getInitData);
|
||||
});
|
||||
|
||||
it('validate', ()=>{
|
||||
it('validate', () => {
|
||||
let state = {};
|
||||
let setError = jest.fn();
|
||||
|
||||
|
||||
@@ -19,52 +19,50 @@ function getFieldDepChange(schema, id) {
|
||||
return _.find(schema.fields, (f)=>f.id==id)?.depChange;
|
||||
}
|
||||
|
||||
describe('TableSchema', ()=>{
|
||||
describe('TableSchema', () => {
|
||||
|
||||
let schemaObj;
|
||||
let getInitData = ()=>Promise.resolve({});
|
||||
|
||||
beforeAll(()=>{
|
||||
jest.spyOn(nodeAjax, 'getNodeAjaxOptions').mockReturnValue(Promise.resolve([]));
|
||||
jest.spyOn(nodeAjax, 'getNodeListByName').mockReturnValue(Promise.resolve([]));
|
||||
schemaObj = getNodeTableSchema({
|
||||
server: {
|
||||
_id: 1,
|
||||
},
|
||||
schema: {
|
||||
_label: 'public',
|
||||
}
|
||||
}, {}, {
|
||||
Nodes: {table: {}},
|
||||
serverInfo: {
|
||||
1: {
|
||||
user: {
|
||||
name: 'Postgres',
|
||||
}
|
||||
const createTableSchemaObject = () => getNodeTableSchema({
|
||||
server: {
|
||||
_id: 1,
|
||||
},
|
||||
schema: {
|
||||
_label: 'public',
|
||||
}
|
||||
}, {}, {
|
||||
Nodes: {table: {}},
|
||||
serverInfo: {
|
||||
1: {
|
||||
user: {
|
||||
name: 'Postgres',
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
let schemaObj = createTableSchemaObject();
|
||||
let getInitData = ()=>Promise.resolve({});
|
||||
|
||||
beforeAll(() => {
|
||||
jest.spyOn(nodeAjax, 'getNodeAjaxOptions').mockReturnValue(Promise.resolve([]));
|
||||
jest.spyOn(nodeAjax, 'getNodeListByName').mockReturnValue(Promise.resolve([]));
|
||||
});
|
||||
|
||||
|
||||
|
||||
beforeEach(()=>{
|
||||
beforeEach(() => {
|
||||
genericBeforeEach();
|
||||
});
|
||||
|
||||
it('create', async ()=>{
|
||||
await getCreateView(schemaObj);
|
||||
it('create', async () => {
|
||||
await getCreateView(createTableSchemaObject());
|
||||
});
|
||||
|
||||
it('edit', async ()=>{
|
||||
await getEditView(schemaObj, getInitData);
|
||||
it('edit', async () => {
|
||||
await getEditView(createTableSchemaObject(), getInitData);
|
||||
});
|
||||
|
||||
it('properties', async ()=>{
|
||||
await getPropertiesView(schemaObj, getInitData);
|
||||
it('properties', async () => {
|
||||
await getPropertiesView(createTableSchemaObject(), getInitData);
|
||||
});
|
||||
|
||||
it('getTableOid', ()=>{
|
||||
it('getTableOid', () => {
|
||||
schemaObj.inheritedTableList = [
|
||||
{label: 'tab1', tid: 140391},
|
||||
{label: 'tab2', tid: 180191}
|
||||
@@ -72,12 +70,12 @@ describe('TableSchema', ()=>{
|
||||
expect(schemaObj.getTableOid('tab2')).toBe(180191);
|
||||
});
|
||||
|
||||
it('canEditDeleteRowColumns', ()=>{
|
||||
it('canEditDeleteRowColumns', () => {
|
||||
expect(schemaObj.canEditDeleteRowColumns({inheritedfrom: 1234})).toBe(false);
|
||||
expect(schemaObj.canEditDeleteRowColumns({inheritedfrom: null})).toBe(true);
|
||||
});
|
||||
|
||||
it('LikeSchema typname change', ()=>{
|
||||
it('LikeSchema typname change', () => {
|
||||
let likeSchemaObj = new LikeSchema([]);
|
||||
/* Dummy */
|
||||
likeSchemaObj.top = new LikeSchema([]);
|
||||
@@ -96,13 +94,13 @@ describe('TableSchema', ()=>{
|
||||
});
|
||||
});
|
||||
|
||||
describe('typname change', ()=>{
|
||||
describe('typname change', () => {
|
||||
let confirmSpy;
|
||||
let deferredDepChange;
|
||||
let oftypeColumns = [
|
||||
{name: 'id'}
|
||||
];
|
||||
beforeEach(()=>{
|
||||
beforeEach(() => {
|
||||
jest.spyOn(schemaObj, 'changeColumnOptions');
|
||||
jest.spyOn(schemaObj, 'getTableOid').mockReturnValue(140391);
|
||||
confirmSpy = jest.spyOn(pgAdmin.Browser.notifier, 'confirm');
|
||||
@@ -184,7 +182,7 @@ describe('TableSchema', ()=>{
|
||||
});
|
||||
});
|
||||
|
||||
describe('coll_inherits change', ()=>{
|
||||
describe('coll_inherits change', () => {
|
||||
let deferredDepChange;
|
||||
let inheritCol = {name: 'id'};
|
||||
let onRemoveAction = (depChange, state, done)=> {
|
||||
@@ -197,7 +195,7 @@ describe('TableSchema', ()=>{
|
||||
done();
|
||||
};
|
||||
|
||||
beforeEach(()=>{
|
||||
beforeEach(() => {
|
||||
jest.spyOn(schemaObj, 'changeColumnOptions');
|
||||
jest.spyOn(schemaObj, 'getTableOid').mockReturnValue(140391);
|
||||
jest.spyOn(schemaObj, 'getColumns').mockReturnValue(Promise.resolve([inheritCol]));
|
||||
@@ -271,7 +269,7 @@ describe('TableSchema', ()=>{
|
||||
});
|
||||
});
|
||||
|
||||
it('depChange', ()=>{
|
||||
it('depChange', () => {
|
||||
jest.spyOn(schemaObj, 'getTableOid').mockReturnValue(140391);
|
||||
let state = {};
|
||||
|
||||
@@ -300,7 +298,7 @@ describe('TableSchema', ()=>{
|
||||
});
|
||||
});
|
||||
|
||||
it('validate', ()=>{
|
||||
it('validate', () => {
|
||||
let state = {is_partitioned: true};
|
||||
let setError = jest.fn();
|
||||
|
||||
|
||||
@@ -20,23 +20,20 @@ class MockSchema extends BaseUISchema {
|
||||
|
||||
describe('TablespaceSchema', ()=>{
|
||||
|
||||
let schemaObj = new TablespaceSchema(
|
||||
()=>new MockSchema(),
|
||||
()=>new MockSchema(),
|
||||
{
|
||||
role: ()=>[],
|
||||
},
|
||||
{
|
||||
spcuser: 'postgres'
|
||||
}
|
||||
);
|
||||
let schemaObj;
|
||||
let getInitData = ()=>Promise.resolve({});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
beforeEach(()=>{
|
||||
schemaObj = new TablespaceSchema(
|
||||
()=>new MockSchema(),
|
||||
()=>new MockSchema(),
|
||||
{
|
||||
role: ()=>[],
|
||||
},
|
||||
{
|
||||
spcuser: 'postgres'
|
||||
}
|
||||
);
|
||||
genericBeforeEach();
|
||||
});
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ import {genericBeforeEach, getCreateView, getEditView, getPropertiesView} from '
|
||||
|
||||
describe('TriggerSchema', ()=>{
|
||||
|
||||
let schemaObj = new TriggerSchema(
|
||||
let createSchemaObj = () => new TriggerSchema(
|
||||
{
|
||||
triggerFunction: [],
|
||||
columns: [],
|
||||
@@ -26,27 +26,24 @@ describe('TriggerSchema', ()=>{
|
||||
);
|
||||
let getInitData = ()=>Promise.resolve({});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
beforeEach(()=>{
|
||||
genericBeforeEach();
|
||||
});
|
||||
|
||||
it('create', async ()=>{
|
||||
await getCreateView(schemaObj);
|
||||
await getCreateView(createSchemaObj());
|
||||
});
|
||||
|
||||
it('edit', async ()=>{
|
||||
await getEditView(schemaObj, getInitData);
|
||||
await getEditView(createSchemaObj(), getInitData);
|
||||
});
|
||||
|
||||
it('properties', async ()=>{
|
||||
await getPropertiesView(schemaObj, getInitData);
|
||||
await getPropertiesView(createSchemaObj(), getInitData);
|
||||
});
|
||||
|
||||
it('validate', ()=>{
|
||||
const schemaObj = createSchemaObj();
|
||||
let state = {};
|
||||
let setError = jest.fn();
|
||||
|
||||
@@ -148,7 +145,7 @@ describe('TriggerSchema', ()=>{
|
||||
|
||||
describe('TriggerEventsSchema', ()=>{
|
||||
|
||||
let schemaObj = new EventSchema(
|
||||
let createEventSchemaObj = () => new EventSchema(
|
||||
{
|
||||
nodeInfo: {
|
||||
server: {user: {name:'postgres', id:0}, server_type: 'pg', version: 90400},
|
||||
@@ -167,18 +164,19 @@ describe('TriggerEventsSchema', ()=>{
|
||||
});
|
||||
|
||||
it('create', async ()=>{
|
||||
await getCreateView(schemaObj);
|
||||
await getCreateView(createEventSchemaObj());
|
||||
});
|
||||
|
||||
it('properties', async ()=>{
|
||||
await getPropertiesView(schemaObj, getInitData);
|
||||
await getPropertiesView(createEventSchemaObj(), getInitData);
|
||||
});
|
||||
|
||||
it('edit', async ()=>{
|
||||
await getEditView(schemaObj, getInitData);
|
||||
await getEditView(createEventSchemaObj(), getInitData);
|
||||
});
|
||||
|
||||
it('validate', ()=>{
|
||||
const schemaObj = createEventSchemaObj();
|
||||
let state = {};
|
||||
let setError = jest.fn();
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ class MockSchema extends BaseUISchema {
|
||||
|
||||
describe('TriggerFunctionSchema', ()=>{
|
||||
|
||||
let schemaObj = new TriggerFunctionSchema(
|
||||
const createSchemaObject = () => new TriggerFunctionSchema(
|
||||
()=>new MockSchema(),
|
||||
()=>new MockSchema(),
|
||||
{
|
||||
@@ -33,32 +33,29 @@ describe('TriggerFunctionSchema', ()=>{
|
||||
funcowner: 'postgres',
|
||||
pronamespace: 'public'
|
||||
}
|
||||
);
|
||||
);
|
||||
let getInitData = ()=>Promise.resolve({});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
beforeEach(()=>{
|
||||
genericBeforeEach();
|
||||
});
|
||||
|
||||
it('create', async ()=>{
|
||||
await getCreateView(schemaObj);
|
||||
await getCreateView(createSchemaObject());
|
||||
});
|
||||
|
||||
it('edit', async ()=>{
|
||||
await getEditView(schemaObj, getInitData);
|
||||
await getEditView(createSchemaObject(), getInitData);
|
||||
});
|
||||
|
||||
it('properties', async ()=>{
|
||||
await getPropertiesView(schemaObj, getInitData);
|
||||
await getPropertiesView(createSchemaObject(), getInitData);
|
||||
});
|
||||
|
||||
it('validate', ()=>{
|
||||
let state = {};
|
||||
let setError = jest.fn();
|
||||
let schemaObj = createSchemaObject();
|
||||
|
||||
state.prosrc = null;
|
||||
schemaObj.validate(state, setError);
|
||||
|
||||
@@ -13,6 +13,68 @@ import { getNodePrivilegeRoleSchema } from '../../../pgadmin/browser/server_grou
|
||||
import TypeSchema, { EnumerationSchema, getCompositeSchema, getExternalSchema, getRangeSchema, getDataTypeSchema } from '../../../pgadmin/browser/server_groups/servers/databases/schemas/types/static/js/type.ui';
|
||||
import {genericBeforeEach, getCreateView, getEditView, getPropertiesView} from '../genericFunctions';
|
||||
|
||||
const types = [{
|
||||
label: '', value: ''
|
||||
}, {
|
||||
label: 'lb1', value: 'numeric[]', length: true,
|
||||
min_val: 10, max_val: 100, precision: true, is_collatable: true,
|
||||
}];
|
||||
|
||||
const createCompositeSchemaObject = () => {
|
||||
let compositeCollObj = getCompositeSchema(
|
||||
{}, {server: {user: {name: 'postgres'}}}, {}
|
||||
);
|
||||
let collations = [
|
||||
{ label: '', value: ''}, { label: 'lb1', value: 'numeric[]'}
|
||||
];
|
||||
|
||||
jest.spyOn(compositeCollObj.fieldOptions, 'types').mockReturnValue(types);
|
||||
jest.spyOn(compositeCollObj.fieldOptions, 'collations')
|
||||
.mockReturnValue(collations);
|
||||
|
||||
return compositeCollObj;
|
||||
};
|
||||
|
||||
const createExternalSchemaObject = () => {
|
||||
|
||||
let externalCollObj = getExternalSchema({}, {server: {user: {name: 'postgres'}}}, {});
|
||||
|
||||
jest.spyOn(externalCollObj.fieldOptions, 'externalFunctionsList')
|
||||
.mockReturnValue([
|
||||
{ label: '', value: ''},
|
||||
{ label: 'lb1', cbtype: 'typmodin', value: 'val1'},
|
||||
{ label: 'lb2', cbtype: 'all', value: 'val2'}
|
||||
]);
|
||||
jest.spyOn(externalCollObj.fieldOptions, 'types')
|
||||
.mockReturnValue([{ label: '', value: ''}]);
|
||||
|
||||
return externalCollObj;
|
||||
};
|
||||
|
||||
const createRangeSchemaObject = () => {
|
||||
let rangeCollObj = getRangeSchema({}, {server: {user: {name: 'postgres'}}}, {});
|
||||
|
||||
jest.spyOn(rangeCollObj.fieldOptions, 'getSubOpClass').mockReturnValue([
|
||||
{ label: '', value: ''}, { label: 'lb1', value: 'val1'}
|
||||
]);
|
||||
jest.spyOn(rangeCollObj.fieldOptions, 'getCanonicalFunctions')
|
||||
.mockReturnValue([
|
||||
{ label: '', value: ''}, { label: 'lb1', value: 'val1'}
|
||||
]);
|
||||
jest.spyOn(rangeCollObj.fieldOptions, 'getSubDiffFunctions')
|
||||
.mockReturnValue([
|
||||
{ label: '', value: ''}, { label: 'lb1', value: 'val1'}
|
||||
]);
|
||||
jest.spyOn(rangeCollObj.fieldOptions, 'typnameList').mockReturnValue([
|
||||
{ label: '', value: ''}, { label: 'lb1', value: 'val1'}
|
||||
]);
|
||||
jest.spyOn(rangeCollObj.fieldOptions, 'collationsList').mockReturnValue([
|
||||
{ label: '', value: ''}, { label: 'lb1', value: 'val1'}
|
||||
]);
|
||||
|
||||
return rangeCollObj;
|
||||
};
|
||||
|
||||
describe('TypeSchema', ()=>{
|
||||
let getInitData = ()=>Promise.resolve({});
|
||||
|
||||
@@ -21,15 +83,10 @@ describe('TypeSchema', ()=>{
|
||||
});
|
||||
|
||||
describe('composite schema describe', () => {
|
||||
let compositeCollObj = createCompositeSchemaObject();
|
||||
|
||||
let compositeCollObj = getCompositeSchema({}, {server: {user: {name: 'postgres'}}}, {});
|
||||
let types = [{ label: '', value: ''}, { label: 'lb1', value: 'numeric[]', length: true, min_val: 10, max_val: 100, precision: true, is_collatable: true}];
|
||||
let collations = [{ label: '', value: ''}, { label: 'lb1', value: 'numeric[]'}];
|
||||
|
||||
it('composite collection', async ()=>{
|
||||
it('composite collection', async () => {
|
||||
jest.spyOn(nodeAjax, 'getNodeAjaxOptions').mockReturnValue([]);
|
||||
jest.spyOn(compositeCollObj.fieldOptions, 'types').mockReturnValue(types);
|
||||
jest.spyOn(compositeCollObj.fieldOptions, 'collations').mockReturnValue(collations);
|
||||
await getCreateView(compositeCollObj);
|
||||
await getEditView(compositeCollObj, getInitData);
|
||||
});
|
||||
@@ -91,13 +148,10 @@ describe('TypeSchema', ()=>{
|
||||
|
||||
describe('external schema describe', () => {
|
||||
|
||||
let externalCollObj = getExternalSchema({}, {server: {user: {name: 'postgres'}}}, {});
|
||||
let externalCollObj = createExternalSchemaObject();
|
||||
|
||||
it('external collection', async ()=>{
|
||||
|
||||
jest.spyOn(nodeAjax, 'getNodeAjaxOptions').mockReturnValue([]);
|
||||
jest.spyOn(externalCollObj.fieldOptions, 'externalFunctionsList').mockReturnValue([{ label: '', value: ''}, { label: 'lb1', cbtype: 'typmodin', value: 'val1'}, { label: 'lb2', cbtype: 'all', value: 'val2'}]);
|
||||
jest.spyOn(externalCollObj.fieldOptions, 'types').mockReturnValue([{ label: '', value: ''}]);
|
||||
|
||||
await getCreateView(externalCollObj);
|
||||
await getEditView(externalCollObj, getInitData);
|
||||
@@ -118,16 +172,11 @@ describe('TypeSchema', ()=>{
|
||||
|
||||
describe('range schema describe', () => {
|
||||
|
||||
let rangeCollObj = getRangeSchema({}, {server: {user: {name: 'postgres'}}}, {});
|
||||
let rangeCollObj = createRangeSchemaObject();
|
||||
|
||||
it('range collection', async ()=>{
|
||||
it('range collection', async () => {
|
||||
|
||||
jest.spyOn(nodeAjax, 'getNodeAjaxOptions').mockReturnValue([]);
|
||||
jest.spyOn(rangeCollObj.fieldOptions, 'getSubOpClass').mockReturnValue([{ label: '', value: ''}, { label: 'lb1', value: 'val1'}]);
|
||||
jest.spyOn(rangeCollObj.fieldOptions, 'getCanonicalFunctions').mockReturnValue([{ label: '', value: ''}, { label: 'lb1', value: 'val1'}]);
|
||||
jest.spyOn(rangeCollObj.fieldOptions, 'getSubDiffFunctions').mockReturnValue([{ label: '', value: ''}, { label: 'lb1', value: 'val1'}]);
|
||||
jest.spyOn(rangeCollObj.fieldOptions, 'typnameList').mockReturnValue([{ label: '', value: ''}, { label: 'lb1', value: 'val1'}]);
|
||||
jest.spyOn(rangeCollObj.fieldOptions, 'collationsList').mockReturnValue([{ label: '', value: ''}, { label: 'lb1', value: 'val1'}]);
|
||||
|
||||
await getCreateView(rangeCollObj);
|
||||
await getEditView(rangeCollObj, getInitData);
|
||||
@@ -145,7 +194,13 @@ describe('TypeSchema', ()=>{
|
||||
describe('data type schema describe', () => {
|
||||
|
||||
let dataTypeObj = getDataTypeSchema({}, {server: {user: {name: 'postgres'}}}, {});
|
||||
let types = [{ label: '', value: ''}, { label: 'lb1', value: 'numeric', length: true, min_val: 10, max_val: 100, precision: true}];
|
||||
const types = [
|
||||
{ label: '', value: ''},
|
||||
{
|
||||
label: 'lb1', value: 'numeric', length: true,
|
||||
min_val: 10, max_val: 100, precision: true,
|
||||
}
|
||||
];
|
||||
|
||||
it('data type collection', async ()=>{
|
||||
|
||||
@@ -183,34 +238,40 @@ describe('TypeSchema', ()=>{
|
||||
});
|
||||
});
|
||||
|
||||
let typeSchemaObj = new TypeSchema(
|
||||
(privileges)=>getNodePrivilegeRoleSchema({}, {server: {user: {name: 'postgres'}}}, {}, privileges),
|
||||
()=>getCompositeSchema({}, {server: {user: {name: 'postgres'}}}, {}),
|
||||
()=>getRangeSchema({}, {server: {user: {name: 'postgres'}}}, {}),
|
||||
()=>getExternalSchema({}, {server: {user: {name: 'postgres'}}}, {}),
|
||||
()=>getDataTypeSchema({}, {server: {user: {name: 'postgres'}}}, {}),
|
||||
{
|
||||
roles: ()=>[],
|
||||
schemas: ()=>[{ label: 'pg_demo', value: 'pg_demo'}],
|
||||
server_info: [],
|
||||
node_info: {'schema': []}
|
||||
},
|
||||
{
|
||||
typowner: 'postgres',
|
||||
schema: 'public',
|
||||
typtype: 'c'
|
||||
}
|
||||
);
|
||||
const createTypeSchemaObject = () => {
|
||||
jest.spyOn(nodeAjax, 'getNodeAjaxOptions').mockReturnValue([]);
|
||||
|
||||
return new TypeSchema(
|
||||
(privileges)=>getNodePrivilegeRoleSchema(
|
||||
{}, {server: {user: {name: 'postgres'}}}, {}, privileges
|
||||
),
|
||||
()=>createCompositeSchemaObject(),
|
||||
()=>createRangeSchemaObject(),
|
||||
()=>createExternalSchemaObject(),
|
||||
()=>getDataTypeSchema({}, {server: {user: {name: 'postgres'}}}, {}),
|
||||
{
|
||||
roles: ()=>[],
|
||||
schemas: ()=>[{ label: 'pg_demo', value: 'pg_demo'}],
|
||||
server_info: [],
|
||||
node_info: {'schema': []}
|
||||
},
|
||||
{
|
||||
typowner: 'postgres',
|
||||
schema: 'public',
|
||||
typtype: 'c'
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
it('create', async ()=>{
|
||||
await getCreateView(typeSchemaObj);
|
||||
await getCreateView(createTypeSchemaObject());
|
||||
});
|
||||
|
||||
it('edit', async ()=>{
|
||||
await getEditView(typeSchemaObj, getInitData);
|
||||
await getEditView(createTypeSchemaObject(), getInitData);
|
||||
});
|
||||
|
||||
it('properties', async ()=>{
|
||||
await getPropertiesView(typeSchemaObj, getInitData);
|
||||
await getPropertiesView(createTypeSchemaObject(), getInitData);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -47,8 +47,6 @@ describe('UniqueConstraintSchema', ()=>{
|
||||
}, {});
|
||||
});
|
||||
|
||||
|
||||
|
||||
beforeEach(()=>{
|
||||
genericBeforeEach();
|
||||
});
|
||||
|
||||
@@ -18,36 +18,33 @@ class MockSchema extends BaseUISchema {
|
||||
}
|
||||
}
|
||||
|
||||
describe('UserMappingSchema', ()=>{
|
||||
describe('UserMappingSchema', () => {
|
||||
|
||||
let schemaObj = new UserMappingSchema(
|
||||
()=>new MockSchema(),
|
||||
{
|
||||
role: ()=>[],
|
||||
},
|
||||
{
|
||||
name: 'postgres'
|
||||
}
|
||||
);
|
||||
let schemaObj;
|
||||
let getInitData = ()=>Promise.resolve({});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
beforeEach(()=>{
|
||||
beforeEach(() => {
|
||||
schemaObj = new UserMappingSchema(
|
||||
()=>new MockSchema(),
|
||||
{
|
||||
role: ()=>[],
|
||||
},
|
||||
{
|
||||
name: 'postgres'
|
||||
}
|
||||
);
|
||||
genericBeforeEach();
|
||||
});
|
||||
|
||||
it('create', async ()=>{
|
||||
it('create', async () => {
|
||||
await getCreateView(schemaObj);
|
||||
});
|
||||
|
||||
it('edit', async ()=>{
|
||||
it('edit', async () => {
|
||||
await getEditView(schemaObj, getInitData);
|
||||
});
|
||||
|
||||
it('properties', async ()=>{
|
||||
it('properties', async () => {
|
||||
await getPropertiesView(schemaObj, getInitData);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -7,7 +7,9 @@
|
||||
//
|
||||
//////////////////////////////////////////////////////////////
|
||||
|
||||
import { SchemaState } from '../../../pgadmin/static/js/SchemaView/useSchemaState';
|
||||
import {
|
||||
SchemaState,
|
||||
} from '../../../pgadmin/static/js/SchemaView/SchemaState';
|
||||
|
||||
export function initializeSchemaWithData(schema, data) {
|
||||
const state = schema.state = new SchemaState(
|
||||
|
||||
@@ -34,32 +34,29 @@ class MockSchema extends BaseUISchema {
|
||||
|
||||
describe('VariableSchema', ()=>{
|
||||
|
||||
let schemaObj = new VariableSchema(
|
||||
const createSchemaObject = () => new VariableSchema(
|
||||
()=>[],
|
||||
()=>[],
|
||||
()=>[],
|
||||
null
|
||||
);
|
||||
let schemaObj = createSchemaObject();
|
||||
let getInitData = ()=>Promise.resolve({});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
beforeEach(()=>{
|
||||
genericBeforeEach();
|
||||
});
|
||||
|
||||
it('create', async ()=>{
|
||||
await getCreateView(schemaObj);
|
||||
await getCreateView(createSchemaObject());
|
||||
});
|
||||
|
||||
it('edit', async ()=>{
|
||||
await getEditView(schemaObj, getInitData);
|
||||
await getEditView(createSchemaObject(), getInitData);
|
||||
});
|
||||
|
||||
it('properties', async ()=>{
|
||||
await getPropertiesView(schemaObj, getInitData);
|
||||
await getPropertiesView(createSchemaObject(), getInitData);
|
||||
});
|
||||
|
||||
it('getValueFieldProps', ()=>{
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
import BaseUISchema from 'sources/SchemaView/base_schema.ui';
|
||||
import ViewSchema from '../../../pgadmin/browser/server_groups/servers/databases/schemas/views/static/js/view.ui';
|
||||
import {genericBeforeEach, getCreateView, getEditView, getPropertiesView} from '../genericFunctions';
|
||||
import { initializeSchemaWithData } from './utils';
|
||||
|
||||
class MockSchema extends BaseUISchema {
|
||||
get baseFields() {
|
||||
@@ -20,25 +21,22 @@ class MockSchema extends BaseUISchema {
|
||||
|
||||
describe('ViewSchema', ()=>{
|
||||
|
||||
let schemaObj = new ViewSchema(
|
||||
()=>new MockSchema(),
|
||||
{server: {server_type: 'pg'}},
|
||||
{
|
||||
role: ()=>[],
|
||||
schema: ()=>[],
|
||||
},
|
||||
{
|
||||
owner: 'postgres',
|
||||
schema: 'public'
|
||||
}
|
||||
);
|
||||
let schemaObj;
|
||||
let getInitData = ()=>Promise.resolve({});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
beforeEach(()=>{
|
||||
schemaObj = new ViewSchema(
|
||||
()=>new MockSchema(),
|
||||
{server: {server_type: 'pg'}},
|
||||
{
|
||||
role: ()=>[],
|
||||
schema: ()=>[],
|
||||
},
|
||||
{
|
||||
owner: 'postgres',
|
||||
schema: 'public'
|
||||
}
|
||||
);
|
||||
genericBeforeEach();
|
||||
});
|
||||
|
||||
@@ -57,6 +55,7 @@ describe('ViewSchema', ()=>{
|
||||
it('validate', ()=>{
|
||||
let state = {};
|
||||
let setError = jest.fn();
|
||||
initializeSchemaWithData(schemaObj, {});
|
||||
|
||||
state.definition = null;
|
||||
schemaObj.validate(state, setError);
|
||||
@@ -77,4 +76,3 @@ describe('ViewSchema', ()=>{
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user