-
Couldn't load subscription status.
- Fork 2.4k
feat: Move slash commands to Settings tab with gear icon for discoverability #7988
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 13 commits
0430998
46ae66c
bd9a499
a1f8b7d
f4ab67a
620cf3d
d0ce642
690f680
6173797
8801439
05540da
8041639
c5df5e4
a09893c
9e86f9a
3eac654
4752dfd
365c817
bb43eb2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,150 @@ | ||
| import React from "react" | ||
| import { render, waitFor } from "@testing-library/react" | ||
| import { vi } from "vitest" | ||
| import { QueryClient, QueryClientProvider } from "@tanstack/react-query" | ||
|
|
||
| import App from "../App" | ||
| import TranslationProvider from "../i18n/TranslationContext" | ||
|
|
||
| // Mock vscode API | ||
| const mockPostMessage = vi.fn() | ||
| vi.mock("../utils/vscode", () => ({ | ||
| vscode: { | ||
| postMessage: (message: any) => mockPostMessage(message), | ||
| }, | ||
| })) | ||
|
|
||
| // Mock extension state | ||
| const mockExtensionState = { | ||
| didHydrateState: true, | ||
| showWelcome: false, | ||
| shouldShowAnnouncement: false, | ||
| telemetrySetting: "off" as const, | ||
| telemetryKey: undefined, | ||
| machineId: "test-machine-id", | ||
| cloudUserInfo: null, | ||
| cloudIsAuthenticated: false, | ||
| cloudApiUrl: undefined, | ||
| renderContext: "editor" as const, | ||
| mdmCompliant: true, | ||
| currentApiConfigName: "test-config", | ||
| listApiConfigMeta: [], | ||
| apiConfiguration: {}, | ||
| experiments: {}, | ||
| customModes: [], | ||
| mode: { slug: "code", name: "Code" }, | ||
| clineMessages: [], | ||
| taskHistory: [], | ||
| version: "1.0.0", | ||
| writeDelayMs: 100, | ||
| requestDelaySeconds: 1, | ||
| enableCheckpoints: false, | ||
| maxOpenTabsContext: 10, | ||
| maxWorkspaceFiles: 100, | ||
| showRooIgnoredFiles: false, | ||
| maxReadFileLine: 1000, | ||
| maxImageFileSize: 5, | ||
| maxTotalImageSize: 20, | ||
| mcpEnabled: false, | ||
| enableMcpServerCreation: false, | ||
| sharingEnabled: false, | ||
| organizationAllowList: { | ||
| enabled: false, | ||
| allowed: [], | ||
| providers: {}, | ||
| }, | ||
| autoCondenseContext: false, | ||
| autoCondenseContextPercent: 50, | ||
| profileThresholds: {}, | ||
| hasOpenedModeSelector: false, | ||
| remoteControlEnabled: false, | ||
| taskSyncEnabled: false, | ||
| featureRoomoteControlEnabled: false, | ||
| // Add missing properties required by ChatView components | ||
| openedTabs: [], | ||
| filePaths: [], | ||
| commands: [], | ||
| gitCommits: [], | ||
| browserToolEnabled: false, | ||
| mcpServers: [], | ||
| } | ||
|
|
||
| vi.mock("../context/ExtensionStateContext", () => ({ | ||
| ExtensionStateContextProvider: ({ children }: { children: React.ReactNode }) => children, | ||
| useExtensionState: () => mockExtensionState, | ||
| })) | ||
|
|
||
| describe("Settings Tab Navigation", () => { | ||
| let queryClient: QueryClient | ||
|
|
||
| beforeEach(() => { | ||
| queryClient = new QueryClient({ | ||
| defaultOptions: { | ||
| queries: { retry: false }, | ||
| mutations: { retry: false }, | ||
| }, | ||
| }) | ||
| mockPostMessage.mockClear() | ||
| }) | ||
|
|
||
| it("should navigate to slash commands section when handleSettingsClick is called", async () => { | ||
| const { container } = render( | ||
| <QueryClientProvider client={queryClient}> | ||
| <TranslationProvider> | ||
| <App /> | ||
| </TranslationProvider> | ||
| </QueryClientProvider>, | ||
| ) | ||
|
|
||
| // Simulate message from ContextMenu to switch to settings tab with targetSection | ||
| const messageEvent = new MessageEvent("message", { | ||
| data: { | ||
| type: "action", | ||
| action: "switchTab", | ||
| tab: "settings", | ||
| values: { section: "slashCommands" }, | ||
| }, | ||
| }) | ||
| window.dispatchEvent(messageEvent) | ||
|
|
||
| // Wait for the settings view to render | ||
| await waitFor(() => { | ||
| const slashCommandsTab = container.querySelector('[data-testid="tab-slashCommands"]') | ||
| expect(slashCommandsTab).toBeTruthy() | ||
| }) | ||
|
|
||
| // Verify the slash commands tab is active | ||
| const slashCommandsTab = container.querySelector('[data-testid="tab-slashCommands"]') | ||
| expect(slashCommandsTab?.getAttribute("aria-selected")).toBe("true") | ||
| }) | ||
|
|
||
| it("should switch to settings tab without a specific section", async () => { | ||
| const { container } = render( | ||
| <QueryClientProvider client={queryClient}> | ||
| <TranslationProvider> | ||
| <App /> | ||
| </TranslationProvider> | ||
| </QueryClientProvider>, | ||
| ) | ||
|
|
||
| // Simulate message to switch to settings tab without targetSection | ||
| const messageEvent = new MessageEvent("message", { | ||
| data: { | ||
| type: "action", | ||
| action: "switchTab", | ||
| tab: "settings", | ||
| }, | ||
| }) | ||
| window.dispatchEvent(messageEvent) | ||
|
|
||
| // Wait for the settings view to render | ||
| await waitFor(() => { | ||
| const providersTab = container.querySelector('[data-testid="tab-providers"]') | ||
| expect(providersTab).toBeTruthy() | ||
| }) | ||
|
|
||
| // Verify the default providers tab is active | ||
| const providersTab = container.querySelector('[data-testid="tab-providers"]') | ||
| expect(providersTab?.getAttribute("aria-selected")).toBe("true") | ||
| }) | ||
| }) | ||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I try to avoid these mockExtensionState tests, since you always need to maintain them when you add new things to extension state. Is there a way to write this test without it? If not I might just cut the test.