Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for inaccurate bidrectional edges on edge hover #2342

Merged
merged 3 commits into from
Mar 20, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Changed client tests to use EDGE_ID_SEPARATOR constant
  • Loading branch information
jpellizzari committed Mar 20, 2017
commit c7f6a078389b4f713198b0c741a6c89d82567441
38 changes: 20 additions & 18 deletions client/app/scripts/charts/__tests__/node-layout-test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { fromJS, Map } from 'immutable';

import { constructEdgeId as edge } from '../../utils/layouter-utils';

const makeMap = Map;

describe('NodesLayout', () => {
Expand Down Expand Up @@ -30,9 +32,9 @@ describe('NodesLayout', () => {
n4: {id: 'n4'}
}),
edges: fromJS({
'n1-n3': {id: 'n1-n3', source: 'n1', target: 'n3'},
'n1-n4': {id: 'n1-n4', source: 'n1', target: 'n4'},
'n2-n4': {id: 'n2-n4', source: 'n2', target: 'n4'}
[edge('n1', 'n3')]: {id: edge('n1', 'n3'), source: 'n1', target: 'n3'},
[edge('n1', 'n4')]: {id: edge('n1', 'n4'), source: 'n1', target: 'n4'},
[edge('n2', 'n4')]: {id: edge('n2', 'n4'), source: 'n2', target: 'n4'}
})
},
rank4: {
Expand All @@ -43,9 +45,9 @@ describe('NodesLayout', () => {
n4: {id: 'n4', rank: 'B'}
}),
edges: fromJS({
'n1-n3': {id: 'n1-n3', source: 'n1', target: 'n3'},
'n1-n4': {id: 'n1-n4', source: 'n1', target: 'n4'},
'n2-n4': {id: 'n2-n4', source: 'n2', target: 'n4'}
[edge('n1', 'n3')]: {id: edge('n1', 'n3'), source: 'n1', target: 'n3'},
[edge('n1', 'n4')]: {id: edge('n1', 'n4'), source: 'n1', target: 'n4'},
[edge('n2', 'n4')]: {id: edge('n2', 'n4'), source: 'n2', target: 'n4'}
})
},
rank6: {
Expand All @@ -58,11 +60,11 @@ describe('NodesLayout', () => {
n6: {id: 'n6', rank: 'B'},
}),
edges: fromJS({
'n1-n3': {id: 'n1-n3', source: 'n1', target: 'n3'},
'n1-n4': {id: 'n1-n4', source: 'n1', target: 'n4'},
'n1-n5': {id: 'n1-n5', source: 'n1', target: 'n5'},
'n2-n4': {id: 'n2-n4', source: 'n2', target: 'n4'},
'n2-n6': {id: 'n2-n6', source: 'n2', target: 'n6'},
[edge('n1', 'n3')]: {id: edge('n1', 'n3'), source: 'n1', target: 'n3'},
[edge('n1', 'n4')]: {id: edge('n1', 'n4'), source: 'n1', target: 'n4'},
[edge('n1', 'n5')]: {id: edge('n1', 'n5'), source: 'n1', target: 'n5'},
[edge('n2', 'n4')]: {id: edge('n2', 'n4'), source: 'n2', target: 'n4'},
[edge('n2', 'n6')]: {id: edge('n2', 'n6'), source: 'n2', target: 'n6'},
})
},
removeEdge24: {
Expand All @@ -73,8 +75,8 @@ describe('NodesLayout', () => {
n4: {id: 'n4'}
}),
edges: fromJS({
'n1-n3': {id: 'n1-n3', source: 'n1', target: 'n3'},
'n1-n4': {id: 'n1-n4', source: 'n1', target: 'n4'}
[edge('n1', 'n3')]: {id: edge('n1', 'n3'), source: 'n1', target: 'n3'},
[edge('n1', 'n4')]: {id: edge('n1', 'n4'), source: 'n1', target: 'n4'}
})
},
removeNode2: {
Expand All @@ -84,8 +86,8 @@ describe('NodesLayout', () => {
n4: {id: 'n4'}
}),
edges: fromJS({
'n1-n3': {id: 'n1-n3', source: 'n1', target: 'n3'},
'n1-n4': {id: 'n1-n4', source: 'n1', target: 'n4'}
[edge('n1', 'n3')]: {id: edge('n1', 'n3'), source: 'n1', target: 'n3'},
[edge('n1', 'n4')]: {id: edge('n1', 'n4'), source: 'n1', target: 'n4'}
})
},
removeNode23: {
Expand All @@ -94,7 +96,7 @@ describe('NodesLayout', () => {
n4: {id: 'n4'}
}),
edges: fromJS({
'n1-n4': {id: 'n1-n4', source: 'n1', target: 'n4'}
[edge('n1', 'n4')]: {id: edge('n1', 'n4'), source: 'n1', target: 'n4'}
})
},
single3: {
Expand All @@ -114,7 +116,7 @@ describe('NodesLayout', () => {
n5: {id: 'n5'}
}),
edges: fromJS({
'n1-n4': {id: 'n1-n4', source: 'n1', target: 'n4'}
[edge('n1', 'n4')]: {id: edge('n1', 'n4'), source: 'n1', target: 'n4'}
})
},
singlePortrait6: {
Expand All @@ -127,7 +129,7 @@ describe('NodesLayout', () => {
n6: {id: 'n6'}
}),
edges: fromJS({
'n1-n4': {id: 'n1-n4', source: 'n1', target: 'n4'}
[edge('n1', 'n4')]: {id: edge('n1', 'n4'), source: 'n1', target: 'n4'}
})
}
};
Expand Down
2 changes: 1 addition & 1 deletion client/app/scripts/constants/naming.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@

