Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
92e3273
ui: fix style and layout issues on smaller screens
jamaljsr Jun 9, 2020
f006e62
chore: remove default ReactJS readme
jamaljsr Jun 10, 2020
3f9d33a
swaps: limit max Loop amount to be based on channel balances
jamaljsr Jun 11, 2020
427994f
swaps: add Loop type (in/out) to Processing Loops section
jamaljsr Jun 11, 2020
7e04d9f
theme: change the orange color to yellow
jamaljsr Jun 12, 2020
f9006fb
ui: display tooltip for "In Fee %" header
jamaljsr Jun 12, 2020
39ae2db
swap: update "x channels selected" label
jamaljsr Jun 12, 2020
67de28e
swap: change Invoice Total to Total
jamaljsr Jun 12, 2020
3da8388
swap: fix incorrect multi Loop In warning
jamaljsr Jun 12, 2020
6c16b59
channels: prevent ellipsed amounts on smaller screen resolutions
jamaljsr Jun 13, 2020
abe9249
api: add error handling for GetChanInfo and GetNodeInfo calls
jamaljsr Jun 13, 2020
e007ea0
docs: add yarn to readme and update screenshot
jamaljsr Jun 13, 2020
cb2c084
docs: reformat readme markdown
jamaljsr Jun 13, 2020
941c5a2
channels: indicate channels currently being used in a swap
jamaljsr Jun 15, 2020
2b836e7
ui: fix hamburger menu going offscreen when the page is scrolled
jamaljsr Jun 15, 2020
c4b735f
swap: update ambiguous descriptions in the swap wizard
jamaljsr Jun 15, 2020
b399e47
channels: add full alias to the pubkey tooltip
jamaljsr Jun 16, 2020
f2401db
styles: improve alignment of columns in channels/swaps lists
jamaljsr Jun 16, 2020
94837c9
docs: add note about CAP_NET_BIND_SERVICE to readme
jamaljsr Jun 17, 2020
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
3 changes: 2 additions & 1 deletion app/.prettierrc → .prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
}
],
"printWidth": 90,
"proseWrap": "always",
"singleQuote": true,
"useTabs": false,
"semi": true,
Expand All @@ -16,4 +17,4 @@
"bracketSpacing": true,
"jsxBracketSameLine": false,
"arrowParens": "avoid"
}
}
178 changes: 138 additions & 40 deletions README.md

Large diffs are not rendered by default.

44 changes: 0 additions & 44 deletions app/README.md

This file was deleted.

1 change: 0 additions & 1 deletion app/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
<head>
<meta charset="utf-8" />
<link rel="icon" href="%PUBLIC_URL%/icons/favicon-32x32.png" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<link rel="apple-touch-icon" sizes="48x48" href="%PUBLID_URL%/icons/icon-48x48.png" />
<link rel="apple-touch-icon" sizes="72x72" href="%PUBLID_URL%/icons/icon-72x72.png" />
Expand Down
1 change: 1 addition & 0 deletions app/src/App.scss
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,5 @@ body,
#root {
min-height: 100vh;
width: 100%;
min-width: 1024px;
}
35 changes: 35 additions & 0 deletions app/src/__stories__/ChannelRow.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from 'react';
import { useObserver } from 'mobx-react-lite';
import { SwapState, SwapType } from 'types/generated/loop_pb';
import { SwapDirection } from 'types/state';
import { lndListChannels } from 'util/tests/sampleData';
import { useStore } from 'store';
Expand Down Expand Up @@ -87,3 +88,37 @@ export const Dimmed = () => {
store.buildSwapStore.setDirection(SwapDirection.OUT);
return renderStory(channel);
};

export const LoopingIn = () => {
const store = useStore();
const channel = new Channel(store, lndListChannels.channelsList[0]);
const swap = store.swapStore.sortedSwaps[0];
swap.type = SwapType.LOOP_IN;
swap.state = SwapState.INITIATED;
store.swapStore.addSwappedChannels(swap.id, [channel.chanId]);
return renderStory(channel, { ratio: 0.3 });
};

