Fixed jasmine test cases introduced by the theme patch.

This commit is contained in:
Aditya Toshniwal 2022-07-01 15:01:51 +05:30 committed by Akshay Joshi
parent ed59584fe4
commit 9c45a62b53
9 changed files with 261 additions and 220 deletions

View File

@ -10,6 +10,7 @@
import React from 'react';
import ReactDOM from 'react-dom';
import SchemaView from '../../../../../../static/js/SchemaView';
import Theme from '../../../../../../static/js/Theme';
export default class DialogWrapper {
constructor(dialogContainerSelector, dialogTitle, typeOfDialog, alertify, serverInfo) {
@ -84,22 +85,24 @@ export default class DialogWrapper {
createDialog(container) {
let self = this;
ReactDOM.render(
<SchemaView
formType={'dialog'}
getInitData={()=>Promise.resolve({})}
schema={this.dialogSchema}
viewHelperProps={{
mode: 'create',
keepCid: true,
serverInfo: this.serverInfo,
}}
onSave={this.onSaveClick.bind(this)}
onClose={()=>self.close()}
onDataChange={()=>{/*This is intentional (SonarQube)*/}}
hasSQL={false}
disableSqlHelp={true}
disableDialogHelp={true}
/>, container);
<Theme>
<SchemaView
formType={'dialog'}
getInitData={()=>Promise.resolve({})}
schema={this.dialogSchema}
viewHelperProps={{
mode: 'create',
keepCid: true,
serverInfo: this.serverInfo,
}}
onSave={this.onSaveClick.bind(this)}
onClose={()=>self.close()}
onDataChange={()=>{/*This is intentional (SonarQube)*/}}
hasSQL={false}
disableSqlHelp={true}
disableDialogHelp={true}
/>
</Theme>, container);
}
cleanupDialog(container) {

View File

@ -17,6 +17,7 @@ import {messages} from '../fake_messages';
import SchemaView from '../../../pgadmin/static/js/SchemaView';
import * as legacyConnector from 'sources/helpers/legacyConnector';
import Notify from '../../../pgadmin/static/js/helpers/Notifier';
import Theme from '../../../pgadmin/static/js/Theme';
const initData = {
id: 1,
@ -83,23 +84,25 @@ describe('SchemaView', ()=>{
getSQLValue=jasmine.createSpy('onEdit').and.returnValue(Promise.resolve('select 1;')),
ctrlMount = (props)=>{
ctrl?.unmount();
ctrl = mount(<SchemaView
formType='dialog'
schema={getSchema()}
viewHelperProps={{
mode: 'create',
}}
onSave={onSave}
onClose={onClose}
onHelp={onHelp}
onEdit={onEdit}
onDataChange={onDataChange}
confirmOnCloseReset={true}
hasSQL={true}
getSQLValue={getSQLValue}
disableSqlHelp={false}
{...props}
/>);
ctrl = mount(<Theme>
<SchemaView
formType='dialog'
schema={getSchema()}
viewHelperProps={{
mode: 'create',
}}
onSave={onSave}
onClose={onClose}
onHelp={onHelp}
onEdit={onEdit}
onDataChange={onDataChange}
confirmOnCloseReset={true}
hasSQL={true}
getSQLValue={getSQLValue}
disableSqlHelp={false}
{...props}
/>
</Theme>);
},
simulateValidData = ()=>{
ctrl.find('MappedFormControl[id="field1"]').find('input').simulate('change', {target: {value: 'val1'}});
@ -473,22 +476,24 @@ describe('SchemaView', ()=>{
let ctrl;
beforeEach(()=>{
ctrl?.unmount();
ctrl = mount(<SchemaView
formType='dialog'
schema={getSchemaAllTypes()}
viewHelperProps={{
mode: 'create',
}}
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={true}
getSQLValue={()=>'select 1;'}
disableSqlHelp={false}
/>);
ctrl = mount(<Theme>
<SchemaView
formType='dialog'
schema={getSchemaAllTypes()}
viewHelperProps={{
mode: 'create',
}}
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={true}
getSQLValue={()=>'select 1;'}
disableSqlHelp={false}
/>
</Theme>);
});
it('init', ()=>{
@ -506,17 +511,19 @@ describe('SchemaView', ()=>{
ctrl = null;
beforeEach(()=>{
ctrl = mount(<SchemaView
formType='tab'
schema={getSchema()}
getInitData={getInitData}
viewHelperProps={{
mode: 'properties',
}}
onHelp={onHelp}
disableSqlHelp={false}
onEdit={onEdit}
/>);
ctrl = mount(<Theme>
<SchemaView
formType='tab'
schema={getSchema()}
getInitData={getInitData}
viewHelperProps={{
mode: 'properties',
}}
onHelp={onHelp}
disableSqlHelp={false}
onEdit={onEdit}
/>
</Theme>);
});
it('init', (done)=>{

View File

@ -13,57 +13,64 @@ import pgAdmin from 'sources/pgadmin';
import SchemaView from '../../pgadmin/static/js/SchemaView';
import pgWindow from 'sources/window';
import fakePgAdmin from './fake_pgadmin';
import Theme from 'sources/Theme';
export let getEditView = (schemaObj, getInitData)=> {
return <SchemaView
formType='dialog'
schema={schemaObj}
getInitData={getInitData}
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}
disableDialogHelp={false}
/>;
return <Theme>
<SchemaView
formType='dialog'
schema={schemaObj}
getInitData={getInitData}
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}
disableDialogHelp={false}
/>
</Theme>;
};
export let getCreateView = (schemaObj)=> {
return <SchemaView
formType='dialog'
schema={schemaObj}
viewHelperProps={{
mode: 'create',
}}
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}
disableDialogHelp={false}
/>;
return <Theme>
<SchemaView
formType='dialog'
schema={schemaObj}
viewHelperProps={{
mode: 'create',
}}
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}
disableDialogHelp={false}
/>
</Theme>;
};
export let getPropertiesView = (schemaObj, getInitData)=> {
return <SchemaView
formType='tab'
schema={schemaObj}
getInitData={getInitData}
viewHelperProps={{
mode: 'properties',
}}
onHelp={()=>{/*This is intentional (SonarQube)*/}}
onEdit={()=>{/*This is intentional (SonarQube)*/}}
/>;
return <Theme>
<SchemaView
formType='tab'
schema={schemaObj}
getInitData={getInitData}
viewHelperProps={{
mode: 'properties',
}}
onHelp={()=>{/*This is intentional (SonarQube)*/}}
onEdit={()=>{/*This is intentional (SonarQube)*/}}
/>
</Theme>;
};
export let genericBeforeEach = ()=> {

View File

@ -13,6 +13,7 @@ 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, getQueryOptionSchema, getDisabledOptionSchema, getMiscellaneousSchema} from '../../../pgadmin/tools/backup/static/js/backup.ui';
import Theme from '../../../pgadmin/static/js/Theme';
describe('BackupSchema', ()=>{
@ -41,21 +42,23 @@ describe('BackupSchema', ()=>{
);
it('create object backup', ()=>{
mount(<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}
/>);
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>);
});
@ -76,21 +79,23 @@ describe('BackupSchema', ()=>{
);
it('create server backup', ()=>{
mount(<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}
/>);
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>);
});
});

View File

@ -12,6 +12,7 @@ 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';
describe('BackupGlobalSchema', ()=>{
@ -31,21 +32,23 @@ describe('BackupGlobalSchema', ()=>{
);
it('create', ()=>{
mount(<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}
/>);
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>);
});
});

View File

@ -15,6 +15,7 @@ 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';
describe('DebuggerArgs', () => {
let mount;
@ -35,16 +36,18 @@ describe('DebuggerArgs', () => {
});
it('create', () => {
mount(<SchemaView
formType='dialog'
schema={schemaObj}
viewHelperProps={{
mode: 'create',
}}
onDataChange={() => {/*This is intentional (SonarQube)*/}}
showFooter={false}
isTabView={false}
/>);
mount(<Theme>
<SchemaView
formType='dialog'
schema={schemaObj}
viewHelperProps={{
mode: 'create',
}}
onDataChange={() => {/*This is intentional (SonarQube)*/}}
showFooter={false}
isTabView={false}
/>
</Theme> );
});
});

View File

@ -14,6 +14,7 @@ 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() {
@ -263,22 +264,24 @@ describe('ForeignTableColumnSchema', ()=>{
let initData = ()=>Promise.resolve({typlen: 1, inheritedid: 1, inheritedfrom: 'public'});
mount(<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}
/>);
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> );
});
@ -311,22 +314,24 @@ describe('ForeignTableColumnSchema', ()=>{
});
mount(<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}
/>);
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>);
});
});

View File

@ -14,6 +14,7 @@ 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';
class MockSchema extends BaseUISchema {
get baseFields() {
@ -42,16 +43,18 @@ describe('GrantWizard', () => {
});
it('create', () => {
mount(<SchemaView
formType='dialog'
schema={schemaObj}
viewHelperProps={{
mode: 'create',
}}
onDataChange={() => {/*This is intentional (SonarQube)*/}}
showFooter={false}
isTabView={false}
/>);
mount(<Theme>
<SchemaView
formType='dialog'
schema={schemaObj}
viewHelperProps={{
mode: 'create',
}}
onDataChange={() => {/*This is intentional (SonarQube)*/}}
showFooter={false}
isTabView={false}
/>
</Theme>);
});
});

View File

@ -13,6 +13,7 @@ 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';
describe('ImportExportServers', () => {
let mount;
@ -33,30 +34,34 @@ describe('ImportExportServers', () => {
});
it('import', () => {
mount(<SchemaView
formType='dialog'
schema={schemaObj}
viewHelperProps={{
mode: 'create',
}}
onDataChange={() => {/*This is intentional (SonarQube)*/}}
showFooter={false}
isTabView={false}
/>);
mount(<Theme>
<SchemaView
formType='dialog'
schema={schemaObj}
viewHelperProps={{
mode: 'create',
}}
onDataChange={() => {/*This is intentional (SonarQube)*/}}
showFooter={false}
isTabView={false}
/>
</Theme>);
});
it('export', () => {
schemaObj = new ImportExportSelectionSchema(
{imp_exp: 'e', filename: 'test.json'});
mount(<SchemaView
formType='dialog'
schema={schemaObj}
viewHelperProps={{
mode: 'create',
}}
onDataChange={() => {/*This is intentional (SonarQube)*/}}
showFooter={false}
isTabView={false}
/>);
mount(<Theme>
<SchemaView
formType='dialog'
schema={schemaObj}
viewHelperProps={{
mode: 'create',
}}
onDataChange={() => {/*This is intentional (SonarQube)*/}}
showFooter={false}
isTabView={false}
/>
</Theme>);
});
});