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,6 +85,7 @@ export default class DialogWrapper {
createDialog(container) {
let self = this;
ReactDOM.render(
<Theme>
<SchemaView
formType={'dialog'}
getInitData={()=>Promise.resolve({})}
@ -99,7 +101,8 @@ export default class DialogWrapper {
hasSQL={false}
disableSqlHelp={true}
disableDialogHelp={true}
/>, container);
/>
</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,7 +84,8 @@ describe('SchemaView', ()=>{
getSQLValue=jasmine.createSpy('onEdit').and.returnValue(Promise.resolve('select 1;')),
ctrlMount = (props)=>{
ctrl?.unmount();
ctrl = mount(<SchemaView
ctrl = mount(<Theme>
<SchemaView
formType='dialog'
schema={getSchema()}
viewHelperProps={{
@ -99,7 +101,8 @@ describe('SchemaView', ()=>{
getSQLValue={getSQLValue}
disableSqlHelp={false}
{...props}
/>);
/>
</Theme>);
},
simulateValidData = ()=>{
ctrl.find('MappedFormControl[id="field1"]').find('input').simulate('change', {target: {value: 'val1'}});
@ -473,7 +476,8 @@ describe('SchemaView', ()=>{
let ctrl;
beforeEach(()=>{
ctrl?.unmount();
ctrl = mount(<SchemaView
ctrl = mount(<Theme>
<SchemaView
formType='dialog'
schema={getSchemaAllTypes()}
viewHelperProps={{
@ -488,7 +492,8 @@ describe('SchemaView', ()=>{
hasSQL={true}
getSQLValue={()=>'select 1;'}
disableSqlHelp={false}
/>);
/>
</Theme>);
});
it('init', ()=>{
@ -506,7 +511,8 @@ describe('SchemaView', ()=>{
ctrl = null;
beforeEach(()=>{
ctrl = mount(<SchemaView
ctrl = mount(<Theme>
<SchemaView
formType='tab'
schema={getSchema()}
getInitData={getInitData}
@ -516,7 +522,8 @@ describe('SchemaView', ()=>{
onHelp={onHelp}
disableSqlHelp={false}
onEdit={onEdit}
/>);
/>
</Theme>);
});
it('init', (done)=>{

View File

@ -13,9 +13,11 @@ 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
return <Theme>
<SchemaView
formType='dialog'
schema={schemaObj}
getInitData={getInitData}
@ -31,11 +33,13 @@ export let getEditView = (schemaObj, getInitData)=> {
hasSQL={false}
disableSqlHelp={false}
disableDialogHelp={false}
/>;
/>
</Theme>;
};
export let getCreateView = (schemaObj)=> {
return <SchemaView
return <Theme>
<SchemaView
formType='dialog'
schema={schemaObj}
viewHelperProps={{
@ -50,11 +54,13 @@ export let getCreateView = (schemaObj)=> {
hasSQL={false}
disableSqlHelp={false}
disableDialogHelp={false}
/>;
/>
</Theme>;
};
export let getPropertiesView = (schemaObj, getInitData)=> {
return <SchemaView
return <Theme>
<SchemaView
formType='tab'
schema={schemaObj}
getInitData={getInitData}
@ -63,7 +69,8 @@ export let getPropertiesView = (schemaObj, getInitData)=> {
}}
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,7 +42,8 @@ describe('BackupSchema', ()=>{
);
it('create object backup', ()=>{
mount(<SchemaView
mount(<Theme>
<SchemaView
formType='dialog'
schema={backupSchemaObj}
viewHelperProps={{
@ -55,7 +57,8 @@ describe('BackupSchema', ()=>{
hasSQL={false}
disableSqlHelp={false}
disableDialogHelp={false}
/>);
/>
</Theme>);
});
@ -76,7 +79,8 @@ describe('BackupSchema', ()=>{
);
it('create server backup', ()=>{
mount(<SchemaView
mount(<Theme>
<SchemaView
formType='dialog'
schema={backupServerSchemaObj}
viewHelperProps={{
@ -90,7 +94,8 @@ describe('BackupSchema', ()=>{
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,7 +32,8 @@ describe('BackupGlobalSchema', ()=>{
);
it('create', ()=>{
mount(<SchemaView
mount(<Theme>
<SchemaView
formType='dialog'
schema={backupGlobalSchemaObj}
viewHelperProps={{
@ -45,7 +47,8 @@ describe('BackupGlobalSchema', ()=>{
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,7 +36,8 @@ describe('DebuggerArgs', () => {
});
it('create', () => {
mount(<SchemaView
mount(<Theme>
<SchemaView
formType='dialog'
schema={schemaObj}
viewHelperProps={{
@ -44,7 +46,8 @@ describe('DebuggerArgs', () => {
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,7 +264,8 @@ describe('ForeignTableColumnSchema', ()=>{
let initData = ()=>Promise.resolve({typlen: 1, inheritedid: 1, inheritedfrom: 'public'});
mount(<SchemaView
mount(<Theme>
<SchemaView
formType='dialog'
schema={defaultSchemaObj}
getInitData={initData}
@ -278,7 +280,8 @@ describe('ForeignTableColumnSchema', ()=>{
confirmOnCloseReset={false}
hasSQL={false}
disableSqlHelp={false}
/>);
/>
</Theme> );
});
@ -311,7 +314,8 @@ describe('ForeignTableColumnSchema', ()=>{
});
mount(<SchemaView
mount(<Theme>
<SchemaView
formType='dialog'
schema={defaultSchemaObj}
getInitData={initData}
@ -326,7 +330,8 @@ describe('ForeignTableColumnSchema', ()=>{
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,7 +43,8 @@ describe('GrantWizard', () => {
});
it('create', () => {
mount(<SchemaView
mount(<Theme>
<SchemaView
formType='dialog'
schema={schemaObj}
viewHelperProps={{
@ -51,7 +53,8 @@ describe('GrantWizard', () => {
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,7 +34,8 @@ describe('ImportExportServers', () => {
});
it('import', () => {
mount(<SchemaView
mount(<Theme>
<SchemaView
formType='dialog'
schema={schemaObj}
viewHelperProps={{
@ -42,13 +44,15 @@ describe('ImportExportServers', () => {
onDataChange={() => {/*This is intentional (SonarQube)*/}}
showFooter={false}
isTabView={false}
/>);
/>
</Theme>);
});
it('export', () => {
schemaObj = new ImportExportSelectionSchema(
{imp_exp: 'e', filename: 'test.json'});
mount(<SchemaView
mount(<Theme>
<SchemaView
formType='dialog'
schema={schemaObj}
viewHelperProps={{
@ -57,6 +61,7 @@ describe('ImportExportServers', () => {
onDataChange={() => {/*This is intentional (SonarQube)*/}}
showFooter={false}
isTabView={false}
/>);
/>
</Theme>);
});
});