export const LoopingOut = () => {
const store = useStore();
const channel = new Channel(store, lndListChannels.channelsList[0]);
const swap = store.swapStore.sortedSwaps[0];
swap.type = SwapType.LOOP_OUT;
swap.state = SwapState.INITIATED;
store.swapStore.addSwappedChannels(swap.id, [channel.chanId]);
return renderStory(channel, { ratio: 0.3 });
};

export const LoopingInAndOut = () => {
const store = useStore();
const channel = new Channel(store, lndListChannels.channelsList[0]);
const swap1 = store.swapStore.sortedSwaps[0];
swap1.type = SwapType.LOOP_IN;
swap1.state = SwapState.INITIATED;
store.swapStore.addSwappedChannels(swap1.id, [channel.chanId]);
const swap2 = store.swapStore.sortedSwaps[1];
swap2.type = SwapType.LOOP_OUT;
swap2.state = SwapState.INITIATED;
store.swapStore.addSwappedChannels(swap2.id, [channel.chanId]);
return renderStory(channel, { ratio: 0.3 });
};
4 changes: 2 additions & 2 deletions app/src/__tests__/components/loop/ChannelBalance.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ describe('ChannelBalance component', () => {
const { el, remote, local } = render(0.52);
expect(el.children.length).toBe(3);
expect(width(local)).toBe('52%');
expect(bgColor(local)).toBe('rgb(246, 107, 28)');
expect(bgColor(remote)).toBe('rgb(246, 107, 28)');
expect(bgColor(local)).toBe('rgb(255, 249, 23)');
expect(bgColor(remote)).toBe('rgb(255, 249, 23)');
});

