fix(tests): add test for disabling all tools in CcwToolsMcpCard component

fix(api): handle empty enabledTools array and improve default tool logic
fix(queueScheduler): ignore network errors in loadInitialState
fix(auth): ensure token generation handles max session capacity
chore(dependencies): update package requirements to use compatible version specifiers
chore(tests): add new test cases for incremental indexer and migrations
This commit is contained in:
catlog22
2026-03-02 11:26:15 +08:00
parent b36a46d59d
commit 8ad283086b
7 changed files with 159 additions and 84 deletions

View File

@@ -41,6 +41,43 @@ describe('CcwToolsMcpCard', () => {
vi.clearAllMocks();
});
it('disables all tools when clicking "Disable All" button', async () => {
const { CcwToolsMcpCard } = await import('./CcwToolsMcpCard');
const onUpdateConfigMock = vi.fn();
render(
<CcwToolsMcpCard
target="codex"
isInstalled={true}
enabledTools={['write_file', 'read_file', 'edit_file']}
onToggleTool={vi.fn()}
onUpdateConfig={onUpdateConfigMock}
onInstall={vi.fn()}
/>,
{ locale: 'en' }
);
const user = userEvent.setup();
// Expand the card
await act(async () => {
await user.click(screen.getByText(/CCW MCP Server|mcp\.ccw\.title/i));
});
// Find and click "Disable All" button
const disableAllButton = screen.getByRole('button', {
name: /Disable All|mcp\.ccw\.actions\.disableAll/i,
});
expect(disableAllButton).toBeEnabled();
await act(async () => {
await user.click(disableAllButton);
});
// Verify onUpdateConfig was called with empty enabledTools array
await waitFor(() => {
expect(onUpdateConfigMock).toHaveBeenCalledWith({ enabledTools: [] });
});
});
it('preserves enabledTools when saving config (Codex)', async () => {
const { CcwToolsMcpCard } = await import('./CcwToolsMcpCard');
const updateCodexMock = vi.mocked(apiMock.updateCcwConfigForCodex);