Skip to content

Commit 571f365

Browse files
authored
Merge pull request #61 from lightninglabs/rc-feedback-fixes
RC feedback fixes
2 parents 11ba8a7 + 94837c9 commit 571f365

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+1000
-229
lines changed

app/.prettierrc renamed to .prettierrc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
}
99
],
1010
"printWidth": 90,
11+
"proseWrap": "always",
1112
"singleQuote": true,
1213
"useTabs": false,
1314
"semi": true,
@@ -16,4 +17,4 @@
1617
"bracketSpacing": true,
1718
"jsxBracketSameLine": false,
1819
"arrowParens": "avoid"
19-
}
20+
}

README.md

Lines changed: 138 additions & 40 deletions
Large diffs are not rendered by default.

app/README.md

Lines changed: 0 additions & 44 deletions
This file was deleted.

app/public/index.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
<head>
44
<meta charset="utf-8" />
55
<link rel="icon" href="%PUBLIC_URL%/icons/favicon-32x32.png" />
6-
<meta name="viewport" content="width=device-width, initial-scale=1" />
76
<meta name="theme-color" content="#000000" />
87
<link rel="apple-touch-icon" sizes="48x48" href="%PUBLID_URL%/icons/icon-48x48.png" />
98
<link rel="apple-touch-icon" sizes="72x72" href="%PUBLID_URL%/icons/icon-72x72.png" />

app/src/App.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,4 +75,5 @@ body,
7575
#root {
7676
min-height: 100vh;
7777
width: 100%;
78+
min-width: 1024px;
7879
}

app/src/__stories__/ChannelRow.stories.tsx

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import React from 'react';
22
import { useObserver } from 'mobx-react-lite';
3+
import { SwapState, SwapType } from 'types/generated/loop_pb';
34
import { SwapDirection } from 'types/state';
45
import { lndListChannels } from 'util/tests/sampleData';
56
import { useStore } from 'store';
@@ -87,3 +88,37 @@ export const Dimmed = () => {
8788
store.buildSwapStore.setDirection(SwapDirection.OUT);
8889
return renderStory(channel);
8990
};
91+
92+
export const LoopingIn = () => {
93+
const store = useStore();
94+
const channel = new Channel(store, lndListChannels.channelsList[0]);
95+
const swap = store.swapStore.sortedSwaps[0];
96+
swap.type = SwapType.LOOP_IN;
97+
swap.state = SwapState.INITIATED;
98+
store.swapStore.addSwappedChannels(swap.id, [channel.chanId]);
99+
return renderStory(channel, { ratio: 0.3 });
100+
};
101+
102+
export const LoopingOut = () => {
103+
const store = useStore();
104+
const channel = new Channel(store, lndListChannels.channelsList[0]);
105+
const swap = store.swapStore.sortedSwaps[0];
106+
swap.type = SwapType.LOOP_OUT;
107+
swap.state = SwapState.INITIATED;
108+
store.swapStore.addSwappedChannels(swap.id, [channel.chanId]);
109+
return renderStory(channel, { ratio: 0.3 });
110+
};
111+
112+
export const LoopingInAndOut = () => {
113+
const store = useStore();
114+
const channel = new Channel(store, lndListChannels.channelsList[0]);
115+
const swap1 = store.swapStore.sortedSwaps[0];
116+
swap1.type = SwapType.LOOP_IN;
117+
swap1.state = SwapState.INITIATED;
118+
store.swapStore.addSwappedChannels(swap1.id, [channel.chanId]);
119+
const swap2 = store.swapStore.sortedSwaps[1];
120+
swap2.type = SwapType.LOOP_OUT;
121+
swap2.state = SwapState.INITIATED;
122+
store.swapStore.addSwappedChannels(swap2.id, [channel.chanId]);
123+
return renderStory(channel, { ratio: 0.3 });
124+
};

app/src/__tests__/components/loop/ChannelBalance.spec.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ describe('ChannelBalance component', () => {
4040
const { el, remote, local } = render(0.52);
4141
expect(el.children.length).toBe(3);
4242
expect(width(local)).toBe('52%');
43-
expect(bgColor(local)).toBe('rgb(246, 107, 28)');
44-
expect(bgColor(remote)).toBe('rgb(246, 107, 28)');
43+
expect(bgColor(local)).toBe('rgb(255, 249, 23)');
44+
expect(bgColor(remote)).toBe('rgb(255, 249, 23)');
4545
});
4646

