public inbox for [email protected]
help / color / mirror / Atom feedFrom: Aditya Toshniwal <[email protected]>
To: pgadmin-hackers <[email protected]>
Subject: [pgAdmin][patch] JS test cases fix
Date: Wed, 23 Mar 2022 18:33:22 +0530
Message-ID: <CAM9w-_nZPnSzxHZgCi4SUO-qNCFstR+X5G_ZA-VR9t3Yg39vLg@mail.gmail.com> (raw)
Hi Hackers,
Attached patch fixes failing jasmine test cases.
--
Thanks,
Aditya Toshniwal
pgAdmin Hacker | Software Architect | *edbpostgres.com*
<http://edbpostgres.com;
"Don't Complain about Heat, Plant a TREE"
Attachments:
[application/octet-stream] jasmine.fixes.patch (5.4K, 3-jasmine.fixes.patch)
download | inline diff:
diff --git a/web/pgadmin/static/js/SchemaView/index.jsx b/web/pgadmin/static/js/SchemaView/index.jsx
index 2c180d708..852e1498d 100644
--- a/web/pgadmin/static/js/SchemaView/index.jsx
+++ b/web/pgadmin/static/js/SchemaView/index.jsx
@@ -93,7 +93,7 @@ function isValueEqual(val1, val2) {
return (_.isEqual(val1, val2)
|| ((val1 === null || _.isUndefined(val1)) && val2 === '')
|| ((val1 === null || _.isUndefined(val1)) && typeof(val2) === 'boolean' && !val2)
- || (attrDefined ? _.isEqual(val1.toString(), val2.toString()) : false
+ || (attrDefined ? (!_.isObject(val1) && _.isEqual(val1.toString(), val2.toString())) : false
));
}
@@ -108,7 +108,7 @@ function getChangedData(topSchema, viewHelperProps, sessData, stringify=false, i
/* The comparator and setter */
const attrChanged = (id, change, force=false)=>{
- if(isValueEqual(_.get(origVal, id), _.get(sessVal, id)) && !force && (_.isObject(_.get(origVal, id)) && _.isEqual(_.get(origVal, id), _.get(sessData, id)))) {
+ if(isValueEqual(_.get(origVal, id), _.get(sessVal, id)) && !force) {
return;
} else {
change = change || _.get(sessVal, id);
diff --git a/web/pgadmin/static/js/components/SelectThemes.jsx b/web/pgadmin/static/js/components/SelectThemes.jsx
index 07e157674..5d360159f 100644
--- a/web/pgadmin/static/js/components/SelectThemes.jsx
+++ b/web/pgadmin/static/js/components/SelectThemes.jsx
@@ -28,16 +28,13 @@ export default function SelectThemes({onChange, ...props}) {
props.options.forEach((opt)=> {
if(opt.value == e) {
setPreviewSrc(opt.preview_src);
- }
+ }
});
onChange(e);
};
return (
- <Grid
- container
- direction="column"
- justifyContent="center">
+ <Grid container direction="column">
<Grid item lg={12} md={12} sm={12} xs={12}>
<InputSelect ref={props.inputRef} onChange={themeChange} {...props} />
</Grid>
@@ -55,4 +52,4 @@ SelectThemes.propTypes = {
fields: PropTypes.array,
options: PropTypes.array,
inputRef: CustomPropTypes.ref
-};
\ No newline at end of file
+};
diff --git a/web/regression/javascript/components/FormComponents.spec.js b/web/regression/javascript/components/FormComponents.spec.js
index dc180d42e..d53dd41aa 100644
--- a/web/regression/javascript/components/FormComponents.spec.js
+++ b/web/regression/javascript/components/FormComponents.spec.js
@@ -196,7 +196,7 @@ describe('FormComponents', ()=>{
it('init', ()=>{
expect(ctrl.find(InputLabel).text()).toBe('First');
expect(ctrl.find(CodeMirror).prop('value')).toEqual('thevalue');
- expect(ctrl.find(CodeMirror).prop('op1')).toEqual('test');
+ expect(ctrl.find(CodeMirror).prop('options')).toEqual(jasmine.objectContaining({'op1': 'test'}));
expect(ctrl.find(FormHelperText).text()).toBe('some help message');
});
});
diff --git a/web/regression/javascript/erd/fake_item.js b/web/regression/javascript/erd/fake_item.js
index 2ae3b6070..472c626fa 100644
--- a/web/regression/javascript/erd/fake_item.js
+++ b/web/regression/javascript/erd/fake_item.js
@@ -15,6 +15,7 @@ export class FakeNode {
serializeData() {return this.getData();}
getPortName(attnum) {return `port-${attnum}`;}
getPort() {return null;}
+ getPorts() {return null;}
addPort(obj) {return obj;}
getColumnAt(pos) {return _.find(this.getColumns()||[], (c)=>c.attnum==pos);}
remove() {/*This is intentional (SonarQube)*/}
@@ -45,3 +46,8 @@ export class FakeLink {
setTargetPort() {/*This is intentional (SonarQube)*/}
remove() {/*This is intentional (SonarQube)*/}
}
+
+export class FakePort {
+ constructor() {}
+ getLinks() {return null;}
+}
diff --git a/web/regression/javascript/erd/ui_components/body_widget_spec.js b/web/regression/javascript/erd/ui_components/body_widget_spec.js
index 0738e7f82..3fb2cf0bd 100644
--- a/web/regression/javascript/erd/ui_components/body_widget_spec.js
+++ b/web/regression/javascript/erd/ui_components/body_widget_spec.js
@@ -10,7 +10,7 @@ import * as erdModule from 'pgadmin.tools.erd/erd_module';
import erdPref from './erd_preferences';
import BodyWidget from 'pgadmin.tools.erd/erd_tool/ui_components/BodyWidget';
import * as ERDSqlTool from 'tools/datagrid/static/js/show_query_tool';
-import { FakeLink, FakeNode } from '../fake_item';
+import { FakeLink, FakeNode, FakePort } from '../fake_item';
import Notify from '../../../../pgadmin/static/js/helpers/Notifier';
@@ -310,22 +310,25 @@ describe('ERD BodyWidget', ()=>{
it('onDeleteNode', (done)=>{
let node = new FakeNode({name: 'table1', schema: 'erd1'});
- spyOn(node, 'remove');
let link = new FakeLink({local_table_uid: 'tid1'});
- spyOn(link, 'remove');
+ let port = new FakePort();
+ spyOn(port, 'getLinks').and.returnValue([link]);
+ spyOn(node, 'remove');
+ spyOn(node, 'getPorts').and.returnValue([port]);
let nodesDict = {
'tid1': node
};
spyOn(bodyInstance.diagram, 'getModel').and.returnValue({
'getNodesDict': ()=>nodesDict,
});
+ spyOn(bodyInstance.diagram, 'removeOneToManyLink');
spyOn(bodyInstance.diagram, 'getSelectedNodes').and.returnValue([node]);
spyOn(bodyInstance.diagram, 'getSelectedLinks').and.returnValue([link]);
bodyInstance.onDeleteNode();
setTimeout(()=>{
expect(node.remove).toHaveBeenCalled();
- expect(link.remove).toHaveBeenCalled();
+ expect(bodyInstance.diagram.removeOneToManyLink).toHaveBeenCalledWith(link);
done();
});
});
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected]
Subject: Re: [pgAdmin][patch] JS test cases fix
In-Reply-To: <CAM9w-_nZPnSzxHZgCi4SUO-qNCFstR+X5G_ZA-VR9t3Yg39vLg@mail.gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox