Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions frontend/app/view/webview/webview.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,37 @@ describe("webview preview fallback", () => {
expect(globalStore.get(env.getSettingsKeyAtom("web:defaulturl"))).toBe("https://global.example");
expect(globalStore.get(env.wos.getWaveObjectAtom<Block>(`block:${blockId}`))?.meta?.pinnedurl).toBeUndefined();
});

it("binds fetchBookmarkSuggestions so it can be called unbound without throwing", async () => {
const blockId = "webview-env-block";
const env = makeMockWaveEnv();
let calledData: any = null;
env.rpc = {
FetchSuggestionsCommand: async (_client: any, data: any) => {
calledData = data;
return {
suggestions: [{ type: "url", "url:url": "https://example.com" }],
};
},
} as any;
const model = new WebViewModel({
blockId,
nodeModel: {
isFocused: atom(true),
focusNode: () => {},
} as any,
tabModel: {} as any,
waveEnv: env,
});

const unboundFetch = model.fetchBookmarkSuggestions;
const result = await unboundFetch("test", { widgetid: "w1", reqnum: 1 });
expect(calledData).toEqual({
suggestiontype: "bookmark",
query: "test",
widgetid: "w1",
reqnum: 1,
});
expect(result.suggestions).toHaveLength(1);
});
});
4 changes: 3 additions & 1 deletion frontend/app/view/webview/webview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,8 @@ export class WebViewModel implements ViewModel {

return buttons;
});

this.fetchBookmarkSuggestions = this.fetchBookmarkSuggestions.bind(this);
}

dispose() {
Expand Down Expand Up @@ -755,7 +757,7 @@ const BookmarkTypeahead = memo(
const env = useWaveEnv<WebViewEnv>();
const openBookmarksJson = () => {
fireAndForget(async () => {
const path = `${env.electron.getConfigDir()}/presets/bookmarks.json`;
const path = `${env.electron.getConfigDir()}/bookmarks.json`;
const blockDef: BlockDef = {
meta: {
view: "preview",
Expand Down