fix(plugins): keep the API client and the panel test within their size entries, drop an unused import

This commit is contained in:
Maurice
2026-10-26 00:57:56 +01:00
parent 447ae54b93
commit 64ed2175a5
4 changed files with 10 additions and 29 deletions
+2 -9
View File
@@ -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<PluginInstallRequest, 'version' | 'constraint' | 'withDependencies' | 'acceptTrekRange'>) =>
pluginInstall: (id: string, opts?: Omit<PluginInstallRequest, 'id'>) =>
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.
@@ -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()
})
@@ -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'
@@ -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,