it('should display a bad balance', () => {
Expand Down
53 changes: 52 additions & 1 deletion app/src/__tests__/components/loop/ChannelRow.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import React from 'react';
import { SwapState, SwapType } from 'types/generated/loop_pb';
import { SwapDirection } from 'types/state';
import { fireEvent } from '@testing-library/react';
import { formatSats } from 'util/formatters';
import { renderWithProviders } from 'util/tests';
import { createStore, Store } from 'store';
import { Channel } from 'store/models';
import { Channel, Swap } from 'store/models';
import ChannelRow from 'components/loop/ChannelRow';

describe('ChannelRow component', () => {
Expand Down Expand Up @@ -54,6 +55,16 @@ describe('ChannelRow component', () => {
expect(getByText(channel.aliasLabel)).toBeInTheDocument();
});

it('should display the peer pubkey & alias tooltip', () => {
const { getByText, getAllByText } = render();
channel.alias = 'test-alias';
fireEvent.mouseEnter(getByText(channel.aliasLabel));
expect(getByText(channel.remotePubkey)).toBeInTheDocument();
expect(getAllByText(channel.alias)).toHaveLength(2);
channel.alias = channel.remotePubkey.substring(12);
expect(getByText(channel.remotePubkey)).toBeInTheDocument();
});

it('should display the capacity', () => {
const { getByText } = render();
expect(
Expand Down Expand Up @@ -121,4 +132,44 @@ describe('ChannelRow component', () => {
fireEvent.click(getByRole('checkbox'));
expect(store.buildSwapStore.selectedChanIds).toEqual([]);
});

describe('pending swaps', () => {
let swap1: Swap;
let swap2: Swap;

beforeEach(() => {
swap1 = store.swapStore.sortedSwaps[0];
swap2 = store.swapStore.sortedSwaps[1];
swap1.state = swap2.state = SwapState.INITIATED;
});

it('should display the pending Loop In icon', () => {
swap1.type = SwapType.LOOP_IN;
store.swapStore.addSwappedChannels(swap1.id, [channel.chanId]);
const { getByText } = render();
expect(getByText('chevrons-right.svg')).toBeInTheDocument();
fireEvent.mouseEnter(getByText('chevrons-right.svg'));
expect(getByText('Loop In currently in progress')).toBeInTheDocument();
});

it('should display the pending Loop Out icon', () => {
swap1.type = SwapType.LOOP_OUT;
store.swapStore.addSwappedChannels(swap1.id, [channel.chanId]);
const { getByText } = render();
expect(getByText('chevrons-left.svg')).toBeInTheDocument();
fireEvent.mouseEnter(getByText('chevrons-left.svg'));
expect(getByText('Loop Out currently in progress')).toBeInTheDocument();
});

it('should display the pending Loop In and Loop Out icon', () => {
swap1.type = SwapType.LOOP_IN;
swap2.type = SwapType.LOOP_OUT;
store.swapStore.addSwappedChannels(swap1.id, [channel.chanId]);
store.swapStore.addSwappedChannels(swap2.id, [channel.chanId]);
const { getByText } = render();
expect(getByText('chevrons.svg')).toBeInTheDocument();
fireEvent.mouseEnter(getByText('chevrons.svg'));
expect(getByText('Loop In and Loop Out currently in progress')).toBeInTheDocument();
});
});
});
5 changes: 3 additions & 2 deletions app/src/__tests__/components/loop/LoopPage.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ describe('LoopPage component', () => {
beforeEach(async () => {
store = createStore();
await store.fetchAllData();
await store.buildSwapStore.getTerms();
});

const render = () => {
Expand Down Expand Up @@ -106,7 +107,7 @@ describe('LoopPage component', () => {
store.channelStore.sortedChannels.slice(0, 1).forEach(c => {
store.buildSwapStore.toggleSelectedChannel(c.chanId);
});
fireEvent.click(getByText('Loop In'));
fireEvent.click(getByText('Loop Out'));
expect(getByText('Step 1 of 2')).toBeInTheDocument();
});

Expand All @@ -117,7 +118,7 @@ describe('LoopPage component', () => {
store.channelStore.sortedChannels.slice(0, 1).forEach(c => {
store.buildSwapStore.toggleSelectedChannel(c.chanId);
});
fireEvent.click(getByText('Loop In'));
fireEvent.click(getByText('Loop Out'));
expect(getByText('Step 1 of 2')).toBeInTheDocument();
fireEvent.click(getByText('arrow-left.svg'));
expect(getByText('Loop History')).toBeInTheDocument();
Expand Down
7 changes: 7 additions & 0 deletions app/src/__tests__/components/loop/ProcessingSwaps.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ describe('ProcessingSwaps component', () => {
const swap = addSwap(LOOP_IN, INITIATED);
expect(getByText('dot.svg')).toHaveClass('warn');
expect(getByText(swap.ellipsedId)).toBeInTheDocument();
expect(getByText(swap.typeName)).toBeInTheDocument();
expect(getByTitle(swap.stateLabel)).toBeInTheDocument();
expect(width(getByTitle(swap.stateLabel))).toBe('25%');
});
Expand All @@ -58,6 +59,7 @@ describe('ProcessingSwaps component', () => {
const swap = addSwap(LOOP_IN, HTLC_PUBLISHED);
expect(getByText('dot.svg')).toHaveClass('warn');
expect(getByText(swap.ellipsedId)).toBeInTheDocument();
expect(getByText(swap.typeName)).toBeInTheDocument();
expect(getByTitle(swap.stateLabel)).toBeInTheDocument();
expect(width(getByTitle(swap.stateLabel))).toBe('50%');
});
Expand All @@ -67,6 +69,7 @@ describe('ProcessingSwaps component', () => {
const swap = addSwap(LOOP_IN, INVOICE_SETTLED);
expect(getByText('dot.svg')).toHaveClass('warn');
expect(getByText(swap.ellipsedId)).toBeInTheDocument();
expect(getByText(swap.typeName)).toBeInTheDocument();
expect(getByTitle(swap.stateLabel)).toBeInTheDocument();
expect(width(getByTitle(swap.stateLabel))).toBe('75%');
});
Expand All @@ -75,6 +78,7 @@ describe('ProcessingSwaps component', () => {
const { getByText, getByTitle } = render();
const swap = addSwap(LOOP_IN, SUCCESS);
expect(getByText(swap.ellipsedId)).toBeInTheDocument();
expect(getByText(swap.typeName)).toBeInTheDocument();
expect(getByTitle(swap.stateLabel)).toBeInTheDocument();
expect(width(getByTitle(swap.stateLabel))).toBe('100%');
});
Expand All @@ -92,6 +96,7 @@ describe('ProcessingSwaps component', () => {
const swap = addSwap(LOOP_OUT, INITIATED);
expect(getByText('dot.svg')).toHaveClass('warn');
expect(getByText(swap.ellipsedId)).toBeInTheDocument();
expect(getByText(swap.typeName)).toBeInTheDocument();
expect(getByTitle(swap.stateLabel)).toBeInTheDocument();
expect(width(getByTitle(swap.stateLabel))).toBe('33%');
});
Expand All @@ -101,6 +106,7 @@ describe('ProcessingSwaps component', () => {
const swap = addSwap(LOOP_OUT, PREIMAGE_REVEALED);
expect(getByText('dot.svg')).toHaveClass('warn');
expect(getByText(swap.ellipsedId)).toBeInTheDocument();
expect(getByText(swap.typeName)).toBeInTheDocument();
expect(getByTitle(swap.stateLabel)).toBeInTheDocument();
expect(width(getByTitle(swap.stateLabel))).toBe('66%');
});
Expand All @@ -110,6 +116,7 @@ describe('ProcessingSwaps component', () => {
const swap = addSwap(LOOP_OUT, SUCCESS);
expect(getByText('dot.svg')).toHaveClass('success');
expect(getByText(swap.ellipsedId)).toBeInTheDocument();
expect(getByText(swap.typeName)).toBeInTheDocument();
expect(getByTitle(swap.stateLabel)).toBeInTheDocument();
expect(width(getByTitle(swap.stateLabel))).toBe('100%');
});
Expand Down
8 changes: 4 additions & 4 deletions app/src/__tests__/components/loop/SwapWizard.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ describe('SwapWizard component', () => {
it('should display the description labels', () => {
const { getByText } = render();
expect(getByText('Step 1 of 2')).toBeInTheDocument();
expect(getByText('Set Liquidity Parameters')).toBeInTheDocument();
expect(getByText('Loop Out Amount')).toBeInTheDocument();
});

it('should navigate forward and back through each step', async () => {
Expand Down Expand Up @@ -63,10 +63,10 @@ describe('SwapWizard component', () => {
it('should update the amount when the slider changes', () => {
const { getByText, getByLabelText } = render();
const build = store.buildSwapStore;
expect(+build.amount).toEqual(625000);
expect(+build.amountForSelected).toEqual(625000);
expect(getByText(`625,000 sats`)).toBeInTheDocument();
fireEvent.change(getByLabelText('range-slider'), { target: { value: '575000' } });
expect(+build.amount).toEqual(575000);
expect(+build.amountForSelected).toEqual(575000);
expect(getByText(`575,000 sats`)).toBeInTheDocument();
});
});
Expand All @@ -84,7 +84,7 @@ describe('SwapWizard component', () => {
expect(getByText('Review the quote')).toBeInTheDocument();
expect(getByText('Loop Out Amount')).toBeInTheDocument();
expect(getByText('Fees')).toBeInTheDocument();
expect(getByText('Invoice Total')).toBeInTheDocument();
expect(getByText('Total')).toBeInTheDocument();
});

it('should display the correct values', () => {
Expand Down
Loading