Skip to content

Commit 412e662

Browse files
committed
test: seed the lifecycle control in the panels that now render it
AppsPanel and EntityDetailPanel carry the entity lifecycle control, so their tests need the store keys it reads and a TooltipProvider around the render, the way App.tsx provides one. Without them the panels threw on mount and the Scripts tab assertions could not run.
1 parent a69978d commit 412e662

2 files changed

Lines changed: 25 additions & 3 deletions

File tree

‎src/components/AppsPanel.test.tsx‎

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import { describe, it, expect, vi, beforeEach } from 'vitest';
1616
import { render, screen, waitFor } from '@testing-library/react';
1717
import userEvent from '@testing-library/user-event';
18+
import { TooltipProvider } from '@/components/ui/tooltip';
1819
import { AppsPanel } from './AppsPanel';
1920

2021
vi.mock('@/components/ScriptsPanel', () => ({
@@ -30,15 +31,28 @@ const mockState = {
3031
fetchEntityOperations: vi.fn().mockResolvedValue([]),
3132
listEntityFaults: vi.fn().mockResolvedValue({ items: [], count: 0 }),
3233
scriptsSupported: false,
34+
// EntityStatusControl reads these from the store; inert values keep the
35+
// control mounted without reaching the network.
36+
client: null,
37+
statusByEntity: {},
38+
actuationByEntity: {},
39+
watchEntityStatus: vi.fn(() => () => {}),
3340
};
3441

3542
vi.mock('@/lib/store', () => ({
3643
useAppStore: vi.fn((selector) => selector(mockState)),
44+
entityStatusKey: (entityType: string, entityId: string) => `${entityType}:${entityId}`,
3745
}));
3846

3947
function renderAppsPanel(overrides: Partial<typeof mockState> = {}) {
4048
Object.assign(mockState, { scriptsSupported: false }, overrides);
41-
return render(<AppsPanel appId="talker" appName="Talker" path="/server/ecu/talker" />);
49+
// App.tsx wraps the tree in a TooltipProvider, and the panel renders a
50+
// tooltip for any lifecycle action the current status does not allow.
51+
return render(
52+
<TooltipProvider>
53+
<AppsPanel appId="talker" appName="Talker" path="/server/ecu/talker" />
54+
</TooltipProvider>
55+
);
4256
}
4357

4458
describe('AppsPanel scripts tab', () => {

‎src/components/EntityDetailPanel.test.tsx‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,11 @@ describe('EntityDetailPanel - scripts tab gating (component view)', () => {
176176
scriptsSupported: false,
177177
});
178178

179-
render(<EntityDetailPanel onConnectClick={() => {}} />);
179+
render(
180+
<TooltipProvider>
181+
<EntityDetailPanel onConnectClick={() => {}} />
182+
</TooltipProvider>
183+
);
180184

181185
await waitFor(() => {
182186
expect(screen.getByRole('button', { name: /Data/ })).toBeInTheDocument();
@@ -195,7 +199,11 @@ describe('EntityDetailPanel - scripts tab gating (component view)', () => {
195199
scriptsSupported: true,
196200
});
197201

198-
render(<EntityDetailPanel onConnectClick={() => {}} />);
202+
render(
203+
<TooltipProvider>
204+
<EntityDetailPanel onConnectClick={() => {}} />
205+
</TooltipProvider>
206+
);
199207

200208
const scriptsButton = await screen.findByRole('button', { name: /scripts/i });
201209
fireEvent.click(scriptsButton);

0 commit comments

Comments
 (0)