Archived
fix: serve plugin SVG assets with correct MIME type
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user