fix: serve plugin SVG assets with correct MIME type

This commit is contained in:
Federico Jaramillo Martinez
2026-07-12 22:39:41 +02:00
parent 16b801b8cd
commit 21c58fe656
6 changed files with 58 additions and 8 deletions
+8 -1
View File
@@ -100,7 +100,7 @@ export function registerAppTestHooks(): void {
piWebPlugins: {
manifest: () => Promise.resolve({ plugins: [{ id: "fake", module: "/pi-web-plugins/fake/plugin.js?v=1", source: "test", scope: "local", machineSpecific: false }] }),
plugins: () => Promise.resolve({ plugins: [{ id: "fake", module: "/pi-web-plugins/fake/plugin.js?v=1", source: "test", scope: "local", machineSpecific: false, enabled: true }] }),
readAsset: (pluginId, assetPath) => Promise.resolve(pluginId === "fake" && assetPath === "plugin.js" ? { content: Buffer.from("export default {};"), contentType: "application/javascript; charset=utf-8" } : undefined),
readAsset: fakePiWebPluginAsset,
},
clientDist: false,
logger: false,
@@ -123,6 +123,13 @@ export function registerAppTestHooks(): void {
});
}
function fakePiWebPluginAsset(pluginId: string, assetPath: string): Promise<{ content: Buffer; contentType: string } | undefined> {
if (pluginId !== "fake") return Promise.resolve(undefined);
if (assetPath === "plugin.js") return Promise.resolve({ content: Buffer.from("export default {};"), contentType: "application/javascript; charset=utf-8" });
if (assetPath === "assets/icon.svg") return Promise.resolve({ content: Buffer.from('<svg xmlns="http://www.w3.org/2000/svg"></svg>'), contentType: "image/svg+xml" });
return Promise.resolve(undefined);
}
export interface CapturedSessionDaemonRequest {
method: string;
path: string;