Skip to content

Commit aa86abe

Browse files
committed
stories: fix broken stories due to auth changes
1 parent 52031fb commit aa86abe

File tree

4 files changed

+45
-31
lines changed

4 files changed

+45
-31
lines changed

app/src/__stories__/HistoryPage.stories.tsx

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React from 'react';
22
import { SwapState, SwapType } from 'types/generated/loop_pb';
33
import { useStore } from 'store';
4+
import { Swap } from 'store/models';
45
import HistoryPage from 'components/history/HistoryPage';
56
import { Layout } from 'components/layout';
67

@@ -10,24 +11,28 @@ export default {
1011
parameters: { contained: true },
1112
};
1213

14+
const updateSwapsStatus = (swaps: Swap[]) => {
15+
swaps.forEach((s, i) => {
16+
if (s.typeName === 'Unknown') s.type = SwapType.LOOP_IN;
17+
if (i === 0) s.state = SwapState.INITIATED;
18+
if (i === 1) s.state = SwapState.PREIMAGE_REVEALED;
19+
if (i === 2) s.state = SwapState.HTLC_PUBLISHED;
20+
if (i === 3) s.state = SwapState.INVOICE_SETTLED;
21+
});
22+
};
23+
1324
export const Default = () => {
1425
const store = useStore();
1526
store.swapStore.stopAutoPolling();
16-
store.swapStore.sortedSwaps.forEach((s, i) => {
17-
if (s.typeName === 'Unknown') s.type = SwapType.LOOP_IN;
18-
if (i === 0) s.state = SwapState.INVOICE_SETTLED;
19-
});
27+
updateSwapsStatus(store.swapStore.sortedSwaps);
2028
return <HistoryPage />;
2129
};
2230

2331
export const InsideLayout = () => {
2432
const store = useStore();
2533
store.uiStore.page = 'history';
2634
store.swapStore.stopAutoPolling();
27-
store.swapStore.sortedSwaps.forEach((s, i) => {
28-
if (s.typeName === 'Unknown') s.type = SwapType.LOOP_IN;
29-
if (i === 0) s.state = SwapState.INVOICE_SETTLED;
30-
});
35+
updateSwapsStatus(store.swapStore.sortedSwaps);
3136
return (
3237
<Layout>
3338
<HistoryPage />

app/src/__stories__/Layout.stories.tsx

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,27 @@ export default {
88
component: Layout,
99
};
1010

11-
export const Default = () => <Layout />;
11+
export const Default = () => {
12+
const { uiStore } = useStore();
13+
uiStore.goToLoop();
1214

13-
export const WithContent = () => (
14-
<Layout>
15-
<LoopPage />
16-
</Layout>
17-
);
15+
return <Layout />;
16+
};
17+
18+
export const WithContent = () => {
19+
const { uiStore } = useStore();
20+
uiStore.goToLoop();
21+
return (
22+
<Layout>
23+
<LoopPage />
24+
</Layout>
25+
);
26+
};
1827

1928
export const Collapsed = () => {
20-
const store = useStore();
21-
store.settingsStore.sidebarVisible = false;
29+
const { uiStore, settingsStore } = useStore();
30+
uiStore.goToLoop();
31+
settingsStore.sidebarVisible = false;
2232

2333
return (
2434
<Layout>
Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useEffect } from 'react';
1+
import React from 'react';
22
import { useStore } from 'store';
33
import { Layout } from 'components/layout';
44
import LoopPage from 'components/loop/LoopPage';
@@ -11,23 +11,20 @@ export default {
1111

1212
export const Default = () => {
1313
const store = useStore();
14-
useEffect(() => {
15-
// only use a small set of channels
16-
store.channelStore.sortedChannels.splice(10);
17-
18-
// change back to sample data when the component is unmounted
19-
return () => {
20-
store.channelStore.fetchChannels();
21-
};
22-
}, []);
14+
// only use a small set of channels
15+
store.channelStore.sortedChannels.splice(10);
2316

2417
return <LoopPage />;
2518
};
2619

2720
export const ManyChannels = () => <LoopPage />;
2821

29-
export const InsideLayout = () => (
30-
<Layout>
31-
<LoopPage />
32-
</Layout>
33-
);
22+
export const InsideLayout = () => {
23+
const store = useStore();
24+
store.uiStore.goToLoop();
25+
return (
26+
<Layout>
27+
<LoopPage />
28+
</Layout>
29+
);
30+
};

app/src/__stories__/SettingsPage.stories.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ export const BalanceMode = () => {
2626
};
2727

2828
export const InsideLayout = () => {
29+
const { uiStore } = useStore();
30+
uiStore.goToSettings();
2931
return (
3032
<Layout>
3133
<SettingsPage />

0 commit comments

Comments
 (0)