From 64ed2175a5161aa726c04ef7956871a0d5155dbd Mon Sep 17 00:00:00 2001 From: Maurice Date: Mon, 26 Oct 2026 00:57:56 +0100 Subject: [PATCH] fix(plugins): keep the API client and the panel test within their size entries, drop an unused import --- client/src/api/client.ts | 11 ++------- .../Admin/AdminPluginsPanel.test.tsx | 24 +++++-------------- .../components/Admin/AdminPluginsPanel.tsx | 2 +- .../Admin/plugins/usePluginsAdmin.test.ts | 2 +- 4 files changed, 10 insertions(+), 29 deletions(-) diff --git a/client/src/api/client.ts b/client/src/api/client.ts index 9d75b8186..fa7dc7b24 100644 --- a/client/src/api/client.ts +++ b/client/src/api/client.ts @@ -65,7 +65,6 @@ import { type PluginInstanceConfigUpdated, type PluginActionDescriptor, type PluginActionResult, - type PluginActivateRequest, type PluginInstallRequest, RoadtripDayTrack, RoadtripVia, @@ -575,15 +574,9 @@ export const adminApi = { plugins: () => apiClient.get('/admin/plugins').then(r => r.data), pluginBrowse: (refresh?: boolean) => apiClient.get('/admin/plugins/registry', { params: refresh ? { refresh: 1 } : undefined }).then(r => r.data), pluginDetail: (id: string) => apiClient.get(`/admin/plugins/registry/${encodeURIComponent(id)}`).then(r => r.data), - pluginInstall: (id: string, opts?: Pick) => + pluginInstall: (id: string, opts?: Omit) => apiClient.post('/admin/plugins/install', { id, ...opts } satisfies PluginInstallRequest).then(r => r.data), - pluginActivate: (id: string, consent?: boolean, acceptTrekRange?: boolean) => - apiClient - .post(`/admin/plugins/${id}/activate`, { - ...(consent ? { consent: true } : {}), - ...(acceptTrekRange ? { acceptTrekRange: true } : {}), - } satisfies PluginActivateRequest) - .then(r => r.data), + pluginActivate: (id: string, consent?: boolean, accept?: boolean) => apiClient.post(`/admin/plugins/${id}/activate`, { consent: consent || undefined, acceptTrekRange: accept || undefined }).then(r => r.data), pluginDeactivate: (id: string) => apiClient.post(`/admin/plugins/${id}/deactivate`).then(r => r.data), // `version` pins the exact version to install (the rollback path); omitted, the server // resolves the newest TREK-compatible version itself. diff --git a/client/src/components/Admin/AdminPluginsPanel.test.tsx b/client/src/components/Admin/AdminPluginsPanel.test.tsx index c32858068..0fc27b390 100644 --- a/client/src/components/Admin/AdminPluginsPanel.test.tsx +++ b/client/src/components/Admin/AdminPluginsPanel.test.tsx @@ -549,15 +549,10 @@ function panelRoot(container: HTMLElement): HTMLElement { } /** Opens one of the toolbar dropdowns (identified by its current title) and picks an option. */ -/** The toolbar's one Filter button: type, status and order sit in its menu. */ -function filterButton(): HTMLElement { - return screen.getByRole('button', { name: /^Filter/ }) -} - -/** Picks one entry of the filter menu, opening it first when it is closed (a pick leaves it open). */ +/** The toolbar's one Filter button; a pick in its menu leaves the menu open. */ +const filterButton = (): HTMLElement => screen.getByRole('button', { name: /^Filter/ }) async function pickFilter(option: RegExp) { - await screen.findByRole('button', { name: /^Filter/ }) - if (filterButton().getAttribute('aria-expanded') !== 'true') fireEvent.click(filterButton()) + if ((await screen.findByRole('button', { name: /^Filter/ })).getAttribute('aria-expanded') !== 'true') fireEvent.click(filterButton()) fireEvent.click(await screen.findByRole('menuitemradio', { name: option })) } @@ -653,10 +648,8 @@ describe('AdminPluginsPanel — load states and toolbar', () => { await pickFilter(/^Updates first$/) expect(filterButton()).toHaveTextContent('Updates first') - await clickDiscover() - await waitFor(() => expect(filterButton()).not.toHaveTextContent('Updates first')) - expect(filterButton()).toHaveTextContent('Name') + await waitFor(() => expect(filterButton()).toHaveTextContent(/Name$/)) }) it('FE-COMP-PLUGINS-PANEL-008: rescan re-pulls the registry past its cache and confirms with a toast', async () => { @@ -1794,10 +1787,8 @@ describe('AdminPluginsPanel toolbar and dialogs', () => { await pickFilter(user, /^Updates first$/) expect(filterButton()).toHaveTextContent('Updates first') - await user.click(screen.getByRole('tab', { name: /Discover/ })) - await waitFor(() => expect(filterButton()).not.toHaveTextContent('Updates first')) - expect(filterButton()).toHaveTextContent('Name') + await waitFor(() => expect(filterButton()).toHaveTextContent(/Name$/)) }) it('FE-W5PLG-007: the registry sorts by downloads and by review date', async () => { @@ -2017,10 +2008,8 @@ describe('AdminPluginsPanel registry cards and dependency chips', () => { await user.click(filterButton()) await user.click(screen.getByRole('menuitemradio', { name: /^Most downloads$/ })) expect(filterButton()).toHaveTextContent('Most downloads') - await user.click(screen.getByRole('tab', { name: /Installed/ })) - await waitFor(() => expect(filterButton()).not.toHaveTextContent('Most downloads')) - expect(filterButton()).toHaveTextContent('Name') + await waitFor(() => expect(filterButton()).toHaveTextContent(/Name$/)) }) it('FE-W5PLG-017: an outrun release offers the newest compatible version instead of a dead button', async () => { @@ -2038,7 +2027,6 @@ describe('AdminPluginsPanel registry cards and dependency chips', () => { expect(offer).toHaveAttribute('title', expect.stringContaining('3.5.0')) // Nothing fits: no dead button any more, but a card that says so before anything installs. - expect(screen.queryByRole('button', { name: /^Incompatible$/ })).not.toBeInTheDocument() expect(screen.getByText(/^Not confirmed for TREK .+ yet$/)).toBeInTheDocument() }) diff --git a/client/src/components/Admin/AdminPluginsPanel.tsx b/client/src/components/Admin/AdminPluginsPanel.tsx index 9b2d1644b..b866e693c 100644 --- a/client/src/components/Admin/AdminPluginsPanel.tsx +++ b/client/src/components/Admin/AdminPluginsPanel.tsx @@ -24,7 +24,7 @@ import { } from '../Settings/settingsKit' import { KNOWN_TYPES, PERM_KEYS, blockIsCurrent, dependencyRows, fingerprint, formatCompactCount, - installOffer, isRegistrySourced, signatureBlockView, + installOffer, signatureBlockView, type PluginDep, type PluginRow, type RegistryItem, type SigSubject, type T, type VersionInfo, type VersionMismatch, } from './plugins/pluginModel' diff --git a/client/src/components/Admin/plugins/usePluginsAdmin.test.ts b/client/src/components/Admin/plugins/usePluginsAdmin.test.ts index 788deab8b..cf5a663a8 100644 --- a/client/src/components/Admin/plugins/usePluginsAdmin.test.ts +++ b/client/src/components/Admin/plugins/usePluginsAdmin.test.ts @@ -273,7 +273,7 @@ describe('usePluginsAdmin', () => { ]); vi.spyOn(adminApi, 'pluginActivate').mockResolvedValue({}); const { result } = await mounted(); - act(() => result.current.toggle(result.current.plugins[0]!)); + act(() => result.current.toggle(result.current.plugins[0] as PluginRow)); expect(adminApi.pluginActivate).not.toHaveBeenCalled(); expect(result.current.bypass.warning).toMatchObject({ acceptedByAdmin: true,