export const EDGE_ID_SEPARATOR = '-------';
export const EDGE_ID_SEPARATOR = '---';
7 changes: 4 additions & 3 deletions client/app/scripts/reducers/__tests__/root-test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {is, fromJS} from 'immutable';
// Root reducer test suite using Jasmine matchers
import { constructEdgeId } from '../../utils/layouter-utils';

describe('RootReducer', () => {
const ActionTypes = require('../../constants/action-types').default;
Expand Down Expand Up @@ -543,12 +544,12 @@ describe('RootReducer', () => {
it('highlights bidirectional edges', () => {
const action = {
type: ActionTypes.ENTER_EDGE,
edgeId: 'abc123-def456'
edgeId: constructEdgeId('abc123', 'def456')
};
const nextState = reducer(initialState, action);
expect(nextState.get('highlightedEdgeIds').toJS()).toEqual([
'abc123-def456',
'def456-abc123'
constructEdgeId('abc123', 'def456'),
constructEdgeId('def456', 'abc123')
]);
});
});
11 changes: 6 additions & 5 deletions client/app/scripts/utils/__tests__/layouter-utils-test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { fromJS } from 'immutable';

import {
initEdgesFromNodes
initEdgesFromNodes,
constructEdgeId as edge
} from '../layouter-utils';


Expand All @@ -14,10 +15,10 @@ describe('LayouterUtils', () => {
c: {}
});
expect(initEdgesFromNodes(input).toJS()).toEqual({
'a-b': { id: 'a-b', source: 'a', target: 'b', value: 1 },
'a-c': { id: 'a-c', source: 'a', target: 'c', value: 1 },
'b-a': { id: 'b-a', source: 'b', target: 'a', value: 1 },
'b-b': { id: 'b-b', source: 'b', target: 'b', value: 1 },
[edge('a', 'b')]: { id: edge('a', 'b'), source: 'a', target: 'b', value: 1 },
[edge('a', 'c')]: { id: edge('a', 'c'), source: 'a', target: 'c', value: 1 },
[edge('b', 'a')]: { id: edge('b', 'a'), source: 'b', target: 'a', value: 1 },
[edge('b', 'b')]: { id: edge('b', 'b'), source: 'b', target: 'b', value: 1 },
});
});
});
Expand Down
2 changes: 1 addition & 1 deletion client/app/scripts/utils/layouter-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Map as makeMap } from 'immutable';
import { EDGE_ID_SEPARATOR } from '../constants/naming';


function constructEdgeId(source, target) {
export function constructEdgeId(source, target) {
return [source, target].join(EDGE_ID_SEPARATOR);
}

Expand Down