mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-03 01:28:55 +00:00
fix(client): work through the findings from the coverage pass
214 items came out of writing the tests. Real defects are corrected, dead code is removed rather than covered, and the tests that pinned the old behaviour move with them. Also drops two agent coverage scratch files that slipped into the coverage PR and adds the ignore rule that keeps them out.
This commit is contained in:
@@ -118,6 +118,11 @@ export interface ManifestPreview {
|
||||
icon: string | null;
|
||||
requiredAddons: string[];
|
||||
pluginDependencies: PluginDependency[];
|
||||
/**
|
||||
* The UI-facing slice of `capabilities`. A plugin that replaces planner tabs hides core
|
||||
* UI, so the reviewer has to see it BEFORE installing, not only on the installed row.
|
||||
*/
|
||||
capabilities: { widget?: { slot?: string }; tripPage?: { replaces?: string[] } };
|
||||
}
|
||||
|
||||
let _cache: { data: Registry; expiresAt: number } | null = null;
|
||||
@@ -749,6 +754,20 @@ function previewManifest(raw: unknown): ManifestPreview {
|
||||
}))
|
||||
.filter((d) => d.id && d.version)
|
||||
: [];
|
||||
const rawCaps = (m.capabilities && typeof m.capabilities === 'object' ? m.capabilities : {}) as Record<
|
||||
string,
|
||||
unknown
|
||||
>;
|
||||
const widget = (rawCaps.widget && typeof rawCaps.widget === 'object' ? rawCaps.widget : null) as {
|
||||
slot?: unknown;
|
||||
} | null;
|
||||
const tripPage = (rawCaps.tripPage && typeof rawCaps.tripPage === 'object' ? rawCaps.tripPage : null) as {
|
||||
replaces?: unknown;
|
||||
} | null;
|
||||
const capabilities: ManifestPreview['capabilities'] = {};
|
||||
if (widget) capabilities.widget = typeof widget.slot === 'string' ? { slot: widget.slot } : {};
|
||||
if (tripPage) capabilities.tripPage = { replaces: strings(tripPage.replaces) };
|
||||
|
||||
return {
|
||||
permissions: strings(m.permissions),
|
||||
egress: strings(m.egress),
|
||||
@@ -758,6 +777,7 @@ function previewManifest(raw: unknown): ManifestPreview {
|
||||
icon: typeof m.icon === 'string' ? m.icon : null,
|
||||
requiredAddons: strings(m.requiredAddons),
|
||||
pluginDependencies,
|
||||
capabilities,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@ import { db as dbConn } from '../../../src/db/database';
|
||||
import { DatabaseService } from '../../../src/nest/database/database.service';
|
||||
|
||||
import { PluginRegistryService, RegistryError, __clearRegistryCacheForTests } from '../../../src/nest/plugins/registry/registry.service';
|
||||
import type { ManifestPreview } from '../../../src/nest/plugins/registry/registry.service';
|
||||
|
||||
// ── tiny tar.gz builder (wraps the plugin in a codeload-style top dir) ────────
|
||||
function tarHeader(name: string, size: number, typeflag = '0'): Buffer {
|
||||
@@ -181,6 +182,27 @@ describe('PluginRegistryService', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('detail carries the UI-facing capabilities, so the review sheet can chip a tab takeover', async () => {
|
||||
safeDownload.mockResolvedValue({
|
||||
bytes: Buffer.from(JSON.stringify({
|
||||
id: 'flight-tracker', permissions: [], egress: [],
|
||||
capabilities: { widget: { slot: 'hero' }, tripPage: { replaces: ['places'], position: 3 }, settingsUi: true },
|
||||
})),
|
||||
sha256: 'unused',
|
||||
});
|
||||
const d = (await svc.detail('flight-tracker')) as { manifest: ManifestPreview };
|
||||
expect(d.manifest.capabilities).toEqual({ widget: { slot: 'hero' }, tripPage: { replaces: ['places'] } });
|
||||
});
|
||||
|
||||
it('detail leaves capabilities empty when the manifest declares none', async () => {
|
||||
safeDownload.mockResolvedValue({
|
||||
bytes: Buffer.from(JSON.stringify({ id: 'flight-tracker', permissions: [], capabilities: { widget: {} } })),
|
||||
sha256: 'unused',
|
||||
});
|
||||
const d = (await svc.detail('flight-tracker')) as { manifest: ManifestPreview };
|
||||
expect(d.manifest.capabilities).toEqual({ widget: {} });
|
||||
});
|
||||
|
||||
it('detail soft-fails the manifest fetch (registry metadata still renders)', async () => {
|
||||
safeDownload.mockRejectedValue(new Error('offline'));
|
||||
const d = await svc.detail('flight-tracker');
|
||||
|
||||
Reference in New Issue
Block a user