Files
mirror-3x-ui/frontend/src/test/node-list-online-total.test.tsx
T
Hamed ef99e67507 feat(nodes): add fleet monitoring and implement the Penpot layout (#7342)
Expose sampled CPU topology, absolute RAM, TCP/UDP counts, load averages and network throughput through the existing heartbeat and descendant contracts, preserving measured zero versus unavailable values. Add an explicit nullable telemetry migration and freshness/availability checks.

Provide read-only All nodes and Master rows with deduplicated host/client totals, grouped SQL aggregation and reporting coverage. Preserve known descendants during parent outages and prefer the freshest valid observation of shared GUIDs. Keep the ordinary heartbeat broadcast free of fleet-wide totals.

Implement the approved compact Penpot-inspired Nodes layout, responsive stacked details, status diagnostics and existing remote actions. Preserve cached rows, search and controls on overview refresh failures. By maintainer decision, hide both system rows when no remote nodes are registered.

Final review of 44ed457985: no outstanding HIGH or MEDIUM findings. CI and Docs CI passed (13 jobs; 2342 frontend tests in 269 files), including Go/race and mixed-version node E2E. Feature-specific PostgreSQL regression execution was not independently verified in the selected CI logs. See https://github.com/MHSanaei/3x-ui/pull/7342#issuecomment-7363599190.

Closes #7335
Closes #7336
Closes #7337
2026-12-03 04:19:48 +03:30

69 lines
2.0 KiB
TypeScript

import { screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import { describe, expect, it } from 'vitest';
import NodeList from '@/pages/nodes/NodeList';
import type { NodeRecord } from '@/schemas/node';
import { renderWithProviders } from './test-utils';
const noop = () => {};
function renderNode(counts: Pick<NodeRecord, 'onlineCount' | 'onlineTotalCount'>) {
const node: NodeRecord = {
id: 1,
name: 'edge',
guid: 'e1',
enable: true,
status: 'online',
clientCount: 40,
...counts,
};
renderWithProviders(
<NodeList
nodes={[node]}
selectedIds={[]}
onSelectionChange={noop}
onAdd={noop}
onMtls={noop}
onEdit={noop}
onDelete={noop}
onProbe={noop}
onToggleEnable={noop}
onUpdateNode={noop}
onUpdateSelected={noop}
onRestart={noop}
/>,
);
}
// The online badge counts only clients of inbounds imported into this panel, so a node busy on
// its other inbounds looked idle; the node's own total must show beside that count.
describe('NodeList online total', () => {
it('shows synced / total and explains both numbers on hover', async () => {
renderNode({ onlineCount: 3, onlineTotalCount: 12 });
await userEvent.hover(screen.getByText('3 / 12'));
expect((await screen.findByRole('tooltip')).textContent).toBe(
'3 online on inbounds imported into this panel, 12 online on the node in total',
);
});
it('shows the total when no synced client is online', () => {
renderNode({ onlineCount: 0, onlineTotalCount: 5 });
expect(screen.getByText('0 / 5')).toBeTruthy();
});
it.each<[string, Pick<NodeRecord, 'onlineCount' | 'onlineTotalCount'>]>([
['the total equals the synced count', { onlineCount: 7, onlineTotalCount: 7 }],
['the panel reports no total', { onlineCount: 7 }],
])('keeps the single number when %s', (_name, counts) => {
renderNode(counts);
expect(screen.getByText('7')).toBeTruthy();
expect(screen.queryByText(/^\d+ \/ \d+$/)).toBeNull();
});
});