Skip to content

Build your personal knowledge base with Trilium Notes

test(ckeditor): let the palette's assistant stub answer for the plugin

Elian Doranced4e6045712
diff --git a/packages/ckeditor5/src/plugins/mention/slash_commands.spec.ts b/packages/ckeditor5/src/plugins/mention/slash_commands.spec.ts
index 9e6f222676..cb6bc0084e 100644
--- a/packages/ckeditor5/src/plugins/mention/slash_commands.spec.ts
+++ b/packages/ckeditor5/src/plugins/mention/slash_commands.spec.ts
@@ -653,6 +653,13 @@ describe("buildTriliumSlashCommands", () => {
vi.spyOn(editor.plugins, "has").mockImplementation(
(key) => key === "AiAssistantUI" || hasPlugin(key)
);
+ // Answering `has` is not enough: the palette reads the list off the plugin rather than
+ // off the config, which only seeded it. Every other key falls through to the real
+ // collection, which the rest of `buildTriliumSlashCommands` still asks about.
+ const getPlugin = editor.plugins.get.bind(editor.plugins);
+ vi.spyOn(editor.plugins, "get").mockImplementation(
+ ((key: unknown) => (key === "AiAssistantUI" ? { quickActions } : getPlugin(key as string))) as never
+ );
}
function aiEntries() {