Significant changes to use ReactJS extensively.

1. Replace the current layout library wcDocker with ReactJS based rc-dock. #6479
2. Have close buttons on individual panel tabs instead of common. #2821
3. Changes in the context menu on panel tabs - Add close, close all and close others menu items. #5394
4. Allow closing all the tabs, including SQL and Properties. #4733
5. Changes in docking behaviour of different tabs based on user requests and remove lock layout menu.
6. Fix an issue where the scroll position of panels was not remembered on Firefox. #2986
7. Reset layout now will not require page refresh and is done spontaneously.
8. Use the zustand store for storing preferences instead of plain JS objects. This will help reflecting preferences immediately.
9. The above fix incorrect format (no indent) of SQL stored functions/procedures. #6720
10. New version check is moved to an async request now instead of app start to improve startup performance.
11. Remove jQuery and Bootstrap completely.
12. Replace jasmine and karma test runner with jest. Migrate all the JS test cases to jest. This will save time in writing and debugging JS tests.
13. Other important code improvements and cleanup.
This commit is contained in:
Aditya Toshniwal
2023-10-23 17:43:17 +05:30
committed by GitHub
parent 6d555645e9
commit 862f101772
373 changed files with 11149 additions and 14836 deletions

View File

@@ -7,40 +7,33 @@
//
//////////////////////////////////////////////////////////////
import '../helper/enzyme.helper';
import { createMount } from '@material-ui/core/test-utils';
import AggregateSchema from '../../../pgadmin/browser/server_groups/servers/databases/schemas/aggregates/static/js/aggregate.ui';
import {genericBeforeEach, getCreateView, getEditView, getPropertiesView} from '../genericFunctions';
describe('AggregateSchema', ()=>{
let mount;
let schemaObj = new AggregateSchema();
let getInitData = ()=>Promise.resolve({});
/* Use createMount so that material ui components gets the required context */
/* https://material-ui.com/guides/testing/#api */
beforeAll(()=>{
mount = createMount();
});
afterAll(() => {
mount.cleanUp();
});
beforeEach(()=>{
genericBeforeEach();
});
it('create', ()=>{
mount(getCreateView(schemaObj));
it('create', async ()=>{
await getCreateView(schemaObj);
});
it('edit', ()=>{
mount(getEditView(schemaObj, getInitData));
it('edit', async ()=>{
await getEditView(schemaObj, getInitData);
});
it('properties', ()=>{
mount(getPropertiesView(schemaObj, getInitData));
it('properties', async ()=>{
await getPropertiesView(schemaObj, getInitData);
});
});

View File

@@ -8,23 +8,15 @@
//////////////////////////////////////////////////////////////
import React from 'react';
import '../helper/enzyme.helper';
import { createMount } from '@material-ui/core/test-utils';
import pgAdmin from 'sources/pgadmin';
import SchemaView from '../../../pgadmin/static/js/SchemaView';
import BackupSchema, {getSectionSchema, getTypeObjSchema, getSaveOptSchema, getDisabledOptionSchema, getMiscellaneousSchema} from '../../../pgadmin/tools/backup/static/js/backup.ui';
import Theme from '../../../pgadmin/static/js/Theme';
import { getCreateView, withBrowser } from '../genericFunctions';
import { act, render } from '@testing-library/react';
describe('BackupSchema', ()=>{
let mount;
beforeAll(()=>{
mount = createMount();
});
afterAll(() => {
mount.cleanUp();
});
let backupSchemaObj = new BackupSchema(
()=> getSectionSchema(),
()=> getTypeObjSchema(),
@@ -41,24 +33,8 @@ describe('BackupSchema', ()=>{
[]
);
it('create object backup', ()=>{
mount(<Theme>
<SchemaView
formType='dialog'
schema={backupSchemaObj}
viewHelperProps={{
mode: 'create',
}}
onSave={()=>{/*This is intentional (SonarQube)*/}}
onClose={()=>{/*This is intentional (SonarQube)*/}}
onHelp={()=>{/*This is intentional (SonarQube)*/}}
onDataChange={()=>{/*This is intentional (SonarQube)*/}}
confirmOnCloseReset={false}
hasSQL={false}
disableSqlHelp={false}
disableDialogHelp={false}
/>
</Theme>);
it('create object backup', async ()=>{
await getCreateView(backupSchemaObj);
});
@@ -78,9 +54,10 @@ describe('BackupSchema', ()=>{
[{'id': 'public','name': 'public','icon': 'icon-schema', 'children': [{'id': 'public_table','name': 'table','icon': 'icon-coll-table','children': [{'id': 'public_test','name': 'test','icon': 'icon-table','schema': 'public','type': 'table','_name': 'public.test'}],'type': 'table','is_collection': true}],'is_schema': true}]
);
it('create selected object backup', ()=>{
mount(<Theme>
<SchemaView
it('create selected object backup', async ()=>{
const WithBrowser = withBrowser(SchemaView);
await act(async ()=>{
await render(<WithBrowser
formType='dialog'
schema={backupSelectedSchemaObj}
viewHelperProps={{
@@ -95,7 +72,8 @@ describe('BackupSchema', ()=>{
disableSqlHelp={false}
disableDialogHelp={false}
/>
</Theme>);
);
});
});
@@ -115,24 +93,8 @@ describe('BackupSchema', ()=>{
[]
);
it('create server backup', ()=>{
mount(<Theme>
<SchemaView
formType='dialog'
schema={backupServerSchemaObj}
viewHelperProps={{
mode: 'create',
}}
onSave={()=>{/*This is intentional (SonarQube)*/}}
onClose={()=>{/*This is intentional (SonarQube)*/}}
onHelp={()=>{/*This is intentional (SonarQube)*/}}
onDataChange={()=>{/*This is intentional (SonarQube)*/}}
confirmOnCloseReset={false}
hasSQL={false}
disableSqlHelp={false}
disableDialogHelp={false}
/>
</Theme>);
it('create server backup', async ()=>{
await getCreateView(backupServerSchemaObj);
});
});

View File

@@ -7,23 +7,12 @@
//
//////////////////////////////////////////////////////////////
import React from 'react';
import '../helper/enzyme.helper';
import { createMount } from '@material-ui/core/test-utils';
import SchemaView from '../../../pgadmin/static/js/SchemaView';
import BackupGlobalSchema, {getMiscellaneousSchema} from '../../../pgadmin/tools/backup/static/js/backupGlobal.ui';
import Theme from '../../../pgadmin/static/js/Theme';
import { getCreateView } from '../genericFunctions';
describe('BackupGlobalSchema', ()=>{
let mount;
beforeAll(()=>{
mount = createMount();
});
afterAll(() => {
mount.cleanUp();
});
let backupGlobalSchemaObj = new BackupGlobalSchema(
()=> getMiscellaneousSchema(),
{
@@ -31,24 +20,8 @@ describe('BackupGlobalSchema', ()=>{
}
);
it('create', ()=>{
mount(<Theme>
<SchemaView
formType='dialog'
schema={backupGlobalSchemaObj}
viewHelperProps={{
mode: 'create',
}}
onSave={()=>{/*This is intentional (SonarQube)*/}}
onClose={()=>{/*This is intentional (SonarQube)*/}}
onHelp={()=>{/*This is intentional (SonarQube)*/}}
onDataChange={()=>{/*This is intentional (SonarQube)*/}}
confirmOnCloseReset={false}
hasSQL={false}
disableSqlHelp={false}
disableDialogHelp={false}
/>
</Theme>);
it('create', async ()=>{
await getCreateView(backupGlobalSchemaObj);
});
});

View File

@@ -8,34 +8,28 @@
//
//////////////////////////////////////////////////////////////
import '../helper/enzyme.helper';
import { createMount } from '@material-ui/core/test-utils';
import Notify from '../../../pgadmin/static/js/helpers/Notifier';
import {genericBeforeEach, getEditView} from '../genericFunctions';
import {getBinaryPathSchema} from '../../../pgadmin/browser/server_groups/servers/static/js/binary_path.ui';
import pgAdmin from '../fake_pgadmin';
describe('BinaryPathschema', ()=>{
let mount;
let schemaObj = getBinaryPathSchema();
let getInitData = ()=>Promise.resolve({});
/* Use createMount so that material ui components gets the required context */
/* https://material-ui.com/guides/testing/#api */
beforeAll(()=>{
mount = createMount();
spyOn(Notify, 'alert');
jest.spyOn(pgAdmin.Browser.notifier, 'alert').mockImplementation(() => {});
});
afterAll(() => {
mount.cleanUp();
});
beforeEach(()=>{
genericBeforeEach();
});
it('edit', ()=>{
mount(getEditView(schemaObj, getInitData));
it('edit', async ()=>{
await getEditView(schemaObj, getInitData);
});
it('validate path', ()=>{

View File

@@ -7,14 +7,13 @@
//
//////////////////////////////////////////////////////////////
import '../helper/enzyme.helper';
import { createMount } from '@material-ui/core/test-utils';
import CastSchema from '../../../pgadmin/browser/server_groups/servers/databases/casts/static/js/cast.ui';
import {genericBeforeEach, getCreateView, getEditView, getPropertiesView} from '../genericFunctions';
describe('CastSchema', ()=>{
let mount;
let schemaObj = new CastSchema(
{
getTypeOptions: ()=>[],
@@ -23,30 +22,22 @@ describe('CastSchema', ()=>{
);
let getInitData = ()=>Promise.resolve({});
/* Use createMount so that material ui components gets the required context */
/* https://material-ui.com/guides/testing/#api */
beforeAll(()=>{
mount = createMount();
});
afterAll(() => {
mount.cleanUp();
});
beforeEach(()=>{
genericBeforeEach();
});
it('create', ()=>{
mount(getCreateView(schemaObj));
it('create', async ()=>{
await getCreateView(schemaObj);
});
it('edit', ()=>{
mount(getEditView(schemaObj, getInitData));
it('edit', async ()=>{
await getEditView(schemaObj, getInitData);
});
it('properties', ()=>{
mount(getPropertiesView(schemaObj, getInitData));
it('properties', async ()=>{
await getPropertiesView(schemaObj, getInitData);
});
it('srctyp depChange', ()=>{
@@ -63,7 +54,7 @@ describe('CastSchema', ()=>{
it('validate', ()=>{
let state = {};
let setError = jasmine.createSpy('setError');
let setError = jest.fn();
state.srctyp = null;
schemaObj.validate(state, setError);

View File

@@ -7,13 +7,12 @@
//
//////////////////////////////////////////////////////////////
import '../helper/enzyme.helper';
import { createMount } from '@material-ui/core/test-utils';
import CatalogSchema from '../../../pgadmin/browser/server_groups/servers/databases/schemas/static/js/catalog.ui';
import {genericBeforeEach, getCreateView, getEditView, getPropertiesView} from '../genericFunctions';
describe('CatalogSchema', ()=>{
let mount;
let catalogObj = new CatalogSchema(
{
namespaceowner: '',
@@ -21,30 +20,24 @@ describe('CatalogSchema', ()=>{
);
let getInitData = ()=>Promise.resolve({});
/* Use createMount so that material ui components gets the required context */
/* https://material-ui.com/guides/testing/#api */
beforeAll(()=>{
mount = createMount();
});
afterAll(() => {
mount.cleanUp();
});
beforeEach(()=>{
genericBeforeEach();
});
it('create', ()=>{
mount(getCreateView(catalogObj));
it('create', async ()=>{
await getCreateView(catalogObj);
});
it('edit', ()=>{
mount(getEditView(catalogObj, getInitData));
it('edit', async ()=>{
await getEditView(catalogObj, getInitData);
});
it('properties', ()=>{
mount(getPropertiesView(catalogObj, getInitData));
it('properties', async ()=>{
await getPropertiesView(catalogObj, getInitData);
});
});

View File

@@ -7,31 +7,24 @@
//
//////////////////////////////////////////////////////////////
import '../helper/enzyme.helper';
import { createMount } from '@material-ui/core/test-utils';
import CatalogObjectSchema from '../../../pgadmin/browser/server_groups/servers/databases/schemas/catalog_objects/static/js/catalog_object.ui';
import {genericBeforeEach, getPropertiesView} from '../genericFunctions';
describe('CatalogObjectSchema', ()=>{
let mount;
let schemaObj = new CatalogObjectSchema();
let getInitData = ()=>Promise.resolve({});
/* Use createMount so that material ui components gets the required context */
/* https://material-ui.com/guides/testing/#api */
beforeAll(()=>{
mount = createMount();
});
afterAll(() => {
mount.cleanUp();
});
beforeEach(()=>{
genericBeforeEach();
});
it('properties', ()=>{
mount(getPropertiesView(schemaObj, getInitData));
it('properties', async ()=>{
await getPropertiesView(schemaObj, getInitData);
});
});

View File

@@ -7,36 +7,29 @@
//
//////////////////////////////////////////////////////////////
import '../helper/enzyme.helper';
import { createMount } from '@material-ui/core/test-utils';
import CatalogObjectColumn from '../../../pgadmin/browser/server_groups/servers/databases/schemas/catalog_objects/columns/static/js/catalog_object_column.ui';
import {genericBeforeEach, getCreateView, getPropertiesView} from '../genericFunctions';
describe('CatalogObjectColumn', ()=>{
let mount;
let schemaObj = new CatalogObjectColumn();
let getInitData = ()=>Promise.resolve({});
/* Use createMount so that material ui components gets the required context */
/* https://material-ui.com/guides/testing/#api */
beforeAll(()=>{
mount = createMount();
});
afterAll(() => {
mount.cleanUp();
});
beforeEach(()=>{
genericBeforeEach();
});
it('create', ()=>{
mount(getCreateView(schemaObj));
it('create', async ()=>{
await getCreateView(schemaObj);
});
it('properties', ()=>{
mount(getPropertiesView(schemaObj, getInitData));
it('properties', async ()=>{
await getPropertiesView(schemaObj, getInitData);
});
});

View File

@@ -7,12 +7,11 @@
//
//////////////////////////////////////////////////////////////
import '../helper/enzyme.helper';
import { createMount } from '@material-ui/core/test-utils';
import BaseUISchema from '../../../pgadmin/static/js/SchemaView/base_schema.ui';
import _ from 'lodash';
import CheckConstraintSchema from '../../../pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/check_constraint/static/js/check_constraint.ui';
import {genericBeforeEach, getCreateView, getEditView, getPropertiesView} from '../genericFunctions';
import {addNewDatagridRow, genericBeforeEach, getCreateView, getEditView, getPropertiesView} from '../genericFunctions';
class SchemaInColl extends BaseUISchema {
constructor() {
@@ -35,41 +34,36 @@ function getFieldDepChange(schema, id) {
}
describe('CheckConstraintSchema', ()=>{
let mount;
let schemaObj = new CheckConstraintSchema();
let getInitData = ()=>Promise.resolve({});
/* Use createMount so that material ui components gets the required context */
/* https://material-ui.com/guides/testing/#api */
beforeAll(()=>{
mount = createMount();
});
afterAll(() => {
mount.cleanUp();
});
beforeEach(()=>{
genericBeforeEach();
});
it('create', ()=>{
mount(getCreateView(schemaObj));
it('create', async ()=>{
await getCreateView(schemaObj);
});
it('edit', ()=>{
mount(getEditView(schemaObj, getInitData));
it('edit', async ()=>{
await getEditView(schemaObj, getInitData);
});
it('properties', ()=>{
mount(getPropertiesView(schemaObj, getInitData));
it('properties', async ()=>{
await getPropertiesView(schemaObj, getInitData);
});
it('create collection', ()=>{
it('create collection', async ()=>{
let schemaCollObj = new SchemaInColl();
let ctrl = mount(getCreateView(schemaCollObj));
const {ctrl, user} = await getCreateView(schemaCollObj);
/* Make sure you hit every corner */
ctrl.find('DataGridView').at(0).find('PgIconButton[data-test="add-row"]').find('button').simulate('click');
await addNewDatagridRow(user, ctrl);
});
it('depChange', ()=>{

View File

@@ -7,13 +7,12 @@
//
//////////////////////////////////////////////////////////////
import '../helper/enzyme.helper';
import { createMount } from '@material-ui/core/test-utils';
import CollationSchema from '../../../pgadmin/browser/server_groups/servers/databases/schemas/collations/static/js/collation.ui';
import {genericBeforeEach, getCreateView, getEditView, getPropertiesView} from '../genericFunctions';
describe('CollationsSchema', () => {
let mount;
let schemaObj = new CollationSchema(
{
rolesList: () => [],
@@ -27,35 +26,27 @@ describe('CollationsSchema', () => {
);
let getInitData = () => Promise.resolve({});
/* Use createMount so that material ui components gets the required context */
/* https://material-ui.com/guides/testing/#api */
beforeAll(() => {
mount = createMount();
});
afterAll(() => {
mount.cleanUp();
});
beforeEach(() => {
genericBeforeEach();
});
it('create', () => {
mount(getCreateView(schemaObj));
getCreateView(schemaObj);
});
it('edit', () => {
mount(getEditView(schemaObj, getInitData));
getEditView(schemaObj, getInitData);
});
it('properties', () => {
mount(getPropertiesView(schemaObj, getInitData));
getPropertiesView(schemaObj, getInitData);
});
it('validate', () => {
let state = {};
let setError = jasmine.createSpy('setError');
let setError = jest.fn();
state.name = null;
state.locale = 'locale';
@@ -76,17 +67,17 @@ describe('CollationsSchema', () => {
state.name = 'test';
state.locale = 'locale';
expect(schemaObj.disableFields(state)).toBeTrue();
expect(schemaObj.disableFields(state)).toBe(true);
state.name = 'test';
state.copy_collation = 'copy_collation';
state.locale = null;
expect(schemaObj.disableFields(state)).toBeTrue();
expect(schemaObj.disableFields(state)).toBe(true);
state.name = 'test';
state.copy_collation = null;
state.locale = null;
expect(schemaObj.disableFields(state)).toBeFalse();
expect(schemaObj.disableFields(state)).toBe(false);
});
});

View File

@@ -7,12 +7,11 @@
//
//////////////////////////////////////////////////////////////
import '../helper/enzyme.helper';
import { createMount } from '@material-ui/core/test-utils';
import ColumnSchema from '../../../pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/static/js/column.ui';
import BaseUISchema from '../../../pgadmin/static/js/SchemaView/base_schema.ui';
import _ from 'lodash';
import {genericBeforeEach, getCreateView, getEditView, getPropertiesView} from '../genericFunctions';
import {addNewDatagridRow, genericBeforeEach, getCreateView, getEditView, getPropertiesView} from '../genericFunctions';
class MockSchema extends BaseUISchema {
get baseFields() {
@@ -46,7 +45,7 @@ function getFieldDepChange(schema, id) {
}
describe('ColumnSchema', ()=>{
let mount;
let schemaObj = new ColumnSchema(
()=>new MockSchema(),
{},
@@ -59,37 +58,28 @@ describe('ColumnSchema', ()=>{
];
let getInitData = ()=>Promise.resolve({});
/* Use createMount so that material ui components gets the required context */
/* https://material-ui.com/guides/testing/#api */
beforeAll(()=>{
mount = createMount();
});
afterAll(() => {
mount.cleanUp();
});
beforeEach(()=>{
genericBeforeEach();
});
it('create', ()=>{
mount(getCreateView(schemaObj));
it('create', async ()=>{
await getCreateView(schemaObj);
});
it('edit', ()=>{
mount(getEditView(schemaObj, getInitData));
it('edit', async ()=>{
await getEditView(schemaObj, getInitData);
});
it('properties', ()=>{
mount(getPropertiesView(schemaObj, getInitData));
it('properties', async ()=>{
await getPropertiesView(schemaObj, getInitData);
});
it('create collection', ()=>{
it('create collection', async ()=>{
let schemaCollObj = new ColumnInColl();
let ctrl = mount(getCreateView(schemaCollObj));
const {ctrl, user} = await getCreateView(schemaCollObj);
/* Make sure you hit every corner */
ctrl.find('DataGridView').at(0).find('PgIconButton[data-test="add-row"]').find('button').simulate('click');
await addNewDatagridRow(user, ctrl);
});
it('isTypeIdentity', ()=>{
@@ -168,7 +158,7 @@ describe('ColumnSchema', ()=>{
it('validate', ()=>{
let state = {};
let setError = jasmine.createSpy('setError');
let setError = jest.fn();
state.cltype = 'bigint';
state.min_val_attlen = 5;

View File

@@ -7,13 +7,12 @@
//
//////////////////////////////////////////////////////////////
import '../helper/enzyme.helper';
import { createMount } from '@material-ui/core/test-utils';
import CompoundTriggerSchema from '../../../pgadmin/browser/server_groups/servers/databases/schemas/tables/compound_triggers/static/js/compound_trigger.ui';
import {genericBeforeEach, getCreateView, getEditView, getPropertiesView} from '../genericFunctions';
describe('CompoundTriggerSchema', ()=>{
let mount;
let schemaObj = new CompoundTriggerSchema(
{
columns: [],
@@ -26,35 +25,29 @@ describe('CompoundTriggerSchema', ()=>{
);
let getInitData = ()=>Promise.resolve({});
/* Use createMount so that material ui components gets the required context */
/* https://material-ui.com/guides/testing/#api */
beforeAll(()=>{
mount = createMount();
});
afterAll(() => {
mount.cleanUp();
});
beforeEach(()=>{
genericBeforeEach();
});
it('create', ()=>{
mount(getCreateView(schemaObj));
it('create', async ()=>{
await getCreateView(schemaObj);
});
it('edit', ()=>{
mount(getEditView(schemaObj, getInitData));
it('edit', async ()=>{
await getEditView(schemaObj, getInitData);
});
it('properties', ()=>{
mount(getPropertiesView(schemaObj, getInitData));
it('properties', async ()=>{
await getPropertiesView(schemaObj, getInitData);
});
it('validate', ()=>{
let state = {};
let setError = jasmine.createSpy('setError');
let setError = jest.fn();
state.evnt_truncate = false;
state.evnt_delete = false;

View File

@@ -8,8 +8,7 @@
//////////////////////////////////////////////////////////////
import _ from 'lodash';
import '../helper/enzyme.helper';
import { createMount } from '@material-ui/core/test-utils';
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';
@@ -21,7 +20,7 @@ class MockSchema extends BaseUISchema {
}
describe('DatabaseSchema', ()=>{
let mount;
let schemaObj = new DatabaseSchema(
()=>new MockSchema(),
()=>new MockSchema(),
@@ -39,30 +38,24 @@ describe('DatabaseSchema', ()=>{
);
let getInitData = ()=>Promise.resolve({});
/* Use createMount so that material ui components gets the required context */
/* https://material-ui.com/guides/testing/#api */
beforeAll(()=>{
mount = createMount();
});
afterAll(() => {
mount.cleanUp();
});
beforeEach(()=>{
genericBeforeEach();
});
it('create', ()=>{
mount(getCreateView(schemaObj));
it('create', async ()=>{
await getCreateView(schemaObj);
});
it('edit', ()=>{
mount(getEditView(schemaObj, getInitData));
it('edit', async ()=>{
await getEditView(schemaObj, getInitData);
});
it('properties', ()=>{
mount(getPropertiesView(schemaObj, getInitData));
it('properties', async ()=>{
await getPropertiesView(schemaObj, getInitData);
});
it('schema_res depChange', ()=>{

View File

@@ -7,47 +7,24 @@
//
//////////////////////////////////////////////////////////////
import '../helper/enzyme.helper';
import React from 'react';
import { createMount } from '@material-ui/core/test-utils';
import SchemaView from '../../../pgadmin/static/js/SchemaView';
import {DebuggerArgumentSchema} from '../../../pgadmin/tools/debugger/static/js/components/DebuggerArgs.ui';
import {genericBeforeEach} from '../genericFunctions';
import Theme from '../../../pgadmin/static/js/Theme';
import {genericBeforeEach, getCreateView} from '../genericFunctions';
describe('DebuggerArgs', () => {
let mount;
let schemaObj = new DebuggerArgumentSchema();
/* Use createMount so that material ui components gets the required context */
/* https://material-ui.com/guides/testing/#api */
beforeAll(() => {
mount = createMount();
});
afterAll(() => {
mount.cleanUp();
});
beforeEach(() => {
genericBeforeEach();
});
it('create', () => {
mount(<Theme>
<SchemaView
formType='dialog'
schema={schemaObj}
viewHelperProps={{
mode: 'create',
}}
onDataChange={() => {/*This is intentional (SonarQube)*/}}
showFooter={false}
isTabView={false}
/>
</Theme> );
it('create', async () => {
await getCreateView(schemaObj);
});
});

View File

@@ -7,14 +7,13 @@
//
//////////////////////////////////////////////////////////////
import '../helper/enzyme.helper';
import { createMount } from '@material-ui/core/test-utils';
import BaseUISchema from 'sources/SchemaView/base_schema.ui';
import DomainSchema, { DomainConstSchema } from '../../../pgadmin/browser/server_groups/servers/databases/schemas/domains/static/js/domain.ui';
import {genericBeforeEach, getCreateView, getEditView, getPropertiesView} from '../genericFunctions';
import {addNewDatagridRow, genericBeforeEach, getCreateView, getEditView, getPropertiesView} from '../genericFunctions';
describe('DomainSchema', ()=>{
let mount;
let schemaObj = new DomainSchema(
{
role: ()=>[],
@@ -31,30 +30,24 @@ describe('DomainSchema', ()=>{
);
let getInitData = ()=>Promise.resolve({});
/* Use createMount so that material ui components gets the required context */
/* https://material-ui.com/guides/testing/#api */
beforeAll(()=>{
mount = createMount();
});
afterAll(() => {
mount.cleanUp();
});
beforeEach(()=>{
genericBeforeEach();
});
it('create', ()=>{
mount(getCreateView(schemaObj));
it('create', async ()=>{
await getCreateView(schemaObj);
});
it('edit', ()=>{
mount(getEditView(schemaObj, getInitData));
it('edit', async ()=>{
await getEditView(schemaObj, getInitData);
});
it('properties', ()=>{
mount(getPropertiesView(schemaObj, getInitData));
it('properties', async ()=>{
await getPropertiesView(schemaObj, getInitData);
});
});
@@ -77,43 +70,38 @@ class MockSchema extends BaseUISchema {
}
describe('DomainConstSchema', ()=>{
let mount;
let schemaObj = new MockSchema();
let domainConstObj = new DomainConstSchema();
let getInitData = ()=>Promise.resolve({});
/* Use createMount so that material ui components gets the required context */
/* https://material-ui.com/guides/testing/#api */
beforeAll(()=>{
mount = createMount();
});
afterAll(() => {
mount.cleanUp();
});
beforeEach(()=>{
genericBeforeEach();
});
it('create', ()=>{
let ctrl = mount(getCreateView(schemaObj));
it('create', async ()=>{
const {ctrl, user} = await getCreateView(schemaObj);
/* Make sure you hit every corner */
ctrl.find('DataGridView').at(0).find('PgIconButton[data-test="add-row"]').find('button').simulate('click');
await addNewDatagridRow(user, ctrl);
});
it('edit', ()=>{
mount(getEditView(schemaObj, getInitData));
it('edit', async ()=>{
await getEditView(schemaObj, getInitData);
});
it('properties', ()=>{
mount(getPropertiesView(schemaObj, getInitData));
it('properties', async ()=>{
await getPropertiesView(schemaObj, getInitData);
});
it('validate', ()=>{
let state = {};
let setError = jasmine.createSpy('setError');
let setError = jest.fn();
state.conname = undefined;
domainConstObj.validate(state, setError);

View File

@@ -7,40 +7,33 @@
//
//////////////////////////////////////////////////////////////
import '../helper/enzyme.helper';
import { createMount } from '@material-ui/core/test-utils';
import DomainConstraintSchema from '../../../pgadmin/browser/server_groups/servers/databases/schemas/domains/domain_constraints/static/js/domain_constraints.ui';
import {genericBeforeEach, getCreateView, getEditView, getPropertiesView} from '../genericFunctions';
describe('DomainConstraintSchema', ()=>{
let mount;
let schemaObj = new DomainConstraintSchema();
let getInitData = ()=>Promise.resolve({});
/* Use createMount so that material ui components gets the required context */
/* https://material-ui.com/guides/testing/#api */
beforeAll(()=>{
mount = createMount();
});
afterAll(() => {
mount.cleanUp();
});
beforeEach(()=>{
genericBeforeEach();
});
it('create', ()=>{
mount(getCreateView(schemaObj));
it('create', async ()=>{
await getCreateView(schemaObj);
});
it('edit', ()=>{
mount(getEditView(schemaObj, getInitData));
it('edit', async ()=>{
await getEditView(schemaObj, getInitData);
});
it('properties', ()=>{
mount(getPropertiesView(schemaObj, getInitData));
it('properties', async ()=>{
await getPropertiesView(schemaObj, getInitData);
});
});

View File

@@ -7,13 +7,12 @@
//
//////////////////////////////////////////////////////////////
import '../helper/enzyme.helper';
import { createMount } from '@material-ui/core/test-utils';
import EDBFuncSchema from '../../../pgadmin/browser/server_groups/servers/databases/schemas/packages/edbfuncs/static/js/edbfunc.ui';
import {genericBeforeEach, getCreateView, getEditView, getPropertiesView} from '../genericFunctions';
describe('EDBFuncSchema', ()=>{
let mount;
let edbFuncSchemaObj = new EDBFuncSchema(
{}, {
name: 'sysfunc'
@@ -21,30 +20,24 @@ describe('EDBFuncSchema', ()=>{
);
let getInitData = ()=>Promise.resolve({});
/* Use createMount so that material ui components gets the required context */
/* https://material-ui.com/guides/testing/#api */
beforeAll(()=>{
mount = createMount();
});
afterAll(() => {
mount.cleanUp();
});
beforeEach(()=>{
genericBeforeEach();
});
it('create', ()=>{
mount(getCreateView(edbFuncSchemaObj));
it('create', async ()=>{
await getCreateView(edbFuncSchemaObj);
});
it('edit', ()=>{
mount(getEditView(edbFuncSchemaObj, getInitData));
it('edit', async ()=>{
await getEditView(edbFuncSchemaObj, getInitData);
});
it('properties', ()=>{
mount(getPropertiesView(edbFuncSchemaObj, getInitData));
it('properties', async ()=>{
await getPropertiesView(edbFuncSchemaObj, getInitData);
});
});

View File

@@ -7,40 +7,33 @@
//
//////////////////////////////////////////////////////////////
import '../helper/enzyme.helper';
import { createMount } from '@material-ui/core/test-utils';
import EDBVarSchema from '../../../pgadmin/browser/server_groups/servers/databases/schemas/packages/edbvars/static/js/edbvar.ui';
import {genericBeforeEach, getCreateView, getEditView, getPropertiesView} from '../genericFunctions';
describe('EDBVarSchema', ()=>{
let mount;
let edbVarSchemaObj = new EDBVarSchema();
let getInitData = ()=>Promise.resolve({});
/* Use createMount so that material ui components gets the required context */
/* https://material-ui.com/guides/testing/#api */
beforeAll(()=>{
mount = createMount();
});
afterAll(() => {
mount.cleanUp();
});
beforeEach(()=>{
genericBeforeEach();
});
it('create', ()=>{
mount(getCreateView(edbVarSchemaObj));
it('create', async ()=>{
await getCreateView(edbVarSchemaObj);
});
it('edit', ()=>{
mount(getEditView(edbVarSchemaObj, getInitData));
it('edit', async ()=>{
await getEditView(edbVarSchemaObj, getInitData);
});
it('properties', ()=>{
mount(getPropertiesView(edbVarSchemaObj, getInitData));
it('properties', async ()=>{
await getPropertiesView(edbVarSchemaObj, getInitData);
});
});

View File

@@ -7,13 +7,12 @@
//
//////////////////////////////////////////////////////////////
import '../helper/enzyme.helper';
import { createMount } from '@material-ui/core/test-utils';
import EventTriggerSchema from '../../../pgadmin/browser/server_groups/servers/databases/event_triggers/static/js/event_trigger.ui';
import {genericBeforeEach, getCreateView, getEditView, getPropertiesView} from '../genericFunctions';
describe('EventTriggerSchema', ()=>{
let mount;
let schemaObj = new EventTriggerSchema(
{
role: ()=>[],
@@ -25,35 +24,29 @@ describe('EventTriggerSchema', ()=>{
);
let getInitData = ()=>Promise.resolve({});
/* Use createMount so that material ui components gets the required context */
/* https://material-ui.com/guides/testing/#api */
beforeAll(()=>{
mount = createMount();
});
afterAll(() => {
mount.cleanUp();
});
beforeEach(()=>{
genericBeforeEach();
});
it('create', ()=>{
mount(getCreateView(schemaObj));
it('create', async ()=>{
await getCreateView(schemaObj);
});
it('edit', ()=>{
mount(getEditView(schemaObj, getInitData));
it('edit', async ()=>{
await getEditView(schemaObj, getInitData);
});
it('properties', ()=>{
mount(getPropertiesView(schemaObj, getInitData));
it('properties', async ()=>{
await getPropertiesView(schemaObj, getInitData);
});
it('validate', ()=>{
let state = {};
let setError = jasmine.createSpy('setError');
let setError = jest.fn();
state.eventfunname = null;
schemaObj.validate(state, setError);

View File

@@ -7,16 +7,15 @@
//
//////////////////////////////////////////////////////////////
import '../helper/enzyme.helper';
import { createMount } from '@material-ui/core/test-utils';
import { SCHEMA_STATE_ACTIONS } from '../../../pgadmin/static/js/SchemaView';
import BaseUISchema from '../../../pgadmin/static/js/SchemaView/base_schema.ui';
import _ from 'lodash';
import { getNodeExclusionConstraintSchema } from '../../../pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/exclusion_constraint/static/js/exclusion_constraint.ui';
import * as nodeAjax from '../../../pgadmin/browser/static/js/node_ajax';
import TableSchema from '../../../pgadmin/browser/server_groups/servers/databases/schemas/tables/static/js/table.ui';
import Notify from '../../../pgadmin/static/js/helpers/Notifier';
import {genericBeforeEach, getCreateView, getEditView, getPropertiesView} from '../genericFunctions';
import {addNewDatagridRow, genericBeforeEach, getCreateView, getEditView, getPropertiesView} from '../genericFunctions';
import pgAdmin from '../fake_pgadmin';
class SchemaInColl extends BaseUISchema {
constructor(schemaObj) {
@@ -40,48 +39,41 @@ function getFieldDepChange(schema, id) {
}
describe('ExclusionConstraintSchema', ()=>{
let mount;
let schemaObj;
let getInitData = ()=>Promise.resolve({});
/* Use createMount so that material ui components gets the required context */
/* https://material-ui.com/guides/testing/#api */
beforeAll(()=>{
mount = createMount();
spyOn(nodeAjax, 'getNodeAjaxOptions').and.returnValue(Promise.resolve([]));
spyOn(nodeAjax, 'getNodeListByName').and.returnValue(Promise.resolve([]));
jest.spyOn(nodeAjax, 'getNodeAjaxOptions').mockReturnValue(Promise.resolve([]));
jest.spyOn(nodeAjax, 'getNodeListByName').mockReturnValue(Promise.resolve([]));
schemaObj = getNodeExclusionConstraintSchema({}, {}, {Nodes: {table: {}}});
});
afterAll(() => {
mount.cleanUp();
});
beforeEach(()=>{
genericBeforeEach();
});
it('create', ()=>{
mount(getCreateView(schemaObj));
it('create', async ()=>{
await getCreateView(schemaObj);
});
it('edit', ()=>{
mount(getEditView(schemaObj, getInitData));
it('edit', async ()=>{
await getEditView(schemaObj, getInitData);
});
it('properties', ()=>{
mount(getPropertiesView(schemaObj, getInitData));
it('properties', async ()=>{
await getPropertiesView(schemaObj, getInitData);
});
it('create collection', ()=>{
it('create collection', async ()=>{
let schemaCollObj = new SchemaInColl(schemaObj);
let ctrl = mount(getCreateView(schemaCollObj));
const {ctrl, user} = await getCreateView(schemaCollObj);
/* Make sure you hit every corner */
ctrl.find('DataGridView').at(0).find('PgIconButton[data-test="add-row"]').find('button').simulate('click');
await addNewDatagridRow(user, ctrl);
});
it('changeColumnOptions', ()=>{
spyOn(schemaObj.exHeaderSchema, 'changeColumnOptions').and.callThrough();
jest.spyOn(schemaObj.exHeaderSchema, 'changeColumnOptions');
let columns = [{label: 'label', value: 'value'}];
schemaObj.changeColumnOptions(columns);
expect(schemaObj.exHeaderSchema.changeColumnOptions).toHaveBeenCalledWith(columns);
@@ -93,7 +85,7 @@ describe('ExclusionConstraintSchema', ()=>{
{label: 'id', value: 'id', datatype: 'numeric'},
{label: 'name', value: 'name', datatype: 'char'}
];
spyOn(schemaObj.exColumnSchema, 'getNewData');
jest.spyOn(schemaObj.exColumnSchema, 'getNewData').mockImplementation(() => {});
schemaObj.exHeaderSchema.getNewData({
is_exp: false,
column: 'id',
@@ -195,13 +187,14 @@ describe('ExclusionConstraintSchema', ()=>{
];
beforeEach(()=>{
spyOn(schemaObj.exColumnSchema, 'setOperClassOptions').and.callThrough();
spyOn(schemaObj.fieldOptions, 'getOperClass').and.returnValue(operClassOptions);
confirmSpy = spyOn(Notify, 'confirm').and.callThrough();
jest.spyOn(schemaObj.exColumnSchema, 'setOperClassOptions');
jest.spyOn(schemaObj.fieldOptions, 'getOperClass').mockReturnValue(operClassOptions);
confirmSpy = jest.spyOn(pgAdmin.Browser.notifier, 'confirm');
deferredDepChange = _.find(schemaObj.fields, (f)=>f.id=='amname')?.deferredDepChange;
});
it('btree', (done)=>{
confirmSpy.mockClear();
let state = {amname: 'btree'};
let deferredPromise = deferredDepChange(state);
deferredPromise.then((depChange)=>{
@@ -212,10 +205,11 @@ describe('ExclusionConstraintSchema', ()=>{
done();
});
/* Press OK */
confirmSpy.calls.argsFor(0)[2]();
confirmSpy.mock.calls[0][2]();
});
it('not btree', (done)=>{
confirmSpy.mockClear();
let state = {amname: 'gist'};
let deferredPromise = deferredDepChange(state);
deferredPromise.then((depChange)=>{
@@ -226,10 +220,11 @@ describe('ExclusionConstraintSchema', ()=>{
done();
});
/* Press OK */
confirmSpy.calls.argsFor(0)[2]();
confirmSpy.mock.calls[0][2]();
});
it('press no', (done)=>{
confirmSpy.mockClear();
let state = {amname: 'gist'};
let deferredPromise = deferredDepChange(state, null, null, {
oldState: {
@@ -237,7 +232,7 @@ describe('ExclusionConstraintSchema', ()=>{
},
});
/* Press Cancel */
confirmSpy.calls.argsFor(0)[3]();
confirmSpy.mock.calls[0][3]();
deferredPromise.then((depChange)=>{
expect(depChange()).toEqual({
amname: 'btree',
@@ -249,7 +244,7 @@ describe('ExclusionConstraintSchema', ()=>{
it('validate', ()=>{
let state = {};
let setError = jasmine.createSpy('setError');
let setError = jest.fn();
state.columns = ['id'];
state.autoindex = true;

View File

@@ -7,13 +7,12 @@
//
//////////////////////////////////////////////////////////////
import '../helper/enzyme.helper';
import { createMount } from '@material-ui/core/test-utils';
import ExtensionsSchema from '../../../pgadmin/browser/server_groups/servers/databases/extensions/static/js/extension.ui';
import {genericBeforeEach, getCreateView, getEditView, getPropertiesView} from '../genericFunctions';
describe('ExtensionSchema', ()=>{
let mount;
let schemaObj = new ExtensionsSchema(
{
extensionsList: ()=>[],
@@ -22,35 +21,29 @@ describe('ExtensionSchema', ()=>{
);
let getInitData = ()=>Promise.resolve({});
/* Use createMount so that material ui components gets the required context */
/* https://material-ui.com/guides/testing/#api */
beforeAll(()=>{
mount = createMount();
});
afterAll(() => {
mount.cleanUp();
});
beforeEach(()=>{
genericBeforeEach();
});
it('create', ()=>{
mount(getCreateView(schemaObj));
it('create', async ()=>{
await getCreateView(schemaObj);
});
it('edit', ()=>{
mount(getEditView(schemaObj, getInitData));
it('edit', async ()=>{
await getEditView(schemaObj, getInitData);
});
it('properties', ()=>{
mount(getPropertiesView(schemaObj, getInitData));
it('properties', async ()=>{
await getPropertiesView(schemaObj, getInitData);
});
it('validate', ()=>{
let state = {};
let setError = jasmine.createSpy('setError');
let setError = jest.fn();
state.name = null;
schemaObj.validate(state, setError);

View File

@@ -7,8 +7,7 @@
//
//////////////////////////////////////////////////////////////
import '../helper/enzyme.helper';
import { createMount } from '@material-ui/core/test-utils';
import BaseUISchema from 'sources/SchemaView/base_schema.ui';
import ForeignDataWrapperSchema from '../../../pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/static/js/foreign_data_wrapper.ui';
import {genericBeforeEach, getCreateView, getEditView, getPropertiesView} from '../genericFunctions';
@@ -20,7 +19,7 @@ class MockSchema extends BaseUISchema {
}
describe('ForeignDataWrapperSchema', ()=>{
let mount;
let schemaObj = new ForeignDataWrapperSchema(
()=>new MockSchema(),
{
@@ -34,30 +33,24 @@ describe('ForeignDataWrapperSchema', ()=>{
);
let getInitData = ()=>Promise.resolve({});
/* Use createMount so that material ui components gets the required context */
/* https://material-ui.com/guides/testing/#api */
beforeAll(()=>{
mount = createMount();
});
afterAll(() => {
mount.cleanUp();
});
beforeEach(()=>{
genericBeforeEach();
});
it('create', ()=>{
mount(getCreateView(schemaObj));
it('create', async ()=>{
await getCreateView(schemaObj);
});
it('edit', ()=>{
mount(getEditView(schemaObj, getInitData));
it('edit', async ()=>{
await getEditView(schemaObj, getInitData);
});
it('properties', ()=>{
mount(getPropertiesView(schemaObj, getInitData));
it('properties', async ()=>{
await getPropertiesView(schemaObj, getInitData);
});
});

View File

@@ -7,15 +7,14 @@
//
//////////////////////////////////////////////////////////////
import '../helper/enzyme.helper';
import { createMount } from '@material-ui/core/test-utils';
import { SCHEMA_STATE_ACTIONS } from '../../../pgadmin/static/js/SchemaView';
import BaseUISchema from '../../../pgadmin/static/js/SchemaView/base_schema.ui';
import _ from 'lodash';
import * as nodeAjax from '../../../pgadmin/browser/static/js/node_ajax';
import { getNodeForeignKeySchema } from '../../../pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/static/js/foreign_key.ui';
import TableSchema from '../../../pgadmin/browser/server_groups/servers/databases/schemas/tables/static/js/table.ui';
import {genericBeforeEach, getCreateView, getEditView, getPropertiesView} from '../genericFunctions';
import {addNewDatagridRow, genericBeforeEach, getCreateView, getEditView, getPropertiesView} from '../genericFunctions';
class SchemaInColl extends BaseUISchema {
constructor(schemaObj) {
@@ -39,48 +38,43 @@ function getFieldDepChange(schema, id) {
}
describe('ForeignKeySchema', ()=>{
let mount;
let schemaObj;
let getInitData = ()=>Promise.resolve({});
/* Use createMount so that material ui components gets the required context */
/* https://material-ui.com/guides/testing/#api */
beforeAll(()=>{
mount = createMount();
spyOn(nodeAjax, 'getNodeAjaxOptions').and.returnValue(Promise.resolve([]));
spyOn(nodeAjax, 'getNodeListByName').and.returnValue(Promise.resolve([]));
jest.spyOn(nodeAjax, 'getNodeAjaxOptions').mockReturnValue(Promise.resolve([]));
jest.spyOn(nodeAjax, 'getNodeListByName').mockReturnValue(Promise.resolve([]));
schemaObj = getNodeForeignKeySchema({}, {}, {Nodes: {table: {}}});
});
afterAll(() => {
mount.cleanUp();
});
beforeEach(()=>{
genericBeforeEach();
});
it('create', ()=>{
mount(getCreateView(schemaObj));
it('create', async ()=>{
await getCreateView(schemaObj);
});
it('edit', ()=>{
mount(getEditView(schemaObj, getInitData));
it('edit', async ()=>{
await getEditView(schemaObj, getInitData);
});
it('properties', ()=>{
mount(getPropertiesView(schemaObj, getInitData));
it('properties', async ()=>{
await getPropertiesView(schemaObj, getInitData);
});
it('create collection', ()=>{
it('create collection', async ()=>{
let schemaCollObj = new SchemaInColl(schemaObj);
let ctrl = mount(getCreateView(schemaCollObj));
const {ctrl, user} = await getCreateView(schemaCollObj);
/* Make sure you hit every corner */
ctrl.find('DataGridView').at(0).find('PgIconButton[data-test="add-row"]').find('button').simulate('click');
await addNewDatagridRow(user, ctrl);
});
it('changeColumnOptions', ()=>{
spyOn(schemaObj.fkHeaderSchema, 'changeColumnOptions').and.callThrough();
jest.spyOn(schemaObj.fkHeaderSchema, 'changeColumnOptions');
let columns = [{label: 'label', value: 'value'}];
schemaObj.changeColumnOptions(columns);
expect(schemaObj.fkHeaderSchema.changeColumnOptions).toHaveBeenCalledWith(columns);
@@ -196,7 +190,7 @@ describe('ForeignKeySchema', ()=>{
it('validate', ()=>{
let state = {};
let setError = jasmine.createSpy('setError');
let setError = jest.fn();
state.columns = ['id'];
state.autoindex = true;

View File

@@ -7,8 +7,7 @@
//
//////////////////////////////////////////////////////////////
import '../helper/enzyme.helper';
import { createMount } from '@material-ui/core/test-utils';
import BaseUISchema from 'sources/SchemaView/base_schema.ui';
import ForeignServerSchema from '../../../pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/static/js/foreign_server.ui';
import {genericBeforeEach, getCreateView, getEditView, getPropertiesView} from '../genericFunctions';
@@ -20,7 +19,7 @@ class MockSchema extends BaseUISchema {
}
describe('ForeignServerSchema', ()=>{
let mount;
let schemaObj = new ForeignServerSchema(
()=>new MockSchema(),
{
@@ -32,30 +31,24 @@ describe('ForeignServerSchema', ()=>{
);
let getInitData = ()=>Promise.resolve({});
/* Use createMount so that material ui components gets the required context */
/* https://material-ui.com/guides/testing/#api */
beforeAll(()=>{
mount = createMount();
});
afterAll(() => {
mount.cleanUp();
});
beforeEach(()=>{
genericBeforeEach();
});
it('create', ()=>{
mount(getCreateView(schemaObj));
it('create', async ()=>{
await getCreateView(schemaObj);
});
it('edit', ()=>{
mount(getEditView(schemaObj, getInitData));
it('edit', async ()=>{
await getEditView(schemaObj, getInitData);
});
it('properties', ()=>{
mount(getPropertiesView(schemaObj, getInitData));
it('properties', async ()=>{
await getPropertiesView(schemaObj, getInitData);
});
});

View File

@@ -7,14 +7,10 @@
//
//////////////////////////////////////////////////////////////
import React from 'react';
import '../helper/enzyme.helper';
import { createMount } from '@material-ui/core/test-utils';
import SchemaView from '../../../pgadmin/static/js/SchemaView';
import BaseUISchema from 'sources/SchemaView/base_schema.ui';
import ForeignTableSchema, { ColumnSchema, CheckConstraintSchema } from '../../../pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/static/js/foreign_table.ui';
import {genericBeforeEach, getCreateView, getEditView, getPropertiesView} from '../genericFunctions';
import Theme from '../../../pgadmin/static/js/Theme';
class MockSchema extends BaseUISchema {
get baseFields() {
@@ -23,7 +19,7 @@ class MockSchema extends BaseUISchema {
}
describe('ForeignTableSchema', ()=>{
let mount;
let schemaObj = new ForeignTableSchema(
()=>new MockSchema(),
()=>new MockSchema(),
@@ -44,35 +40,25 @@ describe('ForeignTableSchema', ()=>{
);
let getInitData = ()=>Promise.resolve({});
/* Use createMount so that material ui components gets the required context */
/* https://material-ui.com/guides/testing/#api */
beforeAll(()=>{
mount = createMount();
});
afterAll(() => {
mount.cleanUp();
});
beforeEach(()=>{
genericBeforeEach();
});
it('create', ()=>{
mount(getCreateView(schemaObj));
it('create', async ()=>{
await getCreateView(schemaObj);
});
it('edit', ()=>{
mount(getEditView(schemaObj, getInitData));
it('edit', async ()=>{
await getEditView(schemaObj, getInitData);
});
it('properties', ()=>{
mount(getPropertiesView(schemaObj, getInitData));
it('properties', async ()=>{
await getPropertiesView(schemaObj, getInitData);
});
it('validate', ()=>{
let state = {};
let setError = jasmine.createSpy('setError');
let setError = jest.fn();
state.ftsrvname = null;
schemaObj.validate(state, setError);
@@ -134,8 +120,8 @@ describe('ForeignTableSchema', ()=>{
};
beforeEach(()=>{
spyOn(schemaObj, 'getTableOid').and.returnValue(123456);
spyOn(schemaObj, 'getColumns').and.returnValue(Promise.resolve([inheritCol]));
jest.spyOn(schemaObj, 'getTableOid').mockReturnValue(123456);
jest.spyOn(schemaObj, 'getColumns').mockReturnValue(Promise.resolve([inheritCol]));
deferredDepChange = _.find(schemaObj.fields, (f)=>f.id=='inherits')?.deferredDepChange;
});
@@ -188,7 +174,7 @@ describe('ForeignTableSchema', ()=>{
describe('ForeignTableColumnSchema', ()=>{
let mount;
let schemaObj = new ColumnSchema(
{},
()=>new MockSchema(),
@@ -202,33 +188,34 @@ describe('ForeignTableColumnSchema', ()=>{
);
let getInitData = ()=>Promise.resolve({});
/* Use createMount so that material ui components gets the required context */
/* https://material-ui.com/guides/testing/#api */
beforeAll(()=>{
mount = createMount();
});
afterAll(() => {
mount.cleanUp();
});
beforeEach(()=>{
genericBeforeEach();
});
it('create', ()=>{
mount(getCreateView(schemaObj));
it('create', async ()=>{
await getCreateView(schemaObj);
});
it('properties', ()=>{
mount(getPropertiesView(schemaObj, getInitData));
it('properties', async ()=>{
await getPropertiesView(schemaObj, getInitData);
});
it('edit', ()=>{
mount(getEditView(schemaObj, getInitData));
it('edit', async ()=>{
await getEditView(schemaObj, getInitData);
});
it('typdefault_edit', ()=>{
it('column editable', ()=>{
let state = {};
let editable = _.find(schemaObj.fields, (f)=>f.id=='name').editable;
let status = editable(state);
expect(status).toBe(true);
});
it('typdefault_edit', async ()=>{
let defaultSchemaObj = new ForeignTableSchema(
()=>new MockSchema(),
()=>new MockSchema(),
@@ -250,29 +237,12 @@ describe('ForeignTableColumnSchema', ()=>{
let initData = ()=>Promise.resolve({typlen: 1, inheritedid: 1, inheritedfrom: 'public'});
mount(<Theme>
<SchemaView
formType='dialog'
schema={defaultSchemaObj}
getInitData={initData}
viewHelperProps={{
mode: 'edit',
}}
onSave={()=>{/*This is intentional (SonarQube)*/}}
onClose={()=>{/*This is intentional (SonarQube)*/}}
onHelp={()=>{/*This is intentional (SonarQube)*/}}
onEdit={()=>{/*This is intentional (SonarQube)*/}}
onDataChange={()=>{/*This is intentional (SonarQube)*/}}
confirmOnCloseReset={false}
hasSQL={false}
disableSqlHelp={false}
/>
</Theme> );
await getEditView(defaultSchemaObj, initData);
});
it('attstattarget', ()=>{
it('attstattarget', async ()=>{
let defaultSchemaObj = new ForeignTableSchema(
()=>new MockSchema(),
()=>new MockSchema(),
@@ -300,58 +270,31 @@ describe('ForeignTableColumnSchema', ()=>{
});
mount(<Theme>
<SchemaView
formType='dialog'
schema={defaultSchemaObj}
getInitData={initData}
viewHelperProps={{
mode: 'edit',
}}
onSave={()=>{/*This is intentional (SonarQube)*/}}
onClose={()=>{/*This is intentional (SonarQube)*/}}
onHelp={()=>{/*This is intentional (SonarQube)*/}}
onEdit={()=>{/*This is intentional (SonarQube)*/}}
onDataChange={()=>{/*This is intentional (SonarQube)*/}}
confirmOnCloseReset={false}
hasSQL={false}
disableSqlHelp={false}
/>
</Theme>);
await getEditView(defaultSchemaObj, initData);
});
});
describe('ForeignTableCheckConstraint', ()=>{
let mount;
let schemaObj = new CheckConstraintSchema();
let getInitData = ()=>Promise.resolve({});
/* Use createMount so that material ui components gets the required context */
/* https://material-ui.com/guides/testing/#api */
beforeAll(()=>{
mount = createMount();
});
afterAll(() => {
mount.cleanUp();
});
beforeEach(()=>{
genericBeforeEach();
});
it('create', ()=>{
mount(getCreateView(schemaObj));
it('create', async ()=>{
await getCreateView(schemaObj);
});
it('properties', ()=>{
mount(getPropertiesView(schemaObj, getInitData));
it('properties', async ()=>{
await getPropertiesView(schemaObj, getInitData);
});
it('edit', ()=>{
mount(getEditView(schemaObj, getInitData));
it('edit', async ()=>{
await getEditView(schemaObj, getInitData);
});
it('conname editable', ()=>{
@@ -381,7 +324,7 @@ describe('ForeignTableCheckConstraint', ()=>{
let status = editable(state);
expect(status).toBe(true);
spyOn(schemaObj, 'isNew').and.returnValue(false);
jest.spyOn(schemaObj, 'isNew').mockReturnValue(false);
editable = _.find(schemaObj.fields, (f)=>f.id=='convalidated').editable;
status = editable(state);
expect(status).toBe(true);

View File

@@ -7,13 +7,12 @@
//
//////////////////////////////////////////////////////////////
import '../helper/enzyme.helper';
import { createMount } from '@material-ui/core/test-utils';
import FTSConfigurationSchema from '../../../pgadmin/browser/server_groups/servers/databases/schemas/fts_configurations/static/js/fts_configuration.ui';
import {genericBeforeEach, getCreateView, getEditView, getPropertiesView} from '../genericFunctions';
describe('FTSConfigurationSchema', ()=>{
let mount;
let schemaObj = new FTSConfigurationSchema(
{
role: ()=>[],
@@ -30,35 +29,29 @@ describe('FTSConfigurationSchema', ()=>{
);
let getInitData = ()=>Promise.resolve({});
/* Use createMount so that material ui components gets the required context */
/* https://material-ui.com/guides/testing/#api */
beforeAll(()=>{
mount = createMount();
});
afterAll(() => {
mount.cleanUp();
});
beforeEach(()=>{
genericBeforeEach();
});
it('create', ()=>{
mount(getCreateView(schemaObj));
it('create', async ()=>{
await getCreateView(schemaObj);
});
it('edit', ()=>{
mount(getEditView(schemaObj, getInitData));
it('edit', async ()=>{
await getEditView(schemaObj, getInitData);
});
it('properties', ()=>{
mount(getPropertiesView(schemaObj, getInitData));
it('properties', async ()=>{
await getPropertiesView(schemaObj, getInitData);
});
it('validate', ()=>{
let state = {};
let setError = jasmine.createSpy('setError');
let setError = jest.fn();
state.prsname = '';
state.copy_config = '';

View File

@@ -7,13 +7,12 @@
//
//////////////////////////////////////////////////////////////
import '../helper/enzyme.helper';
import { createMount } from '@material-ui/core/test-utils';
import FTSDictionarySchema from '../../../pgadmin/browser/server_groups/servers/databases/schemas/fts_dictionaries/static/js/fts_dictionary.ui';
import {genericBeforeEach, getCreateView, getEditView, getPropertiesView} from '../genericFunctions';
describe('FTSDictionarySchema', ()=>{
let mount;
let schemaObj = new FTSDictionarySchema(
{
role: ()=>[],
@@ -28,30 +27,24 @@ describe('FTSDictionarySchema', ()=>{
);
let getInitData = ()=>Promise.resolve({});
/* Use createMount so that material ui components gets the required context */
/* https://material-ui.com/guides/testing/#api */
beforeAll(()=>{
mount = createMount();
});
afterAll(() => {
mount.cleanUp();
});
beforeEach(()=>{
genericBeforeEach();
});
it('create', ()=>{
mount(getCreateView(schemaObj));
it('create', async ()=>{
await getCreateView(schemaObj);
});
it('edit', ()=>{
mount(getEditView(schemaObj, getInitData));
it('edit', async ()=>{
await getEditView(schemaObj, getInitData);
});
it('properties', ()=>{
mount(getPropertiesView(schemaObj, getInitData));
it('properties', async ()=>{
await getPropertiesView(schemaObj, getInitData);
});
});

View File

@@ -7,13 +7,12 @@
//
//////////////////////////////////////////////////////////////
import '../helper/enzyme.helper';
import { createMount } from '@material-ui/core/test-utils';
import FTSParserSchema from '../../../pgadmin/browser/server_groups/servers/databases/schemas/fts_parsers/static/js/fts_parser.ui';
import {genericBeforeEach, getCreateView, getEditView, getPropertiesView} from '../genericFunctions';
describe('FTSParserSchema', ()=>{
let mount;
let schemaObj = new FTSParserSchema(
{
prsstartList: ()=> [{ label: '', value: ''}, { label: 'lb1', value: 'val1'}],
@@ -29,30 +28,24 @@ describe('FTSParserSchema', ()=>{
);
let getInitData = ()=>Promise.resolve({});
/* Use createMount so that material ui components gets the required context */
/* https://material-ui.com/guides/testing/#api */
beforeAll(()=>{
mount = createMount();
});
afterAll(() => {
mount.cleanUp();
});
beforeEach(()=>{
genericBeforeEach();
});
it('create', ()=>{
mount(getCreateView(schemaObj));
it('create', async ()=>{
await getCreateView(schemaObj);
});
it('edit', ()=>{
mount(getEditView(schemaObj, getInitData));
it('edit', async ()=>{
await getEditView(schemaObj, getInitData);
});
it('properties', ()=>{
mount(getPropertiesView(schemaObj, getInitData));
it('properties', async ()=>{
await getPropertiesView(schemaObj, getInitData);
});
});

View File

@@ -7,13 +7,12 @@
//
//////////////////////////////////////////////////////////////
import '../helper/enzyme.helper';
import { createMount } from '@material-ui/core/test-utils';
import FTSTemplateSchema from '../../../pgadmin/browser/server_groups/servers/databases/schemas/fts_templates/static/js/fts_template.ui';
import {genericBeforeEach, getCreateView, getEditView, getPropertiesView} from '../genericFunctions';
describe('FTSTemplateSchema', ()=>{
let mount;
let schemaObj = new FTSTemplateSchema(
{
schemaList: ()=> [],
@@ -26,30 +25,24 @@ describe('FTSTemplateSchema', ()=>{
);
let getInitData = ()=>Promise.resolve({});
/* Use createMount so that material ui components gets the required context */
/* https://material-ui.com/guides/testing/#api */
beforeAll(()=>{
mount = createMount();
});
afterAll(() => {
mount.cleanUp();
});
beforeEach(()=>{
genericBeforeEach();
});
it('create', ()=>{
mount(getCreateView(schemaObj));
it('create', async ()=>{
await getCreateView(schemaObj);
});
it('edit', ()=>{
mount(getEditView(schemaObj, getInitData));
it('edit', async ()=>{
await getEditView(schemaObj, getInitData);
});
it('properties', ()=>{
mount(getPropertiesView(schemaObj, getInitData));
it('properties', async ()=>{
await getPropertiesView(schemaObj, getInitData);
});
});

View File

@@ -7,8 +7,7 @@
//
//////////////////////////////////////////////////////////////
import '../helper/enzyme.helper';
import { createMount } from '@material-ui/core/test-utils';
import BaseUISchema from 'sources/SchemaView/base_schema.ui';
import FunctionSchema from '../../../pgadmin/browser/server_groups/servers/databases/schemas/functions/static/js/function.ui';
import {genericBeforeEach, getCreateView, getEditView, getPropertiesView} from '../genericFunctions';
@@ -20,7 +19,7 @@ class MockSchema extends BaseUISchema {
}
describe('FunctionSchema', ()=>{
let mount;
//Procedure schema
let procedureSchemaObj = new FunctionSchema(
()=>new MockSchema(),
@@ -109,37 +108,31 @@ describe('FunctionSchema', ()=>{
);
let getInitData = ()=>Promise.resolve({});
/* Use createMount so that material ui components gets the required context */
/* https://material-ui.com/guides/testing/#api */
beforeAll(()=>{
mount = createMount();
});
afterAll(() => {
mount.cleanUp();
});
beforeEach(()=>{
genericBeforeEach();
});
it('create', ()=>{
mount(getCreateView(schemaObj));
it('create', async ()=>{
await getCreateView(schemaObj);
});
it('create', ()=>{
mount(getCreateView(procedureSchemaObj));
it('create', async ()=>{
await getCreateView(procedureSchemaObj);
});
it('edit', ()=>{
mount(getEditView(schemaObj, getInitData));
it('edit', async ()=>{
await getEditView(schemaObj, getInitData);
});
it('properties', ()=>{
mount(getPropertiesView(schemaObj, getInitData));
it('properties', async ()=>{
await getPropertiesView(schemaObj, getInitData);
});
it('proiswindow visible', ()=>{
it('proiswindow visible', async ()=>{
let editSchemaObj = new FunctionSchema(
@@ -187,11 +180,11 @@ describe('FunctionSchema', ()=>{
type: 'function',
});
mount(getEditView(editSchemaObj, initData));
await getEditView(editSchemaObj, initData);
});
it('proiswindow visible', ()=>{
it('proiswindow visible', async ()=>{
let editSchemaObj = new FunctionSchema(
@@ -239,7 +232,7 @@ describe('FunctionSchema', ()=>{
type: 'function',
});
mount(getEditView(editSchemaObj, initData));
await getEditView(editSchemaObj, initData);
});
@@ -248,7 +241,7 @@ describe('FunctionSchema', ()=>{
type: 'procedure',
});
it('proiswindow visible', ()=>{
it('proiswindow visible', async ()=>{
let editSchemaObj = new FunctionSchema(
@@ -290,10 +283,10 @@ describe('FunctionSchema', ()=>{
}
);
mount(getEditView(editSchemaObj, initDataProc));
await getEditView(editSchemaObj, initDataProc);
});
it('proiswindow visible', ()=>{
it('proiswindow visible', async ()=>{
let editSchemaObj = new FunctionSchema(
@@ -340,11 +333,11 @@ describe('FunctionSchema', ()=>{
type: 'procedure',
});
mount(getEditView(editSchemaObj, initData));
await getEditView(editSchemaObj, initData);
});
it('proparallel disabled', ()=>{
it('proparallel disabled', async ()=>{
let editSchemaObj = new FunctionSchema(
@@ -389,7 +382,7 @@ describe('FunctionSchema', ()=>{
}
);
mount(getEditView(editSchemaObj, initDataProc));
await getEditView(editSchemaObj, initDataProc);
});
it('probin visible', ()=>{
@@ -418,7 +411,7 @@ describe('FunctionSchema', ()=>{
it('prorettypename validate', () => {
let state = {lanname: 'c', prorettypename: null};
let setError = jasmine.createSpy('setError');
let setError = jest.fn();
schemaObj.validate(state, setError);
expect(setError).toHaveBeenCalledWith('prorettypename', 'Return type cannot be empty.');
@@ -426,7 +419,7 @@ describe('FunctionSchema', ()=>{
it('probin validate', () => {
let state = { lanname: 'c', prorettypename: 'char' };
let setError = jasmine.createSpy('setError');
let setError = jest.fn();
schemaObj.validate(state, setError);
expect(setError).toHaveBeenCalledWith('probin', 'Object File cannot be empty.');
@@ -434,7 +427,7 @@ describe('FunctionSchema', ()=>{
it('probin validate', () => {
let state = { lanname: 'c', probin: 'test1', prorettypename: 'char'};
let setError = jasmine.createSpy('setError');
let setError = jest.fn();
schemaObj.validate(state, setError);
expect(setError).toHaveBeenCalledWith('probin', null);
@@ -442,7 +435,7 @@ describe('FunctionSchema', ()=>{
it('prosrc_c validate', () => {
let state = { lanname: 'c', probin : '$libdir/', prorettypename: 'char'};
let setError = jasmine.createSpy('setError');
let setError = jest.fn();
schemaObj.validate(state, setError);
expect(setError).toHaveBeenCalledWith('prosrc_c', 'Link Symbol cannot be empty.');
@@ -450,7 +443,7 @@ describe('FunctionSchema', ()=>{
it('prosrc_c validate', () => {
let state = { lanname: 'c', probin : '$libdir/', prosrc_c: 'test1', prorettypename: 'char'};
let setError = jasmine.createSpy('setError');
let setError = jest.fn();
schemaObj.validate(state, setError);
expect(setError).toHaveBeenCalledWith('prosrc_c', null);
@@ -458,7 +451,7 @@ describe('FunctionSchema', ()=>{
it('validate', ()=>{
let state = {prorettypename: 'char'};
let setError = jasmine.createSpy('setError');
let setError = jest.fn();
state.prosrc = null;
schemaObj.validate(state, setError);
expect(setError).toHaveBeenCalledWith('prosrc', 'Code cannot be empty.');

View File

@@ -7,14 +7,10 @@
//
//////////////////////////////////////////////////////////////
import React from 'react';
import '../helper/enzyme.helper';
import { createMount } from '@material-ui/core/test-utils';
import SchemaView from '../../../pgadmin/static/js/SchemaView';
import BaseUISchema from 'sources/SchemaView/base_schema.ui';
import GrantWizardPrivilegeSchema from '../../../pgadmin/tools/grant_wizard/static/js/privilege_schema.ui';
import {genericBeforeEach} from '../genericFunctions';
import Theme from '../../../pgadmin/static/js/Theme';
import {genericBeforeEach, getCreateView} from '../genericFunctions';
class MockSchema extends BaseUISchema {
get baseFields() {
@@ -23,38 +19,17 @@ class MockSchema extends BaseUISchema {
}
describe('GrantWizard', () => {
let mount;
let schemaObj = new GrantWizardPrivilegeSchema(
() => new MockSchema(),
);
/* Use createMount so that material ui components gets the required context */
/* https://material-ui.com/guides/testing/#api */
beforeAll(() => {
mount = createMount();
});
afterAll(() => {
mount.cleanUp();
});
beforeEach(() => {
genericBeforeEach();
});
it('create', () => {
mount(<Theme>
<SchemaView
formType='dialog'
schema={schemaObj}
viewHelperProps={{
mode: 'create',
}}
onDataChange={() => {/*This is intentional (SonarQube)*/}}
showFooter={false}
isTabView={false}
/>
</Theme>);
it('create', async () => {
await getCreateView(schemaObj);
});
});

View File

@@ -7,20 +7,15 @@
//
//////////////////////////////////////////////////////////////
import '../helper/enzyme.helper';
import { createMount } from '@material-ui/core/test-utils';
import ImportExportSchema, {getFileInfoSchema, getMiscellaneousSchema} from '../../../pgadmin/tools/import_export/static/js/import_export.ui';
import {getCreateView} from '../genericFunctions';
describe('ImportExportSchema', ()=>{
let mount;
beforeAll(()=>{
mount = createMount();
});
afterAll(() => {
mount.cleanUp();
});
let importExportSchemaObj = new ImportExportSchema(
()=>getFileInfoSchema(),
@@ -28,8 +23,8 @@ describe('ImportExportSchema', ()=>{
{columns: ()=>[]}
);
it('start import export', ()=>{
mount(getCreateView(importExportSchemaObj));
it('start import export', async ()=>{
await getCreateView(importExportSchemaObj);
});
});

View File

@@ -7,61 +7,26 @@
//
//////////////////////////////////////////////////////////////
import React from 'react';
import '../helper/enzyme.helper';
import { createMount } from '@material-ui/core/test-utils';
import SchemaView from '../../../pgadmin/static/js/SchemaView';
import ImportExportSelectionSchema from '../../../pgadmin/tools/import_export_servers/static/js/import_export_selection.ui';
import {genericBeforeEach} from '../genericFunctions';
import Theme from '../../../pgadmin/static/js/Theme';
import {genericBeforeEach, getCreateView} from '../genericFunctions';
describe('ImportExportServers', () => {
let mount;
let schemaObj = new ImportExportSelectionSchema();
/* Use createMount so that material ui components gets the required context */
/* https://material-ui.com/guides/testing/#api */
beforeAll(() => {
mount = createMount();
});
afterAll(() => {
mount.cleanUp();
});
beforeEach(() => {
genericBeforeEach();
});
it('import', () => {
mount(<Theme>
<SchemaView
formType='dialog'
schema={schemaObj}
viewHelperProps={{
mode: 'create',
}}
onDataChange={() => {/*This is intentional (SonarQube)*/}}
showFooter={false}
isTabView={false}
/>
</Theme>);
it('import', async () => {
await getCreateView(schemaObj);
});
it('export', () => {
it('export', async () => {
schemaObj = new ImportExportSelectionSchema(
{imp_exp: 'e', filename: 'test.json'});
mount(<Theme>
<SchemaView
formType='dialog'
schema={schemaObj}
viewHelperProps={{
mode: 'create',
}}
onDataChange={() => {/*This is intentional (SonarQube)*/}}
showFooter={false}
isTabView={false}
/>
</Theme>);
await getCreateView(schemaObj);
});
});

View File

@@ -7,12 +7,10 @@
//
//////////////////////////////////////////////////////////////
import '../helper/enzyme.helper';
import { createMount } from '@material-ui/core/test-utils';
import * as nodeAjax from '../../../pgadmin/browser/static/js/node_ajax';
import BaseUISchema from '../../../pgadmin/static/js/SchemaView/base_schema.ui';
import IndexSchema from '../../../pgadmin/browser/server_groups/servers/databases/schemas/tables/indexes/static/js/index.ui';
import {genericBeforeEach, getCreateView, getEditView, getPropertiesView} from '../genericFunctions';
import {addNewDatagridRow, genericBeforeEach, getCreateView, getEditView, getPropertiesView} from '../genericFunctions';
class SchemaInColl extends BaseUISchema {
constructor(indexSchemaObj) {
@@ -36,16 +34,12 @@ function getFieldDepChange(schema, id) {
}
describe('IndexSchema', ()=>{
let mount;
let indexSchemaObj;
let getInitData = ()=>Promise.resolve({});
/* Use createMount so that material ui components gets the required context */
/* https://material-ui.com/guides/testing/#api */
beforeAll(()=>{
mount = createMount();
spyOn(nodeAjax, 'getNodeAjaxOptions').and.returnValue(Promise.resolve([]));
spyOn(nodeAjax, 'getNodeListByName').and.returnValue(Promise.resolve([]));
jest.spyOn(nodeAjax, 'getNodeAjaxOptions').mockReturnValue(Promise.resolve([]));
jest.spyOn(nodeAjax, 'getNodeListByName').mockReturnValue(Promise.resolve([]));
indexSchemaObj = new IndexSchema(
{
tablespaceList: ()=>[],
@@ -63,35 +57,33 @@ describe('IndexSchema', ()=>{
);
});
afterAll(() => {
mount.cleanUp();
});
beforeEach(()=>{
genericBeforeEach();
});
it('create', ()=>{
mount(getCreateView(indexSchemaObj));
it('create', async ()=>{
await getCreateView(indexSchemaObj);
});
it('edit', ()=>{
mount(getEditView(indexSchemaObj, getInitData));
it('edit', async ()=>{
await getEditView(indexSchemaObj, getInitData);
});
it('properties', ()=>{
mount(getPropertiesView(indexSchemaObj, getInitData));
it('properties', async ()=>{
await getPropertiesView(indexSchemaObj, getInitData);
});
it('create collection', ()=>{
it('create collection', async ()=>{
let schemaCollObj = new SchemaInColl(indexSchemaObj);
let ctrl = mount(getCreateView(schemaCollObj));
let {ctrl, user} = await getCreateView(schemaCollObj);
/* Make sure you hit every corner */
ctrl.find('DataGridView').at(0).find('PgIconButton[data-test="add-row"]').find('button').simulate('click');
/* Make sure you hit every corner */
await addNewDatagridRow(user, ctrl);
});
it('changeColumnOptions', ()=>{
spyOn(indexSchemaObj.indexHeaderSchema, 'changeColumnOptions').and.callThrough();
jest.spyOn(indexSchemaObj.indexHeaderSchema, 'changeColumnOptions');
let columns = [{label: 'label', value: 'value'}];
indexSchemaObj.changeColumnOptions(columns);
expect(indexSchemaObj.indexHeaderSchema.changeColumnOptions).toHaveBeenCalledWith(columns);
@@ -103,7 +95,7 @@ describe('IndexSchema', ()=>{
{label: 'id', value: 'id'},
{label: 'name', value: 'name'}
];
spyOn(indexSchemaObj.indexColumnSchema, 'getNewData');
jest.spyOn(indexSchemaObj.indexColumnSchema, 'getNewData');
indexSchemaObj.indexHeaderSchema.getNewData({
is_exp: false,
colname: 'id',
@@ -153,12 +145,12 @@ describe('IndexSchema', ()=>{
_sessData: { amname: 'btree' }
};
let state = {};
spyOn(indexSchemaObj.indexColumnSchema, 'inSchemaWithModelCheck').and.returnValue(true);
jest.spyOn(indexSchemaObj.indexColumnSchema, 'inSchemaWithModelCheck').mockReturnValue(true);
let editable = _.find(indexSchemaObj.indexColumnSchema.fields, (f)=>f.id=='sort_order').editable;
let status = editable(state);
expect(status).toBe(false);
spyOn(indexSchemaObj.indexColumnSchema, 'inSchemaWithModelCheck').and.returnValue(false);
jest.spyOn(indexSchemaObj.indexColumnSchema, 'inSchemaWithModelCheck').mockReturnValue(false);
status = editable(state);
expect(status).toBe(true);
@@ -172,12 +164,12 @@ describe('IndexSchema', ()=>{
_sessData: { amname: 'btree' }
};
let state = {};
spyOn(indexSchemaObj.indexColumnSchema, 'inSchemaWithModelCheck').and.returnValue(true);
jest.spyOn(indexSchemaObj.indexColumnSchema, 'inSchemaWithModelCheck').mockReturnValue(true);
let editable = _.find(indexSchemaObj.indexColumnSchema.fields, (f)=>f.id=='nulls').editable;
let status = editable(state);
expect(status).toBe(false);
spyOn(indexSchemaObj.indexColumnSchema, 'inSchemaWithModelCheck').and.returnValue(false);
jest.spyOn(indexSchemaObj.indexColumnSchema, 'inSchemaWithModelCheck').mockReturnValue(false);
status = editable(state);
expect(status).toBe(true);
@@ -223,7 +215,7 @@ describe('IndexSchema', ()=>{
it('validate', ()=>{
let state = { columns: [] };
let setError = jasmine.createSpy('setError');
let setError = jest.fn();
indexSchemaObj.validate(state, setError);
expect(setError).toHaveBeenCalledWith('columns', 'You must specify at least one column/expression.');

View File

@@ -7,8 +7,7 @@
//
//////////////////////////////////////////////////////////////
import '../helper/enzyme.helper';
import { createMount } from '@material-ui/core/test-utils';
import BaseUISchema from 'sources/SchemaView/base_schema.ui';
import LanguageSchema from '../../../pgadmin/browser/server_groups/servers/databases/languages/static/js/language.ui';
import {genericBeforeEach, getCreateView, getEditView, getPropertiesView} from '../genericFunctions';
@@ -20,7 +19,7 @@ class MockSchema extends BaseUISchema {
}
describe('LanguageSchema', ()=>{
let mount;
let schemaObj = new LanguageSchema(
()=>new MockSchema(),
{
@@ -38,35 +37,29 @@ describe('LanguageSchema', ()=>{
);
let getInitData = ()=>Promise.resolve({});
/* Use createMount so that material ui components gets the required context */
/* https://material-ui.com/guides/testing/#api */
beforeAll(()=>{
mount = createMount();
});
afterAll(() => {
mount.cleanUp();
});
beforeEach(()=>{
genericBeforeEach();
});
it('create', ()=>{
mount(getCreateView(schemaObj));
it('create', async ()=>{
await getCreateView(schemaObj);
});
it('edit', ()=>{
mount(getEditView(schemaObj, getInitData));
it('edit', async ()=>{
await getEditView(schemaObj, getInitData);
});
it('properties', ()=>{
mount(getPropertiesView(schemaObj, getInitData));
it('properties', async ()=>{
await getPropertiesView(schemaObj, getInitData);
});
it('validate', ()=>{
let state = {};
let setError = jasmine.createSpy('setError');
let setError = jest.fn();
state.lanproc = '';
schemaObj.isTemplate = true;

View File

@@ -7,20 +7,15 @@
//
//////////////////////////////////////////////////////////////
import '../helper/enzyme.helper';
import { createMount } from '@material-ui/core/test-utils';
import MaintenanceSchema, {getVacuumSchema} from '../../../pgadmin/tools/maintenance/static/js/maintenance.ui';
import {getCreateView} from '../genericFunctions';
describe('MaintenanceSchema', ()=>{
let mount;
beforeAll(()=>{
mount = createMount();
});
afterAll(() => {
mount.cleanUp();
});
let backupSchemaObj = new MaintenanceSchema(
()=> getVacuumSchema(),
{
@@ -28,8 +23,8 @@ describe('MaintenanceSchema', ()=>{
}
);
it('start maintenance', ()=>{
mount(getCreateView(backupSchemaObj));
it('start maintenance', async ()=>{
await getCreateView(backupSchemaObj);
});
});

View File

@@ -7,12 +7,11 @@
//
//////////////////////////////////////////////////////////////
import '../helper/enzyme.helper';
import { createMount } from '@material-ui/core/test-utils';
import MembershipSchema from '../../../pgadmin/browser/server_groups/servers/static/js/membership.ui';
import * as nodeAjax from '../../../pgadmin/browser/static/js/node_ajax';
import BaseUISchema from '../../../pgadmin/static/js/SchemaView/base_schema.ui';
import {genericBeforeEach, getCreateView, getEditView, getPropertiesView} from '../genericFunctions';
import {addNewDatagridRow, genericBeforeEach, getCreateView, getEditView, getPropertiesView} from '../genericFunctions';
class SchemaInColl extends BaseUISchema {
constructor(schemaObj) {
@@ -31,41 +30,36 @@ class SchemaInColl extends BaseUISchema {
}
describe('MembershipSchema', ()=>{
let mount;
let schemaObj = new MembershipSchema(
()=>[]);
let getInitData = ()=>Promise.resolve({});
/* Use createMount so that material ui components gets the required context */
/* https://material-ui.com/guides/testing/#api */
beforeAll(()=>{
mount = createMount();
});
afterAll(() => {
mount.cleanUp();
});
beforeEach(()=>{
genericBeforeEach();
});
it('create', ()=>{
mount(getCreateView(schemaObj));
it('create', async ()=>{
await getCreateView(schemaObj);
});
it('edit', ()=>{
mount(getEditView(schemaObj, getInitData));
it('edit', async ()=>{
await getEditView(schemaObj, getInitData);
});
it('properties', ()=>{
mount(getPropertiesView(schemaObj, getInitData));
it('properties', async ()=>{
await getPropertiesView(schemaObj, getInitData);
});
it('MembershipMemberSchema', ()=>{
spyOn(nodeAjax, 'getNodeListByName').and.returnValue([]);
let ctrl = mount(getCreateView(new SchemaInColl(schemaObj)));
it('MembershipMemberSchema', async ()=>{
jest.spyOn(nodeAjax, 'getNodeListByName').mockReturnValue([]);
const {ctrl, user} = await getCreateView(new SchemaInColl(schemaObj));
/* Make sure you hit every corner */
ctrl.find('DataGridView').at(0).find('PgIconButton[data-test="add-row"]').find('button').simulate('click');
await addNewDatagridRow(user, ctrl);
});
});

View File

@@ -7,8 +7,7 @@
//
//////////////////////////////////////////////////////////////
import '../helper/enzyme.helper';
import { createMount } from '@material-ui/core/test-utils';
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';
@@ -20,7 +19,7 @@ class MockSchema extends BaseUISchema {
}
describe('MaterializedViewSchema', ()=>{
let mount;
let schemaObj = new MViewSchema(
()=>new MockSchema(),
()=>new MockSchema(),
@@ -36,36 +35,25 @@ describe('MaterializedViewSchema', ()=>{
);
let getInitData = ()=>Promise.resolve({});
/* Use createMount so that material ui components gets the required context */
/* https://material-ui.com/guides/testing/#api */
beforeAll(()=>{
mount = createMount();
spyOn(schemaObj, 'getServerVersion').and.returnValue(100000);
});
afterAll(() => {
mount.cleanUp();
});
beforeEach(()=>{
genericBeforeEach();
});
it('create', ()=>{
mount(getCreateView(schemaObj));
it('create', async ()=>{
await getCreateView(schemaObj);
});
it('edit', ()=>{
mount(getEditView(schemaObj, getInitData));
it('edit', async ()=>{
await getEditView(schemaObj, getInitData);
});
it('properties', ()=>{
mount(getPropertiesView(schemaObj, getInitData));
it('properties', async ()=>{
await getPropertiesView(schemaObj, getInitData);
});
it('validate', ()=>{
let state = {};
let setError = jasmine.createSpy('setError');
let setError = jest.fn();
state.definition = null;
schemaObj.validate(state, setError);
@@ -86,4 +74,3 @@ describe('MaterializedViewSchema', ()=>{
});
});

View File

@@ -7,40 +7,33 @@
//
//////////////////////////////////////////////////////////////
import '../helper/enzyme.helper';
import { createMount } from '@material-ui/core/test-utils';
import OperatorSchema from '../../../pgadmin/browser/server_groups/servers/databases/schemas/operators/static/js/operator.ui';
import {genericBeforeEach, getCreateView, getEditView, getPropertiesView} from '../genericFunctions';
describe('OperatorSchema', ()=>{
let mount;
let schemaObj = new OperatorSchema();
let getInitData = ()=>Promise.resolve({});
/* Use createMount so that material ui components gets the required context */
/* https://material-ui.com/guides/testing/#api */
beforeAll(()=>{
mount = createMount();
});
afterAll(() => {
mount.cleanUp();
});
beforeEach(()=>{
genericBeforeEach();
});
it('create', ()=>{
mount(getCreateView(schemaObj));
it('create', async ()=>{
await getCreateView(schemaObj);
});
it('edit', ()=>{
mount(getEditView(schemaObj, getInitData));
it('edit', async ()=>{
await getEditView(schemaObj, getInitData);
});
it('properties', ()=>{
mount(getPropertiesView(schemaObj, getInitData));
it('properties', async ()=>{
await getPropertiesView(schemaObj, getInitData);
});
});

View File

@@ -7,14 +7,13 @@
//
//////////////////////////////////////////////////////////////
import '../helper/enzyme.helper';
import { createMount } from '@material-ui/core/test-utils';
import { getNodePrivilegeRoleSchema } from '../../../pgadmin/browser/server_groups/servers/static/js/privilege.ui';
import PackageSchema from '../../../pgadmin/browser/server_groups/servers/databases/schemas/packages/static/js/package.ui';
import {genericBeforeEach, getCreateView, getEditView, getPropertiesView} from '../genericFunctions';
describe('PackageSchema', ()=>{
let mount;
let packageSchemaObj = new PackageSchema(
(privileges)=>getNodePrivilegeRoleSchema({}, {server: {user: {name: 'postgres'}}}, {}, privileges),
{
@@ -24,30 +23,24 @@ describe('PackageSchema', ()=>{
);
let getInitData = ()=>Promise.resolve({});
/* Use createMount so that material ui components gets the required context */
/* https://material-ui.com/guides/testing/#api */
beforeAll(()=>{
mount = createMount();
});
afterAll(() => {
mount.cleanUp();
});
beforeEach(()=>{
genericBeforeEach();
});
it('create', ()=>{
mount(getCreateView(packageSchemaObj));
it('create', async ()=>{
await getCreateView(packageSchemaObj);
});
it('edit', ()=>{
mount(getEditView(packageSchemaObj, getInitData));
it('edit', async ()=>{
await getEditView(packageSchemaObj, getInitData);
});
it('properties', ()=>{
mount(getPropertiesView(packageSchemaObj, getInitData));
it('properties', async ()=>{
await getPropertiesView(packageSchemaObj, getInitData);
});
it('pkgheadsrc depChange', ()=>{
@@ -94,7 +87,7 @@ describe('PackageSchema', ()=>{
let state = {
pkgheadsrc: undefined
};
let setError = jasmine.createSpy('setError');
let setError = jest.fn();
packageSchemaObj.validate(state, setError);
expect(setError).toHaveBeenCalledWith('pkgheadsrc', 'Header cannot be empty.');

View File

@@ -7,24 +7,20 @@
//
//////////////////////////////////////////////////////////////
import '../helper/enzyme.helper';
import { createMount } from '@material-ui/core/test-utils';
import _ from 'lodash';
import * as nodeAjax from '../../../pgadmin/browser/static/js/node_ajax';
import { getNodePartitionTableSchema } from '../../../pgadmin/browser/server_groups/servers/databases/schemas/tables/partitions/static/js/partition.ui';
import {genericBeforeEach, getCreateView, getEditView, getPropertiesView} from '../genericFunctions';
describe('PartitionTableSchema', ()=>{
let mount;
let schemaObj;
let getInitData = ()=>Promise.resolve({});
/* Use createMount so that material ui components gets the required context */
/* https://material-ui.com/guides/testing/#api */
beforeAll(()=>{
mount = createMount();
spyOn(nodeAjax, 'getNodeAjaxOptions').and.returnValue(Promise.resolve([]));
spyOn(nodeAjax, 'getNodeListByName').and.returnValue(Promise.resolve([]));
jest.spyOn(nodeAjax, 'getNodeAjaxOptions').mockReturnValue(Promise.resolve([]));
jest.spyOn(nodeAjax, 'getNodeListByName').mockReturnValue(Promise.resolve([]));
schemaObj = getNodePartitionTableSchema({
server: {
_id: 1,
@@ -44,24 +40,22 @@ describe('PartitionTableSchema', ()=>{
});
});
afterAll(() => {
mount.cleanUp();
});
beforeEach(()=>{
genericBeforeEach();
});
it('create', ()=>{
mount(getCreateView(schemaObj));
it('create', async ()=>{
await getCreateView(schemaObj);
});
it('edit', ()=>{
mount(getEditView(schemaObj, getInitData));
it('edit', async ()=>{
await getEditView(schemaObj, getInitData);
});
it('properties', ()=>{
mount(getPropertiesView(schemaObj, getInitData));
it('properties', async ()=>{
await getPropertiesView(schemaObj, getInitData);
});
it('depChange', ()=>{
@@ -93,7 +87,7 @@ describe('PartitionTableSchema', ()=>{
it('validate', ()=>{
let state = {is_partitioned: true};
let setError = jasmine.createSpy('setError');
let setError = jest.fn();
schemaObj.validate(state, setError);
expect(setError).toHaveBeenCalledWith('partition_keys', 'Please specify at least one key for partitioned table.');

View File

@@ -7,13 +7,12 @@
//
//////////////////////////////////////////////////////////////
import '../helper/enzyme.helper';
import { createMount } from '@material-ui/core/test-utils';
import BaseUISchema from '../../../pgadmin/static/js/SchemaView/base_schema.ui';
import _ from 'lodash';
import * as nodeAjax from '../../../pgadmin/browser/static/js/node_ajax';
import { PartitionKeysSchema, PartitionsSchema } from '../../../pgadmin/browser/server_groups/servers/databases/schemas/tables/static/js/partition.utils.ui';
import {genericBeforeEach, getCreateView, getEditView, getPropertiesView} from '../genericFunctions';
import {addNewDatagridRow, genericBeforeEach, getCreateView, getEditView, getPropertiesView} from '../genericFunctions';
function getFieldDepChange(schema, id) {
return _.find(schema.fields, (f)=>f.id==id)?.depChange;
@@ -40,42 +39,38 @@ class SchemaInColl extends BaseUISchema {
}
describe('PartitionKeysSchema', ()=>{
let mount;
let schemaObj;
let getInitData = ()=>Promise.resolve({});
/* Use createMount so that material ui components gets the required context */
/* https://material-ui.com/guides/testing/#api */
beforeAll(()=>{
mount = createMount();
spyOn(nodeAjax, 'getNodeAjaxOptions').and.returnValue(Promise.resolve([]));
spyOn(nodeAjax, 'getNodeListByName').and.returnValue(Promise.resolve([]));
jest.spyOn(nodeAjax, 'getNodeAjaxOptions').mockReturnValue(Promise.resolve([]));
jest.spyOn(nodeAjax, 'getNodeListByName').mockReturnValue(Promise.resolve([]));
let partitionObj = new PartitionKeysSchema();
schemaObj = new SchemaInColl(partitionObj);
});
afterAll(() => {
mount.cleanUp();
});
beforeEach(()=>{
genericBeforeEach();
});
it('create', ()=>{
let ctrl = mount(getCreateView(schemaObj));
it('create', async ()=>{
const {ctrl, user} = await getCreateView(schemaObj);
/* Make sure you hit every corner */
ctrl.find('DataGridView').at(0).find('PgIconButton[data-test="add-row"]').find('button').simulate('click');
await addNewDatagridRow(user, ctrl);
});
it('edit', ()=>{
mount(getEditView(schemaObj, getInitData));
it('edit', async ()=>{
await getEditView(schemaObj, getInitData);
});
it('properties', ()=>{
mount(getPropertiesView(schemaObj, getInitData));
it('properties', async ()=>{
await getPropertiesView(schemaObj, getInitData);
});
it('depChange', ()=>{
@@ -94,7 +89,7 @@ describe('PartitionKeysSchema', ()=>{
it('validate', ()=>{
let state = {};
let setError = jasmine.createSpy('setError');
let setError = jest.fn();
state.key_type = 'expression';
schemaObj.collSchema.validate(state, setError);
@@ -107,47 +102,43 @@ describe('PartitionKeysSchema', ()=>{
describe('PartitionsSchema', ()=>{
let mount;
let schemaObj;
let getInitData = ()=>Promise.resolve({});
/* Use createMount so that material ui components gets the required context */
/* https://material-ui.com/guides/testing/#api */
beforeAll(()=>{
mount = createMount();
spyOn(nodeAjax, 'getNodeAjaxOptions').and.returnValue(Promise.resolve([]));
spyOn(nodeAjax, 'getNodeListByName').and.returnValue(Promise.resolve([]));
jest.spyOn(nodeAjax, 'getNodeAjaxOptions').mockReturnValue(Promise.resolve([]));
jest.spyOn(nodeAjax, 'getNodeListByName').mockReturnValue(Promise.resolve([]));
schemaObj = new PartitionsSchema();
schemaObj.top = schemaObj;
});
afterAll(() => {
mount.cleanUp();
});
beforeEach(()=>{
genericBeforeEach();
});
it('create', ()=>{
mount(getCreateView(schemaObj));
it('create', async ()=>{
await getCreateView(schemaObj);
});
it('edit', ()=>{
mount(getEditView(schemaObj, getInitData));
it('edit', async ()=>{
await getEditView(schemaObj, getInitData);
});
it('properties', ()=>{
mount(getPropertiesView(schemaObj, getInitData));
it('properties', async ()=>{
await getPropertiesView(schemaObj, getInitData);
});
it('create collection', ()=>{
it('create collection', async ()=>{
let schemaCollObj = new SchemaInColl(
schemaObj,[ 'is_attach', 'partition_name', 'is_default', 'values_from', 'values_to', 'values_in', 'values_modulus', 'values_remainder']
);
let ctrl = mount(getCreateView(schemaCollObj));
const {ctrl, user} = await getCreateView(schemaCollObj);
/* Make sure you hit every corner */
ctrl.find('DataGridView').at(0).find('PgIconButton[data-test="add-row"]').find('button').simulate('click');
await addNewDatagridRow(user, ctrl);
});
@@ -162,7 +153,7 @@ describe('PartitionsSchema', ()=>{
it('validate', ()=>{
let state = {is_sub_partitioned: true};
let setError = jasmine.createSpy('setError');
let setError = jest.fn();
schemaObj.validate(state, setError);
expect(setError).toHaveBeenCalledWith('sub_partition_keys', 'Please specify at least one key for partitioned table.');

View File

@@ -7,8 +7,7 @@
//
//////////////////////////////////////////////////////////////
import '../helper/enzyme.helper';
import { createMount } from '@material-ui/core/test-utils';
import BaseUISchema from 'sources/SchemaView/base_schema.ui';
import PgaJobSchema from '../../../pgadmin/browser/server_groups/servers/pgagent/static/js/pga_job.ui';
import {genericBeforeEach, getCreateView, getEditView, getPropertiesView} from '../genericFunctions';
@@ -20,7 +19,7 @@ class MockSchema extends BaseUISchema {
}
describe('PgaJobSchema', ()=>{
let mount;
let schemaObj = new PgaJobSchema(
{
jobjclid:()=>[],
@@ -29,30 +28,24 @@ describe('PgaJobSchema', ()=>{
);
let getInitData = ()=>Promise.resolve({});
/* Use createMount so that material ui components gets the required context */
/* https://material-ui.com/guides/testing/#api */
beforeAll(()=>{
mount = createMount();
});
afterAll(() => {
mount.cleanUp();
});
beforeEach(()=>{
genericBeforeEach();
});
it('create', ()=>{
mount(getCreateView(schemaObj));
it('create', async ()=>{
await getCreateView(schemaObj);
});
it('edit', ()=>{
mount(getEditView(schemaObj, getInitData));
it('edit', async ()=>{
await getEditView(schemaObj, getInitData);
});
it('properties', ()=>{
mount(getPropertiesView(schemaObj, getInitData));
it('properties', async ()=>{
await getPropertiesView(schemaObj, getInitData);
});
});

View File

@@ -7,13 +7,12 @@
//
//////////////////////////////////////////////////////////////
import '../helper/enzyme.helper';
import { createMount } from '@material-ui/core/test-utils';
import PgaJobStepSchema from '../../../pgadmin/browser/server_groups/servers/pgagent/steps/static/js/pga_jobstep.ui';
import {genericBeforeEach, getCreateView, getEditView, getPropertiesView} from '../genericFunctions';
describe('PgaJobStepSchema', ()=>{
let mount;
let schemaObj = new PgaJobStepSchema(
{
databases: ()=>[],
@@ -25,84 +24,90 @@ describe('PgaJobStepSchema', ()=>{
);
let getInitData = ()=>Promise.resolve({});
/* Use createMount so that material ui components gets the required context */
/* https://material-ui.com/guides/testing/#api */
beforeAll(()=>{
mount = createMount();
});
afterAll(() => {
mount.cleanUp();
});
beforeEach(()=>{
genericBeforeEach();
});
it('create', ()=>{
mount(getCreateView(schemaObj));
it('create', async ()=>{
await getCreateView(schemaObj);
});
it('edit', ()=>{
mount(getEditView(schemaObj, getInitData));
it('edit', async ()=>{
await getEditView(schemaObj, getInitData);
});
it('properties', ()=>{
mount(getPropertiesView(schemaObj, getInitData));
it('properties', async ()=>{
await getPropertiesView(schemaObj, getInitData);
});
it('validate', ()=>{
let state = {};
let setError = jasmine.createSpy('setError');
let setError = jest.fn();
state.name = 'my_step';
state.jstkind = true;
state.jstconntype = true;
setError.mockClear();
schemaObj.validate(state, setError);
expect(setError).toHaveBeenCalledWith('jstdbname', 'Please select a database.');
state.jstdbname = 'postgres';
setError.mockClear();
schemaObj.validate(state, setError);
expect(setError).toHaveBeenCalledWith('jstdbname', null);
state.jstconntype = false;
state.jstconnstr = null;
setError.mockClear();
schemaObj.validate(state, setError);
expect(setError).toHaveBeenCalledWith('jstconnstr', 'Please enter a connection string.');
state.jstconnstr = '**!!';
schemaObj.validate(state, setError);
expect(setError).toHaveBeenCalledWith('jstconnstr', 'Please enter a connection string.');
state.jstconnstr = 'host:\'192.168.1.7\'';
setError.mockClear();
schemaObj.validate(state, setError);
expect(setError).toHaveBeenCalledWith('jstconnstr', 'Please enter a valid connection string.');
state.jstconnstr = 'host:\'192.168.1.7\'';
setError.mockClear();
schemaObj.validate(state, setError);
expect(setError).toHaveBeenCalledWith('jstconnstr', 'Please enter a valid connection string.');
state.jstconnstr = 'host:\'192.168.1.7\'';
setError.mockClear();
schemaObj.validate(state, setError);
expect(setError).toHaveBeenCalledWith('jstconnstr', 'Please enter a valid connection string.');
state.jstconnstr = 'hostaddrtest=\'192.168.1.7\'';
setError.mockClear();
schemaObj.validate(state, setError);
expect(setError).toHaveBeenCalledWith('jstconnstr', 'Invalid parameter in the connection string - hostaddrtest.');
state.jstconnstr = 'host=\'192.168.1.7\' port=5432';
setError.mockClear();
schemaObj.validate(state, setError);
expect(setError).toHaveBeenCalledWith('jstconnstr', null);
state.jstcode = null;
setError.mockClear();
schemaObj.validate(state, setError);
expect(setError).toHaveBeenCalledWith('jstcode', 'Please specify code to execute.');
state.jstcode = 'PERFORM 1;';
setError.mockClear();
schemaObj.validate(state, setError);
expect(setError).toHaveBeenCalledWith('jstcode', null);
state.jstonerror = null;
setError.mockClear();
schemaObj.validate(state, setError);
expect(setError).toHaveBeenCalledWith('jstonerror', 'Please select valid on error option.');
state.jstonerror = 'f';
setError.mockClear();
schemaObj.validate(state, setError);
expect(setError).toHaveBeenCalledWith('jstonerror', null);
});

View File

@@ -7,48 +7,39 @@
//
//////////////////////////////////////////////////////////////
import '../helper/enzyme.helper';
import { createMount } from '@material-ui/core/test-utils';
import PgaJobScheduleSchema, { ExceptionsSchema } from '../../../pgadmin/browser/server_groups/servers/pgagent/schedules/static/js/pga_schedule.ui';
import {genericBeforeEach, getCreateView, getEditView, getPropertiesView} from '../genericFunctions';
describe('PgaJobScheduleSchema', ()=>{
let mount;
let schemaObj = 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'}],
});
let getInitData = ()=>Promise.resolve({});
/* Use createMount so that material ui components gets the required context */
/* https://material-ui.com/guides/testing/#api */
beforeAll(()=>{
mount = createMount();
});
afterAll(() => {
mount.cleanUp();
});
beforeEach(()=>{
genericBeforeEach();
});
it('create', ()=>{
mount(getCreateView(schemaObj));
it('create', async ()=>{
await getCreateView(schemaObj);
});
it('edit', ()=>{
mount(getEditView(schemaObj, getInitData));
it('edit', async ()=>{
await getEditView(schemaObj, getInitData);
});
it('properties', ()=>{
mount(getPropertiesView(schemaObj, getInitData));
it('properties', async ()=>{
await getPropertiesView(schemaObj, getInitData);
});
it('validate', ()=>{
let state = {};
let setError = jasmine.createSpy('setError');
let setError = jest.fn();
state.jscstart = null;
schemaObj.validate(state, setError);
@@ -69,39 +60,29 @@ describe('PgaJobScheduleSchema', ()=>{
});
describe('ExceptionsSchema', ()=>{
let mount;
let schemaObj = new ExceptionsSchema();
let getInitData = ()=>Promise.resolve({});
/* Use createMount so that material ui components gets the required context */
/* https://material-ui.com/guides/testing/#api */
beforeAll(()=>{
mount = createMount();
});
afterAll(() => {
mount.cleanUp();
});
beforeEach(()=>{
genericBeforeEach();
});
it('create', ()=>{
mount(getCreateView(schemaObj));
it('create', async ()=>{
await getCreateView(schemaObj);
});
it('edit', ()=>{
mount(getEditView(schemaObj, getInitData));
it('edit', async ()=>{
await getEditView(schemaObj, getInitData);
});
it('properties', ()=>{
mount(getPropertiesView(schemaObj, getInitData));
it('properties', async ()=>{
await getPropertiesView(schemaObj, getInitData);
});
it('validate', ()=>{
let state = {};
let setError = jasmine.createSpy('setError');
let setError = jest.fn();
state.jexdate = '<any>';
state.jextime = '<any>';

View File

@@ -7,14 +7,13 @@
//
//////////////////////////////////////////////////////////////
import '../helper/enzyme.helper';
import { createMount } from '@material-ui/core/test-utils';
import { SCHEMA_STATE_ACTIONS } from '../../../pgadmin/static/js/SchemaView';
import BaseUISchema from '../../../pgadmin/static/js/SchemaView/base_schema.ui';
import _ from 'lodash';
import PrimaryKeySchema from '../../../pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/static/js/primary_key.ui';
import TableSchema from '../../../pgadmin/browser/server_groups/servers/databases/schemas/tables/static/js/table.ui';
import {genericBeforeEach, getCreateView, getEditView, getPropertiesView} from '../genericFunctions';
import {addNewDatagridRow, genericBeforeEach, getCreateView, getEditView, getPropertiesView} from '../genericFunctions';
class SchemaInColl extends BaseUISchema {
constructor(schemaObj) {
@@ -38,44 +37,40 @@ function getFieldDepChange(schema, id) {
}
describe('PrimaryKeySchema', ()=>{
let mount;
let schemaObj;
let getInitData = ()=>Promise.resolve({});
/* Use createMount so that material ui components gets the required context */
/* https://material-ui.com/guides/testing/#api */
beforeAll(()=>{
mount = createMount();
schemaObj = new PrimaryKeySchema({
spcname: ()=>Promise.resolve([]),
}, {});
});
afterAll(() => {
mount.cleanUp();
});
beforeEach(()=>{
genericBeforeEach();
});
it('create', ()=>{
mount(getCreateView(schemaObj));
it('create', async ()=>{
await getCreateView(schemaObj);
});
it('edit', ()=>{
mount(getEditView(schemaObj, getInitData));
it('edit', async ()=>{
await getEditView(schemaObj, getInitData);
});
it('properties', ()=>{
mount(getPropertiesView(schemaObj, getInitData));
it('properties', async ()=>{
await getPropertiesView(schemaObj, getInitData);
});
it('create collection', ()=>{
it('create collection', async ()=>{
let schemaCollObj = new SchemaInColl(schemaObj);
let ctrl = mount(getCreateView(schemaCollObj));
const {ctrl, user} = await getCreateView(schemaCollObj);
/* Make sure you hit every corner */
ctrl.find('DataGridView').at(0).find('PgIconButton[data-test="add-row"]').find('button').simulate('click');
await addNewDatagridRow(user, ctrl);
});
it('depChange', ()=>{
@@ -147,7 +142,7 @@ describe('PrimaryKeySchema', ()=>{
it('validate', ()=>{
let state = {};
let setError = jasmine.createSpy('setError');
let setError = jest.fn();
schemaObj.validate(state, setError);
expect(setError).toHaveBeenCalledWith('columns', 'Please specify columns for Primary key.');

View File

@@ -7,15 +7,14 @@
//
//////////////////////////////////////////////////////////////
import '../helper/enzyme.helper';
import { createMount } from '@material-ui/core/test-utils';
import PrivilegeRoleSchema, {getNodePrivilegeRoleSchema} from '../../../pgadmin/browser/server_groups/servers/static/js/privilege.ui';
import {DefaultPrivSchema} from '../../../pgadmin/browser/server_groups/servers/databases/static/js/database.ui';
import * as nodeAjax from '../../../pgadmin/browser/static/js/node_ajax';
import {genericBeforeEach, getCreateView, getEditView, getPropertiesView} from '../genericFunctions';
import {addNewDatagridRow, genericBeforeEach, getCreateView, getEditView, getPropertiesView} from '../genericFunctions';
describe('PrivilegeSchema', ()=>{
let mount;
let schemaObj = new PrivilegeRoleSchema(
()=>[],
()=>[],
@@ -25,45 +24,38 @@ describe('PrivilegeSchema', ()=>{
);
let getInitData = ()=>Promise.resolve({});
/* Use createMount so that material ui components gets the required context */
/* https://material-ui.com/guides/testing/#api */
beforeAll(()=>{
mount = createMount();
});
afterAll(() => {
mount.cleanUp();
});
beforeEach(()=>{
genericBeforeEach();
});
it('create', ()=>{
mount(getCreateView(schemaObj));
it('create', async ()=>{
await getCreateView(schemaObj);
});
it('edit', ()=>{
mount(getEditView(schemaObj, getInitData));
it('edit', async ()=>{
await getEditView(schemaObj, getInitData);
});
it('properties', ()=>{
mount(getPropertiesView(schemaObj, getInitData));
it('properties', async ()=>{
await getPropertiesView(schemaObj, getInitData);
});
it('validate', ()=>{
let state = {};
let setError = jasmine.createSpy('setError');
let setError = jest.fn();
schemaObj.validate(state, setError);
expect(setError).toHaveBeenCalledWith('privileges', 'At least one privilege should be selected.');
});
it('DefaultPrivSchema', ()=>{
spyOn(nodeAjax, 'getNodeListByName').and.returnValue([]);
it('DefaultPrivSchema', async ()=>{
jest.spyOn(nodeAjax, 'getNodeListByName').mockReturnValue([]);
let defPrivObj = new DefaultPrivSchema((privileges)=>getNodePrivilegeRoleSchema({}, {server: {user: {name: 'postgres'}}}, {}, privileges));
let ctrl = mount(getCreateView(defPrivObj));
/* Make sure you hit every corner */
ctrl.find('DataGridView').at(0).find('PgIconButton[data-test="add-row"]').find('button').simulate('click');
let {ctrl, user} = await getCreateView(defPrivObj);
await addNewDatagridRow(user, ctrl);
});
});

View File

@@ -7,13 +7,12 @@
//
//////////////////////////////////////////////////////////////
import '../helper/enzyme.helper';
import { createMount } from '@material-ui/core/test-utils';
import PublicationSchema from '../../../pgadmin/browser/server_groups/servers/databases/publications/static/js/publication.ui';
import {genericBeforeEach, getCreateView, getEditView, getPropertiesView} from '../genericFunctions';
describe('PublicationSchema', ()=>{
let mount;
let schemaObj = new PublicationSchema(
{
allTables: ()=>[],
@@ -33,30 +32,24 @@ describe('PublicationSchema', ()=>{
);
let getInitData = ()=>Promise.resolve({});
/* Use createMount so that material ui components gets the required context */
/* https://material-ui.com/guides/testing/#api */
beforeAll(()=>{
mount = createMount();
});
afterAll(() => {
mount.cleanUp();
});
beforeEach(()=>{
genericBeforeEach();
});
it('create', ()=>{
mount(getCreateView(schemaObj));
it('create', async ()=>{
await getCreateView(schemaObj);
});
it('edit', ()=>{
mount(getEditView(schemaObj, getInitData));
it('edit', async ()=>{
await getEditView(schemaObj, getInitData);
});
it('properties', ()=>{
mount(getPropertiesView(schemaObj, getInitData));
it('properties', async ()=>{
await getPropertiesView(schemaObj, getInitData);
});
it('pubtable disabled', ()=>{
@@ -76,6 +69,6 @@ describe('PublicationSchema', ()=>{
let status = disabled({pubtable: [],all_table: true});
expect(status).toBe(true);
});
});

View File

@@ -7,45 +7,38 @@
//
//////////////////////////////////////////////////////////////
import '../helper/enzyme.helper';
import { createMount } from '@material-ui/core/test-utils';
import ResourceGroupSchema from '../../../pgadmin/browser/server_groups/servers/resource_groups/static/js/resource_group.ui';
import {genericBeforeEach, getCreateView, getEditView, getPropertiesView} from '../genericFunctions';
describe('ResourceGroupSchema', ()=>{
let mount;
let schemaObj = new ResourceGroupSchema();
let getInitData = ()=>Promise.resolve({});
/* Use createMount so that material ui components gets the required context */
/* https://material-ui.com/guides/testing/#api */
beforeAll(()=>{
mount = createMount();
});
afterAll(() => {
mount.cleanUp();
});
beforeEach(()=>{
genericBeforeEach();
});
it('create', ()=>{
mount(getCreateView(schemaObj));
it('create', async ()=>{
await getCreateView(schemaObj);
});
it('edit', ()=>{
mount(getEditView(schemaObj, getInitData));
it('edit', async ()=>{
await getEditView(schemaObj, getInitData);
});
it('properties', ()=>{
mount(getPropertiesView(schemaObj, getInitData));
it('properties', async ()=>{
await getPropertiesView(schemaObj, getInitData);
});
it('validate', ()=>{
let state = {};
let setError = jasmine.createSpy('setError');
let setError = jest.fn();
state.cpu_rate_limit = null;
schemaObj.validate(state, setError);

View File

@@ -7,21 +7,16 @@
//
//////////////////////////////////////////////////////////////
import '../helper/enzyme.helper';
import { createMount } from '@material-ui/core/test-utils';
import pgAdmin from 'sources/pgadmin';
import RestoreSchema, {getRestoreSaveOptSchema, getRestoreDisableOptionSchema, getRestoreMiscellaneousSchema, getRestoreTypeObjSchema, getRestoreSectionSchema} from '../../../pgadmin/tools/restore/static/js/restore.ui';
import {getCreateView} from '../genericFunctions';
describe('RestoreSchema', ()=>{
let mount;
beforeAll(()=>{
mount = createMount();
});
afterAll(() => {
mount.cleanUp();
});
let restoreSchemaObj = new RestoreSchema(
()=>getRestoreSectionSchema({selectedNodeType: 'table'}),
()=>getRestoreTypeObjSchema({selectedNodeType: 'table'}),
@@ -36,13 +31,13 @@ describe('RestoreSchema', ()=>{
pgAdmin.pgBrowser
);
it('restore dialog', ()=>{
mount(getCreateView(restoreSchemaObj));
it('restore dialog', async ()=>{
await getCreateView(restoreSchemaObj);
});
it('restore validate', () => {
let state = { file: undefined }; //validating for empty file
let setError = jasmine.createSpy('setError');
let setError = jest.fn();
restoreSchemaObj.validate(state, setError);
expect(setError).toHaveBeenCalledWith('file', 'Please provide a filename.');

View File

@@ -7,8 +7,7 @@
//
//////////////////////////////////////////////////////////////
import '../helper/enzyme.helper';
import { createMount } from '@material-ui/core/test-utils';
import BaseUISchema from 'sources/SchemaView/base_schema.ui';
import RoleSchema from '../../../pgadmin/browser/server_groups/servers/roles/static/js/role.ui';
import {genericBeforeEach, getCreateView, getEditView, getPropertiesView} from '../genericFunctions';
@@ -20,7 +19,7 @@ class MockSchema extends BaseUISchema {
}
describe('RoleSchema', ()=>{
let mount;
let schemaObj = new RoleSchema(
()=>new MockSchema(),
()=>new MockSchema(),
@@ -31,30 +30,24 @@ describe('RoleSchema', ()=>{
);
let getInitData = ()=>Promise.resolve({});
/* Use createMount so that material ui components gets the required context */
/* https://material-ui.com/guides/testing/#api */
beforeAll(()=>{
mount = createMount();
});
afterAll(() => {
mount.cleanUp();
});
beforeEach(()=>{
genericBeforeEach();
});
it('create', ()=>{
mount(getCreateView(schemaObj));
it('create', async ()=>{
await getCreateView(schemaObj);
});
it('edit', ()=>{
mount(getEditView(schemaObj, getInitData));
it('edit', async ()=>{
await getEditView(schemaObj, getInitData);
});
it('properties', ()=>{
mount(getPropertiesView(schemaObj, getInitData));
it('properties', async ()=>{
await getPropertiesView(schemaObj, getInitData);
});
});

View File

@@ -7,13 +7,12 @@
//
//////////////////////////////////////////////////////////////
import '../helper/enzyme.helper';
import { createMount } from '@material-ui/core/test-utils';
import RowSecurityPolicySchema from '../../../pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/static/js/row_security_policy.ui';
import {genericBeforeEach, getCreateView, getEditView, getPropertiesView} from '../genericFunctions';
describe('RowSecurityPolicySchema', ()=>{
let mount;
let schemaObj = new RowSecurityPolicySchema(
{
role: ()=>[],
@@ -22,30 +21,24 @@ describe('RowSecurityPolicySchema', ()=>{
);
let getInitData = ()=>Promise.resolve({});
/* Use createMount so that material ui components gets the required context */
/* https://material-ui.com/guides/testing/#api */
beforeAll(()=>{
mount = createMount();
});
afterAll(() => {
mount.cleanUp();
});
beforeEach(()=>{
genericBeforeEach();
});
it('create', ()=>{
mount(getCreateView(schemaObj));
it('create', async ()=>{
await getCreateView(schemaObj);
});
it('edit', ()=>{
mount(getEditView(schemaObj, getInitData));
it('edit', async ()=>{
await getEditView(schemaObj, getInitData);
});
it('properties', ()=>{
mount(getPropertiesView(schemaObj, getInitData));
it('properties', async ()=>{
await getPropertiesView(schemaObj, getInitData);
});
});

View File

@@ -7,13 +7,12 @@
//
//////////////////////////////////////////////////////////////
import '../helper/enzyme.helper';
import { createMount } from '@material-ui/core/test-utils';
import RuleSchema from '../../../pgadmin/browser/server_groups/servers/databases/schemas/tables/rules/static/js/rule.ui';
import {genericBeforeEach, getCreateView, getEditView, getPropertiesView} from '../genericFunctions';
describe('RuleSchema', ()=>{
let mount;
let schemaObj = new RuleSchema(
{
nodeInfo: {schema: {label: 'public'}, server: {version: 90400}},
@@ -22,30 +21,24 @@ describe('RuleSchema', ()=>{
);
let getInitData = ()=>Promise.resolve({});
/* Use createMount so that material ui components gets the required context */
/* https://material-ui.com/guides/testing/#api */
beforeAll(()=>{
mount = createMount();
});
afterAll(() => {
mount.cleanUp();
});
beforeEach(()=>{
genericBeforeEach();
});
it('create', ()=>{
mount(getCreateView(schemaObj));
it('create', async ()=>{
await getCreateView(schemaObj);
});
it('edit', ()=>{
mount(getEditView(schemaObj, getInitData));
it('edit', async ()=>{
await getEditView(schemaObj, getInitData);
});
it('properties', ()=>{
mount(getPropertiesView(schemaObj, getInitData));
it('properties', async ()=>{
await getPropertiesView(schemaObj, getInitData);
});
});

View File

@@ -7,14 +7,13 @@
//
//////////////////////////////////////////////////////////////
import '../helper/enzyme.helper';
import { createMount } from '@material-ui/core/test-utils';
import {getNodePrivilegeRoleSchema} from '../../../pgadmin/browser/server_groups/servers/static/js/privilege.ui';
import PGSchema from '../../../pgadmin/browser/server_groups/servers/databases/schemas/static/js/schema.ui';
import {genericBeforeEach, getCreateView, getEditView, getPropertiesView} from '../genericFunctions';
describe('PGSchema', ()=>{
let mount;
let schemaObj = new PGSchema(
()=>getNodePrivilegeRoleSchema({}, {server: {user: {name: 'postgres'}}}, {}),
{
@@ -24,27 +23,21 @@ describe('PGSchema', ()=>{
);
let getInitData = ()=>Promise.resolve({});
/* Use createMount so that material ui components gets the required context */
/* https://material-ui.com/guides/testing/#api */
beforeAll(()=>{
mount = createMount();
});
afterAll(() => {
mount.cleanUp();
});
beforeEach(()=>{
genericBeforeEach();
});
it('create', ()=>{
mount(getCreateView(schemaObj));
it('create', async ()=>{
await getCreateView(schemaObj);
});
it('schema validate', () => {
let state = { name: 'abc' };
let setError = jasmine.createSpy('setError');
let setError = jest.fn();
schemaObj.validate(state, setError);
expect(setError).toHaveBeenCalledWith('namespaceowner', 'Owner cannot be empty.');
@@ -54,12 +47,12 @@ describe('PGSchema', ()=>{
expect(validate).toBe(null);
});
it('edit', ()=>{
mount(getEditView(schemaObj, getInitData));
it('edit', async ()=>{
await getEditView(schemaObj, getInitData);
});
it('properties', ()=>{
mount(getPropertiesView(schemaObj, getInitData));
it('properties', async ()=>{
await getPropertiesView(schemaObj, getInitData);
});
});

View File

@@ -7,8 +7,7 @@
//
//////////////////////////////////////////////////////////////
import '../helper/enzyme.helper';
import { createMount } from '@material-ui/core/test-utils';
import BaseUISchema from 'sources/SchemaView/base_schema.ui';
import SequenceSchema from '../../../pgadmin/browser/server_groups/servers/databases/schemas/sequences/static/js/sequence.ui';
import {genericBeforeEach, getCreateView, getEditView, getPropertiesView} from '../genericFunctions';
@@ -20,7 +19,7 @@ class MockSchema extends BaseUISchema {
}
describe('SequenceSchema', ()=>{
let mount;
let schemaObj = new SequenceSchema(
()=>new MockSchema(),
{
@@ -33,35 +32,29 @@ describe('SequenceSchema', ()=>{
);
let getInitData = ()=>Promise.resolve({});
/* Use createMount so that material ui components gets the required context */
/* https://material-ui.com/guides/testing/#api */
beforeAll(()=>{
mount = createMount();
});
afterAll(() => {
mount.cleanUp();
});
beforeEach(()=>{
genericBeforeEach();
});
it('create', ()=>{
mount(getCreateView(schemaObj));
it('create', async ()=>{
await getCreateView(schemaObj);
});
it('edit', ()=>{
mount(getEditView(schemaObj, getInitData));
it('edit', async ()=>{
await getEditView(schemaObj, getInitData);
});
it('properties', ()=>{
mount(getPropertiesView(schemaObj, getInitData));
it('properties', async ()=>{
await getPropertiesView(schemaObj, getInitData);
});
it('validate', ()=>{
let state = {};
let setError = jasmine.createSpy('setError');
let setError = jest.fn();
state.seqowner = null;
schemaObj.validate(state, setError);

View File

@@ -7,14 +7,13 @@
//
//////////////////////////////////////////////////////////////
import '../helper/enzyme.helper';
import { createMount } from '@material-ui/core/test-utils';
import pgAdmin from 'sources/pgadmin';
import ServerSchema from '../../../pgadmin/browser/server_groups/servers/static/js/server.ui';
import {genericBeforeEach, getCreateView, getEditView, getPropertiesView} from '../genericFunctions';
describe('ServerSchema', ()=>{
let mount;
let schemaObj = new ServerSchema([{
label: 'Servers', value: 1,
}], 0, {
@@ -22,36 +21,26 @@ describe('ServerSchema', ()=>{
});
let getInitData = ()=>Promise.resolve({});
/* Use createMount so that material ui components gets the required context */
/* https://material-ui.com/guides/testing/#api */
beforeAll(()=>{
mount = createMount();
});
afterAll(() => {
mount.cleanUp();
});
beforeEach(()=>{
genericBeforeEach();
pgAdmin.Browser.utils.support_ssh_tunnel = true;
});
it('create', ()=>{
mount(getCreateView(schemaObj));
it('create', async ()=>{
await getCreateView(schemaObj);
});
it('edit', ()=>{
mount(getEditView(schemaObj, getInitData));
it('edit', async ()=>{
await getEditView(schemaObj, getInitData);
});
it('properties', ()=>{
mount(getPropertiesView(schemaObj, getInitData));
it('properties', async ()=>{
await getPropertiesView(schemaObj, getInitData);
});
it('validate', ()=>{
let state = {};
let setError = jasmine.createSpy('setError');
let setError = jest.fn();
schemaObj.validate(state, setError);
expect(setError).toHaveBeenCalledWith('host', 'Either Host name or Service must be specified.');
@@ -84,6 +73,6 @@ describe('ServerSchema', ()=>{
expect(setError).toHaveBeenCalledWith('tunnel_identity_file', 'SSH Tunnel identity file must be specified.');
state.tunnel_identity_file = '/file/path/xyz.pem';
expect(schemaObj.validate(state, setError)).toBeFalse();
expect(schemaObj.validate(state, setError)).toBe(false);
});
});

View File

@@ -7,39 +7,32 @@
//
//////////////////////////////////////////////////////////////
import '../helper/enzyme.helper';
import { createMount } from '@material-ui/core/test-utils';
import ServerGroupSchema from '../../../pgadmin/browser/server_groups/static/js/server_group.ui';
import {genericBeforeEach, getCreateView, getEditView, getPropertiesView} from '../genericFunctions';
describe('ServerGroupSchema', ()=>{
let mount;
let schemaObj = new ServerGroupSchema();
let getInitData = ()=>Promise.resolve({});
/* Use createMount so that material ui components gets the required context */
/* https://material-ui.com/guides/testing/#api */
beforeAll(()=>{
mount = createMount();
});
afterAll(() => {
mount.cleanUp();
});
beforeEach(()=>{
genericBeforeEach();
});
it('create', ()=>{
mount(getCreateView(schemaObj));
it('create', async ()=>{
await getCreateView(schemaObj);
});
it('edit', ()=>{
mount(getEditView(schemaObj, getInitData));
it('edit', async ()=>{
await getEditView(schemaObj, getInitData);
});
it('properties', ()=>{
mount(getPropertiesView(schemaObj, getInitData));
it('properties', async ()=>{
await getPropertiesView(schemaObj, getInitData);
});
});

View File

@@ -7,13 +7,12 @@
//
//////////////////////////////////////////////////////////////
import '../helper/enzyme.helper';
import { createMount } from '@material-ui/core/test-utils';
import SubscriptionSchema from '../../../pgadmin/browser/server_groups/servers/databases/subscriptions/static/js/subscription.ui';
import {genericBeforeEach, getCreateView, getEditView, getPropertiesView} from '../genericFunctions';
describe('SubscriptionSchema', ()=>{
let mount;
let schemaObj = new SubscriptionSchema(
{
getPublication: ()=>[],
@@ -35,30 +34,24 @@ describe('SubscriptionSchema', ()=>{
);
let getInitData = ()=>Promise.resolve({});
/* Use createMount so that material ui components gets the required context */
/* https://material-ui.com/guides/testing/#api */
beforeAll(()=>{
mount = createMount();
});
afterAll(() => {
mount.cleanUp();
});
beforeEach(()=>{
genericBeforeEach();
});
it('create', ()=>{
mount(getCreateView(schemaObj));
it('create', async ()=>{
await getCreateView(schemaObj);
});
it('edit', ()=>{
mount(getEditView(schemaObj, getInitData));
it('edit', async ()=>{
await getEditView(schemaObj, getInitData);
});
it('properties', ()=>{
mount(getPropertiesView(schemaObj, getInitData));
it('properties', async ()=>{
await getPropertiesView(schemaObj, getInitData);
});
@@ -76,7 +69,7 @@ describe('SubscriptionSchema', ()=>{
it('validate', ()=>{
let state = {};
let setError = jasmine.createSpy('setError');
let setError = jest.fn();
state.host = null;
schemaObj.validate(state, setError);
@@ -113,7 +106,7 @@ describe('SubscriptionSchema', ()=>{
expect(setError).toHaveBeenCalledWith('tunnel_identity_file', 'SSH Tunnel identity file must be specified.');
state.tunnel_identity_file = '/file/path/xyz.pem';
expect(schemaObj.validate(state, setError)).toBeFalse();
expect(schemaObj.validate(state, setError)).toBe(false);
});
});

View File

@@ -7,13 +7,12 @@
//
//////////////////////////////////////////////////////////////
import '../helper/enzyme.helper';
import { createMount } from '@material-ui/core/test-utils';
import SynonymSchema from '../../../pgadmin/browser/server_groups/servers/databases/schemas/synonyms/static/js/synonym.ui';
import {genericBeforeEach, getCreateView, getEditView, getPropertiesView} from '../genericFunctions';
describe('SynonymSchema', ()=>{
let mount;
let schemaObj = new SynonymSchema(
{
role: ()=>[],
@@ -30,35 +29,29 @@ describe('SynonymSchema', ()=>{
);
let getInitData = ()=>Promise.resolve({});
/* Use createMount so that material ui components gets the required context */
/* https://material-ui.com/guides/testing/#api */
beforeAll(()=>{
mount = createMount();
});
afterAll(() => {
mount.cleanUp();
});
beforeEach(()=>{
genericBeforeEach();
});
it('create', ()=>{
mount(getCreateView(schemaObj));
it('create', async ()=>{
await getCreateView(schemaObj);
});
it('edit', ()=>{
mount(getEditView(schemaObj, getInitData));
it('edit', async ()=>{
await getEditView(schemaObj, getInitData);
});
it('properties', ()=>{
mount(getPropertiesView(schemaObj, getInitData));
it('properties', async ()=>{
await getPropertiesView(schemaObj, getInitData);
});
it('validate', ()=>{
let state = {};
let setError = jasmine.createSpy('setError');
let setError = jest.fn();
state.name = null;
schemaObj.validate(state, setError);

View File

@@ -7,30 +7,26 @@
//
//////////////////////////////////////////////////////////////
import '../helper/enzyme.helper';
import { createMount } from '@material-ui/core/test-utils';
import { SCHEMA_STATE_ACTIONS } from '../../../pgadmin/static/js/SchemaView';
import _ from 'lodash';
import { getNodeTableSchema, LikeSchema } from '../../../pgadmin/browser/server_groups/servers/databases/schemas/tables/static/js/table.ui';
import * as nodeAjax from '../../../pgadmin/browser/static/js/node_ajax';
import Notify from '../../../pgadmin/static/js/helpers/Notifier';
import {genericBeforeEach, getCreateView, getEditView, getPropertiesView} from '../genericFunctions';
import pgAdmin from '../fake_pgadmin';
function getFieldDepChange(schema, id) {
return _.find(schema.fields, (f)=>f.id==id)?.depChange;
}
describe('TableSchema', ()=>{
let mount;
let schemaObj;
let getInitData = ()=>Promise.resolve({});
/* Use createMount so that material ui components gets the required context */
/* https://material-ui.com/guides/testing/#api */
beforeAll(()=>{
mount = createMount();
spyOn(nodeAjax, 'getNodeAjaxOptions').and.returnValue(Promise.resolve([]));
spyOn(nodeAjax, 'getNodeListByName').and.returnValue(Promise.resolve([]));
jest.spyOn(nodeAjax, 'getNodeAjaxOptions').mockReturnValue(Promise.resolve([]));
jest.spyOn(nodeAjax, 'getNodeListByName').mockReturnValue(Promise.resolve([]));
schemaObj = getNodeTableSchema({
server: {
_id: 1,
@@ -50,24 +46,22 @@ describe('TableSchema', ()=>{
});
});
afterAll(() => {
mount.cleanUp();
});
beforeEach(()=>{
genericBeforeEach();
});
it('create', ()=>{
mount(getCreateView(schemaObj));
it('create', async ()=>{
await getCreateView(schemaObj);
});
it('edit', ()=>{
mount(getEditView(schemaObj, getInitData));
it('edit', async ()=>{
await getEditView(schemaObj, getInitData);
});
it('properties', ()=>{
mount(getPropertiesView(schemaObj, getInitData));
it('properties', async ()=>{
await getPropertiesView(schemaObj, getInitData);
});
it('getTableOid', ()=>{
@@ -109,9 +103,9 @@ describe('TableSchema', ()=>{
{name: 'id'}
];
beforeEach(()=>{
spyOn(schemaObj,'changeColumnOptions').and.callThrough();
spyOn(schemaObj, 'getTableOid').and.returnValue(140391);
confirmSpy = spyOn(Notify, 'confirm').and.callThrough();
jest.spyOn(schemaObj, 'changeColumnOptions');
jest.spyOn(schemaObj, 'getTableOid').mockReturnValue(140391);
confirmSpy = jest.spyOn(pgAdmin.Browser.notifier, 'confirm');
deferredDepChange = _.find(schemaObj.fields, (f)=>f.id=='typname')?.deferredDepChange;
schemaObj.ofTypeTables = [
{label: 'type1', oftype_columns: oftypeColumns}
@@ -143,10 +137,11 @@ describe('TableSchema', ()=>{
onDepChangeAction(depChange, done);
});
/* Press OK */
confirmSpy.calls.argsFor(0)[2]();
confirmSpy.mock.calls[0][2]();
});
it('initial selection with Cancel', (done)=>{
confirmSpy.mockClear();
let state = {typname: 'type1'};
let deferredPromise = deferredDepChange(state, null, null, {
oldState: {
@@ -160,7 +155,7 @@ describe('TableSchema', ()=>{
done();
});
/* Press Cancel */
confirmSpy.calls.argsFor(0)[3]();
confirmSpy.mock.calls[0][3]();
});
it('later selection', (done)=>{
@@ -203,9 +198,9 @@ describe('TableSchema', ()=>{
};
beforeEach(()=>{
spyOn(schemaObj,'changeColumnOptions').and.callThrough();
spyOn(schemaObj, 'getTableOid').and.returnValue(140391);
spyOn(schemaObj, 'getColumns').and.returnValue(Promise.resolve([inheritCol]));
jest.spyOn(schemaObj, 'changeColumnOptions');
jest.spyOn(schemaObj, 'getTableOid').mockReturnValue(140391);
jest.spyOn(schemaObj, 'getColumns').mockReturnValue(Promise.resolve([inheritCol]));
deferredDepChange = _.find(schemaObj.fields, (f)=>f.id=='coll_inherits')?.deferredDepChange;
});
@@ -277,7 +272,7 @@ describe('TableSchema', ()=>{
});
it('depChange', ()=>{
spyOn(schemaObj, 'getTableOid').and.returnValue(140391);
jest.spyOn(schemaObj, 'getTableOid').mockReturnValue(140391);
let state = {};
state.is_partitioned = true;
@@ -289,7 +284,7 @@ describe('TableSchema', ()=>{
coll_inherits: [],
});
spyOn(schemaObj, 'getServerVersion').and.returnValue(100000);
jest.spyOn(schemaObj, 'getServerVersion').mockReturnValue(100000);
schemaObj.constraintsObj.top = schemaObj;
expect(getFieldDepChange(schemaObj.constraintsObj, 'primary_key')({is_partitioned: true})).toEqual({
primary_key: []
@@ -307,7 +302,7 @@ describe('TableSchema', ()=>{
it('validate', ()=>{
let state = {is_partitioned: true};
let setError = jasmine.createSpy('setError');
let setError = jest.fn();
schemaObj.validate(state, setError);
expect(setError).toHaveBeenCalledWith('partition_keys', 'Please specify at least one key for partitioned table.');

View File

@@ -7,8 +7,7 @@
//
//////////////////////////////////////////////////////////////
import '../helper/enzyme.helper';
import { createMount } from '@material-ui/core/test-utils';
import BaseUISchema from 'sources/SchemaView/base_schema.ui';
import TablespaceSchema from '../../../pgadmin/browser/server_groups/servers/tablespaces/static/js/tablespace.ui';
import {genericBeforeEach, getCreateView, getEditView, getPropertiesView} from '../genericFunctions';
@@ -20,7 +19,7 @@ class MockSchema extends BaseUISchema {
}
describe('TablespaceSchema', ()=>{
let mount;
let schemaObj = new TablespaceSchema(
()=>new MockSchema(),
()=>new MockSchema(),
@@ -33,30 +32,24 @@ describe('TablespaceSchema', ()=>{
);
let getInitData = ()=>Promise.resolve({});
/* Use createMount so that material ui components gets the required context */
/* https://material-ui.com/guides/testing/#api */
beforeAll(()=>{
mount = createMount();
});
afterAll(() => {
mount.cleanUp();
});
beforeEach(()=>{
genericBeforeEach();
});
it('create', ()=>{
mount(getCreateView(schemaObj));
it('create', async ()=>{
await getCreateView(schemaObj);
});
it('edit', ()=>{
mount(getEditView(schemaObj, getInitData));
it('edit', async ()=>{
await getEditView(schemaObj, getInitData);
});
it('properties', ()=>{
mount(getPropertiesView(schemaObj, getInitData));
it('properties', async ()=>{
await getPropertiesView(schemaObj, getInitData);
});
});

View File

@@ -7,13 +7,12 @@
//
//////////////////////////////////////////////////////////////
import '../helper/enzyme.helper';
import { createMount } from '@material-ui/core/test-utils';
import TriggerSchema, { EventSchema } from '../../../pgadmin/browser/server_groups/servers/databases/schemas/tables/triggers/static/js/trigger.ui';
import {genericBeforeEach, getCreateView, getEditView, getPropertiesView} from '../genericFunctions';
describe('TriggerSchema', ()=>{
let mount;
let schemaObj = new TriggerSchema(
{
triggerFunction: [],
@@ -27,35 +26,29 @@ describe('TriggerSchema', ()=>{
);
let getInitData = ()=>Promise.resolve({});
/* Use createMount so that material ui components gets the required context */
/* https://material-ui.com/guides/testing/#api */
beforeAll(()=>{
mount = createMount();
});
afterAll(() => {
mount.cleanUp();
});
beforeEach(()=>{
genericBeforeEach();
});
it('create', ()=>{
mount(getCreateView(schemaObj));
it('create', async ()=>{
await getCreateView(schemaObj);
});
it('edit', ()=>{
mount(getEditView(schemaObj, getInitData));
it('edit', async ()=>{
await getEditView(schemaObj, getInitData);
});
it('properties', ()=>{
mount(getPropertiesView(schemaObj, getInitData));
it('properties', async ()=>{
await getPropertiesView(schemaObj, getInitData);
});
it('validate', ()=>{
let state = {};
let setError = jasmine.createSpy('setError');
let setError = jest.fn();
state.tfunction = null;
schemaObj.validate(state, setError);
@@ -79,7 +72,7 @@ describe('TriggerSchema', ()=>{
}
);
mount(getCreateView(catalogSchemaObj));
getCreateView(catalogSchemaObj);
});
it('catalog properties', ()=>{
@@ -95,7 +88,7 @@ describe('TriggerSchema', ()=>{
}
);
mount(getPropertiesView(catalogPropertiesSchemaObj, getInitData));
getPropertiesView(catalogPropertiesSchemaObj, getInitData);
});
it('edit disableTransition', ()=>{
@@ -121,7 +114,7 @@ describe('TriggerSchema', ()=>{
fires: 'AFTER'
});
mount(getEditView(editSchemaObj, initData));
getEditView(editSchemaObj, initData);
});
it('edit disableTransition tgnewtable', ()=>{
@@ -147,14 +140,14 @@ describe('TriggerSchema', ()=>{
fires: 'AFTER'
});
mount(getEditView(editSchemaObj, initData));
getEditView(editSchemaObj, initData);
});
});
describe('TriggerEventsSchema', ()=>{
let mount;
let schemaObj = new EventSchema(
{
nodeInfo: {
@@ -165,35 +158,29 @@ describe('TriggerEventsSchema', ()=>{
);
let getInitData = ()=>Promise.resolve({});
/* Use createMount so that material ui components gets the required context */
/* https://material-ui.com/guides/testing/#api */
beforeAll(()=>{
mount = createMount();
});
afterAll(() => {
mount.cleanUp();
});
beforeEach(()=>{
genericBeforeEach();
});
it('create', ()=>{
mount(getCreateView(schemaObj));
it('create', async ()=>{
await getCreateView(schemaObj);
});
it('properties', ()=>{
mount(getPropertiesView(schemaObj, getInitData));
it('properties', async ()=>{
await getPropertiesView(schemaObj, getInitData);
});
it('edit', ()=>{
mount(getEditView(schemaObj, getInitData));
it('edit', async ()=>{
await getEditView(schemaObj, getInitData);
});
it('validate', ()=>{
let state = {};
let setError = jasmine.createSpy('setError');
let setError = jest.fn();
state.tfunction = 'public';

View File

@@ -7,8 +7,7 @@
//
//////////////////////////////////////////////////////////////
import '../helper/enzyme.helper';
import { createMount } from '@material-ui/core/test-utils';
import BaseUISchema from 'sources/SchemaView/base_schema.ui';
import TriggerFunctionSchema from '../../../pgadmin/browser/server_groups/servers/databases/schemas/functions/static/js/trigger_function.ui';
import {genericBeforeEach, getCreateView, getEditView, getPropertiesView} from '../genericFunctions';
@@ -20,7 +19,7 @@ class MockSchema extends BaseUISchema {
}
describe('TriggerFunctionSchema', ()=>{
let mount;
let schemaObj = new TriggerFunctionSchema(
()=>new MockSchema(),
()=>new MockSchema(),
@@ -37,35 +36,29 @@ describe('TriggerFunctionSchema', ()=>{
);
let getInitData = ()=>Promise.resolve({});
/* Use createMount so that material ui components gets the required context */
/* https://material-ui.com/guides/testing/#api */
beforeAll(()=>{
mount = createMount();
});
afterAll(() => {
mount.cleanUp();
});
beforeEach(()=>{
genericBeforeEach();
});
it('create', ()=>{
mount(getCreateView(schemaObj));
it('create', async ()=>{
await getCreateView(schemaObj);
});
it('edit', ()=>{
mount(getEditView(schemaObj, getInitData));
it('edit', async ()=>{
await getEditView(schemaObj, getInitData);
});
it('properties', ()=>{
mount(getPropertiesView(schemaObj, getInitData));
it('properties', async ()=>{
await getPropertiesView(schemaObj, getInitData);
});
it('validate', ()=>{
let state = {};
let setError = jasmine.createSpy('setError');
let setError = jest.fn();
state.prosrc = null;
schemaObj.validate(state, setError);

View File

@@ -7,28 +7,15 @@
//
//////////////////////////////////////////////////////////////
import '../helper/enzyme.helper';
import { createMount } from '@material-ui/core/test-utils';
import * as nodeAjax from '../../../pgadmin/browser/static/js/node_ajax';
import { getNodePrivilegeRoleSchema } from '../../../pgadmin/browser/server_groups/servers/static/js/privilege.ui';
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';
describe('TypeSchema', ()=>{
let mount;
let getInitData = ()=>Promise.resolve({});
/* Use createMount so that material ui components gets the required context */
/* https://material-ui.com/guides/testing/#api */
beforeAll(()=>{
mount = createMount();
});
afterAll(() => {
mount.cleanUp();
});
beforeEach(()=>{
genericBeforeEach();
});
@@ -39,21 +26,17 @@ describe('TypeSchema', ()=>{
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', ()=>{
spyOn(nodeAjax, 'getNodeAjaxOptions').and.returnValue([]);
spyOn(compositeCollObj.fieldOptions, 'types').and.returnValue(types);
spyOn(compositeCollObj.fieldOptions, 'collations').and.returnValue(collations);
spyOn(compositeCollObj, 'type_options').and.returnValue(compositeCollObj.fieldOptions.types());
mount(getCreateView(compositeCollObj));
mount(getEditView(compositeCollObj, getInitData));
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);
});
it('composite validate', () => {
let state = { typtype: 'b' }; //validating for ExternalSchema which is distinguish as r
let setError = jasmine.createSpy('setError');
let setError = jest.fn();
compositeCollObj.top = {
'sessData': { 'typtype':'c' }
};
@@ -94,15 +77,15 @@ describe('TypeSchema', ()=>{
describe('enumeration schema describe', () => {
it('enumeration collection', ()=>{
it('enumeration collection', async ()=>{
let enumerationCollObj = new EnumerationSchema(
()=>[],
()=>[]
);
mount(getCreateView(enumerationCollObj));
mount(getEditView(enumerationCollObj, getInitData));
await getCreateView(enumerationCollObj);
await getEditView(enumerationCollObj, getInitData);
});
});
@@ -110,19 +93,19 @@ describe('TypeSchema', ()=>{
let externalCollObj = getExternalSchema({}, {server: {user: {name: 'postgres'}}}, {});
it('external collection', ()=>{
it('external collection', async ()=>{
spyOn(nodeAjax, 'getNodeAjaxOptions').and.returnValue([]);
spyOn(externalCollObj.fieldOptions, 'externalFunctionsList').and.returnValue([{ label: '', value: ''}, { label: 'lb1', cbtype: 'typmodin', value: 'val1'}, { label: 'lb2', cbtype: 'all', value: 'val2'}]);
spyOn(externalCollObj.fieldOptions, 'types').and.returnValue([{ label: '', value: ''}]);
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: ''}]);
mount(getCreateView(externalCollObj));
mount(getEditView(externalCollObj, getInitData));
await getCreateView(externalCollObj);
await getEditView(externalCollObj, getInitData);
});
it('external validate', () => {
let state = { typtype: 'b' }; //validating for ExternalSchema which is distinguish as r
let setError = jasmine.createSpy('setError');
let setError = jest.fn();
externalCollObj.validate(state, setError);
expect(setError).toHaveBeenCalledWith('typinput', 'Input function cannot be empty');
@@ -137,22 +120,22 @@ describe('TypeSchema', ()=>{
let rangeCollObj = getRangeSchema({}, {server: {user: {name: 'postgres'}}}, {});
it('range collection', ()=>{
it('range collection', async ()=>{
spyOn(nodeAjax, 'getNodeAjaxOptions').and.returnValue([]);
spyOn(rangeCollObj.fieldOptions, 'getSubOpClass').and.returnValue([{ label: '', value: ''}, { label: 'lb1', value: 'val1'}]);
spyOn(rangeCollObj.fieldOptions, 'getCanonicalFunctions').and.returnValue([{ label: '', value: ''}, { label: 'lb1', value: 'val1'}]);
spyOn(rangeCollObj.fieldOptions, 'getSubDiffFunctions').and.returnValue([{ label: '', value: ''}, { label: 'lb1', value: 'val1'}]);
spyOn(rangeCollObj.fieldOptions, 'typnameList').and.returnValue([{ label: '', value: ''}, { label: 'lb1', value: 'val1'}]);
spyOn(rangeCollObj.fieldOptions, 'collationsList').and.returnValue([{ label: '', value: ''}, { label: 'lb1', value: 'val1'}]);
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'}]);
mount(getCreateView(rangeCollObj));
mount(getEditView(rangeCollObj, getInitData));
await getCreateView(rangeCollObj);
await getEditView(rangeCollObj, getInitData);
});
it('range validate', () => {
let state = { typtype: 'r' }; //validating for RangeSchema which is distinguish as r
let setError = jasmine.createSpy('setError');
let setError = jest.fn();
rangeCollObj.validate(state, setError);
expect(setError).toHaveBeenCalledWith('typname', 'Subtype cannot be empty');
@@ -164,11 +147,11 @@ describe('TypeSchema', ()=>{
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}];
it('data type collection', ()=>{
it('data type collection', async ()=>{
spyOn(nodeAjax, 'getNodeAjaxOptions').and.returnValue([]);
mount(getCreateView(dataTypeObj));
mount(getEditView(dataTypeObj, getInitData));
jest.spyOn(nodeAjax, 'getNodeAjaxOptions').mockReturnValue([]);
await getCreateView(dataTypeObj);
await getEditView(dataTypeObj, getInitData);
});
it('tlength editable', ()=>{
@@ -219,15 +202,15 @@ describe('TypeSchema', ()=>{
}
);
it('create', ()=>{
mount(getCreateView(typeSchemaObj));
it('create', async ()=>{
await getCreateView(typeSchemaObj);
});
it('edit', ()=>{
mount(getEditView(typeSchemaObj, getInitData));
it('edit', async ()=>{
await getEditView(typeSchemaObj, getInitData);
});
it('properties', ()=>{
mount(getPropertiesView(typeSchemaObj, getInitData));
it('properties', async ()=>{
await getPropertiesView(typeSchemaObj, getInitData);
});
});

View File

@@ -7,14 +7,13 @@
//
//////////////////////////////////////////////////////////////
import '../helper/enzyme.helper';
import { createMount } from '@material-ui/core/test-utils';
import { SCHEMA_STATE_ACTIONS } from '../../../pgadmin/static/js/SchemaView';
import BaseUISchema from '../../../pgadmin/static/js/SchemaView/base_schema.ui';
import _ from 'lodash';
import UniqueConstraintSchema from '../../../pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/static/js/unique_constraint.ui';
import TableSchema from '../../../pgadmin/browser/server_groups/servers/databases/schemas/tables/static/js/table.ui';
import {genericBeforeEach, getCreateView, getEditView, getPropertiesView} from '../genericFunctions';
import {addNewDatagridRow, genericBeforeEach, getCreateView, getEditView, getPropertiesView} from '../genericFunctions';
class SchemaInColl extends BaseUISchema {
constructor(schemaObj) {
@@ -38,44 +37,40 @@ function getFieldDepChange(schema, id) {
}
describe('UniqueConstraintSchema', ()=>{
let mount;
let schemaObj;
let getInitData = ()=>Promise.resolve({});
/* Use createMount so that material ui components gets the required context */
/* https://material-ui.com/guides/testing/#api */
beforeAll(()=>{
mount = createMount();
schemaObj = new UniqueConstraintSchema({
spcname: ()=>Promise.resolve([]),
}, {});
});
afterAll(() => {
mount.cleanUp();
});
beforeEach(()=>{
genericBeforeEach();
});
it('create', ()=>{
mount(getCreateView(schemaObj));
it('create', async ()=>{
await getCreateView(schemaObj);
});
it('edit', ()=>{
mount(getEditView(schemaObj, getInitData));
it('edit', async ()=>{
await getEditView(schemaObj, getInitData);
});
it('properties', ()=>{
mount(getPropertiesView(schemaObj, getInitData));
it('properties', async ()=>{
await getPropertiesView(schemaObj, getInitData);
});
it('create collection', ()=>{
it('create collection', async ()=>{
let schemaCollObj = new SchemaInColl(schemaObj);
let ctrl = mount(getCreateView(schemaCollObj));
const {ctrl, user} = await getCreateView(schemaCollObj);
/* Make sure you hit every corner */
ctrl.find('DataGridView').at(0).find('PgIconButton[data-test="add-row"]').find('button').simulate('click');
await addNewDatagridRow(user, ctrl);
});
it('depChange', ()=>{
@@ -146,7 +141,7 @@ describe('UniqueConstraintSchema', ()=>{
it('validate', ()=>{
let state = {};
let setError = jasmine.createSpy('setError');
let setError = jest.fn();
schemaObj.validate(state, setError);
expect(setError).toHaveBeenCalledWith('columns', 'Please specify columns for Unique constraint.');

View File

@@ -7,8 +7,7 @@
//
//////////////////////////////////////////////////////////////
import '../helper/enzyme.helper';
import { createMount } from '@material-ui/core/test-utils';
import BaseUISchema from 'sources/SchemaView/base_schema.ui';
import UserMappingSchema from '../../../pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/user_mappings/static/js/user_mapping.ui';
import {genericBeforeEach, getCreateView, getEditView, getPropertiesView} from '../genericFunctions';
@@ -20,7 +19,7 @@ class MockSchema extends BaseUISchema {
}
describe('UserMappingSchema', ()=>{
let mount;
let schemaObj = new UserMappingSchema(
()=>new MockSchema(),
{
@@ -32,30 +31,24 @@ describe('UserMappingSchema', ()=>{
);
let getInitData = ()=>Promise.resolve({});
/* Use createMount so that material ui components gets the required context */
/* https://material-ui.com/guides/testing/#api */
beforeAll(()=>{
mount = createMount();
});
afterAll(() => {
mount.cleanUp();
});
beforeEach(()=>{
genericBeforeEach();
});
it('create', ()=>{
mount(getCreateView(schemaObj));
it('create', async ()=>{
await getCreateView(schemaObj);
});
it('edit', ()=>{
mount(getEditView(schemaObj, getInitData));
it('edit', async ()=>{
await getEditView(schemaObj, getInitData);
});
it('properties', ()=>{
mount(getPropertiesView(schemaObj, getInitData));
it('properties', async ()=>{
await getPropertiesView(schemaObj, getInitData);
});
});

View File

@@ -7,12 +7,11 @@
//
//////////////////////////////////////////////////////////////
import '../helper/enzyme.helper';
import { createMount } from '@material-ui/core/test-utils';
import BaseUISchema from 'sources/SchemaView/base_schema.ui';
import VariableSchema, {getNodeVariableSchema} from '../../../pgadmin/browser/server_groups/servers/static/js/variable.ui';
import * as nodeAjax from '../../../pgadmin/browser/static/js/node_ajax';
import {genericBeforeEach, getCreateView, getEditView, getPropertiesView} from '../genericFunctions';
import {addNewDatagridRow, genericBeforeEach, getCreateView, getEditView, getPropertiesView} from '../genericFunctions';
/* Used to check collection mode */
class MockSchema extends BaseUISchema {
@@ -34,7 +33,7 @@ class MockSchema extends BaseUISchema {
}
describe('VariableSchema', ()=>{
let mount;
let schemaObj = new VariableSchema(
()=>[],
()=>[],
@@ -43,58 +42,53 @@ describe('VariableSchema', ()=>{
);
let getInitData = ()=>Promise.resolve({});
/* Use createMount so that material ui components gets the required context */
/* https://material-ui.com/guides/testing/#api */
beforeAll(()=>{
mount = createMount();
});
afterAll(() => {
mount.cleanUp();
});
beforeEach(()=>{
genericBeforeEach();
});
it('create', ()=>{
mount(getCreateView(schemaObj));
it('create', async ()=>{
await getCreateView(schemaObj);
});
it('edit', ()=>{
mount(getEditView(schemaObj, getInitData));
it('edit', async ()=>{
await getEditView(schemaObj, getInitData);
});
it('properties', ()=>{
mount(getPropertiesView(schemaObj, getInitData));
it('properties', async ()=>{
await getPropertiesView(schemaObj, getInitData);
});
it('getValueFieldProps', ()=>{
expect(schemaObj.getValueFieldProps({vartype: 'bool'})).toBe('switch');
expect(schemaObj.getValueFieldProps({vartype: 'enum', enumvals: []})).toEqual(jasmine.objectContaining({
expect(schemaObj.getValueFieldProps({vartype: 'enum', enumvals: []})).toEqual(expect.objectContaining({
cell: 'select',
}));
expect(schemaObj.getValueFieldProps({vartype: 'integer'})).toEqual(jasmine.objectContaining({
expect(schemaObj.getValueFieldProps({vartype: 'integer'})).toEqual(expect.objectContaining({
cell: 'int',
}));
expect(schemaObj.getValueFieldProps({vartype: 'real'})).toEqual(jasmine.objectContaining({
expect(schemaObj.getValueFieldProps({vartype: 'real'})).toEqual(expect.objectContaining({
cell: 'numeric',
}));
expect(schemaObj.getValueFieldProps({vartype: 'string'})).toEqual(jasmine.objectContaining({
expect(schemaObj.getValueFieldProps({vartype: 'string'})).toEqual(expect.objectContaining({
cell: 'text',
}));
expect(schemaObj.getValueFieldProps({vartype: 'file'})).toEqual(jasmine.objectContaining({
expect(schemaObj.getValueFieldProps({vartype: 'file'})).toEqual(expect.objectContaining({
cell: 'file',
}));
expect(schemaObj.getValueFieldProps({})).toBe('');
});
it('variable collection', ()=>{
spyOn(nodeAjax, 'getNodeAjaxOptions').and.returnValue([]);
spyOn(nodeAjax, 'getNodeListByName').and.returnValue([]);
it('variable collection', async ()=>{
jest.spyOn(nodeAjax, 'getNodeAjaxOptions').mockReturnValue([]);
jest.spyOn(nodeAjax, 'getNodeListByName').mockReturnValue([]);
let varCollObj = new MockSchema(()=>getNodeVariableSchema({}, {server: {user: {name: 'postgres'}}}, {}, true, true));
let ctrl = mount(getCreateView(varCollObj));
const {ctrl, user} = await getCreateView(varCollObj);
/* Make sure you hit every corner */
ctrl.find('DataGridView').at(0).find('PgIconButton[data-test="add-row"]').find('button').simulate('click');
await addNewDatagridRow(user, ctrl);
});
});

View File

@@ -7,8 +7,7 @@
//
//////////////////////////////////////////////////////////////
import '../helper/enzyme.helper';
import { createMount } from '@material-ui/core/test-utils';
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';
@@ -20,7 +19,7 @@ class MockSchema extends BaseUISchema {
}
describe('ViewSchema', ()=>{
let mount;
let schemaObj = new ViewSchema(
()=>new MockSchema(),
{server: {server_type: 'pg'}},
@@ -35,35 +34,29 @@ describe('ViewSchema', ()=>{
);
let getInitData = ()=>Promise.resolve({});
/* Use createMount so that material ui components gets the required context */
/* https://material-ui.com/guides/testing/#api */
beforeAll(()=>{
mount = createMount();
});
afterAll(() => {
mount.cleanUp();
});
beforeEach(()=>{
genericBeforeEach();
});
it('create', ()=>{
mount(getCreateView(schemaObj));
it('create', async ()=>{
await getCreateView(schemaObj);
});
it('edit', ()=>{
mount(getEditView(schemaObj, getInitData));
it('edit', async ()=>{
await getEditView(schemaObj, getInitData);
});
it('properties', ()=>{
mount(getPropertiesView(schemaObj, getInitData));
it('properties', async ()=>{
await getPropertiesView(schemaObj, getInitData);
});
it('validate', ()=>{
let state = {};
let setError = jasmine.createSpy('setError');
let setError = jest.fn();
state.definition = null;
schemaObj.validate(state, setError);