Skip to content

Commit 61a6e3c

Browse files
Fixed Tests
1 parent 01e5f0c commit 61a6e3c

5 files changed

Lines changed: 14 additions & 19 deletions

File tree

apps/frontend/src/components/cln/CLNOffersList/CLNOffersList.test.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { screen, within } from '@testing-library/react';
2-
import { mockAppStore, mockBKPRStoreData, mockCLNStoreData, mockListOffers, mockRootStoreData } from '../../../utilities/test-utilities/mockData';
2+
import { mockAppStore, mockBKPRStoreData, mockCLNStoreData, mockRootStoreData } from '../../../utilities/test-utilities/mockData';
33
import { renderWithProviders } from '../../../utilities/test-utilities/mockStore';
44
import CLNOffersList from './CLNOffersList';
55

@@ -10,8 +10,10 @@ describe('CLNOffersList component ', () => {
1010
cln: {
1111
...mockCLNStoreData,
1212
listOffers: {
13-
...mockListOffers,
14-
isLoading: true
13+
isLoading: true,
14+
page: 1,
15+
hasMore: true,
16+
offers: []
1517
}
1618
},
1719
bkpr: mockBKPRStoreData

apps/frontend/src/components/cln/CLNTransactionsList/CLNTransactionsList.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ describe('CLNTransactionsList component ', () => {
7575
bkpr: mockBKPRStoreData
7676
};
7777
await renderWithProviders(<CLNTransactionsList />, { preloadedState: customMockStore, initialRoute: ['/cln'] });
78-
expect(screen.getByText('No transaction found. Open channel to start!')).toBeInTheDocument();
78+
expect(screen.getByText('No channel found. Open channel to start!')).toBeInTheDocument();
7979
});
8080

8181
it('if there are are active channels, show the text saying to use a channel', async () => {

apps/frontend/src/utilities/bookkeeper-sql.ts

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,4 @@ export const SatsFlowSQL = (startTimestamp: number, endTimestamp: number): strin
2929
endTimestamp +
3030
';';
3131

32-
export const VolumeSQL =
33-
'SELECT in_channel, ' +
34-
'(SELECT peer_id FROM peerchannels WHERE peerchannels.short_channel_id=in_channel) AS in_channel_peerid, ' +
35-
'(SELECT nodes.alias FROM nodes WHERE nodes.nodeid=(SELECT peer_id FROM peerchannels WHERE peerchannels.short_channel_id=in_channel)) AS in_channel_peer_alias, ' +
36-
'SUM(in_msat), ' +
37-
'out_channel, ' +
38-
'(SELECT peer_id FROM peerchannels WHERE peerchannels.short_channel_id=out_channel) AS out_channel_peerid, ' +
39-
'(SELECT nodes.alias FROM nodes WHERE nodes.nodeid=(SELECT peer_id FROM peerchannels WHERE peerchannels.short_channel_id=out_channel)) AS out_channel_peer_alias, ' +
40-
'SUM(out_msat), ' +
41-
'SUM(fee_msat) ' +
42-
'FROM forwards ' +
43-
"WHERE forwards.status='settled' " +
44-
'GROUP BY in_channel, out_channel;';
32+
export const VolumeSQL = "SELECT f.in_channel, pc_in.peer_id AS in_channel_peerid, n_in.alias AS in_channel_peer_alias, SUM(f.in_msat) AS total_in_msat, f.out_channel, pc_out.peer_id AS out_channel_peerid, n_out.alias AS out_channel_peer_alias, SUM(f.out_msat) AS total_out_msat, SUM(f.fee_msat) AS total_fee_msat FROM forwards f LEFT JOIN peerchannels pc_in ON pc_in.short_channel_id = f.in_channel LEFT JOIN nodes n_in ON n_in.nodeid = pc_in.peer_id LEFT JOIN peerchannels pc_out ON pc_out.short_channel_id = f.out_channel LEFT JOIN nodes n_out ON n_out.nodeid = pc_out.peer_id WHERE f.status = 'settled' GROUP BY f.in_channel, pc_in.peer_id, n_in.alias, f.out_channel, pc_out.peer_id, n_out.alias;";

apps/frontend/src/utilities/test-utilities/mockData.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -636,6 +636,11 @@ export const mockActiveChannels = [mockActiveChannel1, mockActiveChannel2, mockA
636636
export const mockPendingChannels = [];
637637
export const mockInactiveChannels = [];
638638

639+
export const mockListChannelsAPIRes = {
640+
channels: [...mockActiveChannels, ...mockPendingChannels, ...mockInactiveChannels],
641+
isLoading: false
642+
};
643+
639644
export const mockListChannels = {
640645
activeChannels: mockActiveChannels,
641646
pendingChannels: mockPendingChannels,

apps/frontend/src/utilities/test-utilities/mockService.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import SHA256 from 'crypto-js/sha256';
22
import { BookkeeperService, CLNService, RootService } from '../../services/http.service';
3-
import { mockAccountEventsData, mockAuthStatus, mockDecodedInvoice, mockFetchInvoice, mockInvoiceRune, mockListChannels, mockListFunds, mockNewAddr, mockNodeInfo, mockSatsFlowData, mockSendPayment, mockSQLResponse, mockVolumeData } from '../../utilities/test-utilities/mockData';
3+
import { mockAccountEventsData, mockAuthStatus, mockDecodedInvoice, mockFetchInvoice, mockInvoiceRune, mockListChannelsAPIRes, mockListFunds, mockNewAddr, mockNodeInfo, mockSatsFlowData, mockSendPayment, mockSQLResponse, mockVolumeData } from '../../utilities/test-utilities/mockData';
44

55
export const spyOnUserLogin = () => (
66
jest.spyOn(RootService, 'userLogin').mockImplementation(async (password) => {
@@ -19,7 +19,7 @@ export const spyOnGetInfo = () => (
1919
);
2020

2121
export const spyOnListChannels = () => (
22-
jest.spyOn(RootService, 'listChannels').mockImplementation(async () => mockListChannels)
22+
jest.spyOn(RootService, 'listChannels').mockImplementation(async () => mockListChannelsAPIRes)
2323
);
2424

2525
export const spyOnListFunds = () => (

0 commit comments

Comments
 (0)