4747
it('should display a bad balance', () => {

app/src/__tests__/components/loop/ChannelRow.spec.tsx

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import React from 'react';
2+
import { SwapState, SwapType } from 'types/generated/loop_pb';
23
import { SwapDirection } from 'types/state';
34
import { fireEvent } from '@testing-library/react';
45
import { formatSats } from 'util/formatters';
56
import { renderWithProviders } from 'util/tests';
67
import { createStore, Store } from 'store';
7-
import { Channel } from 'store/models';
8+
import { Channel, Swap } from 'store/models';
89
import ChannelRow from 'components/loop/ChannelRow';
910

1011
describe('ChannelRow component', () => {
@@ -54,6 +55,16 @@ describe('ChannelRow component', () => {
5455
expect(getByText(channel.aliasLabel)).toBeInTheDocument();
5556
});
5657

58+
it('should display the peer pubkey & alias tooltip', () => {
59+
const { getByText, getAllByText } = render();
60+
channel.alias = 'test-alias';
61+
fireEvent.mouseEnter(getByText(channel.aliasLabel));
62+
expect(getByText(channel.remotePubkey)).toBeInTheDocument();
63+
expect(getAllByText(channel.alias)).toHaveLength(2);
64+
channel.alias = channel.remotePubkey.substring(12);
65+
expect(getByText(channel.remotePubkey)).toBeInTheDocument();
66+
});
67+
5768
it('should display the capacity', () => {
5869
const { getByText } = render();
5970
expect(
@@ -121,4 +132,44 @@ describe('ChannelRow component', () => {
121132
fireEvent.click(getByRole('checkbox'));
122133
expect(store.buildSwapStore.selectedChanIds).toEqual([]);
123134
});
135+
136+
describe('pending swaps', () => {
137+
let swap1: Swap;
138+
let swap2: Swap;
139+
140+
beforeEach(() => {
141+
swap1 = store.swapStore.sortedSwaps[0];
142+
swap2 = store.swapStore.sortedSwaps[1];
143+
swap1.state = swap2.state = SwapState.INITIATED;
144+
});
145+
146+
it('should display the pending Loop In icon', () => {
147+
swap1.type = SwapType.LOOP_IN;
148+
store.swapStore.addSwappedChannels(swap1.id, [channel.chanId]);
149+
const { getByText } = render();
150+
expect(getByText('chevrons-right.svg')).toBeInTheDocument();
151+
fireEvent.mouseEnter(getByText('chevrons-right.svg'));
152+
expect(getByText('Loop In currently in progress')).toBeInTheDocument();
153+
});
154+
155+
it('should display the pending Loop Out icon', () => {
156+
swap1.type = SwapType.LOOP_OUT;
157+
store.swapStore.addSwappedChannels(swap1.id, [channel.chanId]);
158+
const { getByText } = render();
159+
expect(getByText('chevrons-left.svg')).toBeInTheDocument();
160+
fireEvent.mouseEnter(getByText('chevrons-left.svg'));
161+
expect(getByText('Loop Out currently in progress')).toBeInTheDocument();
162+
});
163+
164+
it('should display the pending Loop In and Loop Out icon', () => {
165+
swap1.type = SwapType.LOOP_IN;
166+
swap2.type = SwapType.LOOP_OUT;
167+
store.swapStore.addSwappedChannels(swap1.id, [channel.chanId]);
168+
store.swapStore.addSwappedChannels(swap2.id, [channel.chanId]);
169+
const { getByText } = render();
170+
expect(getByText('chevrons.svg')).toBeInTheDocument();
171+
fireEvent.mouseEnter(getByText('chevrons.svg'));
172+
expect(getByText('Loop In and Loop Out currently in progress')).toBeInTheDocument();
173+
});
174+
});
124175
});

app/src/__tests__/components/loop/LoopPage.spec.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ describe('LoopPage component', () => {
1717
beforeEach(async () => {
1818
store = createStore();
1919
await store.fetchAllData();
20+
await store.buildSwapStore.getTerms();
2021
});
2122

2223
const render = () => {
@@ -106,7 +107,7 @@ describe('LoopPage component', () => {
106107
store.channelStore.sortedChannels.slice(0, 1).forEach(c => {
107108
store.buildSwapStore.toggleSelectedChannel(c.chanId);
108109
});
109-
fireEvent.click(getByText('Loop In'));
110+
fireEvent.click(getByText('Loop Out'));
110111
expect(getByText('Step 1 of 2')).toBeInTheDocument();
111112
});
112113

@@ -117,7 +118,7 @@ describe('LoopPage component', () => {
117118
store.channelStore.sortedChannels.slice(0, 1).forEach(c => {
118119
store.buildSwapStore.toggleSelectedChannel(c.chanId);
119120
});
120-
fireEvent.click(getByText('Loop In'));
121+
fireEvent.click(getByText('Loop Out'));
121122
expect(getByText('Step 1 of 2')).toBeInTheDocument();
122123
fireEvent.click(getByText('arrow-left.svg'));
123124
expect(getByText('Loop History')).toBeInTheDocument();

app/src/__tests__/components/loop/ProcessingSwaps.spec.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ describe('ProcessingSwaps component', () => {
4949
const swap = addSwap(LOOP_IN, INITIATED);
5050
expect(getByText('dot.svg')).toHaveClass('warn');
5151
expect(getByText(swap.ellipsedId)).toBeInTheDocument();
52+
expect(getByText(swap.typeName)).toBeInTheDocument();
5253
expect(getByTitle(swap.stateLabel)).toBeInTheDocument();
5354
expect(width(getByTitle(swap.stateLabel))).toBe('25%');
5455
});
@@ -58,6 +59,7 @@ describe('ProcessingSwaps component', () => {
5859
const swap = addSwap(LOOP_IN, HTLC_PUBLISHED);
5960
expect(getByText('dot.svg')).toHaveClass('warn');
6061
expect(getByText(swap.ellipsedId)).toBeInTheDocument();
62+
expect(getByText(swap.typeName)).toBeInTheDocument();
6163
expect(getByTitle(swap.stateLabel)).toBeInTheDocument();
6264
expect(width(getByTitle(swap.stateLabel))).toBe('50%');
6365
});
@@ -67,6 +69,7 @@ describe('ProcessingSwaps component', () => {
6769
const swap = addSwap(LOOP_IN, INVOICE_SETTLED);
6870
expect(getByText('dot.svg')).toHaveClass('warn');
6971
expect(getByText(swap.ellipsedId)).toBeInTheDocument();
72+
expect(getByText(swap.typeName)).toBeInTheDocument();
7073
expect(getByTitle(swap.stateLabel)).toBeInTheDocument();
7174
expect(width(getByTitle(swap.stateLabel))).toBe('75%');
7275
});
@@ -75,6 +78,7 @@ describe('ProcessingSwaps component', () => {
7578
const { getByText, getByTitle } = render();
7679
const swap = addSwap(LOOP_IN, SUCCESS);
7780
expect(getByText(swap.ellipsedId)).toBeInTheDocument();
81+
expect(getByText(swap.typeName)).toBeInTheDocument();
7882
expect(getByTitle(swap.stateLabel)).toBeInTheDocument();
7983
expect(width(getByTitle(swap.stateLabel))).toBe('100%');
8084
});
@@ -92,6 +96,7 @@ describe('ProcessingSwaps component', () => {
9296
const swap = addSwap(LOOP_OUT, INITIATED);
9397
expect(getByText('dot.svg')).toHaveClass('warn');
9498
expect(getByText(swap.ellipsedId)).toBeInTheDocument();
99+
expect(getByText(swap.typeName)).toBeInTheDocument();
95100
expect(getByTitle(swap.stateLabel)).toBeInTheDocument();
96101
expect(width(getByTitle(swap.stateLabel))).toBe('33%');
97102
});
@@ -101,6 +106,7 @@ describe('ProcessingSwaps component', () => {
101106
const swap = addSwap(LOOP_OUT, PREIMAGE_REVEALED);
102107
expect(getByText('dot.svg')).toHaveClass('warn');
103108
expect(getByText(swap.ellipsedId)).toBeInTheDocument();
109+
expect(getByText(swap.typeName)).toBeInTheDocument();
104110
expect(getByTitle(swap.stateLabel)).toBeInTheDocument();
105111
expect(width(getByTitle(swap.stateLabel))).toBe('66%');
106112
});
@@ -110,6 +116,7 @@ describe('ProcessingSwaps component', () => {
110116
const swap = addSwap(LOOP_OUT, SUCCESS);
111117
expect(getByText('dot.svg')).toHaveClass('success');
112118
expect(getByText(swap.ellipsedId)).toBeInTheDocument();
119+
expect(getByText(swap.typeName)).toBeInTheDocument();
113120
expect(getByTitle(swap.stateLabel)).toBeInTheDocument();
114121
expect(width(getByTitle(swap.stateLabel))).toBe('100%');
115122
});

0 commit comments

Comments
 (0)