Skip to content

Commit c950751

Browse files
authored
[issues/163] Add Bookmarks section to RangeLink status bar menu (#193)
* Add new bookmark-focused command and strings * Selecting a bookmark from the quickpick copies it to clipboard and pastes to destination manager * Bookmarks are now added to the quickpick menu * Plumbing for new changes * Adjust already-existing tests to new structure * Introduce `createMockBookmarkStore()` * Add tests for menu building when there are and are not bookmarks * New tests
1 parent b576763 commit c950751

File tree

9 files changed

+526
-24
lines changed

9 files changed

+526
-24
lines changed

packages/rangelink-vscode-extension/src/__tests__/extension.test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3273,7 +3273,7 @@ describe('Extension lifecycle', () => {
32733273

32743274
// Verify all commands are registered
32753275
// Note: Command registration is IDE-agnostic; runtime availability differs by environment
3276-
expect(mockCommands.registerCommand).toHaveBeenCalledTimes(17);
3276+
expect(mockCommands.registerCommand).toHaveBeenCalledTimes(19);
32773277
expect(mockContext.subscriptions.length).toBeGreaterThan(0);
32783278
expect(vscode.window.createOutputChannel).toHaveBeenCalledWith('RangeLink');
32793279

@@ -3284,6 +3284,8 @@ describe('Extension lifecycle', () => {
32843284
'rangelink.bindToGitHubCopilotChat',
32853285
'rangelink.bindToTerminal',
32863286
'rangelink.bindToTextEditor',
3287+
'rangelink.bookmark.add',
3288+
'rangelink.bookmark.manage',
32873289
'rangelink.copyLinkOnlyWithAbsolutePath',
32883290
'rangelink.copyLinkOnlyWithRelativePath',
32893291
'rangelink.copyLinkWithAbsolutePath',
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/**
2+
* Mock BookmarksStore for testing
3+
*
4+
* Provides factory function to create mock bookmarks stores with sensible defaults.
5+
*/
6+
7+
import { Result } from 'rangelink-core-ts';
8+
9+
import type { Bookmark, BookmarksStore } from '../../bookmarks';
10+
11+
/**
12+
* Options for creating a mock bookmarks store
13+
*/
14+
export interface MockBookmarksStoreOptions {
15+
/** Initial bookmarks to return from getAll (default: []) */
16+
bookmarks?: Bookmark[];
17+
}
18+
19+
/**
20+
* Create a mock BookmarksStore for testing
21+
*
22+
* @param options - Optional configuration for the mock
23+
* @returns Mock BookmarksStore with jest functions
24+
*/
25+
export const createMockBookmarksStore = (
26+
options: MockBookmarksStoreOptions = {},
27+
): jest.Mocked<BookmarksStore> => {
28+
const bookmarks = options.bookmarks ?? [];
29+
30+
return {
31+
getAll: jest.fn(() => bookmarks),
32+
getById: jest.fn((id: string) => bookmarks.find((b) => b.id === id)),
33+
add: jest.fn().mockResolvedValue(Result.ok({})),
34+
update: jest.fn().mockResolvedValue(Result.ok({})),
35+
remove: jest.fn().mockResolvedValue(Result.ok(undefined)),
36+
recordAccess: jest.fn().mockResolvedValue(Result.ok(undefined)),
37+
} as unknown as jest.Mocked<BookmarksStore>;
38+
};

packages/rangelink-vscode-extension/src/__tests__/helpers/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*/
66

77
export * from './createMockAsRelativePath';
8+
export * from './createMockBookmarksStore';
89
export * from './createMockCancellationToken';
910
export * from './createMockClaudeCodeComposableDestination';
1011
export * from './createMockClaudeCodeDestination';

0 commit comments

Comments
 (0)