Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

Keep Docs and reconnect coverage faithful to their contracts

pulse-triage[bot]748678e7a810
diff --git a/frontend-modern/src/__tests__/useAppRuntimeState.test.ts b/frontend-modern/src/__tests__/useAppRuntimeState.test.ts
index fed0833b99..483011bee5 100644
--- a/frontend-modern/src/__tests__/useAppRuntimeState.test.ts
+++ b/frontend-modern/src/__tests__/useAppRuntimeState.test.ts
@@ -80,6 +80,8 @@ describe('useAppRuntimeState', () => {
let websocketConnected: boolean;
let websocketReconnecting: boolean;
let websocketInitialDataReceived: boolean;
+ let onStoreAcquired: (() => void) | undefined;
+ const mountedRoots = new Set<() => void>();
beforeEach(async () => {
vi.resetModules();
@@ -159,17 +161,22 @@ describe('useAppRuntimeState', () => {
websocketConnected = false;
websocketReconnecting = false;
websocketInitialDataReceived = false;
+ onStoreAcquired = undefined;
vi.doMock('@/stores/websocket-global', () => ({
- getGlobalWebSocketStore: () => ({
- state: websocketState,
- connected: () => websocketConnected,
- reconnecting: () => websocketReconnecting,
- initialDataReceived: () => websocketInitialDataReceived,
- resourceSnapshotReceived: () => websocketInitialDataReceived,
- reconnect: vi.fn(),
- switchUrl: vi.fn(),
- }),
+ getGlobalWebSocketStore: () => {
+ const store = {
+ state: websocketState,
+ connected: () => websocketConnected,
+ reconnecting: () => websocketReconnecting,
+ initialDataReceived: () => websocketInitialDataReceived,
+ resourceSnapshotReceived: () => websocketInitialDataReceived,
+ reconnect: vi.fn(),
+ switchUrl: vi.fn(),
+ };
+ onStoreAcquired?.();
+ return store;
+ },
}));
vi.doMock('@/utils/logger', () => ({
@@ -305,6 +312,10 @@ describe('useAppRuntimeState', () => {
});
afterEach(async () => {
+ // A failed assertion must not leave a root/interval alive in the next case.
+ for (const dispose of mountedRoots) dispose();
+ mountedRoots.clear();
+ onStoreAcquired = undefined;
vi.clearAllMocks();
window.localStorage.removeItem('org_id');
window.localStorage.removeItem('just_logged_out');
@@ -318,7 +329,11 @@ describe('useAppRuntimeState', () => {
let hookState: ReturnType<UseAppRuntimeStateModule['useAppRuntimeState']>;
createRoot((d) => {
- dispose = d;
+ dispose = () => {
+ d();
+ mountedRoots.delete(dispose);
+ };
+ mountedRoots.add(dispose);
hookState = useAppRuntimeState();
});
@@ -854,13 +869,17 @@ describe('useAppRuntimeState', () => {
throw new Error(`Unhandled apiFetch URL: ${url}`);
});
- const { hookState, dispose } = mountHook();
-
- await waitFor(() => {
- expect(hookState.needsAuth()).toBe(false);
- expect(hookState.reconnecting()).toBe(true);
+ // This hook-only fixture has no DOM transition to poll. Wait for its
+ // actual acquisition boundary, then check every retained-state contract.
+ // A bootstrap that never acquires the store still hits the normal deadline.
+ const acquired = new Promise<void>((resolve) => {
+ onStoreAcquired = resolve;
});
+ const { hookState, dispose } = mountHook();
+ await acquired;
+ expect(hookState.needsAuth()).toBe(false);
+ expect(hookState.reconnecting()).toBe(true);
expect(hookState.enhancedStore()?.initialDataReceived()).toBe(false);
expect(hookState.runtimeStateResolved()).toBe(true);
expect(hookState.state().resources).toEqual([retainedResource]);
diff --git a/frontend-modern/src/pages/__tests__/Docs.navigation.test.tsx b/frontend-modern/src/pages/__tests__/Docs.navigation.test.tsx
index 25a1c61926..a73abb78a9 100644
--- a/frontend-modern/src/pages/__tests__/Docs.navigation.test.tsx
+++ b/frontend-modern/src/pages/__tests__/Docs.navigation.test.tsx
@@ -153,7 +153,7 @@ describe('Docs section navigation', () => {
});
it.each(['html fallback', 'read failure'])(
- 'retains a truthful missing-document state on %s without targeting the prior content',
+ 'does not target prior content after %s while the next guide is unavailable',
async (failure) => {
renderGuide();
await screen.findByRole('heading', { name: 'Existing section' });
@@ -165,9 +165,15 @@ describe('Docs section navigation', () => {
: new Response('unavailable', { status: 503 }),
);
fireEvent.click(screen.getByRole('link', { name: 'Next guide' }));
- await screen.findByText(
- "That document is not part of this installation's shipped documentation set.",
- );
+ if (failure === 'html fallback') {
+ await screen.findByText(
+ "That document is not part of this installation's shipped documentation set.",
+ );
+ } else {
+ // A 503 does not establish absence (#3102). This navigation regression
+ // checks stale-content focus, not the separate load-recovery copy.
+ await screen.findByRole('link', { name: 'Back to the documentation index' });
+ }
flushFrames();
expect(scrollIntoView).not.toHaveBeenCalled();
expect(screen.queryByRole('heading', { name: 'Existing section' })).not.toBeInTheDocument();