feat: show plugin features from the manifest on the plugin page

This commit is contained in:
LukeGus committed 2026-10-06 22:38:13 -05:00
1 parent 60024bdd4e
commit b6bb3ffc73
13 files changed
+158 -2

No files matched your search

@@ -13,6 +13,7 @@ import {
SUPPORTED_PLUGIN_API_VERSION,
isTermixCompatible,
youtubeVideoId,
pluginFeatures,
} from "../../plugins/manifest.js";
function base(overrides: Record<string, unknown> = {}) {
@@ -885,6 +886,37 @@ describe("manifest video", () => {
});
});
describe("manifest features", () => {
it("accepts a short list of lines", () => {
expect(
validateManifest(base({ features: ["Start containers", "Read logs"] })),
).toEqual([]);
});
it("rejects bad lists", () => {
expect(validateManifest(base({ features: "Logs" }))).toEqual([
'Field "features" must be an array of strings',
]);
expect(validateManifest(base({ features: ["ok", "", 4] }))).toHaveLength(2);
expect(
validateManifest(base({ features: ["x".repeat(161)] })).join(),
).toMatch(/features\[0\]/);
expect(
validateManifest(base({ features: Array(21).fill("x") })).join(),
).toMatch(/at most 20/);
});
});
describe("pluginFeatures", () => {
it("keeps only usable lines", () => {
expect(pluginFeatures([" Logs ", "", 3, "x".repeat(161), "Stats"])).toEqual(
["Logs", "Stats"],
);
expect(pluginFeatures(Array(30).fill("x"))).toHaveLength(20);
expect(pluginFeatures("Logs")).toEqual([]);
});
});
describe("youtubeVideoId", () => {
it("returns only the id", () => {
expect(
@@ -143,6 +143,17 @@ describe("parseRegistryIndex", () => {
expect(index.plugins[1].versions[0].notes).toHaveLength(20_000);
});
it("keeps only usable feature lines", () => {
const index = parseRegistryIndex({
plugins: [
{ id: "docker", features: ["Logs", 5, ""], versions: [version()] },
{ id: "other", features: "Logs", versions: [version()] },
],
});
expect(index.plugins[0].features).toEqual(["Logs"]);
expect(index.plugins[1].features).toEqual([]);
});
it("refuses something that is not an index", () => {
expect(() => parseRegistryIndex({ nope: true })).toThrow(/no plugins/);
});