Skip to content

Commit

Permalink
fix(designer): fix channels hiding when removing a node in a stopped …
Browse files Browse the repository at this point in the history
…network
  • Loading branch information
jamaljsr committed Sep 23, 2020
1 parent 1272a97 commit 534892c
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 11 deletions.
6 changes: 3 additions & 3 deletions src/components/common/RemoveNode.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,16 @@ describe('RemoveNode', () => {
});

it('should remove the node with the network stopped', async () => {
const { getByText, findByText, getByLabelText } = renderComponent(Status.Started);
const { getByText, findByText, getByLabelText } = renderComponent(Status.Stopped);
expect(getByText('Remove')).toBeInTheDocument();
fireEvent.click(getByText('Remove'));
fireEvent.click(await findByText('Yes'));
// wait for the error notification to be displayed
await waitFor(() => getByLabelText('check-circle'));
expect(
getByText('The node alice has been removed from the network'),
getByText('The node bob has been removed from the network'),
).toBeInTheDocument();
expect(dockerServiceMock.removeNode).toBeCalledTimes(1);
expect(dockerServiceMock.removeNode).toBeCalledTimes(0);
});

it('should remove the node with the network started', async () => {
Expand Down
15 changes: 7 additions & 8 deletions src/store/models/designer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,14 +119,13 @@ const designerModel: DesignerModel = {
}),
syncChart: thunk(
async (actions, network, { getState, getStoreState, getStoreActions }) => {
if (network.status === Status.Started) {
// fetch data from all of the nodes
await Promise.all(
network.nodes.lightning
.filter(n => n.status === Status.Started)
.map(getStoreActions().lightning.getAllInfo),
);
}
if (network.status !== Status.Started) return;
// fetch data from all of the nodes
await Promise.all(
network.nodes.lightning
.filter(n => n.status === Status.Started)
.map(getStoreActions().lightning.getAllInfo),
);

const nodesData = getStoreState().lightning.nodes;
const { allCharts } = getState();
Expand Down
11 changes: 11 additions & 0 deletions src/utils/chart.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,17 @@ describe('Chart Util', () => {
expect(result.links['backend1-backend2']).not.toBeDefined();
});

it('should create bitcoin link for a peer', () => {
network.nodes.bitcoin.push(
createBitcoindNetworkNode(network, '0.19.0.1', testNodeDocker),
);
chart = initChartFromNetwork(network);
expect(chart.links['backend1-backend2']).toBeDefined();
delete chart.links['backend1-backend2'];
const result = updateChartFromNodes(chart, network, nodesData);
expect(result.links['backend1-backend2']).toBeDefined();
});

it('should update the node sizes', () => {
chart.nodes['alice'].size = { width: 100, height: 20 };
chart.nodes['bob'].size = undefined;
Expand Down

0 comments on commit 534892c

Please sign in to comment.