From 8fd72b947a5ff09d86e6c1fbf0f680e99bdda367 Mon Sep 17 00:00:00 2001 From: archipelago Date: Tue, 28 Jul 2026 05:55:12 -0400 Subject: [PATCH] =?UTF-8?q?test(ui):=20adapt=20SWR=20contract=20tests=20to?= =?UTF-8?q?=20the=20cached-resource=20layer=20=E2=80=94=20692/692?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The keeps-data-visible-while-refreshing tests for PeerFiles, Server, and LightningChannels mounted without Pinia (the converted components now pull the resources store in setup) — add createPinia to the mounts. LightningChannelsPanel: refresh the main channel list before the closed history so the primary entry gets the first response, and null-guard both fetchers' response shapes. Co-Authored-By: Claude Fable 5 --- neode-ui/src/components/LightningChannelsPanel.vue | 11 ++++++----- neode-ui/src/views/__tests__/PeerFilesRefresh.test.ts | 3 +++ .../src/views/__tests__/ServerNetworkRefresh.test.ts | 3 +++ 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/neode-ui/src/components/LightningChannelsPanel.vue b/neode-ui/src/components/LightningChannelsPanel.vue index 696218a0..6597aac8 100644 --- a/neode-ui/src/components/LightningChannelsPanel.vue +++ b/neode-ui/src/components/LightningChannelsPanel.vue @@ -474,9 +474,9 @@ const channelsRes = useCachedResource({ method: 'lnd.listchannels', timeout: 15000, signal, dedup: true, maxRetries: 1, }) return { - channels: result.channels || [], - total_inbound: result.total_inbound || 0, - total_outbound: result.total_outbound || 0, + channels: result?.channels || [], + total_inbound: result?.total_inbound || 0, + total_outbound: result?.total_outbound || 0, } }, }) @@ -486,7 +486,7 @@ const closedRes = useCachedResource({ const closed = await rpcClient.call<{ channels: ClosedChannel[] }>({ method: 'lnd.closedchannels', timeout: 15000, signal, dedup: true, maxRetries: 1, }) - return closed.channels || [] + return closed?.channels || [] }, }) const loading = computed(() => @@ -570,8 +570,9 @@ function capacityPercent(amount: number, capacity: number): number { } function loadChannels(): Promise { + const main = channelsRes.refresh() void closedRes.refresh() - return channelsRes.refresh() + return main } function feeParams(): { target_conf?: number; sat_per_vbyte?: number } | null { diff --git a/neode-ui/src/views/__tests__/PeerFilesRefresh.test.ts b/neode-ui/src/views/__tests__/PeerFilesRefresh.test.ts index 1c9ce24d..21277387 100644 --- a/neode-ui/src/views/__tests__/PeerFilesRefresh.test.ts +++ b/neode-ui/src/views/__tests__/PeerFilesRefresh.test.ts @@ -1,5 +1,6 @@ import { flushPromises, mount } from '@vue/test-utils' import { describe, expect, it, vi } from 'vitest' +import { createPinia } from 'pinia' import PeerFiles from '../PeerFiles.vue' import { rpcClient } from '@/api/rpc-client' @@ -55,6 +56,8 @@ describe('PeerFiles', () => { const wrapper = mount(PeerFiles, { props: { peerId: 'peer.onion' }, global: { + // The shared peer-browse cache lives in the Pinia resources store. + plugins: [createPinia()], stubs: { Teleport: true, }, diff --git a/neode-ui/src/views/__tests__/ServerNetworkRefresh.test.ts b/neode-ui/src/views/__tests__/ServerNetworkRefresh.test.ts index eed224b1..6f00e44a 100644 --- a/neode-ui/src/views/__tests__/ServerNetworkRefresh.test.ts +++ b/neode-ui/src/views/__tests__/ServerNetworkRefresh.test.ts @@ -1,5 +1,6 @@ import { flushPromises, mount } from '@vue/test-utils' import { describe, expect, it, vi } from 'vitest' +import { createPinia } from 'pinia' import Server from '../Server.vue' import { rpcClient } from '@/api/rpc-client' @@ -29,6 +30,8 @@ function deferred() { function mountServer(options: { renderTorServices?: boolean } = {}) { return mount(Server, { global: { + // The cached-resource layer pulls the Pinia resources store in setup. + plugins: [createPinia()], stubs: { QuickActionsCard: true, TorServicesCard: options.renderTorServices ? false : true,